Skip to content

Commit

Permalink
chore(ui): remove MUI (tari-project#261)
Browse files Browse the repository at this point in the history
Description
---

### package changes:

- removed material ui and related packages - `@mui/material`,
`@emotion/react`, and `@emotion/styled`.
- removed `react-transition-group` since it was only used in one place
and we have `framer-motion` already
- added `styled-components` for our main styling package

### implementation changes:

- removed all uses of Material UI components and replace with custom
styled components, main ones so far are:
    * Typography
    * Button & IconButton
    * Stack
    * Linear & Circular Progress
    * Toggle Switch
    * Select
    * Input
    * Dialog
- updated theme vars to suit `styled-components`
- added `GlobalStyles` and `GlobalReset`
- updated fontface implemetations
- added theme types
- replaced mui/styled syntax errrwhere
- split out the items in `Settings.tsx` to some of their own
files/component


Motivation and Context
---
- resolves tari-project#238 
- material ui is super difficult to customise

How Has This Been Tested?
---
locally


_**screenshots:**_

| components |
| :---: |
| <img width="393" alt="image"
src="https://github.com/user-attachments/assets/73c8a32b-4372-4519-a88f-22abb04e51ca">
|
| <img width="480" alt="image"
src="https://github.com/user-attachments/assets/c668f316-020a-4e4d-b168-7699220f31ce">
|
| <img width="355" alt="image"
src="https://github.com/user-attachments/assets/075be908-1839-4377-87ae-45d8c492325f">
<img width="368" alt="image"
src="https://github.com/user-attachments/assets/80617ff9-7c25-49cb-9b5a-84546416263d">
|
| <img width="910" alt="image"
src="https://github.com/user-attachments/assets/be51575f-ec90-495f-85e1-add7643c61f5">
|
| <img width="871" alt="image"
src="https://github.com/user-attachments/assets/0d1b047a-78f6-4b76-966b-3809262fde53">
|
| <img width="744" alt="image"
src="https://github.com/user-attachments/assets/188176f6-a034-4aa8-bade-37dd2c4e73df">
|
| <img width="220" alt="image"
src="https://github.com/user-attachments/assets/07580b6f-5064-4a3b-b2e9-993148104f3c">
<img width="207" alt="image"
src="https://github.com/user-attachments/assets/fbbaedf2-ca32-48ec-9fa2-10522f00e354">
|


**_videos:_**


https://github.com/user-attachments/assets/6cf41a2a-5e37-4d0b-a5fe-9b7b27bd92f9


https://github.com/user-attachments/assets/07298156-a0a9-4a9d-89c2-7ee4609aa5ce



https://github.com/user-attachments/assets/6fffd36e-261a-464a-b284-1bb61ee1b7ca




What process can a PR reviewer use to test or verify this change?
---
run locally :p  

Breaking Changes
---

- [ ] None
- [ ] Requires data directory on base node to be deleted
- [ ] Requires hard fork
- [x] Other - Please specify

<!-- Does this include a breaking change? If so, include this line as a
footer -->
BREAKING CHANGE:

- requires `npm ci` and possibly a fresh `npm install`
- any wip work that uses `@mui/x` or `react-transition-group` will need
to be updated
-
  • Loading branch information
shanimal08 authored Sep 3, 2024
1 parent 36b5166 commit f7644ab
Show file tree
Hide file tree
Showing 152 changed files with 160,815 additions and 2,792 deletions.
27 changes: 12 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/tari.svg" />
<script type="module" crossorigin src="/assets/glApp.js"></script>
<title>Tari Universe</title>
<style>
#canvas {
position: absolute;
/* border-radius: 12px; */
z-index: 0;
}
#root {
pointer-events: none;
}
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/tari.svg" />
<script type="module" crossorigin src="/assets/glApp.js"></script>
<title>Tari Universe</title>
<style>
#canvas {
position: absolute;
pointer-events: auto;
z-index: 0;
}
</style>
</head>
<body>
Expand Down
1,470 changes: 456 additions & 1,014 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"lint:fix": "eslint src/ --fix"
},
"dependencies": {
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@mui/material": "^5.16.7",
"@tauri-apps/api": "^1",
"framer-motion": "^11.3.29",
"globals": "^15.9.0",
Expand All @@ -27,8 +24,8 @@
"react-hook-form": "^7.52.2",
"react-i18next": "^15.0.1",
"react-icons": "^5.3.0",
"styled-components": "^6.1.12",
"uuid": "^10.0.0",
"react-transition-group": "^4.4.5",
"vite-tsconfig-paths": "^5.0.1",
"zustand": "^4.5.5"
},
Expand All @@ -37,12 +34,13 @@
"@nabla/vite-plugin-eslint": "^2.0.4",
"@tauri-apps/cli": "^1",
"@types/eslint__js": "^8.42.3",
"@types/node": "^22.5.1",
"@types/react": "^18.3.4",
"@types/node": "^22.5.2",
"@types/react": "^18.3.5",
"@types/react-dom": "^18.2.7",
"@types/uuid": "^10.0.0",
"@typescript-eslint/parser": "8.2.0",
"@typescript-eslint/parser": "^8.3.0",
"@vitejs/plugin-react": "^4.2.1",
"babel-plugin-styled-components": "^2.1.4",
"eslint": "^9.9.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
Expand All @@ -54,4 +52,4 @@
"typescript-eslint": "^8.3.0",
"vite": "^5.4.2"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added public/assets/fonts/Poppins/Poppins-Black.woff
Binary file not shown.
Binary file added public/assets/fonts/Poppins/Poppins-Black.woff2
Binary file not shown.
File renamed without changes.
Binary file added public/assets/fonts/Poppins/Poppins-Bold.woff
Binary file not shown.
Binary file added public/assets/fonts/Poppins/Poppins-Bold.woff2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file added public/assets/fonts/Poppins/Poppins-Italic.woff
Binary file not shown.
Binary file added public/assets/fonts/Poppins/Poppins-Italic.woff2
Binary file not shown.
File renamed without changes.
Binary file added public/assets/fonts/Poppins/Poppins-Light.woff
Binary file not shown.
Binary file added public/assets/fonts/Poppins/Poppins-Light.woff2
Binary file not shown.
File renamed without changes.
Binary file not shown.
Binary file added public/assets/fonts/Poppins/Poppins-Medium.woff2
Binary file not shown.
File renamed without changes.
Binary file added public/assets/fonts/Poppins/Poppins-Regular.woff
Binary file not shown.
Binary file added public/assets/fonts/Poppins/Poppins-Regular.woff2
Binary file not shown.
Binary file added public/assets/fonts/Poppins/Poppins-SemiBold.woff
Binary file not shown.
Binary file not shown.
File renamed without changes.
Binary file added public/assets/fonts/Poppins/Poppins-Thin.woff
Binary file not shown.
Binary file added public/assets/fonts/Poppins/Poppins-Thin.woff2
Binary file not shown.
4 changes: 2 additions & 2 deletions public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"change-language": "Change language",
"logs": "Logs",
"open-logs-directory": "Open logs directory",
"debug-info": "Debug info",
"debug-info": "Debug",
"hardware-status": "Hardware status",
"update-versions": "Update versions",
"refresh-versions": "Refresh versions",
Expand All @@ -22,4 +22,4 @@
"visual-mode": "Visual mode",
"pool-mining": "Pool Mining",
"pool-mining-description": "When enabled, you will mine in a pool and join a group of miners (tribe)."
}
}
42 changes: 20 additions & 22 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import './theme/theme.css';
import { StrictMode, useEffect } from 'react';
import CssBaseline from '@mui/material/CssBaseline';
import { ThemeProvider } from '@mui/material/styles';
import { lightTheme } from './theme/themes';
import { useEffect } from 'react';

import { ContainerInner, DashboardContainer } from './theme/styles';
import { SideBar } from './containers/SideBar';
import { Dashboard } from './containers/Dashboard';
import { AppBackground } from './containers/AppBackground';
import ErrorSnackbar from './containers/Error/ErrorSnackbar';
import { useUIStore } from './store/useUIStore.ts';
import { useGetStatus } from './hooks/useGetStatus.ts';
import { useSetUp } from './hooks/useSetUp.ts';
import { useEnvironment } from './hooks/useEnvironment.ts';
import { useAirdropTokensRefresh } from './hooks/airdrop/useAirdropTokensRefresh.ts';
import { SplashScreen } from './containers/SplashScreen';
import ThemeProvider from './theme/ThemeProvider.tsx';
import { GlobalReset, GlobalStyle } from '@app/theme/GlobalStyle.ts';
import { useMiningEffects } from './hooks/mining/useMiningEffects.ts';
import { setupLogger } from './utils/logger.ts';
import ErrorSnackbar from '@app/containers/Error/ErrorSnackbar.tsx';

function App() {
useAirdropTokensRefresh();
Expand All @@ -32,22 +31,21 @@ function App() {
}, []);

return (
<StrictMode>
<ThemeProvider theme={lightTheme}>
<CssBaseline enableColorScheme />
<AppBackground />
<SplashScreen />
{!showSplash && (
<DashboardContainer>
<ContainerInner>
<SideBar />
<Dashboard status={view} />
</ContainerInner>
</DashboardContainer>
)}
<ErrorSnackbar />
</ThemeProvider>
</StrictMode>
<ThemeProvider>
<GlobalReset />
<GlobalStyle />
<AppBackground />
<SplashScreen />
{!showSplash && (
<DashboardContainer>
<ContainerInner>
<SideBar />
<Dashboard status={view} />
</ContainerInner>
</DashboardContainer>
)}
<ErrorSnackbar />
</ThemeProvider>
);
}

Expand Down
Binary file added src/assets/backgrounds/button-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/assets/icons/cube.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/tiny-soon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 16 additions & 16 deletions src/assets/tbot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions src/components/CharSpinner/CharSpinner.styles.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { styled } from '@mui/system';
import { motion } from 'framer-motion';
import { CharSpinnerVariant } from '@app/components/CharSpinner/CharSpinner.tsx';
import styled from 'styled-components';

interface Props {
$decimal?: boolean;
Expand Down Expand Up @@ -42,9 +42,9 @@ export const Characters = styled(motion.div)<Props>`
display: flex;
flex-direction: column;
align-items: center;
letter-spacing: -3px;
font-family: ${({ $variant }) =>
$variant == 'simple' ? '"PoppinsSemiBold", sans-serif' : `"DrukWideLCGBold", sans-serif`};
letter-spacing: -4px;
font-weight: ${({ $variant }) => ($variant == 'simple' ? 600 : 700)};
font-family: ${({ $variant }) => ($variant == 'simple' ? 'Poppins' : 'Druk')}, sans-serif;
font-size: ${({ $fontSize }) => `${$fontSize}px`};
line-height: ${({ $letterHeight }) => `${$letterHeight}px`};
`;
Expand All @@ -53,5 +53,5 @@ export const Character = styled('div')<Props>`
display: flex;
justify-self: center;
font-size: ${({ $fontSize }) => `${$fontSize}px`};
letter-spacing: -0.05ch;
letter-spacing: -0.02ch;
`;
10 changes: 3 additions & 7 deletions src/components/FieldErrorMessage/FieldErrorMessage.component.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { FieldError } from 'react-hook-form';
import Typography from '@mui/material/Typography';

import { FieldsErrors } from './FieldErrorMessage.constants';
import type { FieldErrorMessageProps } from './FieldErrorMessage.types';
import { Typography } from '@app/components/elements/Typography.tsx';
import { useTranslation } from 'react-i18next';
import { TFunction } from 'i18next';

Expand All @@ -17,11 +17,7 @@ export const getFieldError = (error: FieldError | undefined, t: TFunction<'trans
return t('field-error-message.invalid');
};

export const FieldErrorMessage: React.FC<FieldErrorMessageProps> = ({ error }) => {
export const FieldErrorMessage = ({ error }: FieldErrorMessageProps) => {
const { t } = useTranslation('components', { useSuspense: false });
return (
<Typography color="error" variant="body1" sx={{ width: '100%', display: 'inline-block' }}>
{getFieldError(error, t)}
</Typography>
);
return <Typography variant="p">{getFieldError(error, t)}</Typography>;
};
32 changes: 10 additions & 22 deletions src/components/MoneroAddressInput/MoneroAddressInput.component.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Input, Stack } from '@mui/material';
import { Control, Controller, FieldValues } from 'react-hook-form';

import { FieldErrorMessage } from '../FieldErrorMessage/FieldErrorMessage.component';
Expand All @@ -10,44 +9,33 @@ import type {
MoneroAddressInputProps,
MoneroAddressInputType,
} from './MoneroAddressInput.types';
import { Stack } from '@app/components/elements/Stack.tsx';
import { Input } from '@app/components/elements/inputs/Input.tsx';
import { ChangeEvent } from 'react';

const valueParses: Record<MoneroAddressInputType, RegExp> = {
string: moneroAddressRegex,
};

export const MoneroAddressInput: React.FC<MoneroAddressInputProps> = ({
export const MoneroAddressInput = ({
title,
value,
onChange,
labelSx,
error,
type = 'string',
...inputProps
}) => {
const validateChange = (event: React.ChangeEvent<HTMLInputElement>) => {
}: MoneroAddressInputProps) => {
const validateChange = (event: ChangeEvent<HTMLInputElement>) => {
const newValue = event.target.value;

if (onChange && (valueParses[type].test(newValue) || newValue === '')) onChange(event);
};

return (
<Stack
gap={1}
sx={{
width: 'auto',
flexDirection: 'column',
justifyContent: 'flex-end',
position: 'relative',
...inputProps.sx,
}}
>
{title && (
<MoneroAddressInputTypography variant="body1" component="label" sx={labelSx}>
{title}
</MoneroAddressInputTypography>
)}
<Stack gap={1}>
{title && <MoneroAddressInputTypography>{title}</MoneroAddressInputTypography>}
<Stack flexDirection="row" gap={1}>
<Input error={Boolean(error)} fullWidth value={value} onChange={validateChange} {...inputProps} />
<Input hasError={Boolean(error)} value={value} onChange={validateChange} {...inputProps} />
</Stack>
{error && <FieldErrorMessage error={error} />}
</Stack>
Expand All @@ -74,7 +62,7 @@ export const ControlledMoneroAddressInput = <FormValues extends FieldValues>({
/>
)}
name={name}
control={control as Control<FieldValues>}
control={control as Control}
rules={rules}
/>
);
15 changes: 8 additions & 7 deletions src/components/MoneroAddressInput/MoneroAddressInput.styles.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { styled, Typography } from '@mui/material';
import styled from 'styled-components';
import { Typography } from '@app/components/elements/Typography.tsx';

export const MoneroAddressInputTypography = styled(Typography)<{ component: string }>(({ theme }) => ({
marginBottom: theme.spacing(1),
lineHeight: '135%',
display: 'inline-block',
color: theme.palette.text.primary,
}));
export const MoneroAddressInputTypography = styled(Typography)`
margin-bottom: 20px;
line-height: 135%;
display: inline-block;
color: ${({ theme }) => theme.palette.text.primary};,
`;
Loading

0 comments on commit f7644ab

Please sign in to comment.