Skip to content

Commit 9ebe071

Browse files
committed
emotion: TemplateFiles
1 parent e07bf78 commit 9ebe071

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

site/src/components/TemplateFiles/TemplateFiles.tsx

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { makeStyles } from "@mui/styles";
1+
import { type Interpolation, type Theme } from "@emotion/react";
2+
import { type FC } from "react";
23
import { DockerIcon } from "components/Icons/DockerIcon";
34
import { MarkdownIcon } from "components/Icons/MarkdownIcon";
45
import { TerraformIcon } from "components/Icons/TerraformIcon";
56
import { SyntaxHighlighter } from "components/SyntaxHighlighter/SyntaxHighlighter";
67
import { UseTabResult } from "hooks/useTab";
7-
import { FC } from "react";
8-
import { combineClasses } from "utils/combineClasses";
98
import { AllowedExtension, TemplateVersionFiles } from "utils/templateVersion";
109
import InsertDriveFileOutlined from "@mui/icons-material/InsertDriveFileOutlined";
1110

@@ -43,15 +42,14 @@ export const TemplateFiles: FC<{
4342
previousFiles?: TemplateVersionFiles;
4443
tab: UseTabResult;
4544
}> = ({ currentFiles, previousFiles, tab }) => {
46-
const styles = useStyles();
4745
const filenames = Object.keys(currentFiles);
4846
const selectedFilename = filenames[Number(tab.value)];
4947
const currentFile = currentFiles[selectedFilename];
5048
const previousFile = previousFiles && previousFiles[selectedFilename];
5149

5250
return (
53-
<div className={styles.files}>
54-
<div className={styles.tabs}>
51+
<div css={styles.files}>
52+
<div css={styles.tabs}>
5553
{filenames.map((filename, index) => {
5654
const tabValue = index.toString();
5755
const extension = getExtension(filename) as AllowedExtension;
@@ -63,18 +61,15 @@ export const TemplateFiles: FC<{
6361

6462
return (
6563
<button
66-
className={combineClasses({
67-
[styles.tab]: true,
68-
[styles.tabActive]: tabValue === tab.value,
69-
})}
64+
css={[styles.tab, tabValue === tab.value && styles.tabActive]}
7065
onClick={() => {
7166
tab.set(tabValue);
7267
}}
7368
key={filename}
7469
>
7570
{icon}
7671
{filename}
77-
{hasDiff && <div className={styles.tabDiff} />}
72+
{hasDiff && <div css={styles.tabDiff} />}
7873
</button>
7974
);
8075
})}
@@ -92,16 +87,16 @@ export const TemplateFiles: FC<{
9287
</div>
9388
);
9489
};
95-
const useStyles = makeStyles((theme) => ({
96-
tabs: {
90+
const styles = {
91+
tabs: (theme) => ({
9792
display: "flex",
9893
alignItems: "baseline",
9994
borderBottom: `1px solid ${theme.palette.divider}`,
10095
gap: 1,
10196
overflowX: "auto",
102-
},
97+
}),
10398

104-
tab: {
99+
tab: (theme) => ({
105100
background: "transparent",
106101
border: 0,
107102
padding: theme.spacing(0, 3),
@@ -123,9 +118,9 @@ const useStyles = makeStyles((theme) => ({
123118
"&:hover": {
124119
backgroundColor: theme.palette.action.hover,
125120
},
126-
},
121+
}),
127122

128-
tabActive: {
123+
tabActive: (theme) => ({
129124
opacity: 1,
130125
background: theme.palette.action.hover,
131126
color: theme.palette.text.primary,
@@ -140,26 +135,26 @@ const useStyles = makeStyles((theme) => ({
140135
backgroundColor: theme.palette.secondary.dark,
141136
position: "absolute",
142137
},
143-
},
138+
}),
144139

145-
tabDiff: {
140+
tabDiff: (theme) => ({
146141
height: 6,
147142
width: 6,
148143
backgroundColor: theme.palette.warning.light,
149144
borderRadius: "100%",
150145
marginLeft: theme.spacing(0.5),
151-
},
146+
}),
152147

153-
codeWrapper: {
148+
codeWrapper: (theme) => ({
154149
background: theme.palette.background.paperLight,
155-
},
150+
}),
156151

157-
files: {
152+
files: (theme) => ({
158153
borderRadius: theme.shape.borderRadius,
159154
border: `1px solid ${theme.palette.divider}`,
160-
},
155+
}),
161156

162157
prism: {
163158
borderRadius: 0,
164159
},
165-
}));
160+
} satisfies Record<string, Interpolation<Theme>>;

0 commit comments

Comments
 (0)