Skip to content

Commit

Permalink
remove exported custom styles into a MUIStyles.js
Browse files Browse the repository at this point in the history
  • Loading branch information
kweeuhree committed Oct 19, 2024
1 parent d6e08d8 commit d5443d7
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 50 deletions.
18 changes: 0 additions & 18 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@ import { useShoppingLists } from './api';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';

const paperStyle = {
color: 'white',
p: '1rem',
};

export const darkPaperStyle = {
...paperStyle,
paddingBlockStart: '4rem',
paddingBlockEnd: '4rem',
background: `linear-gradient(45deg, rgba(117, 124, 232, 0.2) 0%, rgba(117, 124, 232, 0.05) 100%)`, // Pale blue gradient on top
backdropFilter: 'blur(2px)',
};

export const lightPaperStyle = {
...paperStyle,
background: `rgba(117, 124, 232, 0.2)`,
};

export function App() {
/**
* This custom hook takes the path of a shopping list
Expand Down
2 changes: 1 addition & 1 deletion src/components/AddItems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { normalizeItemName } from '../utils';
import { RadioInputElement, TextInputElement } from './index.js';
import { toast } from 'react-toastify';
import { Box, Button, FormControl, RadioGroup } from '@mui/material';
import { buttonStyle } from '../views';
import { buttonStyle } from './index';

const radioGroupStyle = {
mx: 1,
Expand Down
7 changes: 1 addition & 6 deletions src/components/ConfirmDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Button,
} from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';
import { buttonStyle } from '../views';
import { buttonStyle } from './index';
import './ConfirmDialog.css';

// MUI's Dialog already comes with built-in focus management and accessibility features.
Expand All @@ -23,11 +23,6 @@ const dialogStyle = {
backgroundColor: 'rgb(20, 20, 20)',
};

export const typographyStyle = {
padding: '1em',
color: 'white',
};

export function ConfirmDialog({ props }) {
const { handleDelete, title, setOpen, open } = props;

Expand Down
7 changes: 1 addition & 6 deletions src/components/DeleteIconWithTooltip.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { DeleteOutlineOutlined } from '@mui/icons-material';
import { Tooltip, IconButton } from '@mui/material';

export const tooltipStyle = {
fontSize: '1.5rem',
marginBlockStart: '0',
marginBlockEnd: '0',
};
import { tooltipStyle } from './MUIStyles';

export const DeleteIconWithTooltip = ({ ariaLabel, toggleDialog }) => {
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/ListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { updateItem, deleteItem } from '../api';
import { calculateDateNextPurchased, ONE_DAY_IN_MILLISECONDS } from '../utils';
import { toast } from 'react-toastify';
import { useConfirmDialog } from '../hooks/useConfirmDialog';
import { DeleteIconWithTooltip, tooltipStyle, ConfirmDialog } from './index';
import { DeleteIconWithTooltip, ConfirmDialog, tooltipStyle } from './index';
import {
ListItem as MaterialListItem,
Tooltip,
Expand Down
38 changes: 38 additions & 0 deletions src/components/MUIStyles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const paperStyle = {
color: 'white',
p: '1rem',
};

export const darkPaperStyle = {
...paperStyle,
paddingBlockStart: '4rem',
paddingBlockEnd: '4rem',
background: `linear-gradient(45deg, rgba(117, 124, 232, 0.2) 0%, rgba(117, 124, 232, 0.05) 100%)`, // Pale blue gradient on top
backdropFilter: 'blur(2px)',
};

export const lightPaperStyle = {
...paperStyle,
background: `rgba(117, 124, 232, 0.2)`,
};

export const tooltipStyle = {
fontSize: '1.5rem',
marginBlockStart: '0',
marginBlockEnd: '0',
};

export const buttonStyle = {
color: 'white',
fontSize: '1.5rem',
};

export const buttonWithTopMarginStyle = {
...buttonStyle,
marginTop: '0.5rem',
};

export const typographyStyle = {
padding: '1em',
color: 'white',
};
2 changes: 1 addition & 1 deletion src/components/RadioInputElement.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Radio, Tooltip, FormControlLabel } from '@mui/material';
import { tooltipStyle } from './DeleteIconWithTooltip';
import { tooltipStyle } from './MUIStyles';

const radioStyle = {
color: 'white',
Expand Down
3 changes: 1 addition & 2 deletions src/components/ShareList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { useStateWithStorage, useAuth } from '../hooks';
import { shareList } from '../api';
import { toast } from 'react-toastify';
import { Box, Button } from '@mui/material';
import { TextInputElement } from './index.js';
import { buttonWithTopMarginStyle } from '../views/Home';
import { TextInputElement, buttonWithTopMarginStyle } from './index.js';

export function ShareList() {
const [listPath] = useStateWithStorage('tcl-shopping-list-path', null);
Expand Down
2 changes: 1 addition & 1 deletion src/components/TextInputElement.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TextField, Typography } from '@mui/material';
import { typographyStyle } from './ConfirmDialog';
import { typographyStyle } from '../components/index';

const textFieldStyle = {
'& .MuiInputBase-input': {
Expand Down
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from './TextInputElement';
export * from './RadioInputElement';
export * from './ConfirmDialog';
export * from './DeleteIconWithTooltip';
export * from './MUIStyles';
18 changes: 6 additions & 12 deletions src/views/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,14 @@ import {
Button,
List as UnorderedList,
} from '@mui/material';
import { SingleList, TextInputElement } from '../components';
import { lightPaperStyle, darkPaperStyle } from '../App';
import {
SingleList,
TextInputElement,
lightPaperStyle,
darkPaperStyle,
} from '../components';
import './Home.css';

export const buttonStyle = {
color: 'white',
fontSize: '1.5rem',
};

export const buttonWithTopMarginStyle = {
...buttonStyle,
marginTop: '0.5rem',
};

const dividerStyle = {
borderColor: 'primary.main',
};
Expand Down
9 changes: 7 additions & 2 deletions src/views/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import {
Button,
} from '@mui/material';
import { ArrowDropDown, ArrowDropUp } from '@mui/icons-material';
import { ListItem, AddItems, TextInputElement } from '../components';
import { darkPaperStyle, lightPaperStyle } from '../App';
import {
ListItem,
AddItems,
TextInputElement,
darkPaperStyle,
lightPaperStyle,
} from '../components';

// React.memo is needed to prevent unnecessary re-renders of the List component
// when the props (data and listPath) haven't changed,
Expand Down

0 comments on commit d5443d7

Please sign in to comment.