1
+ import { css } from "@emotion/css" ;
2
+ import { type Interpolation , type Theme , useTheme } from "@emotion/react" ;
1
3
import IconButton from "@mui/material/IconButton" ;
2
4
import { EditSquare } from "components/Icons/EditSquare" ;
3
- import { FC } from "react" ;
4
- import { makeStyles } from "@mui/styles" ;
5
+ import { type FC } from "react" ;
5
6
import { Stack } from "components/Stack/Stack" ;
6
7
import Checkbox from "@mui/material/Checkbox" ;
7
8
import UserIcon from "@mui/icons-material/PersonOutline" ;
@@ -34,15 +35,13 @@ const Option: React.FC<{
34
35
isChecked : boolean ;
35
36
onChange : ( roleName : string ) => void ;
36
37
} > = ( { value, name, description, isChecked, onChange } ) => {
37
- const styles = useStyles ( ) ;
38
-
39
38
return (
40
- < label htmlFor = { name } className = { styles . option } >
39
+ < label htmlFor = { name } css = { styles . option } >
41
40
< Stack direction = "row" alignItems = "flex-start" >
42
41
< Checkbox
43
42
id = { name }
44
43
size = "small"
45
- className = { styles . checkbox }
44
+ css = { styles . checkbox }
46
45
value = { value }
47
46
checked = { isChecked }
48
47
onChange = { ( e ) => {
@@ -51,7 +50,7 @@ const Option: React.FC<{
51
50
/>
52
51
< Stack spacing = { 0 } >
53
52
< strong > { name } </ strong >
54
- < span className = { styles . optionDescription } > { description } </ span >
53
+ < span css = { styles . optionDescription } > { description } </ span >
55
54
</ Stack >
56
55
</ Stack >
57
56
</ label >
@@ -77,7 +76,7 @@ export const EditRolesButton: FC<EditRolesButtonProps> = ({
77
76
userLoginType,
78
77
oidcRoleSync,
79
78
} ) => {
80
- const styles = useStyles ( ) ;
79
+ const theme = useTheme ( ) ;
81
80
82
81
const handleChange = ( roleName : string ) => {
83
82
if ( selectedRoleNames . has ( roleName ) ) {
@@ -108,20 +107,28 @@ export const EditRolesButton: FC<EditRolesButtonProps> = ({
108
107
< PopoverTrigger >
109
108
< IconButton
110
109
size = "small"
111
- className = { styles . editButton }
110
+ css = { styles . editButton }
112
111
title = "Edit user roles"
113
112
>
114
113
< EditSquare />
115
114
</ IconButton >
116
115
</ PopoverTrigger >
117
116
118
- < PopoverContent classes = { { paper : styles . popoverPaper } } >
117
+ < PopoverContent
118
+ classes = { {
119
+ paper : css `
120
+ width : ${ theme . spacing ( 45 ) } ;
121
+ margin-top : ${ theme . spacing ( 1 ) } ;
122
+ background : ${ theme . palette . background . paperLight } ;
123
+ ` ,
124
+ } }
125
+ >
119
126
< fieldset
120
- className = { styles . fieldset }
127
+ css = { styles . fieldset }
121
128
disabled = { isLoading }
122
129
title = "Available roles"
123
130
>
124
- < Stack className = { styles . options } spacing = { 3 } >
131
+ < Stack css = { styles . options } spacing = { 3 } >
125
132
{ roles . map ( ( role ) => (
126
133
< Option
127
134
key = { role . name }
@@ -134,12 +141,12 @@ export const EditRolesButton: FC<EditRolesButtonProps> = ({
134
141
) ) }
135
142
</ Stack >
136
143
</ fieldset >
137
- < div className = { styles . footer } >
144
+ < div css = { styles . footer } >
138
145
< Stack direction = "row" alignItems = "flex-start" >
139
- < UserIcon className = { styles . userIcon } />
146
+ < UserIcon css = { styles . userIcon } />
140
147
< Stack spacing = { 0 } >
141
148
< strong > Member</ strong >
142
- < span className = { styles . optionDescription } >
149
+ < span css = { styles . optionDescription } >
143
150
{ roleDescriptions . member }
144
151
</ span >
145
152
</ Stack >
@@ -150,8 +157,8 @@ export const EditRolesButton: FC<EditRolesButtonProps> = ({
150
157
) ;
151
158
} ;
152
159
153
- const useStyles = makeStyles ( ( theme ) => ( {
154
- editButton : {
160
+ const styles = {
161
+ editButton : ( theme ) => ( {
155
162
color : theme . palette . text . secondary ,
156
163
157
164
"& .MuiSvgIcon-root" : {
@@ -165,12 +172,7 @@ const useStyles = makeStyles((theme) => ({
165
172
color : theme . palette . text . primary ,
166
173
backgroundColor : "transparent" ,
167
174
} ,
168
- } ,
169
- popoverPaper : {
170
- width : theme . spacing ( 45 ) ,
171
- marginTop : theme . spacing ( 1 ) ,
172
- background : theme . palette . background . paperLight ,
173
- } ,
175
+ } ) ,
174
176
fieldset : {
175
177
border : 0 ,
176
178
margin : 0 ,
@@ -180,14 +182,14 @@ const useStyles = makeStyles((theme) => ({
180
182
opacity : 0.5 ,
181
183
} ,
182
184
} ,
183
- options : {
185
+ options : ( theme ) => ( {
184
186
padding : theme . spacing ( 3 ) ,
185
- } ,
187
+ } ) ,
186
188
option : {
187
189
cursor : "pointer" ,
188
190
fontSize : 14 ,
189
191
} ,
190
- checkbox : {
192
+ checkbox : ( theme ) => ( {
191
193
padding : 0 ,
192
194
position : "relative" ,
193
195
top : 1 , // Alignment
@@ -196,21 +198,21 @@ const useStyles = makeStyles((theme) => ({
196
198
width : theme . spacing ( 2.5 ) ,
197
199
height : theme . spacing ( 2.5 ) ,
198
200
} ,
199
- } ,
200
- optionDescription : {
201
+ } ) ,
202
+ optionDescription : ( theme ) => ( {
201
203
fontSize : 13 ,
202
204
color : theme . palette . text . secondary ,
203
205
lineHeight : "160%" ,
204
- } ,
205
- footer : {
206
+ } ) ,
207
+ footer : ( theme ) => ( {
206
208
padding : theme . spacing ( 3 ) ,
207
209
backgroundColor : theme . palette . background . paper ,
208
210
borderTop : `1px solid ${ theme . palette . divider } ` ,
209
211
fontSize : 14 ,
210
- } ,
211
- userIcon : {
212
+ } ) ,
213
+ userIcon : ( theme ) => ( {
212
214
width : theme . spacing ( 2.5 ) , // Same as the checkbox
213
215
height : theme . spacing ( 2.5 ) ,
214
216
color : theme . palette . primary . main ,
215
- } ,
216
- } ) ) ;
217
+ } ) ,
218
+ } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments