Skip to content

Commit f4c888f

Browse files
authored
chore: add stories for Latency component (#12374)
1 parent f00935b commit f4c888f

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { Latency } from "./Latency";
3+
4+
const meta: Meta<typeof Latency> = {
5+
title: "components/Latency",
6+
component: Latency,
7+
};
8+
9+
export default meta;
10+
type Story = StoryObj<typeof Latency>;
11+
12+
export const Low: Story = {
13+
args: {
14+
latency: 10,
15+
},
16+
};
17+
18+
export const Medium: Story = {
19+
args: {
20+
latency: 150,
21+
},
22+
};
23+
24+
export const High: Story = {
25+
args: {
26+
latency: 300,
27+
},
28+
};
29+
30+
export const Loading: Story = {
31+
args: {
32+
isLoading: true,
33+
},
34+
};

site/src/components/ProxyStatusLatency/ProxyStatusLatency.tsx renamed to site/src/components/Latency/Latency.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@ import { type FC } from "react";
77
import { getLatencyColor } from "utils/latency";
88
import { Abbr } from "components/Abbr/Abbr";
99

10-
interface ProxyStatusLatencyProps {
10+
interface LatencyProps {
1111
latency?: number;
1212
isLoading?: boolean;
1313
}
1414

15-
export const ProxyStatusLatency: FC<ProxyStatusLatencyProps> = ({
16-
latency,
17-
isLoading,
18-
}) => {
15+
export const Latency: FC<LatencyProps> = ({ latency, isLoading }) => {
1916
const theme = useTheme();
2017
// Always use the no latency color for loading.
2118
const color = getLatencyColor(theme, isLoading ? undefined : latency);

site/src/modules/dashboard/Navbar/NavbarView.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { usePermissions } from "contexts/auth/usePermissions";
1717
import type { ProxyContextValue } from "contexts/ProxyContext";
1818
import { Abbr } from "components/Abbr/Abbr";
1919
import { displayError } from "components/GlobalSnackbar/utils";
20-
import { ProxyStatusLatency } from "components/ProxyStatusLatency/ProxyStatusLatency";
20+
import { Latency } from "components/Latency/Latency";
2121
import { CoderIcon } from "components/Icons/CoderIcon";
2222
import { UserDropdown } from "./UserDropdown/UserDropdown";
2323

@@ -276,7 +276,7 @@ const ProxyMenu: FC<ProxyMenuProps> = ({ proxyContextValue }) => {
276276
/>
277277
</div>
278278

279-
<ProxyStatusLatency
279+
<Latency
280280
latency={latencies?.[selectedProxy.id]?.latencyMS}
281281
isLoading={proxyLatencyLoading(selectedProxy)}
282282
/>
@@ -385,7 +385,7 @@ const ProxyMenu: FC<ProxyMenuProps> = ({ proxyContextValue }) => {
385385

386386
{proxy.display_name}
387387

388-
<ProxyStatusLatency
388+
<Latency
389389
latency={latencies?.[proxy.id]?.latencyMS}
390390
isLoading={proxyLatencyLoading(proxy)}
391391
/>

0 commit comments

Comments
 (0)