Skip to content

Commit

Permalink
fix(appStyle): various fixes & minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Clm-Roig committed Oct 3, 2022
1 parent 1f0646b commit 575ab74
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 185 deletions.
253 changes: 130 additions & 123 deletions src/app/DrawerMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,123 +1,130 @@
import CheckIcon from '@mui/icons-material/Check';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import DarkModeIcon from '@mui/icons-material/DarkMode';
import HomeIcon from '@mui/icons-material/Home';
import LightModeIcon from '@mui/icons-material/LightMode';
import ListAltIcon from '@mui/icons-material/ListAlt';
import SettingsIcon from '@mui/icons-material/Settings';
import TimelineIcon from '@mui/icons-material/Timeline';
import {
Box,
Button,
Divider,
IconButton,
List,
ListItemButton,
ListItemIcon,
ListItemText,
SwipeableDrawer
} from '@mui/material';
import { FC } from 'react';
import { Link, useLocation } from 'react-router-dom';

import { useAppSelector } from '../hooks/redux';
import { selectThemeMode } from '../store/theme/theme.selectors';

interface MenuItemProps {
icon: React.ReactNode;
name: string;
onClick: () => void;
selected: boolean;
url: string;
}
const MenuItem: FC<MenuItemProps> = ({ icon, name, onClick, selected, url }) => (
<ListItemButton selected={selected} component={Link} to={url} key={name} onClick={onClick}>
<ListItemIcon>{icon}</ListItemIcon>
<ListItemText primary={name} />
</ListItemButton>
);

interface Props {
open: boolean;
toggleDrawerMenu: () => void;
toggleThemeMode: () => void;
width: string;
}

const DrawerMenu: FC<Props> = ({ open, toggleDrawerMenu, toggleThemeMode, width }) => {
const themeMode = useAppSelector(selectThemeMode);
const currentPathName = useLocation().pathname;
const menuItems = [
{
icon: <HomeIcon />,
name: 'Accueil',
url: '/'
},
{
icon: <CheckIcon />,
name: 'Valider mes trackers',
url: '/trackers'
},
{
icon: <ListAltIcon />,
name: 'Tous mes trackers',
url: '/trackers/manage'
},
{
icon: <TimelineIcon />,
name: 'Statistiques',
url: '/stats'
},
{
icon: <SettingsIcon />,
name: 'Paramètres',
url: '/settings'
}
];

return (
<SwipeableDrawer
anchor="left"
onClose={toggleDrawerMenu}
onOpen={toggleDrawerMenu}
open={open}
sx={{
width: width,
flexShrink: 0,
'& .MuiDrawer-paper': {
width: width,
boxSizing: 'border-box'
}
}}>
<Box display="flex" justifyContent="space-between">
<IconButton sx={{ ml: 1 }} onClick={toggleThemeMode} color="inherit">
{themeMode === 'dark' ? <DarkModeIcon /> : <LightModeIcon />}
</IconButton>
<IconButton onClick={toggleDrawerMenu}>
<ChevronLeftIcon />
</IconButton>
</Box>
<Divider />
<List>
{menuItems.map((mi) => (
<MenuItem
key={mi.name}
icon={mi.icon}
name={mi.name}
onClick={toggleDrawerMenu}
selected={currentPathName === mi.url}
url={mi.url}
/>
))}
</List>
<Divider />
<Box display="flex" justifyContent="center" paddingY={1}>
<Button variant="contained" component={Link} onClick={toggleDrawerMenu} to="/about">
À Propos
</Button>
</Box>
</SwipeableDrawer>
);
};

export default DrawerMenu;
import CheckIcon from '@mui/icons-material/Check';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import DarkModeIcon from '@mui/icons-material/DarkMode';
import HomeIcon from '@mui/icons-material/Home';
import LightModeIcon from '@mui/icons-material/LightMode';
import ListAltIcon from '@mui/icons-material/ListAlt';
import SettingsIcon from '@mui/icons-material/Settings';
import TimelineIcon from '@mui/icons-material/Timeline';
import {
Box,
Button,
Divider,
IconButton,
List,
ListItemButton,
ListItemIcon,
ListItemText,
SwipeableDrawer
} from '@mui/material';
import { FC } from 'react';
import { Link, useLocation } from 'react-router-dom';

import { useAppSelector } from '../hooks/redux';
import ThemeMode from '../models/ThemeMode';
import PackageVersion from '../pages/About/PackageVersion';
import { selectThemeMode } from '../store/theme/theme.selectors';

interface MenuItemProps {
icon: React.ReactNode;
name: string;
onClick: () => void;
selected: boolean;
url: string;
}
const MenuItem: FC<MenuItemProps> = ({ icon, name, onClick, selected, url }) => {
const themeMode = useAppSelector(selectThemeMode);
const isDarkMode = themeMode === ThemeMode.DARK;
return (
<ListItemButton selected={selected} component={Link} to={url} key={name} onClick={onClick}>
<ListItemIcon>{icon}</ListItemIcon>
<ListItemText primaryTypographyProps={{ color: isDarkMode ? '#fff' : '' }} primary={name} />
</ListItemButton>
);
};

interface Props {
open: boolean;
toggleDrawerMenu: () => void;
toggleThemeMode: () => void;
width: string;
}

const DrawerMenu: FC<Props> = ({ open, toggleDrawerMenu, toggleThemeMode, width }) => {
const themeMode = useAppSelector(selectThemeMode);
const currentPathName = useLocation().pathname;
const menuItems = [
{
icon: <HomeIcon color="primary" />,
name: 'Accueil',
url: '/'
},
{
icon: <CheckIcon color="primary" />,
name: 'Valider mes trackers',
url: '/trackers'
},
{
icon: <ListAltIcon color="primary" />,
name: 'Tous mes trackers',
url: '/trackers/manage'
},
{
icon: <TimelineIcon color="primary" />,
name: 'Statistiques',
url: '/stats'
},
{
icon: <SettingsIcon color="primary" />,
name: 'Paramètres',
url: '/settings'
}
];

return (
<SwipeableDrawer
anchor="left"
onClose={toggleDrawerMenu}
onOpen={toggleDrawerMenu}
open={open}
sx={{
width: width,
flexShrink: 0,
'& .MuiDrawer-paper': {
width: width,
boxSizing: 'border-box'
}
}}>
<PackageVersion style={{ bottom: 0, right: 0, position: 'absolute' }} />
<Box display="flex" justifyContent="space-between">
<IconButton sx={{ ml: 1 }} onClick={toggleThemeMode} color="inherit">
{themeMode === 'dark' ? <DarkModeIcon /> : <LightModeIcon />}
</IconButton>
<IconButton onClick={toggleDrawerMenu}>
<ChevronLeftIcon />
</IconButton>
</Box>
<Divider />
<List>
{menuItems.map((mi) => (
<MenuItem
key={mi.name}
icon={mi.icon}
name={mi.name}
onClick={toggleDrawerMenu}
selected={currentPathName === mi.url}
url={mi.url}
/>
))}
</List>
<Divider />
<Box display="flex" justifyContent="center" paddingY={1}>
<Button variant="contained" component={Link} onClick={toggleDrawerMenu} to="/about">
À Propos
</Button>
</Box>
</SwipeableDrawer>
);
};

export default DrawerMenu;
1 change: 1 addition & 0 deletions src/app/MainContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface ContentPaperProps {
const ContentPaper = styled(Paper, {
shouldForwardProp: (prop) => prop !== 'themeMode'
})<ContentPaperProps>(({ theme, themeMode }) => ({
borderRadius: 0,
flex: 1,
padding: theme.spacing(2),
backgroundImage: `radial-gradient(at 0% 100%, ${
Expand Down
2 changes: 1 addition & 1 deletion src/components/ExternalLink/ExternalLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FC } from 'react';

const ExternalLink: FC<LinkProps> = (linkProps) => (
<>
<Link {...linkProps} target="_blank" rel="noreferrer">
<Link color="info.main" {...linkProps} target="_blank" rel="noreferrer">
{linkProps.children}
<LaunchIcon fontSize={'small'} sx={{ fontSize: '0.8rem', ml: '1px', verticalAlign: 'top' }} />
</Link>
Expand Down
70 changes: 34 additions & 36 deletions src/components/forms/TrackerColorPicker/TrackerColorButton.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
import { Box, Button, styled } from '@mui/material';
import { FC } from 'react';

interface BlockProps {
bg: string;
}
const ColorBlockButton = styled(Button)<BlockProps>((props) => ({
background: props.bg,
boxShadow: '1px',
minHeight: '40px',
minWidth: '70px',
':hover': {
background: props.bg
}
}));

interface Props {
colorCode: string;
isSelected: boolean;
onBlockClick: () => void;
}

const TrackerColorButton: FC<Props> = ({ colorCode, isSelected, onBlockClick }) => {
return (
<Box boxShadow={1}>
<ColorBlockButton
id={colorCode}
sx={{ border: isSelected ? 1 : undefined }}
bg={colorCode}
onClick={onBlockClick}>
{isSelected && '✓'}
</ColorBlockButton>
</Box>
);
};
export default TrackerColorButton;
import { Button, styled } from '@mui/material';
import { FC } from 'react';

interface BlockProps {
bg: string;
}
const ColorBlockButton = styled(Button)<BlockProps>((props) => ({
background: props.bg,
boxShadow: '1px',
minHeight: '40px',
minWidth: '70px',
':hover': {
background: props.bg
}
}));

interface Props {
colorCode: string;
isSelected: boolean;
onBlockClick: () => void;
}

const TrackerColorButton: FC<Props> = ({ colorCode, isSelected, onBlockClick }) => {
return (
<ColorBlockButton
id={colorCode}
sx={{ border: isSelected ? 2 : undefined, boxShadow: 1 }}
bg={colorCode}
onClick={onBlockClick}>
{isSelected && '✓'}
</ColorBlockButton>
);
};
export default TrackerColorButton;
2 changes: 1 addition & 1 deletion src/config/Constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { subDays } from 'date-fns';

export const DRAWER_MENU_WIDTH = '250px';
export const DRAWER_MENU_WIDTH = '260px';
export const JSON_DATA_EXTENSION = '.sv.json'; // SuiVie json
export const PAYPAL_DONATE_URL =
'https://www.paypal.com/donate/?business=UF2GH7ZPMLES8&no_recurring=0&item_name=Chaque+don+me+permet+de+continuer+%C3%A0+d%C3%A9velopper+et+%C3%A0+am%C3%A9liorer+l%27application+SuiVie%2C+merci+%21+%3A%29&currency_code=EUR';
Expand Down
7 changes: 4 additions & 3 deletions src/config/CustomTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,12 @@ export const shadows: Shadows = [
''
];

const titleFont = 'Merriweather Sans';
const fallbackFont = 'sans-serif';
const titleFont = ['Merriweather Sans', fallbackFont].join(',');
export const typography = {
fontFamily: ['Poppins', 'sans-serif'].join(','),
fontFamily: ['Poppins', fallbackFont].join(','),
h1: {
fontSize: '4.2rem',
fontSize: '4rem',
fontFamily: titleFont
},
h2: {
Expand Down
Loading

0 comments on commit 575ab74

Please sign in to comment.