Skip to content

refactor: add more fill variants to the experimental theme #11827

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 1 commit into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions site/src/components/Dialogs/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,24 @@ export const DialogActionButtons: FC<DialogActionButtonsProps> = ({
const styles = {
dangerButton: (theme) => ({
"&.MuiButton-contained": {
backgroundColor: theme.experimental.roles.danger.fill,
borderColor: theme.experimental.roles.danger.outline,
backgroundColor: theme.experimental.roles.danger.fill.solid,
borderColor: theme.experimental.roles.danger.fill.outline,

"&:not(.MuiLoadingButton-loading)": {
color: theme.experimental.roles.danger.text,
color: theme.experimental.roles.danger.fill.text,
},

"&:hover:not(:disabled)": {
backgroundColor: theme.experimental.roles.danger.hover.fill,
borderColor: theme.experimental.roles.danger.hover.outline,
backgroundColor: theme.experimental.roles.danger.hover.fill.solid,
borderColor: theme.experimental.roles.danger.hover.fill.outline,
},

"&.Mui-disabled": {
backgroundColor: theme.experimental.roles.danger.disabled.background,
borderColor: theme.experimental.roles.danger.disabled.outline,

"&:not(.MuiLoadingButton-loading)": {
color: theme.experimental.roles.danger.disabled.text,
color: theme.experimental.roles.danger.disabled.fill.text,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/HelpTooltip/HelpTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const styles = {
display: "flex",
alignItems: "center",
...(theme.typography.body2 as CSSObject),
color: theme.experimental.roles.active.fill,
color: theme.experimental.roles.active.fill.outline,
}),

linkIcon: {
Expand Down
6 changes: 3 additions & 3 deletions site/src/components/LastSeen/LastSeen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ export const LastSeen: FC<LastSeenProps> = ({ at, ...attrs }) => {
// Since the agent reports on a 10m interval,
// the last_used_at can be inaccurate when recent.
message = "Now";
color = theme.experimental.roles.success.fill;
color = theme.experimental.roles.success.fill.solid;
} else if (t.isAfter(now.subtract(3, "day"))) {
color = theme.experimental.l2.text;
} else if (t.isAfter(now.subtract(1, "month"))) {
color = theme.experimental.roles.warning.fill;
color = theme.experimental.roles.warning.fill.solid;
} else if (t.isAfter(now.subtract(100, "year"))) {
color = theme.experimental.roles.error.fill;
color = theme.experimental.roles.error.fill.solid;
} else {
message = "Never";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export const WorkspaceStatusText: FC<WorkspaceStatusBadgeProps> = ({
css={(theme) => ({
fontWeight: 600,
color: type
? theme.experimental.roles[type].fill
? theme.experimental.roles[type].fill.solid
: theme.experimental.l1.text,
})}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const UserDropdown: FC<UserDropdownProps> = ({
/>
</Badge>
<DropdownArrow
color={theme.experimental.l2.fill}
color={theme.experimental.l2.fill.solid}
close={popover.isOpen}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const styles = {
}),

providerConnectedLabelIcon: (theme) => ({
color: theme.experimental.roles.success.fill,
color: theme.experimental.roles.success.fill.solid,
fontSize: 16,
}),
} as Record<string, Interpolation<Theme>>;
60 changes: 28 additions & 32 deletions site/src/pages/DeploySettingsPage/Option.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import CheckCircleOutlined from "@mui/icons-material/CheckCircleOutlined";
import { css, useTheme } from "@emotion/react";
import { type HTMLAttributes, type PropsWithChildren, type FC } from "react";
import { css, type Interpolation, type Theme, useTheme } from "@emotion/react";
import { type FC, type HTMLAttributes, type PropsWithChildren } from "react";
import { MONOSPACE_FONT_FAMILY } from "theme/constants";
import { DisabledBadge, EnabledBadge } from "components/Badges/Badges";

Expand Down Expand Up @@ -107,42 +107,16 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
type OptionConfigProps = HTMLAttributes<HTMLDivElement> & { isSource: boolean };

// OptionConfig takes a isSource bool to indicate if the Option is the source of the configured value.
export const OptionConfig = ({ isSource, ...attrs }: OptionConfigProps) => {
const theme = useTheme();
const borderColor = isSource
? theme.experimental.roles.active.outline
: theme.palette.divider;

export const OptionConfig: FC<OptionConfigProps> = ({ isSource, ...attrs }) => {
return (
<div
{...attrs}
css={[
{
fontSize: 13,
fontFamily: MONOSPACE_FONT_FAMILY,
fontWeight: 600,
backgroundColor: theme.palette.background.paper,
display: "inline-flex",
alignItems: "center",
borderRadius: 4,
padding: 6,
lineHeight: 1,
gap: 6,
border: `1px solid ${borderColor}`,
},
isSource
? {
"& .OptionConfigFlag": {
background: theme.experimental.roles.active.fill,
},
}
: undefined,
]}
css={[styles.configOption, isSource && styles.sourceConfigOption]}
/>
);
};

export const OptionConfigFlag = (props: HTMLAttributes<HTMLDivElement>) => {
export const OptionConfigFlag: FC<HTMLAttributes<HTMLDivElement>> = (props) => {
const theme = useTheme();

return (
Expand All @@ -163,6 +137,28 @@ export const OptionConfigFlag = (props: HTMLAttributes<HTMLDivElement>) => {
};

const styles = {
configOption: (theme) => ({
fontSize: 13,
fontFamily: MONOSPACE_FONT_FAMILY,
fontWeight: 600,
backgroundColor: theme.palette.background.paper,
display: "inline-flex",
alignItems: "center",
borderRadius: 4,
padding: 6,
lineHeight: 1,
gap: 6,
border: `1px solid ${theme.palette.divider}`,
}),

sourceConfigOption: (theme) => ({
border: `1px solid ${theme.experimental.roles.active.fill.outline}`,

"& .OptionConfigFlag": {
background: theme.experimental.roles.active.fill.solid,
},
}),

option: css`
font-size: 14px;
font-family: ${MONOSPACE_FONT_FAMILY};
Expand All @@ -173,4 +169,4 @@ const styles = {
padding: 16px;
}
`,
};
} satisfies Record<string, Interpolation<Theme>>;
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,8 @@ const TemplateUsagePanel: FC<TemplateUsagePanelProps> = ({
validUsage?.reduce((total, usage) => total + usage.seconds, 0) ?? 1;
const usageColors = chroma
.scale([
theme.experimental.roles.success.fill,
theme.experimental.roles.notice.fill,
theme.experimental.roles.success.fill.solid,
theme.experimental.roles.notice.fill.solid,
])
.mode("lch")
.colors(validUsage?.length ?? 0);
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/UsersPage/UsersFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const StatusIndicator: FC<StatusIndicatorProps> = ({ option }) => {
height: 8,
width: 8,
borderRadius: 4,
backgroundColor: theme.experimental.roles[option.color].fill,
backgroundColor: theme.experimental.roles[option.color].fill.solid,
}}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ const styles = {
lineHeight: "18px",

"& .option": {
color: theme.experimental.roles.danger.fill,
color: theme.experimental.roles.danger.fill.solid,
"&.Mui-checked": {
color: theme.experimental.roles.danger.fill,
color: theme.experimental.roles.danger.fill.solid,
},
},

Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/WorkspacesPage/BatchUpdateConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ const styles = {
newVersion: (theme) => ({
fontSize: 13,
fontWeight: 500,
color: theme.experimental.roles.active.fill,
color: theme.experimental.roles.active.fill.solid,
}),

message: {
Expand Down
6 changes: 3 additions & 3 deletions site/src/pages/WorkspacesPage/LastUsed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ export const LastUsed: FC<LastUsedProps> = ({ lastUsedAt }) => {
);

if (t.isAfter(now.subtract(1, "hour"))) {
circle = <Circle color={theme.experimental.roles.success.fill} />;
circle = <Circle color={theme.experimental.roles.success.fill.solid} />;
// Since the agent reports on a 10m interval,
// the last_used_at can be inaccurate when recent.
message = "Now";
} else if (t.isAfter(now.subtract(3, "day"))) {
circle = <Circle color={theme.palette.text.secondary} />;
} else if (t.isAfter(now.subtract(1, "month"))) {
circle = <Circle color={theme.palette.warning.light} />;
circle = <Circle color={theme.experimental.roles.warning.fill.solid} />;
} else if (t.isAfter(now.subtract(100, "year"))) {
circle = <Circle color={theme.experimental.roles.error.fill} />;
circle = <Circle color={theme.experimental.roles.error.fill.solid} />;
} else {
message = "Never";
}
Expand Down
2 changes: 1 addition & 1 deletion site/src/pages/WorkspacesPage/filter/filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ const StatusIndicator: FC<StatusIndicatorProps> = ({ option }) => {
height: 8,
width: 8,
borderRadius: 4,
backgroundColor: theme.experimental.roles[option.color].fill,
backgroundColor: theme.experimental.roles[option.color].fill.solid,
}}
/>
);
Expand Down
Loading