Skip to content

Commit 0826d76

Browse files
Copilot0xrinegade
andcommitted
Fix black screen issue by migrating makeStyles to modern MUI patterns
Co-authored-by: 0xrinegade <[email protected]>
1 parent fc54707 commit 0826d76

File tree

6 files changed

+511
-1668
lines changed

6 files changed

+511
-1668
lines changed

craco.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const webpack = require('webpack');
33
module.exports = {
44
webpack: {
55
configure: (webpackConfig) => {
6+
// Add polyfills for node modules
67
webpackConfig.resolve.fallback = {
78
...webpackConfig.resolve.fallback,
89
crypto: require.resolve('crypto-browserify'),
@@ -20,12 +21,16 @@ module.exports = {
2021
tls: false,
2122
};
2223

24+
// Provide global variables for compatibility
2325
webpackConfig.plugins = [
2426
...webpackConfig.plugins,
2527
new webpack.ProvidePlugin({
2628
Buffer: ['buffer', 'Buffer'],
2729
process: 'process/browser',
2830
}),
31+
new webpack.DefinePlugin({
32+
global: 'globalThis',
33+
}),
2934
];
3035

3136
return webpackConfig;

src/components/AddTokenDialog.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { TOKENS } from '../utils/tokens/tokens'
1515
import { useUpdateTokenName } from '../utils/tokens/names';
1616
import { useAsyncData } from '../utils/fetch-loop';
1717
import LoadingIndicator from './LoadingIndicator';
18-
import { makeStyles, Tab, Tabs } from '@mui/material';
18+
import { Tab, Tabs } from '@mui/material';
1919
import { useSendTransaction } from '../utils/notifications';
2020
import List from '@mui/material/List';
2121
import ListItem from '@mui/material/ListItem';
@@ -41,20 +41,12 @@ const feeFormat = new Intl.NumberFormat(undefined, {
4141
maximumFractionDigits: 6,
4242
});
4343

44-
const useStyles = makeStyles((theme) => ({
45-
tabs: {
46-
marginBottom: theme.spacing(1),
47-
borderBottom: `1px solid ${theme.palette.background.paper}`,
48-
},
49-
}));
50-
5144
export default function AddTokenDialog({ open, onClose }) {
5245
let wallet = useWallet();
5346
let [tokenAccountCost] = useAsyncData(
5447
wallet.tokenAccountCost,
5548
wallet.tokenAccountCost,
5649
);
57-
let classes = useStyles();
5850
let updateTokenName = useUpdateTokenName();
5951
const [sendTransaction, sending] = useSendTransaction();
6052
const { endpoint } = useConnectionConfig();
@@ -131,7 +123,10 @@ export default function AddTokenDialog({ open, onClose }) {
131123
value={tab}
132124
textColor="primary"
133125
indicatorColor="primary"
134-
className={classes.tabs}
126+
sx={{
127+
marginBottom: 1,
128+
borderBottom: (theme) => `1px solid ${theme.palette.background.paper}`,
129+
}}
135130
onChange={(e, value) => setTab(value)}
136131
>
137132
<Tab label="Popular Tokens" value="popular" />

src/components/LoadingIndicator.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
11
import React, { useState } from 'react';
22
import CircularProgress from '@mui/material/CircularProgress';
3+
import Box from '@mui/material/Box';
34
import { useEffectAfterTimeout } from '../utils/utils';
4-
import { makeStyles } from '@mui/material/styles';
5-
6-
const useStyles = makeStyles((theme) => ({
7-
root: {
8-
display: 'flex',
9-
alignItems: 'center',
10-
justifyContent: 'center',
11-
width: '100%',
12-
height: '100%',
13-
padding: theme.spacing(2),
14-
},
15-
}));
165

176
export default function LoadingIndicator({
187
height = null,
198
delay = 500,
209
...rest
2110
}) {
22-
const classes = useStyles();
2311
const [visible, setVisible] = useState(false);
2412

2513
useEffectAfterTimeout(() => setVisible(true), delay);
@@ -34,8 +22,19 @@ export default function LoadingIndicator({
3422
}
3523

3624
return (
37-
<div className={classes.root} style={style} {...rest}>
25+
<Box
26+
sx={{
27+
display: 'flex',
28+
alignItems: 'center',
29+
justifyContent: 'center',
30+
width: '100%',
31+
height: '100%',
32+
padding: 2,
33+
}}
34+
style={style}
35+
{...rest}
36+
>
3837
<CircularProgress />
39-
</div>
38+
</Box>
4039
);
4140
}

src/components/Navbar/NavigationFrame.js

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useState } from 'react';
22
import styled from 'styled-components';
33
import Typography from '@mui/material/Typography';
4-
import { makeStyles } from '@mui/material/styles';
54
import Button from '@mui/material/Button';
65
import Menu from '@mui/material/Menu';
76
import MenuItem from '@mui/material/MenuItem';
@@ -28,25 +27,6 @@ import { MobileFooter } from '../Footer/MobileFooter';
2827

2928
export const footerHeight = isExtension ? 0 : 6;
3029

31-
const useStyles = makeStyles((theme) => ({
32-
content: {
33-
flexGrow: 1,
34-
paddingTop: 24,
35-
paddingBottom: 24,
36-
paddingLeft: 8,
37-
paddingRight: 8,
38-
},
39-
title: {
40-
flexGrow: 1,
41-
},
42-
button: {
43-
marginLeft: 8,
44-
},
45-
menuItemIcon: {
46-
minWidth: 32,
47-
},
48-
}));
49-
5030
const StyledMain = styled.main`
5131
height: ${(props) =>
5232
props.isConnectPopup
@@ -97,7 +77,6 @@ export function WalletSelector() {
9777
] = useState(false);
9878
const [deleteMnemonicOpen, setDeleteMnemonicOpen] = useState(false);
9979
const [exportMnemonicOpen, setExportMnemonicOpen] = useState(false);
100-
const classes = useStyles();
10180

10281
if (accounts.length === 0) {
10382
return null;
@@ -148,7 +127,7 @@ export function WalletSelector() {
148127
<Button
149128
color="inherit"
150129
onClick={(e) => setAnchorEl(e.target)}
151-
className={classes.button}
130+
sx={{ marginLeft: 1 }}
152131
>
153132
Account
154133
</Button>
@@ -180,7 +159,7 @@ export function WalletSelector() {
180159
selected={isSelected}
181160
component="div"
182161
>
183-
<ListItemIcon className={classes.menuItemIcon}>
162+
<ListItemIcon sx={{ minWidth: 32 }}>
184163
{isSelected ? <CheckIcon fontSize="small" /> : null}
185164
</ListItemIcon>
186165
<div style={{ display: 'flex', flexDirection: 'column' }}>
@@ -193,7 +172,7 @@ export function WalletSelector() {
193172
))}
194173
<Divider />
195174
<MenuItem onClick={() => setAddHardwareWalletDialogOpen(true)}>
196-
<ListItemIcon className={classes.menuItemIcon}>
175+
<ListItemIcon sx={{ minWidth: 32 }}>
197176
<UsbIcon fontSize="small" />
198177
</ListItemIcon>
199178
Import Hardware Wallet
@@ -204,7 +183,7 @@ export function WalletSelector() {
204183
setAddAccountOpen(true);
205184
}}
206185
>
207-
<ListItemIcon className={classes.menuItemIcon}>
186+
<ListItemIcon sx={{ minWidth: 32 }}>
208187
<AddIcon fontSize="small" />
209188
</ListItemIcon>
210189
Add Account
@@ -215,7 +194,7 @@ export function WalletSelector() {
215194
setExportMnemonicOpen(true);
216195
}}
217196
>
218-
<ListItemIcon className={classes.menuItemIcon}>
197+
<ListItemIcon sx={{ minWidth: 32 }}>
219198
<ImportExportIcon fontSize="small" />
220199
</ListItemIcon>
221200
Export Mnemonic
@@ -226,7 +205,7 @@ export function WalletSelector() {
226205
setDeleteMnemonicOpen(true);
227206
}}
228207
>
229-
<ListItemIcon className={classes.menuItemIcon}>
208+
<ListItemIcon sx={{ minWidth: 32 }}>
230209
<ExitToApp fontSize="small" />
231210
</ListItemIcon>
232211
Delete Mnemonic
@@ -236,19 +215,12 @@ export function WalletSelector() {
236215
);
237216
}
238217

239-
const useFooterStyles = makeStyles((theme) => ({
240-
footer: {
241-
display: 'flex',
242-
justifyContent: 'space-between',
243-
alignItems: 'center',
244-
},
245-
}));
246-
247218
const FooterComponent = styled.footer`
248219
height: 6rem;
249220
padding: 0 3rem 0 3rem;
250221
display: flex;
251222
justify-content: space-between;
223+
align-items: center;
252224
@media (max-width: 540px) {
253225
padding: 0;
254226
height: 0;
@@ -265,17 +237,15 @@ const FooterComponentForExtension = styled.footer`
265237
`;
266238

267239
function Footer() {
268-
const classes = useFooterStyles();
269240
const isConnectPopup = window.opener;
270-
// const theme = useTheme();
271241
const location = useLocation();
272242
console.log('location', location);
273243

274244
if (isConnectPopup) return null
275245

276246
return (
277247
<>
278-
<FooterComponent className={classes.footer}>
248+
<FooterComponent>
279249
<span
280250
style={{
281251
fontSize: '1.3rem',

src/components/TokenInfoDialog.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,6 @@ import DialogContent from '@mui/material/DialogContent';
77
import DialogForm from '../pages/Wallet/components/DialogForm';
88
import { abbreviateAddress } from '../utils/utils';
99
import CopyableDisplay from './CopyableDisplay';
10-
import { makeStyles } from '@mui/material/styles';
11-
12-
const useStyles = makeStyles((theme) => ({
13-
explorerLink: {
14-
marginBottom: theme.spacing(2),
15-
},
16-
warning: {
17-
marginBottom: theme.spacing(2),
18-
},
19-
container: {
20-
minWidth: 600,
21-
},
22-
}));
2310

2411
export default function TokenInfoDialog({
2512
open,
@@ -29,19 +16,18 @@ export default function TokenInfoDialog({
2916
}) {
3017
let { mint, tokenName, tokenSymbol } = balanceInfo;
3118
const urlSuffix = useSolanaExplorerUrlSuffix();
32-
const classes = useStyles();
3319

3420
return (
3521
<DialogForm open={open} onClose={onClose}>
3622
<DialogTitle>
3723
{tokenName ?? abbreviateAddress(mint)}
3824
{tokenSymbol ? ` (${tokenSymbol})` : null}
3925
</DialogTitle>
40-
<DialogContent className={classes.container}>
41-
<Typography className={classes.warning}>
26+
<DialogContent sx={{ minWidth: 600 }}>
27+
<Typography sx={{ marginBottom: 2 }}>
4228
Information about {tokenName ?? abbreviateAddress(mint)}
4329
</Typography>
44-
<Typography variant="body2" className={classes.explorerLink}>
30+
<Typography variant="body2" sx={{ marginBottom: 2 }}>
4531
<Link
4632
href={
4733
`https://explorer.solana.com/account/${publicKey.toBase58()}` +

0 commit comments

Comments
 (0)