Skip to content

Commit 3504769

Browse files
committed
emotion: AgentRowPreview
1 parent 8d5ef4c commit 3504769

File tree

1 file changed

+42
-56
lines changed

1 file changed

+42
-56
lines changed
Lines changed: 42 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import { makeStyles } from "@mui/styles";
2-
import { AppPreviewLink } from "components/Resources/AppLink/AppPreviewLink";
3-
import { FC } from "react";
4-
import { combineClasses } from "utils/combineClasses";
5-
import { WorkspaceAgent } from "api/typesGenerated";
1+
import { type Interpolation, type Theme } from "@emotion/react";
2+
import { type FC } from "react";
3+
import type { WorkspaceAgent } from "api/typesGenerated";
64
import { Stack } from "../Stack/Stack";
5+
import { AppPreviewLink } from "./AppLink/AppPreviewLink";
76

87
interface AgentRowPreviewStyles {
98
// Helpful when there are more than one row so the values are aligned
@@ -18,57 +17,58 @@ export const AgentRowPreview: FC<AgentRowPreviewProps> = ({
1817
agent,
1918
alignValues,
2019
}) => {
21-
const styles = useStyles({ alignValues });
22-
2320
return (
2421
<Stack
2522
key={agent.id}
2623
direction="row"
2724
alignItems="center"
2825
justifyContent="space-between"
29-
className={styles.agentRow}
26+
css={styles.agentRow}
3027
>
3128
<Stack direction="row" alignItems="baseline">
32-
<div className={styles.agentStatusWrapper}>
33-
<div className={styles.agentStatusPreview}></div>
29+
<div css={styles.agentStatusWrapper}>
30+
<div css={styles.agentStatusPreview}></div>
3431
</div>
3532
<Stack
3633
alignItems="baseline"
3734
direction="row"
3835
spacing={4}
39-
className={styles.agentData}
36+
css={styles.agentData}
4037
>
4138
<Stack
4239
direction="row"
4340
alignItems="baseline"
4441
spacing={1}
45-
className={combineClasses([
42+
css={[
4643
styles.noShrink,
4744
styles.agentDataItem,
48-
styles.agentDataName,
49-
])}
45+
(theme) => ({
46+
[theme.breakpoints.up("sm")]: {
47+
minWidth: alignValues ? 240 : undefined,
48+
},
49+
}),
50+
]}
5051
>
5152
<span>Agent:</span>
52-
<span className={styles.agentDataValue}>{agent.name}</span>
53+
<span css={styles.agentDataValue}>{agent.name}</span>
5354
</Stack>
5455

5556
<Stack
5657
direction="row"
5758
alignItems="baseline"
5859
spacing={1}
59-
className={combineClasses([
60+
css={[
6061
styles.noShrink,
6162
styles.agentDataItem,
62-
styles.agentDataOS,
63-
])}
63+
(theme) => ({
64+
[theme.breakpoints.up("sm")]: {
65+
minWidth: alignValues ? 100 : undefined,
66+
},
67+
}),
68+
]}
6469
>
6570
<span>OS:</span>
66-
<span
67-
className={combineClasses([
68-
styles.agentDataValue,
69-
styles.agentOS,
70-
])}
71-
>
71+
<span css={[styles.agentDataValue, styles.agentOS]}>
7272
{agent.operating_system}
7373
</span>
7474
</Stack>
@@ -77,7 +77,7 @@ export const AgentRowPreview: FC<AgentRowPreviewProps> = ({
7777
direction="row"
7878
alignItems="center"
7979
spacing={1}
80-
className={styles.agentDataItem}
80+
css={styles.agentDataItem}
8181
>
8282
<span>Apps:</span>
8383
<Stack
@@ -90,7 +90,7 @@ export const AgentRowPreview: FC<AgentRowPreviewProps> = ({
9090
<AppPreviewLink key={app.slug} app={app} />
9191
))}
9292
{agent.apps.length === 0 && (
93-
<span className={styles.agentDataValue}>None</span>
93+
<span css={styles.agentDataValue}>None</span>
9494
)}
9595
</Stack>
9696
</Stack>
@@ -100,8 +100,8 @@ export const AgentRowPreview: FC<AgentRowPreviewProps> = ({
100100
);
101101
};
102102

103-
const useStyles = makeStyles((theme) => ({
104-
agentRow: {
103+
const styles = {
104+
agentRow: (theme) => ({
105105
padding: theme.spacing(2, 4),
106106
backgroundColor: theme.palette.background.paperLight,
107107
fontSize: 16,
@@ -120,73 +120,59 @@ const useStyles = makeStyles((theme) => ({
120120
top: 0,
121121
left: 49,
122122
},
123-
},
123+
}),
124124

125-
agentStatusWrapper: {
125+
agentStatusWrapper: (theme) => ({
126126
width: theme.spacing(4.5),
127127
display: "flex",
128128
justifyContent: "center",
129129
flexShrink: 0,
130-
},
130+
}),
131131

132-
agentStatusPreview: {
132+
agentStatusPreview: (theme) => ({
133133
width: 10,
134134
height: 10,
135135
border: `2px solid ${theme.palette.text.secondary}`,
136136
borderRadius: "100%",
137137
position: "relative",
138138
zIndex: 1,
139139
background: theme.palette.background.paper,
140-
},
140+
}),
141141

142142
agentName: {
143143
fontWeight: 600,
144144
},
145145

146-
agentOS: {
146+
agentOS: (theme) => ({
147147
textTransform: "capitalize",
148148
fontSize: 14,
149149
color: theme.palette.text.secondary,
150-
},
150+
}),
151151

152-
agentData: {
152+
agentData: (theme) => ({
153153
fontSize: 14,
154154
color: theme.palette.text.secondary,
155155

156156
[theme.breakpoints.down("md")]: {
157157
gap: theme.spacing(2),
158158
flexWrap: "wrap",
159159
},
160-
},
160+
}),
161161

162-
agentDataName: {
163-
[theme.breakpoints.up("sm")]: {
164-
minWidth: ({ alignValues }: AgentRowPreviewStyles) =>
165-
alignValues ? 240 : undefined,
166-
},
167-
},
168-
169-
agentDataOS: {
170-
[theme.breakpoints.up("sm")]: {
171-
minWidth: ({ alignValues }: AgentRowPreviewStyles) =>
172-
alignValues ? 100 : undefined,
173-
},
174-
},
175-
176-
agentDataValue: {
162+
agentDataValue: (theme) => ({
177163
color: theme.palette.text.primary,
178-
},
164+
}),
179165

180166
noShrink: {
181167
flexShrink: 0,
182168
},
183169

184-
agentDataItem: {
170+
agentDataItem: (theme) => ({
185171
[theme.breakpoints.down("md")]: {
186172
flexDirection: "column",
187173
alignItems: "flex-start",
188174
gap: theme.spacing(1),
189175
width: "fit-content",
190176
},
191-
},
192-
}));
177+
}),
178+
} satisfies Record<string, Interpolation<Theme>>;

0 commit comments

Comments
 (0)