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

[ISSUE 14] - Add Material UI throughout app #75

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4045552
fix: update exports from components folder, add ShareList
kweeuhree Oct 16, 2024
7e4e609
feat: update imports, add MUI Box component
kweeuhree Oct 16, 2024
978a24d
wq
kweeuhree Oct 16, 2024
7fa8bf1
feat: use MUI Button component for sign in and sign out buttons
kweeuhree Oct 16, 2024
e3d20e4
fix: update buttonStyle import
kweeuhree Oct 16, 2024
86fe281
fix: remove comments
kweeuhree Oct 16, 2024
9d8b167
feat: add MUI components and update labels to be more friendly
kweeuhree Oct 16, 2024
fe85941
feat: add MUI components and minor custom styling
kweeuhree Oct 16, 2024
7358af1
feat: use TextField component instead of input and use Typography com…
kweeuhree Oct 16, 2024
f0d4eb1
feat: ConfirmDialog exports typography style
kweeuhree Oct 16, 2024
76e3090
feat: add MUI components and minor custom styling
kweeuhree Oct 16, 2024
f41fd52
feat: add MUI components
kweeuhree Oct 16, 2024
13c9e46
feat: update SingleList component
kweeuhree Oct 16, 2024
4c88cf1
feat: update List component
kweeuhree Oct 16, 2024
8a6c5e1
feat: update ListItem imports and remove redundant console log
kweeuhree Oct 16, 2024
d9f5cfe
test: update labels in List test
kweeuhree Oct 16, 2024
2d12b86
test: update labels in ManageList test
kweeuhree Oct 16, 2024
a9d3373
Merge branch 'main' of https://github.com/the-collab-lab/tcl-75-smart…
kweeuhree Oct 17, 2024
560ba74
feat: introduce a collapsible box in List component that displays Add…
kweeuhree Oct 17, 2024
e8d4d27
test: add a data-testid for New Item button for testing purposes
kweeuhree Oct 17, 2024
8a90574
test: update List test to be able to click on a New Item button
kweeuhree Oct 17, 2024
f0a0a54
fix: update kindOfSoon to be "kind of soon" and notSoon to be "not soon"
kweeuhree Oct 17, 2024
78fe00e
feat: add paper component across the views, add variation of MUI prim…
kweeuhree Oct 17, 2024
d6e08d8
fix: import darkPaperStyle, lightPaperStyle from App
kweeuhree Oct 18, 2024
d5443d7
remove exported custom styles into a MUIStyles.js
kweeuhree Oct 19, 2024
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
57 changes: 40 additions & 17 deletions src/components/AddItems.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { useCallback } from 'react';
import { normalizeItemName } from '../utils';
import { useStateWithStorage } from '../hooks';
import { addItem } from '../api';
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 './index';

const radioGroupStyle = {
mx: 1,
justifyContent: 'space-between',
};

const daysUntilPurchaseOptions = {
Soon: 7,
Expand Down Expand Up @@ -59,27 +66,43 @@ export function AddItems({ items }) {
);

return (
<div>
<form onSubmit={handleSubmit}>
<Box component="section">
<Box
component="form"
noValidate
autoComplete="off"
onSubmit={handleSubmit}
>
<TextInputElement
type="text"
id="item-name"
placeholder="Enter item name"
label="Item Name:"
placeholder="Item name"
label="Add item:"
required={true}
/>
<FormControl fullWidth required>
<RadioGroup
aria-labelledby="purchase-date-radios"
name="purchase-date"
sx={radioGroupStyle}
row
>
{Object.entries(daysUntilPurchaseOptions).map(([key, value]) => (
<RadioInputElement
key={key}
label={key}
id={key}
value={value}
required={true}
/>
))}
</RadioGroup>
</FormControl>

{Object.entries(daysUntilPurchaseOptions).map(([key, value]) => (
<RadioInputElement
key={key}
label={key}
id={key}
value={value}
required={true}
/>
))}
<button type="submit">Submit</button>
</form>
</div>
<Button sx={buttonStyle} fullWidth variant="outlined" type="submit">
Submit
</Button>
</Box>
</Box>
);
}
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 @@
Button,
} from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';
import { buttonStyle } from './SingleList';
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 @@
backgroundColor: 'rgb(20, 20, 20)',
};

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

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

Expand Down Expand Up @@ -79,7 +74,7 @@
</IconButton>

<Typography
sx={typographyStyle}

Check failure on line 77 in src/components/ConfirmDialog.jsx

View workflow job for this annotation

GitHub Actions / Run Tests

tests/SingleList.test.jsx > SingleList component > calls deleteList function

ReferenceError: typographyStyle is not defined ❯ ConfirmDialog src/components/ConfirmDialog.jsx:77:9 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 ❯ workLoopSync node_modules/react-dom/cjs/react-dom.development.js:26505:5 ❯ renderRootSync node_modules/react-dom/cjs/react-dom.development.js:26473:7 ❯ recoverFromConcurrentError node_modules/react-dom/cjs/react-dom.development.js:25889:20 ❯ performConcurrentWorkOnRoot node_modules/react-dom/cjs/react-dom.development.js:25789:22

Check failure on line 77 in src/components/ConfirmDialog.jsx

View workflow job for this annotation

GitHub Actions / Run Tests

tests/SingleList.test.jsx > SingleList component > calls deleteList function

ReferenceError: typographyStyle is not defined ❯ ConfirmDialog src/components/ConfirmDialog.jsx:77:9 ❯ renderWithHooks node_modules/react-dom/cjs/react-dom.development.js:15486:18 ❯ mountIndeterminateComponent node_modules/react-dom/cjs/react-dom.development.js:20103:13 ❯ beginWork node_modules/react-dom/cjs/react-dom.development.js:21626:16 ❯ beginWork$1 node_modules/react-dom/cjs/react-dom.development.js:27465:14 ❯ performUnitOfWork node_modules/react-dom/cjs/react-dom.development.js:26599:12 ❯ workLoopSync node_modules/react-dom/cjs/react-dom.development.js:26505:5 ❯ renderRootSync node_modules/react-dom/cjs/react-dom.development.js:26473:7 ❯ recoverFromConcurrentError node_modules/react-dom/cjs/react-dom.development.js:25889:20 ❯ performConcurrentWorkOnRoot node_modules/react-dom/cjs/react-dom.development.js:25789:22
fontSize="large"
variant="h5"
gutterBottom
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
18 changes: 5 additions & 13 deletions src/components/ListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +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 { ConfirmDialog } from './ConfirmDialog';
import { DeleteIconWithTooltip, tooltipStyle } from './DeleteIconWithTooltip';
import { DeleteIconWithTooltip, ConfirmDialog, tooltipStyle } from './index';
import {
ListItem as MaterialListItem,
Tooltip,
Expand All @@ -29,8 +28,8 @@ const currentDate = new Date();
const urgencyStatusIcons = {
overdue: OverdueIcon,
soon: SoonIcon,
kindOfSoon: KindOfSoonIcon,
notSoon: NotSoonIcon,
'kind of soon': KindOfSoonIcon,
'not soon': NotSoonIcon,
inactive: InactiveIcon,
};

Expand All @@ -39,12 +38,6 @@ const urgencyStatusStyle = {
color: 'white',
};

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

const calculateIsPurchased = (dateLastPurchased) => {
if (!dateLastPurchased) {
return false;
Expand Down Expand Up @@ -86,7 +79,6 @@ export function ListItem({ item, listPath, itemUrgencyStatus }) {
};

const handleDeleteItem = async () => {
console.log('attempting item deletion');
try {
await deleteItem(listPath, id);
toast.success('Item deleted');
Expand All @@ -102,7 +94,7 @@ export function ListItem({ item, listPath, itemUrgencyStatus }) {
handleDelete: handleDeleteItem,
title: `Are you sure you want to delete ${name}?`,
setOpen: isOpen,
open: open,
open,
};

const tooltipTitle = isPurchased
Expand All @@ -115,7 +107,7 @@ export function ListItem({ item, listPath, itemUrgencyStatus }) {
<MaterialListItem className="ListItem">
{UrgencyStatusIcon && (
<Tooltip
title={<p style={toolTipStyle}>{itemUrgencyStatus}</p>}
title={<p style={tooltipStyle}>{itemUrgencyStatus}</p>}
placement="left"
arrow
>
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',
};
40 changes: 29 additions & 11 deletions src/components/RadioInputElement.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import { Radio, Tooltip, FormControlLabel } from '@mui/material';
import { tooltipStyle } from './MUIStyles';

const radioStyle = {
color: 'white',
m: 2,
my: 3,
};

export const RadioInputElement = ({ label, id, value, required }) => {
return (
<>
<input
type="radio"
name="purchase-date"
id={id}
value={value}
required={required}
/>
<label htmlFor={id}>{label}</label>
<br />
</>
<FormControlLabel
control={
<Radio
value={value}
id={id}
required={required}
inputProps={{ 'aria-label': label }}
color="success"
sx={radioStyle}
/>
}
label={
<Tooltip
title={<p style={tooltipStyle}>{`${value} days from today`}</p>}
arrow
>
<span style={{ fontSize: '1.8rem' }}>{label}</span>
</Tooltip>
}
/>
);
};
29 changes: 21 additions & 8 deletions src/components/ShareList.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { shareList } from '../api';
import { useStateWithStorage, useAuth } from '../hooks';
import { TextInputElement } from './index.js';
import { shareList } from '../api';
import { toast } from 'react-toastify';
import { Box, Button } from '@mui/material';
import { TextInputElement, buttonWithTopMarginStyle } from './index.js';

export function ShareList() {
const [listPath] = useStateWithStorage('tcl-shopping-list-path', null);
Expand Down Expand Up @@ -39,17 +40,29 @@ export function ShareList() {
};

return (
<div>
<form onSubmit={handleEmailInputSubmit}>
<Box component="section">
<Box
component="form"
noValidate
autoComplete="off"
onSubmit={handleEmailInputSubmit}
>
<TextInputElement
type="email"
id="email-input"
placeholder="Enter email"
label="Enter Email:"
label="Share this list with a friend by entering their email:"
required={true}
/>
<button type="submit">Invite User</button>
</form>
</div>
<Button
sx={buttonWithTopMarginStyle}
fullWidth
variant="outlined"
type="submit"
>
Share
</Button>
</Box>
</Box>
);
}
1 change: 1 addition & 0 deletions src/components/SingleList.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.SingleList {
align-items: baseline;
display: flex;
width: inherit;
flex-direction: row;
align-items: center;
font-size: 1.2em;
Expand Down
Loading
Loading