Skip to content

Commit a3bd2a0

Browse files
committed
refactor: update the workspace table design
1 parent c8c4de5 commit a3bd2a0

File tree

5 files changed

+194
-244
lines changed

5 files changed

+194
-244
lines changed

site/src/hooks/useClickableTableRow.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@
1313
* It might not make sense to test this hook until the underlying design
1414
* problems are fixed.
1515
*/
16-
import { type CSSObject, useTheme } from "@emotion/react";
1716
import type { TableRowProps } from "@mui/material/TableRow";
1817
import type { MouseEventHandler } from "react";
1918
import {
2019
type ClickableAriaRole,
2120
type UseClickableResult,
2221
useClickable,
2322
} from "./useClickable";
23+
import { cn } from "utils/cn";
2424

2525
type UseClickableTableRowResult<
2626
TRole extends ClickableAriaRole = ClickableAriaRole,
2727
> = UseClickableResult<HTMLTableRowElement, TRole> &
2828
TableRowProps & {
29-
css: CSSObject;
29+
className: string;
3030
hover: true;
3131
onAuxClick: MouseEventHandler<HTMLTableRowElement>;
3232
};
@@ -54,23 +54,13 @@ export const useClickableTableRow = <
5454
onAuxClick: externalOnAuxClick,
5555
}: UseClickableTableRowConfig<TRole>): UseClickableTableRowResult<TRole> => {
5656
const clickableProps = useClickable(onClick, (role ?? "button") as TRole);
57-
const theme = useTheme();
5857

5958
return {
6059
...clickableProps,
61-
css: {
62-
cursor: "pointer",
63-
64-
"&:focus": {
65-
outline: `1px solid ${theme.palette.primary.main}`,
66-
outlineOffset: -1,
67-
},
68-
69-
"&:last-of-type": {
70-
borderBottomLeftRadius: 8,
71-
borderBottomRightRadius: 8,
72-
},
73-
},
60+
className: cn([
61+
"cursor-pointer hover:outline focus:outline -outline-offset-1 outline-border-hover",
62+
"first:rounded-t-md last:rounded-b-md",
63+
]),
7464
hover: true,
7565
onDoubleClick,
7666
onAuxClick: (event) => {

site/src/pages/TemplatesPage/TemplatesPageView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const TemplateRow: FC<TemplateRowProps> = ({
102102
);
103103
const navigate = useNavigate();
104104

105-
const { css: clickableCss, ...clickableRow } = useClickableTableRow({
105+
const clickableRow = useClickableTableRow({
106106
onClick: () => navigate(templatePageLink),
107107
});
108108

@@ -111,7 +111,7 @@ const TemplateRow: FC<TemplateRowProps> = ({
111111
key={template.id}
112112
data-testid={`template-${template.id}`}
113113
{...clickableRow}
114-
css={[clickableCss, styles.tableRow]}
114+
css={styles.tableRow}
115115
>
116116
<TableCell>
117117
<AvatarData

site/src/pages/WorkspacesPage/LastUsed.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useTheme } from "@emotion/react";
21
import { Stack } from "components/Stack/Stack";
32
import { StatusIndicatorDot } from "components/StatusIndicator/StatusIndicator";
43
import dayjs from "dayjs";
@@ -12,8 +11,6 @@ interface LastUsedProps {
1211
}
1312

1413
export const LastUsed: FC<LastUsedProps> = ({ lastUsedAt }) => {
15-
const theme = useTheme();
16-
1714
const [circle, message] = useTime(() => {
1815
const t = dayjs(lastUsedAt);
1916
const now = dayjs();
@@ -40,7 +37,7 @@ export const LastUsed: FC<LastUsedProps> = ({ lastUsedAt }) => {
4037

4138
return (
4239
<Stack
43-
style={{ color: theme.palette.text.secondary }}
40+
className="text-content-secondary"
4441
direction="row"
4542
spacing={1}
4643
alignItems="center"
@@ -49,4 +46,4 @@ export const LastUsed: FC<LastUsedProps> = ({ lastUsedAt }) => {
4946
<span data-chromatic="ignore">{message}</span>
5047
</Stack>
5148
);
52-
};
49+
};

site/src/pages/WorkspacesPage/WorkspacesPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,4 @@ export const WorkspacesPageView: FC<WorkspacesPageViewProps> = ({
239239
)}
240240
</Margins>
241241
);
242-
};
242+
};

0 commit comments

Comments
 (0)