1
- import { makeStyles } from "@mui/styles" ;
1
+ import { type Interpolation , type Theme } from "@emotion/react" ;
2
+ import { type FC } from "react" ;
2
3
import { DockerIcon } from "components/Icons/DockerIcon" ;
3
4
import { MarkdownIcon } from "components/Icons/MarkdownIcon" ;
4
5
import { TerraformIcon } from "components/Icons/TerraformIcon" ;
5
6
import { SyntaxHighlighter } from "components/SyntaxHighlighter/SyntaxHighlighter" ;
6
7
import { UseTabResult } from "hooks/useTab" ;
7
- import { FC } from "react" ;
8
- import { combineClasses } from "utils/combineClasses" ;
9
8
import { AllowedExtension , TemplateVersionFiles } from "utils/templateVersion" ;
10
9
import InsertDriveFileOutlined from "@mui/icons-material/InsertDriveFileOutlined" ;
11
10
@@ -43,15 +42,14 @@ export const TemplateFiles: FC<{
43
42
previousFiles ?: TemplateVersionFiles ;
44
43
tab : UseTabResult ;
45
44
} > = ( { currentFiles, previousFiles, tab } ) => {
46
- const styles = useStyles ( ) ;
47
45
const filenames = Object . keys ( currentFiles ) ;
48
46
const selectedFilename = filenames [ Number ( tab . value ) ] ;
49
47
const currentFile = currentFiles [ selectedFilename ] ;
50
48
const previousFile = previousFiles && previousFiles [ selectedFilename ] ;
51
49
52
50
return (
53
- < div className = { styles . files } >
54
- < div className = { styles . tabs } >
51
+ < div css = { styles . files } >
52
+ < div css = { styles . tabs } >
55
53
{ filenames . map ( ( filename , index ) => {
56
54
const tabValue = index . toString ( ) ;
57
55
const extension = getExtension ( filename ) as AllowedExtension ;
@@ -63,18 +61,15 @@ export const TemplateFiles: FC<{
63
61
64
62
return (
65
63
< button
66
- className = { combineClasses ( {
67
- [ styles . tab ] : true ,
68
- [ styles . tabActive ] : tabValue === tab . value ,
69
- } ) }
64
+ css = { [ styles . tab , tabValue === tab . value && styles . tabActive ] }
70
65
onClick = { ( ) => {
71
66
tab . set ( tabValue ) ;
72
67
} }
73
68
key = { filename }
74
69
>
75
70
{ icon }
76
71
{ filename }
77
- { hasDiff && < div className = { styles . tabDiff } /> }
72
+ { hasDiff && < div css = { styles . tabDiff } /> }
78
73
</ button >
79
74
) ;
80
75
} ) }
@@ -92,16 +87,16 @@ export const TemplateFiles: FC<{
92
87
</ div >
93
88
) ;
94
89
} ;
95
- const useStyles = makeStyles ( ( theme ) => ( {
96
- tabs : {
90
+ const styles = {
91
+ tabs : ( theme ) => ( {
97
92
display : "flex" ,
98
93
alignItems : "baseline" ,
99
94
borderBottom : `1px solid ${ theme . palette . divider } ` ,
100
95
gap : 1 ,
101
96
overflowX : "auto" ,
102
- } ,
97
+ } ) ,
103
98
104
- tab : {
99
+ tab : ( theme ) => ( {
105
100
background : "transparent" ,
106
101
border : 0 ,
107
102
padding : theme . spacing ( 0 , 3 ) ,
@@ -123,9 +118,9 @@ const useStyles = makeStyles((theme) => ({
123
118
"&:hover" : {
124
119
backgroundColor : theme . palette . action . hover ,
125
120
} ,
126
- } ,
121
+ } ) ,
127
122
128
- tabActive : {
123
+ tabActive : ( theme ) => ( {
129
124
opacity : 1 ,
130
125
background : theme . palette . action . hover ,
131
126
color : theme . palette . text . primary ,
@@ -140,26 +135,26 @@ const useStyles = makeStyles((theme) => ({
140
135
backgroundColor : theme . palette . secondary . dark ,
141
136
position : "absolute" ,
142
137
} ,
143
- } ,
138
+ } ) ,
144
139
145
- tabDiff : {
140
+ tabDiff : ( theme ) => ( {
146
141
height : 6 ,
147
142
width : 6 ,
148
143
backgroundColor : theme . palette . warning . light ,
149
144
borderRadius : "100%" ,
150
145
marginLeft : theme . spacing ( 0.5 ) ,
151
- } ,
146
+ } ) ,
152
147
153
- codeWrapper : {
148
+ codeWrapper : ( theme ) => ( {
154
149
background : theme . palette . background . paperLight ,
155
- } ,
150
+ } ) ,
156
151
157
- files : {
152
+ files : ( theme ) => ( {
158
153
borderRadius : theme . shape . borderRadius ,
159
154
border : `1px solid ${ theme . palette . divider } ` ,
160
- } ,
155
+ } ) ,
161
156
162
157
prism : {
163
158
borderRadius : 0 ,
164
159
} ,
165
- } ) ) ;
160
+ } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments