Move some components into styles folder, delete duplicated themes

This commit is contained in:
Nicola Benaglia 2025-04-12 15:44:03 +02:00
parent dcfa7b258e
commit efd3624e92
9 changed files with 151 additions and 163 deletions

View File

@ -149,7 +149,7 @@ import { BuyQortInformation } from './components/BuyQortInformation';
import { QortPayment } from './components/QortPayment'; import { QortPayment } from './components/QortPayment';
import { GeneralNotifications } from './components/GeneralNotifications'; import { GeneralNotifications } from './components/GeneralNotifications';
import { PdfViewer } from './common/PdfViewer'; import { PdfViewer } from './common/PdfViewer';
import ThemeSelector from './components/Theme/ThemeSelector'; import ThemeSelector from './styles/ThemeSelector.tsx';
type extStates = type extStates =
| 'not-authenticated' | 'not-authenticated'

View File

@ -29,7 +29,7 @@ import { CustomizedSnackbars } from '../components/Snackbar/Snackbar';
import { cleanUrl, gateways } from '../background'; import { cleanUrl, gateways } from '../background';
import { GlobalContext } from '../App'; import { GlobalContext } from '../App';
import Tooltip, { TooltipProps, tooltipClasses } from '@mui/material/Tooltip'; import Tooltip, { TooltipProps, tooltipClasses } from '@mui/material/Tooltip';
import ThemeSelector from '../components/Theme/ThemeSelector'; import ThemeSelector from '../styles/ThemeSelector';
const manifestData = { const manifestData = {
version: '0.5.3', version: '0.5.3',

View File

@ -423,7 +423,7 @@ const WalletItem = ({ wallet, updateWalletItem, idx, setSelectedWallet }) => {
> >
<ListItem <ListItem
sx={{ sx={{
bgcolor: 'background.paper', bgcolor: 'background.paper', // TODO: set background color
flexGrow: 1, flexGrow: 1,
'&:hover': { '&:hover': {
backgroundColor: 'secondary.main', backgroundColor: 'secondary.main',

View File

@ -1,21 +1,21 @@
import React, { useState } from "react"; import React, { useState } from 'react';
import { import {
AppCircle, AppCircle,
AppCircleContainer, AppCircleContainer,
AppCircleLabel, AppCircleLabel,
AppLibrarySubTitle, AppLibrarySubTitle,
AppsContainer, AppsContainer,
} from "./Apps-styles"; } from './Apps-styles';
import { Box, ButtonBase, Input } from "@mui/material"; import { Box, ButtonBase, Input } from '@mui/material';
import { Add } from "@mui/icons-material"; import { Add } from '@mui/icons-material';
import { isMobile } from "../../App"; import { isMobile } from '../../App';
import { executeEvent } from "../../utils/events"; import { executeEvent } from '../../utils/events';
import { Spacer } from "../../common/Spacer"; import { Spacer } from '../../common/Spacer';
import { SortablePinnedApps } from "./SortablePinnedApps"; import { SortablePinnedApps } from './SortablePinnedApps';
import { extractComponents } from "../Chat/MessageDisplay"; import { extractComponents } from '../Chat/MessageDisplay';
import ArrowOutwardIcon from "@mui/icons-material/ArrowOutward"; import ArrowOutwardIcon from '@mui/icons-material/ArrowOutward';
import { AppsPrivate } from "./AppsPrivate"; import { AppsPrivate } from './AppsPrivate';
import ThemeSelector from "../Theme/ThemeSelector"; import ThemeSelector from '../../styles/ThemeSelector';
export const AppsHomeDesktop = ({ export const AppsHomeDesktop = ({
setMode, setMode,
myApp, myApp,
@ -23,7 +23,7 @@ export const AppsHomeDesktop = ({
availableQapps, availableQapps,
myName, myName,
}) => { }) => {
const [qortalUrl, setQortalUrl] = useState(""); const [qortalUrl, setQortalUrl] = useState('');
const openQortalUrl = () => { const openQortalUrl = () => {
try { try {
@ -31,9 +31,9 @@ export const AppsHomeDesktop = ({
const res = extractComponents(qortalUrl); const res = extractComponents(qortalUrl);
if (res) { if (res) {
const { service, name, identifier, path } = res; const { service, name, identifier, path } = res;
executeEvent("addTab", { data: { service, name, identifier, path } }); executeEvent('addTab', { data: { service, name, identifier, path } });
executeEvent("open-apps-mode", {}); executeEvent('open-apps-mode', {});
setQortalUrl("qortal://"); setQortalUrl('qortal://');
} }
} catch (error) {} } catch (error) {}
}; };
@ -41,12 +41,12 @@ export const AppsHomeDesktop = ({
<> <>
<AppsContainer <AppsContainer
sx={{ sx={{
justifyContent: "flex-start", justifyContent: 'flex-start',
}} }}
> >
<AppLibrarySubTitle <AppLibrarySubTitle
sx={{ sx={{
fontSize: "30px", fontSize: '30px',
}} }}
> >
Apps Dashboard Apps Dashboard
@ -57,19 +57,19 @@ export const AppsHomeDesktop = ({
<AppsContainer <AppsContainer
sx={{ sx={{
justifyContent: "flex-start", justifyContent: 'flex-start',
}} }}
> >
<Box <Box
sx={{ sx={{
display: "flex", display: 'flex',
gap: "20px", gap: '20px',
alignItems: "center", alignItems: 'center',
backgroundColor: "#1f2023", backgroundColor: '#1f2023',
padding: "7px", padding: '7px',
borderRadius: "20px", borderRadius: '20px',
width: "100%", width: '100%',
maxWidth: "500px", maxWidth: '500px',
}} }}
> >
<Input <Input
@ -83,24 +83,24 @@ export const AppsHomeDesktop = ({
autoCorrect="off" autoCorrect="off"
placeholder="qortal://" placeholder="qortal://"
sx={{ sx={{
width: "100%", width: '100%',
color: "white", color: 'white',
"& .MuiInput-input::placeholder": { '& .MuiInput-input::placeholder': {
color: "rgba(84, 84, 84, 0.70) !important", color: 'rgba(84, 84, 84, 0.70) !important',
fontSize: "20px", fontSize: '20px',
fontStyle: "normal", fontStyle: 'normal',
fontWeight: 400, fontWeight: 400,
lineHeight: "120%", // 24px lineHeight: '120%', // 24px
letterSpacing: "0.15px", letterSpacing: '0.15px',
opacity: 1, opacity: 1,
}, },
"&:focus": { '&:focus': {
outline: "none", outline: 'none',
}, },
// Add any additional styles for the input here // Add any additional styles for the input here
}} }}
onKeyDown={(e) => { onKeyDown={(e) => {
if (e.key === "Enter" && qortalUrl) { if (e.key === 'Enter' && qortalUrl) {
openQortalUrl(); openQortalUrl();
} }
}} }}
@ -108,7 +108,7 @@ export const AppsHomeDesktop = ({
<ButtonBase onClick={() => openQortalUrl()}> <ButtonBase onClick={() => openQortalUrl()}>
<ArrowOutwardIcon <ArrowOutwardIcon
sx={{ sx={{
color: qortalUrl ? "white" : "rgba(84, 84, 84, 0.70)", color: qortalUrl ? 'white' : 'rgba(84, 84, 84, 0.70)',
}} }}
/> />
</ButtonBase> </ButtonBase>
@ -119,18 +119,18 @@ export const AppsHomeDesktop = ({
<AppsContainer <AppsContainer
sx={{ sx={{
gap: "50px", gap: '50px',
justifyContent: "flex-start", justifyContent: 'flex-start',
}} }}
> >
<ButtonBase <ButtonBase
onClick={() => { onClick={() => {
setMode("library"); setMode('library');
}} }}
> >
<AppCircleContainer <AppCircleContainer
sx={{ sx={{
gap: !isMobile ? "10px" : "5px", gap: !isMobile ? '10px' : '5px',
}} }}
> >
<AppCircle> <AppCircle>
@ -150,7 +150,7 @@ export const AppsHomeDesktop = ({
/> />
</AppsContainer> </AppsContainer>
<ThemeSelector style={{ position: "fixed", bottom: "1%", left: "0%" }} /> <ThemeSelector style={{ position: 'fixed', bottom: '1%', left: '0%' }} />
</> </>
); );
}; };

View File

@ -1,12 +1,12 @@
import { Box, ButtonBase, useTheme } from "@mui/material"; import { Box, ButtonBase, useTheme } from '@mui/material';
import { HomeIcon } from "../assets/Icons/HomeIcon"; import { HomeIcon } from '../assets/Icons/HomeIcon';
import { MessagingIcon } from "../assets/Icons/MessagingIcon"; import { MessagingIcon } from '../assets/Icons/MessagingIcon';
import { Save } from "./Save/Save"; import { Save } from './Save/Save';
import { IconWrapper } from "./Desktop/DesktopFooter"; import { IconWrapper } from './Desktop/DesktopFooter';
import { useRecoilState } from "recoil"; import { useRecoilState } from 'recoil';
import { enabledDevModeAtom } from "../atoms/global"; import { enabledDevModeAtom } from '../atoms/global';
import { AppsIcon } from "../assets/Icons/AppsIcon"; import { AppsIcon } from '../assets/Icons/AppsIcon';
import ThemeSelector from "./Theme/ThemeSelector"; import ThemeSelector from '../styles/ThemeSelector';
export const DesktopSideBar = ({ export const DesktopSideBar = ({
goToHome, goToHome,
@ -24,25 +24,25 @@ export const DesktopSideBar = ({
}) => { }) => {
const [isEnabledDevMode, setIsEnabledDevMode] = const [isEnabledDevMode, setIsEnabledDevMode] =
useRecoilState(enabledDevModeAtom); useRecoilState(enabledDevModeAtom);
const theme = useTheme(); const theme = useTheme();
return ( return (
<Box <Box
sx={{ sx={{
width: "60px", width: '60px',
flexDirection: "column", flexDirection: 'column',
height: "100vh", height: '100vh',
alignItems: "center", alignItems: 'center',
display: "flex", display: 'flex',
gap: "25px", gap: '25px',
}} }}
> >
<ButtonBase <ButtonBase
sx={{ sx={{
width: "60px", width: '60px',
height: "60px", height: '60px',
paddingTop: "23px", paddingTop: '23px',
}} }}
onClick={() => { onClick={() => {
goToHome(); goToHome();
@ -51,39 +51,39 @@ export const DesktopSideBar = ({
<HomeIcon <HomeIcon
height={34} height={34}
color={ color={
desktopViewMode === "home" ? "white" : "rgba(250, 250, 250, 0.5)" desktopViewMode === 'home' ? 'white' : 'rgba(250, 250, 250, 0.5)'
} }
/> />
</ButtonBase> </ButtonBase>
<ButtonBase <ButtonBase
onClick={() => { onClick={() => {
setDesktopViewMode("apps"); setDesktopViewMode('apps');
// setIsOpenSideViewDirects(false) // setIsOpenSideViewDirects(false)
// setIsOpenSideViewGroups(false) // setIsOpenSideViewGroups(false)
}} }}
> >
<IconWrapper <IconWrapper
color={isApps ? "white" : "rgba(250, 250, 250, 0.5)"} color={isApps ? 'white' : 'rgba(250, 250, 250, 0.5)'}
label="Apps" label="Apps"
selected={isApps} selected={isApps}
disableWidth disableWidth
> >
<AppsIcon <AppsIcon
color={isApps ? "white" : "rgba(250, 250, 250, 0.5)"} color={isApps ? 'white' : 'rgba(250, 250, 250, 0.5)'}
height={30} height={30}
/> />
</IconWrapper> </IconWrapper>
</ButtonBase> </ButtonBase>
<ButtonBase <ButtonBase
onClick={() => { onClick={() => {
setDesktopViewMode("chat"); setDesktopViewMode('chat');
}} }}
> >
<IconWrapper <IconWrapper
color={ color={
hasUnreadDirects || hasUnreadGroups hasUnreadDirects || hasUnreadGroups
? "var(--unread)" ? 'var(--unread)'
: theme.palette.text.primary : theme.palette.text.primary
} }
label="Chat" label="Chat"
disableWidth disableWidth
@ -92,7 +92,7 @@ export const DesktopSideBar = ({
height={30} height={30}
color={ color={
hasUnreadDirects || hasUnreadGroups hasUnreadDirects || hasUnreadGroups
? "var(--unread)" ? 'var(--unread)'
: theme.palette.text.primary : theme.palette.text.primary
} }
/> />
@ -121,24 +121,22 @@ export const DesktopSideBar = ({
{isEnabledDevMode && ( {isEnabledDevMode && (
<ButtonBase <ButtonBase
onClick={() => { onClick={() => {
setDesktopViewMode("dev"); setDesktopViewMode('dev');
}} }}
> >
<IconWrapper <IconWrapper
color={ color={
desktopViewMode === "dev" ? "white" : "rgba(250, 250, 250, 0.5)" desktopViewMode === 'dev' ? 'white' : 'rgba(250, 250, 250, 0.5)'
} }
label="Dev" label="Dev"
disableWidth disableWidth
> >
<AppsIcon <AppsIcon height={30} />
height={30}
/>
</IconWrapper> </IconWrapper>
</ButtonBase> </ButtonBase>
)} )}
<ThemeSelector style={{ position: "fixed", bottom: "1%" }} /> <ThemeSelector style={{ position: 'fixed', bottom: '1%' }} />
</Box> </Box>
); );
}; };

View File

@ -1,13 +1,13 @@
import React from "react"; import React from 'react';
import ReactDOM from "react-dom/client"; import ReactDOM from 'react-dom/client';
import App from "./App.tsx"; import App from './App.tsx';
import "./index.css"; import './index.css';
import "./messaging/messagesToBackground"; import './messaging/messagesToBackground';
import { MessageQueueProvider } from "./MessageQueueContext.tsx"; import { MessageQueueProvider } from './MessageQueueContext.tsx';
import { RecoilRoot } from "recoil"; import { RecoilRoot } from 'recoil';
import { ThemeProvider } from "./components/Theme/ThemeContext.tsx"; import { ThemeProvider } from './styles/ThemeContext.tsx';
ReactDOM.createRoot(document.getElementById("root")!).render( ReactDOM.createRoot(document.getElementById('root')!).render(
<> <>
<ThemeProvider> <ThemeProvider>
<MessageQueueProvider> <MessageQueueProvider>

View File

@ -1,24 +1,19 @@
import { createContext, useContext, useState, useMemo } from 'react'; import { createContext, useContext, useState, useMemo } from 'react';
import { createTheme, ThemeProvider as MuiThemeProvider } from '@mui/material/styles'; import { ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
import { darkTheme, lightTheme } from './theme';
const darkTheme = createTheme({ const ThemeContext = createContext({
palette: { themeMode: 'light',
mode: 'dark', toggleTheme: () => {},
},
}); });
const lightTheme = createTheme({
palette: {
mode: 'light',
},
});
const ThemeContext = createContext({ themeMode: 'light', toggleTheme: () => {} });
export const ThemeProvider = ({ children }: { children: React.ReactNode }) => { export const ThemeProvider = ({ children }: { children: React.ReactNode }) => {
const [themeMode, setThemeMode] = useState('light'); const [themeMode, setThemeMode] = useState('light');
const theme = useMemo(() => (themeMode === 'light' ? lightTheme : darkTheme), [themeMode]); const theme = useMemo(
() => (themeMode === 'light' ? lightTheme : darkTheme),
[themeMode]
);
const toggleTheme = () => { const toggleTheme = () => {
setThemeMode((prevMode) => (prevMode === 'light' ? 'dark' : 'light')); setThemeMode((prevMode) => (prevMode === 'light' ? 'dark' : 'light'));
@ -31,4 +26,4 @@ export const ThemeProvider = ({ children }: { children: React.ReactNode }) => {
); );
}; };
export const useThemeContext = () => useContext(ThemeContext); export const useThemeContext = () => useContext(ThemeContext);

View File

@ -1,54 +1,50 @@
import { createTheme } from '@mui/material/styles' import { createTheme } from '@mui/material/styles';
// Extend the Theme interface // Extend the Theme interface
const commonThemeOptions = { const commonThemeOptions = {
typography: { typography: {
fontFamily: [ fontFamily: ['Roboto'].join(','),
'Roboto'
].join(','),
h1: { h1: {
fontSize: '2rem', fontSize: '2rem',
fontWeight: 600 fontWeight: 600,
}, },
h2: { h2: {
fontSize: '1.75rem', fontSize: '1.75rem',
fontWeight: 500 fontWeight: 500,
}, },
h3: { h3: {
fontSize: '1.5rem', fontSize: '1.5rem',
fontWeight: 500 fontWeight: 500,
}, },
h4: { h4: {
fontSize: '1.25rem', fontSize: '1.25rem',
fontWeight: 500 fontWeight: 500,
}, },
h5: { h5: {
fontSize: '1rem', fontSize: '1rem',
fontWeight: 500 fontWeight: 500,
}, },
h6: { h6: {
fontSize: '0.875rem', fontSize: '0.875rem',
fontWeight: 500 fontWeight: 500,
}, },
body1: { body1: {
fontSize: '23px', fontSize: '23px',
fontWeight: 400, fontWeight: 400,
lineHeight: 1.5, lineHeight: 1.5,
letterSpacing: '0.5px' letterSpacing: '0.5px',
}, },
body2: { body2: {
fontSize: '18px', fontSize: '18px',
fontWeight: 400, fontWeight: 400,
lineHeight: 1.4, lineHeight: 1.4,
letterSpacing: '0.2px' letterSpacing: '0.2px',
} },
}, },
spacing: 8, spacing: 8,
shape: { shape: {
borderRadius: 4 borderRadius: 4,
}, },
breakpoints: { breakpoints: {
values: { values: {
@ -56,8 +52,8 @@ const commonThemeOptions = {
sm: 600, sm: 600,
md: 900, md: 900,
lg: 1200, lg: 1200,
xl: 1536 xl: 1536,
} },
}, },
components: { components: {
MuiButton: { MuiButton: {
@ -66,25 +62,24 @@ const commonThemeOptions = {
backgroundColor: 'inherit', backgroundColor: 'inherit',
transition: 'filter 0.3s ease-in-out', transition: 'filter 0.3s ease-in-out',
'&:hover': { '&:hover': {
filter: 'brightness(1.1)' filter: 'brightness(1.1)',
} },
} },
}, },
defaultProps: { defaultProps: {
disableElevation: true, disableElevation: true,
disableRipple: true disableRipple: true,
} },
}, },
MuiModal: { MuiModal: {
styleOverrides: { styleOverrides: {
root: { root: {
zIndex: 50000, zIndex: 50000,
}, },
} },
},
} },
} };
}
const lightTheme = createTheme({ const lightTheme = createTheme({
...commonThemeOptions, ...commonThemeOptions,
@ -93,19 +88,19 @@ const lightTheme = createTheme({
primary: { primary: {
main: '#f4f4fb', main: '#f4f4fb',
dark: '#eaecf4', dark: '#eaecf4',
light: '#f9f9fd' light: '#f9f9fd',
}, },
secondary: { secondary: {
main: '#1EAAF1' main: '#1EAAF1',
}, },
background: { background: {
default: '#fafafa', default: '#fafafa',
paper: '#f0f0f0' paper: '#f0f0f0',
}, },
text: { text: {
primary: '#000000', primary: '#000000',
secondary: '#525252' secondary: '#525252',
} },
}, },
components: { components: {
@ -119,20 +114,20 @@ const lightTheme = createTheme({
'&:hover': { '&:hover': {
cursor: 'pointer', cursor: 'pointer',
boxShadow: boxShadow:
'rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;' 'rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;',
} },
} },
} },
}, },
MuiIcon: { MuiIcon: {
defaultProps: { defaultProps: {
style: { style: {
color: '#000000' color: '#000000',
} },
} },
} },
}, },
}) });
const darkTheme = createTheme({ const darkTheme = createTheme({
...commonThemeOptions, ...commonThemeOptions,
@ -140,45 +135,45 @@ const darkTheme = createTheme({
mode: 'dark', mode: 'dark',
primary: { primary: {
main: '#2e3d60', main: '#2e3d60',
dark: "#1a2744", dark: '#1a2744',
light: "#3f4b66", light: '#3f4b66',
}, },
secondary: { secondary: {
main: '#45adff' main: '#45adff',
}, },
background: { background: {
default: '#313338', default: '#313338',
paper: "#1e1e20" paper: '#1e1e20',
}, },
text: { text: {
primary: '#ffffff', primary: '#ffffff',
secondary: '#b3b3b3' secondary: '#b3b3b3',
} },
}, },
components: { components: {
MuiCard: { MuiCard: {
styleOverrides: { styleOverrides: {
root: { root: {
boxShadow: "none", boxShadow: 'none',
borderRadius: '8px', borderRadius: '8px',
transition: 'all 0.3s ease-in-out', transition: 'all 0.3s ease-in-out',
'&:hover': { '&:hover': {
cursor: 'pointer', cursor: 'pointer',
boxShadow: boxShadow:
' 0px 3px 4px 0px hsla(0,0%,0%,0.14), 0px 3px 3px -2px hsla(0,0%,0%,0.12), 0px 1px 8px 0px hsla(0,0%,0%,0.2);' ' 0px 3px 4px 0px hsla(0,0%,0%,0.14), 0px 3px 3px -2px hsla(0,0%,0%,0.12), 0px 1px 8px 0px hsla(0,0%,0%,0.2);',
} },
} },
} },
}, },
MuiIcon: { MuiIcon: {
defaultProps: { defaultProps: {
style: { style: {
color: '#ffffff' color: '#ffffff',
} },
} },
} },
}, },
}) });
export { lightTheme, darkTheme } export { lightTheme, darkTheme };