1
1
import Button from "@mui/material/Button" ;
2
2
import Link from "@mui/material/Link" ;
3
- import { makeStyles } from "@mui/styles" ;
4
3
import RefreshOutlined from "@mui/icons-material/RefreshOutlined" ;
5
- import { BuildInfoResponse } from "api/typesGenerated" ;
4
+ import { type FC , useEffect , useState } from "react" ;
5
+ import { Helmet } from "react-helmet-async" ;
6
+ import { css } from "@emotion/css" ;
7
+ import { useTheme , type Interpolation , type Theme } from "@emotion/react" ;
8
+ import type { BuildInfoResponse } from "api/typesGenerated" ;
6
9
import { CopyButton } from "components/CopyButton/CopyButton" ;
7
10
import { CoderIcon } from "components/Icons/CoderIcon" ;
8
11
import { FullScreenLoader } from "components/Loader/FullScreenLoader" ;
9
12
import { Stack } from "components/Stack/Stack" ;
10
- import { FC , useEffect , useState } from "react" ;
11
- import { Helmet } from "react-helmet-async" ;
12
13
import { Margins } from "components/Margins/Margins" ;
13
14
14
15
const fetchDynamicallyImportedModuleError =
@@ -17,7 +18,7 @@ const fetchDynamicallyImportedModuleError =
17
18
export type RuntimeErrorStateProps = { error : Error } ;
18
19
19
20
export const RuntimeErrorState : FC < RuntimeErrorStateProps > = ( { error } ) => {
20
- const styles = useStyles ( ) ;
21
+ const theme = useTheme ( ) ;
21
22
const [ checkingError , setCheckingError ] = useState ( true ) ;
22
23
const [ staticBuildInfo , setStaticBuildInfo ] = useState < BuildInfoResponse > ( ) ;
23
24
const coderVersion = staticBuildInfo ?. version ;
@@ -52,11 +53,11 @@ export const RuntimeErrorState: FC<RuntimeErrorStateProps> = ({ error }) => {
52
53
< title > Something went wrong...</ title >
53
54
</ Helmet >
54
55
{ ! checkingError ? (
55
- < Margins className = { styles . root } >
56
- < div className = { styles . innerRoot } >
57
- < CoderIcon className = { styles . logo } />
58
- < h1 className = { styles . title } > Something went wrong...</ h1 >
59
- < p className = { styles . text } >
56
+ < Margins css = { styles . root } >
57
+ < div css = { { width : "100%" } } >
58
+ < CoderIcon css = { styles . logo } />
59
+ < h1 css = { styles . title } > Something went wrong...</ h1 >
60
+ < p css = { styles . text } >
60
61
Please try reloading the page, if that doesn‘t work, you can
61
62
ask for help in the{ " " }
62
63
< Link href = "https://discord.gg/coder" >
@@ -93,20 +94,33 @@ export const RuntimeErrorState: FC<RuntimeErrorStateProps> = ({ error }) => {
93
94
</ Button >
94
95
</ Stack >
95
96
{ error . stack && (
96
- < div className = { styles . stack } >
97
- < div className = { styles . stackHeader } >
97
+ < div css = { styles . stack } >
98
+ < div css = { styles . stackHeader } >
98
99
Stacktrace
99
100
< CopyButton
100
- buttonClassName = { styles . copyButton }
101
+ buttonClassName = { css `
102
+ background-color : transparent;
103
+ border : 0 ;
104
+ border-radius : 999px ;
105
+ min-height : ${ theme . spacing ( 4 ) } ;
106
+ min-width : ${ theme . spacing ( 4 ) } ;
107
+ height : ${ theme . spacing ( 4 ) } ;
108
+ width : ${ theme . spacing ( 4 ) } ;
109
+
110
+ & svg {
111
+ width : 16px ;
112
+ height : 16px ;
113
+ }
114
+ ` }
101
115
text = { error . stack }
102
116
tooltipTitle = "Copy stacktrace"
103
117
/>
104
118
</ div >
105
- < pre className = { styles . stackCode } > { error . stack } </ pre >
119
+ < pre css = { styles . stackCode } > { error . stack } </ pre >
106
120
</ div >
107
121
) }
108
122
{ coderVersion && (
109
- < div className = { styles . version } > Version: { coderVersion } </ div >
123
+ < div css = { styles . version } > Version: { coderVersion } </ div >
110
124
) }
111
125
</ div >
112
126
</ Margins >
@@ -132,8 +146,8 @@ const getStaticBuildInfo = () => {
132
146
}
133
147
} ;
134
148
135
- const useStyles = makeStyles ( ( theme ) => ( {
136
- root : {
149
+ const styles = {
150
+ root : ( theme ) => ( {
137
151
paddingTop : theme . spacing ( 4 ) ,
138
152
paddingBottom : theme . spacing ( 4 ) ,
139
153
textAlign : "center" ,
@@ -142,36 +156,34 @@ const useStyles = makeStyles((theme) => ({
142
156
justifyContent : "center" ,
143
157
minHeight : "100%" ,
144
158
maxWidth : theme . spacing ( 75 ) ,
145
- } ,
159
+ } ) ,
146
160
147
- innerRoot : { width : "100%" } ,
148
-
149
- logo : {
161
+ logo : ( theme ) => ( {
150
162
fontSize : theme . spacing ( 8 ) ,
151
- } ,
163
+ } ) ,
152
164
153
- title : {
165
+ title : ( theme ) => ( {
154
166
fontSize : theme . spacing ( 4 ) ,
155
167
fontWeight : 400 ,
156
- } ,
168
+ } ) ,
157
169
158
- text : {
170
+ text : ( theme ) => ( {
159
171
fontSize : 16 ,
160
172
color : theme . palette . text . secondary ,
161
173
lineHeight : "160%" ,
162
174
marginBottom : theme . spacing ( 4 ) ,
163
- } ,
175
+ } ) ,
164
176
165
- stack : {
177
+ stack : ( theme ) => ( {
166
178
backgroundColor : theme . palette . background . paper ,
167
179
border : `1px solid ${ theme . palette . divider } ` ,
168
180
borderRadius : 4 ,
169
181
marginTop : theme . spacing ( 8 ) ,
170
182
display : "block" ,
171
183
textAlign : "left" ,
172
- } ,
184
+ } ) ,
173
185
174
- stackHeader : {
186
+ stackHeader : ( theme ) => ( {
175
187
fontSize : 10 ,
176
188
textTransform : "uppercase" ,
177
189
fontWeight : 600 ,
@@ -184,33 +196,18 @@ const useStyles = makeStyles((theme) => ({
184
196
flexAlign : "center" ,
185
197
justifyContent : "space-between" ,
186
198
alignItems : "center" ,
187
- } ,
199
+ } ) ,
188
200
189
- stackCode : {
201
+ stackCode : ( theme ) => ( {
190
202
padding : theme . spacing ( 2 ) ,
191
203
margin : 0 ,
192
204
wordWrap : "break-word" ,
193
205
whiteSpace : "break-spaces" ,
194
- } ,
195
-
196
- copyButton : {
197
- backgroundColor : "transparent" ,
198
- border : 0 ,
199
- borderRadius : 999 ,
200
- minHeight : theme . spacing ( 4 ) ,
201
- minWidth : theme . spacing ( 4 ) ,
202
- height : theme . spacing ( 4 ) ,
203
- width : theme . spacing ( 4 ) ,
204
-
205
- "& svg" : {
206
- width : 16 ,
207
- height : 16 ,
208
- } ,
209
- } ,
210
-
211
- version : {
206
+ } ) ,
207
+
208
+ version : ( theme ) => ( {
212
209
marginTop : theme . spacing ( 4 ) ,
213
210
fontSize : 12 ,
214
211
color : theme . palette . text . secondary ,
215
- } ,
216
- } ) ) ;
212
+ } ) ,
213
+ } satisfies Record < string , Interpolation < Theme > > ;
0 commit comments