Skip to content

Commit f47ed9d

Browse files
committed
Align avatar with the timeline vertical line
1 parent d6fc56b commit f47ed9d

File tree

3 files changed

+44
-33
lines changed

3 files changed

+44
-33
lines changed

site/src/components/Avatar/Avatar.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ const avatarVariants = cva(
1616
{
1717
variants: {
1818
size: {
19-
lg: "h-10 w-10 rounded-[6px] text-sm font-medium",
20-
default: "h-6 w-6 text-2xs",
21-
sm: "h-[18px] w-[18px] text-[8px]",
19+
lg: "h-[--avatar-lg] w-[--avatar-lg] rounded-[6px] text-sm font-medium",
20+
default: "h-[--avatar-default] w-[--avatar-default] text-2xs",
21+
sm: "h-[--avatar-sm] w-[--avatar-sm] text-[8px]",
2222
},
2323
variant: {
2424
default: "",
Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import type { Interpolation } from "@emotion/react";
12
import TableRow, { type TableRowProps } from "@mui/material/TableRow";
23
import { forwardRef } from "react";
4+
import type { Theme } from "theme";
35

46
interface TimelineEntryProps extends TableRowProps {
57
clickable?: boolean;
@@ -12,39 +14,44 @@ export const TimelineEntry = forwardRef<
1214
return (
1315
<TableRow
1416
ref={ref}
15-
css={(theme) => [
16-
{
17-
"&:focus": {
18-
outlineStyle: "solid",
19-
outlineOffset: -1,
20-
outlineWidth: 2,
21-
outlineColor: theme.palette.primary.main,
22-
},
23-
"& td": {
24-
position: "relative",
25-
overflow: "hidden",
26-
},
27-
"& td:before": {
28-
position: "absolute",
29-
left: 49, // 50px - (width / 2)
30-
display: "block",
31-
content: "''",
32-
height: "100%",
33-
width: 2,
34-
background: theme.palette.divider,
35-
},
36-
},
37-
clickable && {
38-
cursor: "pointer",
39-
40-
"&:hover": {
41-
backgroundColor: theme.palette.action.hover,
42-
},
43-
},
44-
]}
17+
css={[styles.row, clickable ? styles.clickable : null]}
4518
{...props}
4619
>
4720
{children}
4821
</TableRow>
4922
);
5023
});
24+
25+
const styles = {
26+
row: (theme) => ({
27+
"--side-padding": "32px",
28+
"&:focus": {
29+
outlineStyle: "solid",
30+
outlineOffset: -1,
31+
outlineWidth: 2,
32+
outlineColor: theme.palette.primary.main,
33+
},
34+
"& td": {
35+
position: "relative",
36+
overflow: "hidden",
37+
},
38+
"& td:before": {
39+
"--line-width": "2px",
40+
position: "absolute",
41+
left: "calc((var(--side-padding) + var(--avatar-default)/2) - var(--line-width) / 2)",
42+
display: "block",
43+
content: "''",
44+
height: "100%",
45+
width: "var(--line-width)",
46+
background: theme.palette.divider,
47+
},
48+
}),
49+
50+
clickable: (theme) => ({
51+
cursor: "pointer",
52+
53+
"&:hover": {
54+
backgroundColor: theme.palette.action.hover,
55+
},
56+
}),
57+
} satisfies Record<string, Interpolation<Theme>>;

site/src/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
--border: 240 5.9% 90%;
3232
--input: 240 5.9% 90%;
3333
--ring: 240 10% 3.9%;
34+
35+
--avatar-lg: 2.5rem;
36+
--avatar-default: 1.5rem;
37+
--avatar-sm: 1.125rem;
3438
}
3539
.dark {
3640
--content-primary: 0, 0%, 98%;

0 commit comments

Comments
 (0)