diff --git a/site/src/modules/workspaces/WorkspaceTiming/Chart/Bar.tsx b/site/src/modules/workspaces/WorkspaceTiming/Chart/Bar.tsx index a98d91ae428b5..3ed7fdcd31898 100644 --- a/site/src/modules/workspaces/WorkspaceTiming/Chart/Bar.tsx +++ b/site/src/modules/workspaces/WorkspaceTiming/Chart/Bar.tsx @@ -91,7 +91,7 @@ const styles = { left: -8, }, }), - clickable: { + clickable: (theme) => ({ cursor: "pointer", // We need to make the bar width at least 34px to allow the "..." icons to be displayed. // The calculation is border * 1 + side paddings * 2 + icon width (which is 18px) @@ -99,7 +99,7 @@ const styles = { "&:focus, &:hover, &:active": { outline: "none", - borderColor: "#38BDF8", + borderColor: theme.roles.active.outline, }, - }, + }), } satisfies Record>; diff --git a/site/src/modules/workspaces/WorkspaceTiming/Chart/Blocks.tsx b/site/src/modules/workspaces/WorkspaceTiming/Chart/Blocks.tsx index 752e53c5b5c4a..00660c39f495c 100644 --- a/site/src/modules/workspaces/WorkspaceTiming/Chart/Blocks.tsx +++ b/site/src/modules/workspaces/WorkspaceTiming/Chart/Blocks.tsx @@ -52,16 +52,16 @@ const styles = { gap: spaceBetweenBlocks, alignItems: "center", }, - block: { + block: (theme) => ({ borderRadius: 4, height: 18, - backgroundColor: "#082F49", - border: "1px solid #38BDF8", + backgroundColor: theme.roles.active.background, + border: `1px solid ${theme.roles.active.outline}`, flexShrink: 0, flex: 1, - }, - more: { - color: "#38BDF8", + }), + more: (theme) => ({ + color: theme.roles.active.outline, lineHeight: 0, flexShrink: 0, flex: 1, @@ -69,5 +69,5 @@ const styles = { "& svg": { fontSize: moreIconSize, }, - }, + }), } satisfies Record>; diff --git a/site/src/modules/workspaces/WorkspaceTiming/ResourcesChart.tsx b/site/src/modules/workspaces/WorkspaceTiming/ResourcesChart.tsx index b1c69b6d1baf7..3f1f7d761e748 100644 --- a/site/src/modules/workspaces/WorkspaceTiming/ResourcesChart.tsx +++ b/site/src/modules/workspaces/WorkspaceTiming/ResourcesChart.tsx @@ -32,33 +32,6 @@ import { } from "./Chart/utils"; import type { StageCategory } from "./StagesChart"; -const legendsByAction: Record = { - "state refresh": { - label: "state refresh", - }, - create: { - label: "create", - colors: { - fill: "#022C22", - stroke: "#BBF7D0", - }, - }, - delete: { - label: "delete", - colors: { - fill: "#422006", - stroke: "#FDBA74", - }, - }, - read: { - label: "read", - colors: { - fill: "#082F49", - stroke: "#38BDF8", - }, - }, -}; - type ResourceTiming = { name: string; source: string; @@ -86,6 +59,8 @@ export const ResourcesChart: FC = ({ const visibleTimings = timings.filter( (t) => !isCoderResource(t.name) && t.name.includes(filter), ); + const theme = useTheme(); + const legendsByAction = getLegendsByAction(theme); const visibleLegends = [...new Set(visibleTimings.map((t) => t.action))].map( (a) => legendsByAction[a], ); @@ -168,3 +143,32 @@ export const isCoderResource = (resource: string) => { resource.startsWith("coder_") ); }; + +function getLegendsByAction(theme: Theme): Record { + return { + "state refresh": { + label: "state refresh", + }, + create: { + label: "create", + colors: { + fill: theme.roles.success.background, + stroke: theme.roles.success.outline, + }, + }, + delete: { + label: "delete", + colors: { + fill: theme.roles.warning.background, + stroke: theme.roles.warning.outline, + }, + }, + read: { + label: "read", + colors: { + fill: theme.roles.active.background, + stroke: theme.roles.active.outline, + }, + }, + }; +} diff --git a/site/src/modules/workspaces/WorkspaceTiming/ScriptsChart.tsx b/site/src/modules/workspaces/WorkspaceTiming/ScriptsChart.tsx index 5dfc57e51098f..64d97bff7cfdb 100644 --- a/site/src/modules/workspaces/WorkspaceTiming/ScriptsChart.tsx +++ b/site/src/modules/workspaces/WorkspaceTiming/ScriptsChart.tsx @@ -1,3 +1,4 @@ +import { type Theme, useTheme } from "@emotion/react"; import { type FC, useState } from "react"; import { Bar } from "./Chart/Bar"; import { @@ -28,30 +29,6 @@ import { } from "./Chart/utils"; import type { StageCategory } from "./StagesChart"; -const legendsByStatus: Record = { - ok: { - label: "success", - colors: { - fill: "#022C22", - stroke: "#BBF7D0", - }, - }, - exit_failure: { - label: "failure", - colors: { - fill: "#450A0A", - stroke: "#F87171", - }, - }, - timeout: { - label: "timed out", - colors: { - fill: "#422006", - stroke: "#FDBA74", - }, - }, -}; - type ScriptTiming = { name: string; status: string; @@ -77,6 +54,8 @@ export const ScriptsChart: FC = ({ const [ticks, scale] = makeTicks(totalTime); const [filter, setFilter] = useState(""); const visibleTimings = timings.filter((t) => t.name.includes(filter)); + const theme = useTheme(); + const legendsByStatus = getLegendsByStatus(theme); const visibleLegends = [...new Set(visibleTimings.map((t) => t.status))].map( (s) => legendsByStatus[s], ); @@ -151,3 +130,29 @@ export const ScriptsChart: FC = ({ ); }; + +function getLegendsByStatus(theme: Theme): Record { + return { + ok: { + label: "success", + colors: { + fill: theme.roles.success.background, + stroke: theme.roles.success.outline, + }, + }, + exit_failure: { + label: "failure", + colors: { + fill: theme.roles.error.background, + stroke: theme.roles.error.outline, + }, + }, + timeout: { + label: "timed out", + colors: { + fill: theme.roles.warning.background, + stroke: theme.roles.warning.outline, + }, + }, + }; +} diff --git a/site/src/modules/workspaces/WorkspaceTiming/WorkspaceTimings.stories.tsx b/site/src/modules/workspaces/WorkspaceTiming/WorkspaceTimings.stories.tsx index b1bf487c52732..f546e271395ab 100644 --- a/site/src/modules/workspaces/WorkspaceTiming/WorkspaceTimings.stories.tsx +++ b/site/src/modules/workspaces/WorkspaceTiming/WorkspaceTimings.stories.tsx @@ -1,5 +1,6 @@ import type { Meta, StoryObj } from "@storybook/react"; import { expect, userEvent, waitFor, within } from "@storybook/test"; +import { chromatic } from "testHelpers/chromatic"; import { WorkspaceTimings } from "./WorkspaceTimings"; import { WorkspaceTimingsResponse } from "./storybookData"; @@ -11,6 +12,9 @@ const meta: Meta = { provisionerTimings: WorkspaceTimingsResponse.provisioner_timings, agentScriptTimings: WorkspaceTimingsResponse.agent_script_timings, }, + parameters: { + chromatic, + }, }; export default meta;