Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Upgrade to mui v6 #207

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src-gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@
"tauri": "tauri"
},
"dependencies": {
"@emotion/react": "^11.13.5",
"@emotion/styled": "^11.13.5",
"@fontsource/roboto": "^5.1.0",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@material-ui/lab": "^4.0.0-alpha.61",
"@mui/icons-material": "^5.0.0",
"@mui/lab": "^6.0.0-alpha",
"@mui/material": "^6.0.0",
"@mui/styles": "^6.0.0",
"@reduxjs/toolkit": "^2.3.0",
"@tauri-apps/api": "^2.0.0",
"@tauri-apps/plugin-cli": "^2.0.0",
Expand All @@ -35,10 +38,10 @@
"notistack": "^3.0.1",
"pino": "^9.2.0",
"pino-pretty": "^11.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"react-qr-code": "^2.0.15",
"react-redux": "^9.1.2",
"react-redux": "^8.0.0",
"react-router-dom": "^6.28.0",
"redux-persist": "^6.0.0",
"semver": "^7.6.2",
Expand Down Expand Up @@ -68,4 +71,4 @@
"vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.1.1"
}
}
}
34 changes: 22 additions & 12 deletions src-gui/src/renderer/components/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, CssBaseline, makeStyles } from "@material-ui/core";
import { ThemeProvider } from "@material-ui/core/styles";
import { Box, CssBaseline } from "@mui/material";
import makeStyles from '@mui/styles/makeStyles';
import { ThemeProvider, Theme, StyledEngineProvider } from "@mui/material/styles";
import "@tauri-apps/plugin-shell";
import { Route, MemoryRouter as Router, Routes } from "react-router-dom";
import Navigation, { drawerWidth } from "./navigation/Navigation";
Expand All @@ -15,6 +16,13 @@ import { useEffect } from "react";
import { setupBackgroundTasks } from "renderer/background";
import "@fontsource/roboto";


declare module '@mui/styles/defaultTheme' {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface DefaultTheme extends Theme {}
}


const useStyles = makeStyles((theme) => ({
innerContent: {
padding: theme.spacing(4),
Expand All @@ -32,16 +40,18 @@ export default function App() {
const theme = useSettings((s) => s.theme);

return (
<ThemeProvider theme={themes[theme]}>
<GlobalSnackbarProvider>
<CssBaseline />
<Router>
<Navigation />
<InnerContent />
<UpdaterDialog />
</Router>
</GlobalSnackbarProvider>
</ThemeProvider>
<StyledEngineProvider injectFirst>
(<ThemeProvider theme={themes[theme]}>
<GlobalSnackbarProvider>
<CssBaseline />
<Router>
<Navigation />
<InnerContent />
<UpdaterDialog />
</Router>
</GlobalSnackbarProvider>
</ThemeProvider>)
</StyledEngineProvider>
);
}

Expand Down
1 change: 1 addition & 0 deletions src-gui/src/renderer/components/ExampleComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

10 changes: 5 additions & 5 deletions src-gui/src/renderer/components/PromiseInvokeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
IconButton,
IconButtonProps,
Tooltip,
} from "@material-ui/core";
import CircularProgress from "@material-ui/core/CircularProgress";
} from "@mui/material";
import CircularProgress from "@mui/material/CircularProgress";
import { useSnackbar } from "notistack";
import { ReactNode, useState } from "react";
import { useIsContextAvailable } from "store/hooks";
Expand Down Expand Up @@ -77,14 +77,14 @@ export default function PromiseInvokeButton<T>({
: tooltipTitle) ?? "";

return (
<Tooltip title={actualTooltipTitle}>
(<Tooltip title={actualTooltipTitle}>
<span>
{isIconButton ? (
<IconButton
onClick={handleClick}
disabled={isDisabled}
{...(rest as IconButtonProps)}
>
size="large">
{actualEndIcon}
</IconButton>
) : (
Expand All @@ -96,6 +96,6 @@ export default function PromiseInvokeButton<T>({
/>
)}
</span>
</Tooltip>
</Tooltip>)
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BackgroundRefundState } from "models/tauriModel";
import { useAppSelector } from "store/hooks";
import { LoadingSpinnerAlert } from "./LoadingSpinnerAlert";
import { AlertTitle } from "@material-ui/lab";
import { AlertTitle } from '@mui/material';
import TruncatedText from "../other/TruncatedText";
import { useSnackbar } from "notistack";
import { useEffect } from "react";
Expand Down
5 changes: 3 additions & 2 deletions src-gui/src/renderer/components/alert/DaemonStatusAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, Button, LinearProgress, makeStyles } from "@material-ui/core";
import { Alert } from "@material-ui/lab";
import { Box, Button, LinearProgress } from "@mui/material";
import makeStyles from '@mui/styles/makeStyles';
import { Alert } from '@mui/material';
import { useNavigate } from "react-router-dom";
import { useAppSelector } from "store/hooks";
import { exhaustiveGuard } from "utils/typescriptUtils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from "@material-ui/core";
import Alert from "@material-ui/lab/Alert";
import { Button } from "@mui/material";
import Alert from '@mui/material/Alert';
import { useNavigate } from "react-router-dom";
import { useAppSelector } from "store/hooks";

Expand Down
5 changes: 3 additions & 2 deletions src-gui/src/renderer/components/alert/LoadingSpinnerAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { CircularProgress } from "@material-ui/core";
import { AlertProps, Alert } from "@material-ui/lab";
import { CircularProgress } from "@mui/material";
import { Alert } from '@mui/material';
import { AlertProps } from '@mui/lab';

export function LoadingSpinnerAlert({ ...rest }: AlertProps) {
return <Alert icon={<CircularProgress size={22} />} {...rest} />;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, LinearProgress } from "@material-ui/core";
import { Alert } from "@material-ui/lab";
import { Box, LinearProgress } from "@mui/material";
import { Alert } from '@mui/material';
import { useAppSelector } from "store/hooks";

export default function MoneroWalletRpcUpdatingAlert() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, makeStyles } from "@material-ui/core";
import { Alert } from "@material-ui/lab";
import { Box } from "@mui/material";
import makeStyles from '@mui/styles/makeStyles';
import { Alert } from '@mui/material';
import { useAppSelector } from "store/hooks";
import { SatsAmount } from "../other/Units";
import WalletRefreshButton from "../pages/wallet/WalletRefreshButton";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Box, makeStyles } from "@material-ui/core";
import { Alert, AlertTitle } from "@material-ui/lab/";
import { Box } from "@mui/material";
import makeStyles from '@mui/styles/makeStyles';
import { Alert, AlertTitle } from "@mui/lab/";
import {
BobStateName,
GetSwapInfoResponseExt,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useTheme, Tooltip, Typography, Box, LinearProgress, Paper } from "@material-ui/core";
import { useTheme, Tooltip, Typography, Box, LinearProgress, Paper } from "@mui/material";
import { ExpiredTimelocks } from "models/tauriModel";
import { GetSwapInfoResponseExt, getAbsoluteBlock } from "models/tauriModelExt";
import HumanizedBitcoinBlockDuration from "renderer/components/other/HumanizedBitcoinBlockDuration";
Expand Down Expand Up @@ -28,16 +28,23 @@ function TimelineSegment({
const theme = useTheme();

return (
<Tooltip title={<Typography variant="caption">{segment.title}</Typography>}>
<Box sx={{
(<Tooltip title={<Typography variant="caption">{segment.title}</Typography>}>
<Box sx={[{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
bgcolor: segment.bgcolor,
width: `${durationOfSegment ? ((durationOfSegment / totalBlocks) * 85) : 15}%`,
position: 'relative',
}} style={{
position: 'relative'
}, durationOfSegment ? {
width: {
width: ((durationOfSegment / totalBlocks) * 85)
}
} : {
width: {
width: 15
}
}]} style={{
opacity: isActive ? 1 : 0.3
}}>
{isActive && (
Expand Down Expand Up @@ -88,7 +95,7 @@ function TimelineSegment({
</Typography>
)}
</Box>
</Tooltip>
</Tooltip>)
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Box, makeStyles } from "@material-ui/core";
import { Box } from "@mui/material";
import makeStyles from '@mui/styles/makeStyles';
import { useSwapInfosSortedByDate } from "store/hooks";
import SwapStatusAlert from "./SwapStatusAlert/SwapStatusAlert";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Button } from "@material-ui/core";
import Alert from "@material-ui/lab/Alert";
import { Button } from "@mui/material";
import Alert from '@mui/material/Alert';
import { useNavigate } from "react-router-dom";
import { useResumeableSwapsCountExcludingPunished } from "store/hooks";

Expand Down
4 changes: 2 additions & 2 deletions src-gui/src/renderer/components/icons/BitcoinIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SvgIcon } from "@material-ui/core";
import { SvgIconProps } from "@material-ui/core/SvgIcon/SvgIcon";
import { SvgIcon } from "@mui/material";
import { SvgIconProps } from "@mui/material/SvgIcon/SvgIcon";

export default function BitcoinIcon(props: SvgIconProps) {
return (
Expand Down
4 changes: 2 additions & 2 deletions src-gui/src/renderer/components/icons/DiscordIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SvgIcon } from "@material-ui/core";
import { SvgIconProps } from "@material-ui/core/SvgIcon/SvgIcon";
import { SvgIcon } from "@mui/material";
import { SvgIconProps } from "@mui/material/SvgIcon/SvgIcon";

export default function DiscordIcon(props: SvgIconProps) {
return (
Expand Down
6 changes: 3 additions & 3 deletions src-gui/src/renderer/components/icons/LinkIconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IconButton } from "@material-ui/core";
import { IconButton } from "@mui/material";
import { open } from "@tauri-apps/plugin-shell";
import { ReactNode } from "react";

Expand All @@ -10,8 +10,8 @@ export default function LinkIconButton({
children: ReactNode;
}) {
return (
<IconButton component="span" onClick={() => open(url)}>
(<IconButton component="span" onClick={() => open(url)} size="large">
{children}
</IconButton>
</IconButton>)
);
}
4 changes: 2 additions & 2 deletions src-gui/src/renderer/components/icons/MoneroIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SvgIcon } from "@material-ui/core";
import { SvgIconProps } from "@material-ui/core/SvgIcon/SvgIcon";
import { SvgIcon } from "@mui/material";
import { SvgIconProps } from "@mui/material/SvgIcon/SvgIcon";

export default function MoneroIcon(props: SvgIconProps) {
return (
Expand Down
4 changes: 2 additions & 2 deletions src-gui/src/renderer/components/icons/TorIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SvgIcon } from "@material-ui/core";
import { SvgIconProps } from "@material-ui/core/SvgIcon/SvgIcon";
import { SvgIcon } from "@mui/material";
import { SvgIconProps } from "@mui/material/SvgIcon/SvgIcon";

export default function TorIcon(props: SvgIconProps) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TextField } from "@material-ui/core";
import { TextFieldProps } from "@material-ui/core/TextField/TextField";
import { TextField } from "@mui/material";
import { TextFieldProps } from "@mui/material/TextField/TextField";
import { useEffect } from "react";
import { isTestnet } from "store/config";
import { isBtcAddressValid } from "utils/conversionUtils";
Expand Down
34 changes: 21 additions & 13 deletions src-gui/src/renderer/components/inputs/MoneroAddressTextField.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { Box, Button, Dialog, DialogActions, DialogContent, IconButton, List, ListItem, ListItemText, TextField } from "@material-ui/core";
import { TextFieldProps } from "@material-ui/core/TextField/TextField";
import {
Box,
Button,
Dialog,
DialogActions,
DialogContent,
IconButton,
List,
ListItemText,
TextField,
} from "@mui/material";
import { TextFieldProps } from "@mui/material/TextField/TextField";
import { useEffect, useState } from "react";
import { getMoneroAddresses } from "renderer/rpc";
import { isTestnet } from "store/config";
import { isXmrAddressValid } from "utils/conversionUtils";
import ImportContactsIcon from '@material-ui/icons/ImportContacts';
import ImportContactsIcon from '@mui/icons-material/ImportContacts';
import TruncatedText from "../other/TruncatedText";

import ListItemButton from "@mui/material/ListItemButton";

type MoneroAddressTextFieldProps = TextFieldProps & {
address: string;
onAddressChange: (address: string) => void;
Expand Down Expand Up @@ -93,7 +105,7 @@ function RecentlyUsedAddressesDialog({
onAddressSelect
}: RecentlyUsedAddressesDialogProps) {
return (
<Dialog
(<Dialog
open={open}
onClose={onClose}
maxWidth="sm"
Expand All @@ -102,12 +114,8 @@ function RecentlyUsedAddressesDialog({
<DialogContent>
<List>
{addresses.map((addr) => (
<ListItem
button
key={addr}
onClick={() => onAddressSelect(addr)}
>
<ListItemText
<ListItemButton key={addr} onClick={() => onAddressSelect(addr)}>
<ListItemText
primary={
<Box fontFamily="monospace">
<TruncatedText limit={40} truncateMiddle>
Expand All @@ -117,19 +125,19 @@ function RecentlyUsedAddressesDialog({
}
secondary="Recently used as a redeem address"
/>
</ListItem>
</ListItemButton>
))}
</List>
</DialogContent>
<DialogActions>
<Button
<Button
onClick={onClose}
variant="contained"
color="primary"
>
Close
</Button>
</DialogActions>
</Dialog>
</Dialog>)
);
}
7 changes: 4 additions & 3 deletions src-gui/src/renderer/components/modal/DialogHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DialogTitle, makeStyles, Typography } from "@material-ui/core";
import { DialogTitle, Typography } from "@mui/material";
import makeStyles from '@mui/styles/makeStyles';
import { ReactNode } from "react";

const useStyles = makeStyles({
Expand All @@ -16,8 +17,8 @@ export default function DialogHeader({ title }: DialogTitleProps) {
const classes = useStyles();

return (
<DialogTitle disableTypography className={classes.root}>
(<DialogTitle className={classes.root}>
<Typography variant="h6">{title}</Typography>
</DialogTitle>
</DialogTitle>)
);
}
Loading
Loading