From 442a5f614b3429514a45607a22ad813df982eedc Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Tue, 2 Jan 2024 16:53:12 +0000 Subject: [PATCH 1/2] fix(site): fix pill spinner size --- site/src/components/Pill/Pill.tsx | 19 +++++++++++++++++++ site/src/utils/workspace.tsx | 22 ++++++---------------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/site/src/components/Pill/Pill.tsx b/site/src/components/Pill/Pill.tsx index fd4c9558c2565..8fa3b2073ba0e 100644 --- a/site/src/components/Pill/Pill.tsx +++ b/site/src/components/Pill/Pill.tsx @@ -7,6 +7,9 @@ import { } from "react"; import { useTheme, type Interpolation, type Theme } from "@emotion/react"; import type { ThemeRole } from "theme/experimental"; +import CircularProgress, { + CircularProgressProps, +} from "@mui/material/CircularProgress"; export type PillType = ThemeRole | keyof typeof themeOverrides; @@ -81,3 +84,19 @@ export const Pill: FC = forwardRef( ); }, ); + +export const PillSpinner = (props: CircularProgressProps) => { + return ( + ({ + color: theme.experimental.l1.text, + // It is necessary to align it with the MUI Icons internal padding + "& svg": { + transform: "scale(.75)", + }, + })} + {...props} + /> + ); +}; diff --git a/site/src/utils/workspace.tsx b/site/src/utils/workspace.tsx index 3f823b659f686..606fc343035cb 100644 --- a/site/src/utils/workspace.tsx +++ b/site/src/utils/workspace.tsx @@ -1,4 +1,3 @@ -import CircularProgress from "@mui/material/CircularProgress"; import ErrorIcon from "@mui/icons-material/ErrorOutline"; import StopIcon from "@mui/icons-material/StopOutlined"; import PlayIcon from "@mui/icons-material/PlayArrowOutlined"; @@ -8,9 +7,9 @@ import duration from "dayjs/plugin/duration"; import minMax from "dayjs/plugin/minMax"; import utc from "dayjs/plugin/utc"; import { type Theme } from "@emotion/react"; -import { type FC } from "react"; import semver from "semver"; import type * as TypesGen from "api/typesGenerated"; +import { PillSpinner } from "components/Pill/Pill"; dayjs.extend(duration); dayjs.extend(utc); @@ -29,15 +28,6 @@ const DisplayAgentVersionLanguage = { unknown: "Unknown", }; -const LoadingIcon: FC = () => { - return ( - ({ color: theme.experimental.l1.text })} - /> - ); -}; - export const getDisplayWorkspaceBuildStatus = ( theme: Theme, build: TypesGen.WorkspaceBuild, @@ -185,7 +175,7 @@ export const getDisplayWorkspaceStatus = ( case undefined: return { text: "Loading", - icon: , + icon: , } as const; case "running": return { @@ -197,13 +187,13 @@ export const getDisplayWorkspaceStatus = ( return { type: "active", text: "Starting", - icon: , + icon: , } as const; case "stopping": return { type: "notice", text: "Stopping", - icon: , + icon: , } as const; case "stopped": return { @@ -215,7 +205,7 @@ export const getDisplayWorkspaceStatus = ( return { type: "danger", text: "Deleting", - icon: , + icon: , } as const; case "deleted": return { @@ -227,7 +217,7 @@ export const getDisplayWorkspaceStatus = ( return { type: "notice", text: "Canceling", - icon: , + icon: , } as const; case "canceled": return { From de79ae8c541bf768569f7baad32f4ddb2d3fbc93 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Tue, 2 Jan 2024 16:59:21 +0000 Subject: [PATCH 2/2] add story for loading --- site/src/components/Pill/Pill.stories.tsx | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/site/src/components/Pill/Pill.stories.tsx b/site/src/components/Pill/Pill.stories.tsx index f3ea362c2cb69..5ee6802538f98 100644 --- a/site/src/components/Pill/Pill.stories.tsx +++ b/site/src/components/Pill/Pill.stories.tsx @@ -1,20 +1,19 @@ -import { Pill } from "./Pill"; +import { Pill, PillSpinner } from "./Pill"; import type { Meta, StoryObj } from "@storybook/react"; import InfoOutlined from "@mui/icons-material/InfoOutlined"; const meta: Meta = { title: "components/Pill", component: Pill, + args: { + children: "Default", + }, }; export default meta; type Story = StoryObj; -export const Default: Story = { - args: { - children: "Default", - }, -}; +export const Default: Story = {}; export const Danger: Story = { args: { @@ -72,3 +71,12 @@ export const WithIcon: Story = { icon: , }, }; + +export const WithSpinner: Story = { + args: { + icon: , + }, + parameters: { + chromatic: { delay: 700 }, + }, +};