1
- import { makeStyles } from "@mui/styles" ;
2
1
import { Stack } from "components/Stack/Stack" ;
3
- import { FC , DragEvent , useRef , ReactNode } from "react" ;
2
+ import { type FC , type DragEvent , useRef , type ReactNode } from "react" ;
4
3
import UploadIcon from "@mui/icons-material/CloudUploadOutlined" ;
5
4
import { useClickable } from "hooks/useClickable" ;
6
5
import CircularProgress from "@mui/material/CircularProgress" ;
7
- import { combineClasses } from "utils/combineClasses" ;
8
6
import IconButton from "@mui/material/IconButton" ;
9
7
import RemoveIcon from "@mui/icons-material/DeleteOutline" ;
10
8
import FileIcon from "@mui/icons-material/FolderOutlined" ;
9
+ import { css , type Interpolation , type Theme } from "@emotion/react" ;
11
10
12
11
const useFileDrop = (
13
12
callback : ( file : File ) => void ,
@@ -62,7 +61,6 @@ export const FileUpload: FC<FileUploadProps> = ({
62
61
extension,
63
62
fileTypeRequired,
64
63
} ) => {
65
- const styles = useStyles ( ) ;
66
64
const inputRef = useRef < HTMLInputElement > ( null ) ;
67
65
const tarDrop = useFileDrop ( onUpload , fileTypeRequired ) ;
68
66
@@ -75,7 +73,7 @@ export const FileUpload: FC<FileUploadProps> = ({
75
73
if ( ! isUploading && file ) {
76
74
return (
77
75
< Stack
78
- className = { styles . file }
76
+ css = { styles . file }
79
77
direction = "row"
80
78
justifyContent = "space-between"
81
79
alignItems = "center"
@@ -95,23 +93,20 @@ export const FileUpload: FC<FileUploadProps> = ({
95
93
return (
96
94
< >
97
95
< div
98
- className = { combineClasses ( {
99
- [ styles . root ] : true ,
100
- [ styles . disabled ] : isUploading ,
101
- } ) }
96
+ css = { [ styles . root , isUploading && styles . disabled ] }
102
97
{ ...clickable }
103
98
{ ...tarDrop }
104
99
>
105
100
< Stack alignItems = "center" spacing = { 1 } >
106
101
{ isUploading ? (
107
102
< CircularProgress size = { 32 } />
108
103
) : (
109
- < UploadIcon className = { styles . icon } />
104
+ < UploadIcon css = { styles . icon } />
110
105
) }
111
106
112
107
< Stack alignItems = "center" spacing = { 0.5 } >
113
- < span className = { styles . title } > { title } </ span >
114
- < span className = { styles . description } > { description } </ span >
108
+ < span css = { styles . title } > { title } </ span >
109
+ < span css = { styles . description } > { description } </ span >
115
110
</ Stack >
116
111
</ Stack >
117
112
</ div >
@@ -120,7 +115,7 @@ export const FileUpload: FC<FileUploadProps> = ({
120
115
type = "file"
121
116
data-testid = "file-upload"
122
117
ref = { inputRef }
123
- className = { styles . input }
118
+ css = { styles . input }
124
119
accept = { extension }
125
120
onChange = { ( event ) => {
126
121
const file = event . currentTarget . files ?. [ 0 ] ;
@@ -133,48 +128,48 @@ export const FileUpload: FC<FileUploadProps> = ({
133
128
) ;
134
129
} ;
135
130
136
- const useStyles = makeStyles ( ( theme ) => ( {
137
- root : {
138
- display : " flex" ,
139
- alignItems : " center" ,
140
- justifyContent : " center" ,
141
- borderRadius : theme . shape . borderRadius ,
142
- border : ` 2px dashed ${ theme . palette . divider } ` ,
143
- padding : theme . spacing ( 6 ) ,
144
- cursor : " pointer" ,
145
-
146
- " &:hover" : {
147
- backgroundColor : theme . palette . background . paper ,
148
- } ,
149
- } ,
131
+ const styles = {
132
+ root : ( theme ) => css `
133
+ display : flex;
134
+ align-items : center;
135
+ justify-content : center;
136
+ border-radius : ${ theme . shape . borderRadius } ;
137
+ border : 2px dashed ${ theme . palette . divider } ;
138
+ padding : ${ theme . spacing ( 6 ) } ;
139
+ cursor : pointer;
140
+
141
+ & : hover {
142
+ background-color : ${ theme . palette . background . paper } ;
143
+ }
144
+ ` ,
150
145
151
146
disabled : {
152
147
pointerEvents : "none" ,
153
148
opacity : 0.75 ,
154
149
} ,
155
150
156
- icon : {
151
+ icon : ( theme ) => ( {
157
152
fontSize : theme . spacing ( 8 ) ,
158
- } ,
153
+ } ) ,
159
154
160
- title : {
155
+ title : ( theme ) => ( {
161
156
fontSize : theme . spacing ( 2 ) ,
162
- } ,
157
+ } ) ,
163
158
164
- description : {
159
+ description : ( theme ) => ( {
165
160
color : theme . palette . text . secondary ,
166
161
textAlign : "center" ,
167
162
maxWidth : theme . spacing ( 50 ) ,
168
- } ,
163
+ } ) ,
169
164
170
165
input : {
171
166
display : "none" ,
172
167
} ,
173
168
174
- file : {
169
+ file : ( theme ) => ( {
175
170
borderRadius : theme . shape . borderRadius ,
176
171
border : `1px solid ${ theme . palette . divider } ` ,
177
172
padding : theme . spacing ( 2 ) ,
178
173
background : theme . palette . background . paper ,
179
- } ,
180
- } ) ) ;
174
+ } ) ,
175
+ } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments