diff --git a/site/src/components/Latency/Latency.stories.tsx b/site/src/components/Latency/Latency.stories.tsx new file mode 100644 index 0000000000..0b1b76439c --- /dev/null +++ b/site/src/components/Latency/Latency.stories.tsx @@ -0,0 +1,34 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import { Latency } from "./Latency"; + +const meta: Meta = { + title: "components/Latency", + component: Latency, +}; + +export default meta; +type Story = StoryObj; + +export const Low: Story = { + args: { + latency: 10, + }, +}; + +export const Medium: Story = { + args: { + latency: 150, + }, +}; + +export const High: Story = { + args: { + latency: 300, + }, +}; + +export const Loading: Story = { + args: { + isLoading: true, + }, +}; diff --git a/site/src/components/ProxyStatusLatency/ProxyStatusLatency.tsx b/site/src/components/Latency/Latency.tsx similarity index 91% rename from site/src/components/ProxyStatusLatency/ProxyStatusLatency.tsx rename to site/src/components/Latency/Latency.tsx index 6efb105961..738ef1a85b 100644 --- a/site/src/components/ProxyStatusLatency/ProxyStatusLatency.tsx +++ b/site/src/components/Latency/Latency.tsx @@ -7,15 +7,12 @@ import { type FC } from "react"; import { getLatencyColor } from "utils/latency"; import { Abbr } from "components/Abbr/Abbr"; -interface ProxyStatusLatencyProps { +interface LatencyProps { latency?: number; isLoading?: boolean; } -export const ProxyStatusLatency: FC = ({ - latency, - isLoading, -}) => { +export const Latency: FC = ({ latency, isLoading }) => { const theme = useTheme(); // Always use the no latency color for loading. const color = getLatencyColor(theme, isLoading ? undefined : latency); diff --git a/site/src/modules/dashboard/Navbar/NavbarView.tsx b/site/src/modules/dashboard/Navbar/NavbarView.tsx index 533d5a84bb..60e6db1fea 100644 --- a/site/src/modules/dashboard/Navbar/NavbarView.tsx +++ b/site/src/modules/dashboard/Navbar/NavbarView.tsx @@ -17,7 +17,7 @@ import { usePermissions } from "contexts/auth/usePermissions"; import type { ProxyContextValue } from "contexts/ProxyContext"; import { Abbr } from "components/Abbr/Abbr"; import { displayError } from "components/GlobalSnackbar/utils"; -import { ProxyStatusLatency } from "components/ProxyStatusLatency/ProxyStatusLatency"; +import { Latency } from "components/Latency/Latency"; import { CoderIcon } from "components/Icons/CoderIcon"; import { UserDropdown } from "./UserDropdown/UserDropdown"; @@ -276,7 +276,7 @@ const ProxyMenu: FC = ({ proxyContextValue }) => { /> - @@ -385,7 +385,7 @@ const ProxyMenu: FC = ({ proxyContextValue }) => { {proxy.display_name} -