Skip to content

chore: use emotion for styling (pt. 9) #10474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Nov 2, 2023
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
emotion: WorkspaceBuildProgress
  • Loading branch information
aslilac committed Nov 1, 2023
commit 44f9d4232c26c3e53560b0ea49537a06917db4dc
43 changes: 22 additions & 21 deletions site/src/pages/WorkspacePage/WorkspaceBuildProgress.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { css } from "@emotion/css";
import { type Interpolation, type Theme } from "@emotion/react";
import LinearProgress from "@mui/material/LinearProgress";
import makeStyles from "@mui/styles/makeStyles";
import { TransitionStats, Template, Workspace } from "api/typesGenerated";
import dayjs, { Dayjs } from "dayjs";
import { FC, useEffect, useState } from "react";
import type { TransitionStats, Template, Workspace } from "api/typesGenerated";
import dayjs, { type Dayjs } from "dayjs";
import { type FC, useEffect, useState } from "react";
import capitalize from "lodash/capitalize";

import duration from "dayjs/plugin/duration";
Expand Down Expand Up @@ -68,7 +69,6 @@ export const WorkspaceBuildProgress: FC<WorkspaceBuildProgressProps> = ({
workspace,
transitionStats: transitionStats,
}) => {
const styles = useStyles();
const job = workspace.latest_build.job;
const [progressValue, setProgressValue] = useState<number | undefined>(0);
const [progressText, setProgressText] = useState<string | undefined>(
Expand Down Expand Up @@ -107,7 +107,7 @@ export const WorkspaceBuildProgress: FC<WorkspaceBuildProgressProps> = ({
return <></>;
}
return (
<div className={styles.stack}>
<div css={styles.stack}>
<LinearProgress
data-chromatic="ignore"
value={progressValue !== undefined ? progressValue : 0}
Expand All @@ -123,37 +123,38 @@ export const WorkspaceBuildProgress: FC<WorkspaceBuildProgressProps> = ({
// If a transition is set, there is a moment on new load where the
// bar accelerates to progressValue and then rapidly decelerates, which
// is not indicative of true progress.
classes={{ bar: styles.noTransition }}
classes={{
bar: css`
transition: none;
`,
}}
/>
<div className={styles.barHelpers}>
<div className={styles.label}>
<div css={styles.barHelpers}>
<div css={styles.label}>
{capitalize(workspace.latest_build.status)} workspace...
</div>
<div className={styles.label} data-chromatic="ignore">
<div css={styles.label} data-chromatic="ignore">
{progressText}
</div>
</div>
</div>
);
};

const useStyles = makeStyles((theme) => ({
stack: {
const styles = {
stack: (theme) => ({
paddingLeft: theme.spacing(0.2),
paddingRight: theme.spacing(0.2),
},
noTransition: {
transition: "none",
},
barHelpers: {
}),
barHelpers: (theme) => ({
display: "flex",
justifyContent: "space-between",
marginTop: theme.spacing(0.5),
},
label: {
}),
label: (theme) => ({
fontSize: 12,
display: "block",
fontWeight: 600,
color: theme.palette.text.secondary,
},
}));
}),
} satisfies Record<string, Interpolation<Theme>>;