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 # 56. Designing responsive list component for the list page #67

Merged
merged 28 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
566bd0b
style: listitem name and checkbox colors
eternalmaha Oct 8, 2024
ac390b5
style: layout of list items
eternalmaha Oct 9, 2024
d708574
style: styling the list item component and layout
eternalmaha Oct 10, 2024
fa4ebea
style: aligning filterlist form label with its form control
eternalmaha Oct 10, 2024
6640516
style: font sizing and margins of list items
eternalmaha Oct 11, 2024
348974e
layout: adding React col, row, container components
eternalmaha Oct 11, 2024
fff0edf
layout: adjusted grid layout to better suit list items
eternalmaha Oct 12, 2024
882d546
fix: list items no longer overflow their parent
eternalmaha Oct 12, 2024
34cfb7b
style: imported and added react icons to itemquantity edits
eternalmaha Oct 13, 2024
9e37b04
refactor: using flexbox instead of bootstrap grid for layout
eternalmaha Oct 13, 2024
ead409b
style: align delete button below edit button on small screen sizes
eternalmaha Oct 13, 2024
f76004b
adding additem, sharelist into list page view
eternalmaha Oct 17, 2024
df827f3
style: stlying the add item form inside the listpage
eternalmaha Oct 17, 2024
10a5d95
style: listpage layouting
eternalmaha Oct 17, 2024
ea845fb
fix: mobile responsive
eternalmaha Oct 17, 2024
6cfaca2
refactor: scrolling back up to top of listpage view when at bottom of…
eternalmaha Oct 17, 2024
e1ce2a0
style: cleaning up button sizing
eternalmaha Oct 17, 2024
d0a4684
style: updated urgency status to reflect urgency with color codes
eternalmaha Oct 18, 2024
6844c90
style: improved visibility of filterlist text upon scrolling
eternalmaha Oct 18, 2024
52db7a1
refactor: listpage to excluse additem form and refactor sharelist for…
eternalmaha Oct 18, 2024
b998305
refactor: disregard additem navigation logic
eternalmaha Oct 18, 2024
6d8843b
Merge branch 'main' into ma/designing-responsive-listview
eternalmaha Oct 18, 2024
d1a41de
fix: resolve merge conflict in list page
eternalmaha Oct 18, 2024
1a8a0e8
refactor: removing unnecessary css in list page style page
eternalmaha Oct 18, 2024
f89fc80
making adjustments to use RB 1 Container on list, adjust classes on e…
bbland1 Oct 18, 2024
cfc6a8e
fix: adjusted font-sizes and listitem inputs to be more responsive at…
eternalmaha Oct 19, 2024
430e5e2
style: center view list button
eternalmaha Oct 19, 2024
e56ab5c
refactor: remove managelist navbar button as no longer necessart
eternalmaha 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
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-bootstrap": "^2.10.5",
"react-dom": "^18.3.1",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.3.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YASSSSS! I love the use of icons while keeping the button colors the same for smaller screen sizes!

"react-router-dom": "^6.26.2"
},
"devDependencies": {
Expand Down
9 changes: 6 additions & 3 deletions src/components/FilterListInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ export function FilterListInput({

return (
<Form onSubmit={handleSubmit}>
<InputGroup>
<Form.Label htmlFor="filterList">Filter List:</Form.Label>
<InputGroup className="d-flex align-items-center">
<Form.Label htmlFor="filterList" className="me-2 mb-0">
{" "}
Filter List:
</Form.Label>
<Form.Control
type="text"
onChange={handleChange}
Expand All @@ -36,7 +39,7 @@ export function FilterListInput({
aria-label="Filter items in the list"
placeholder="Search items..."
/>
<Button onClick={handleClear}>x</Button>
<Button onClick={handleClear}>Clear</Button>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change to clear, with bootstrap the x that was in the input didn't show any more and the button to clear was the best workaround but the x was awkard so it is much clearer (lol) with clear.

</InputGroup>
</Form>
);
Expand Down
33 changes: 25 additions & 8 deletions src/components/ListItem.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
.ListItem {
@import "../styles/_variables";

.ListItemBox {
align-items: baseline;
display: flex;
flex-direction: row;
font-size: 1.2em;
font-size: 1.5em;
justify-content: space-between;
background-color: $primary-blue;
color: $primary-beige;
border-radius: 4px;
max-width: 100%;
box-sizing: border-box;
}

.UrgencyStatus {
display: block;
background-color: $secondary-blue;
color: $primary-beige;
font-size: 1.25em;
max-width: 50%;
width: 100%;
border-radius: 4px;
}

.ListItem-checkbox {
accent-color: var(--color-accent);
.DeleteButton {
width: fit-content;
}

.ListItem-label {
margin-left: 0.2em;
@media (max-width: 576px) {
.EditItem {
flex-direction: column;
}
}
47 changes: 32 additions & 15 deletions src/components/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { moreThan24HoursPassed, getDaysBetweenDates } from "../utils";
import { ItemQuantityForm } from "./forms/ItemQuantityForm";
import Button from "react-bootstrap/Button";
import Form from "react-bootstrap/Form";
import { MdOutlineDeleteForever } from "react-icons/md";

interface Props {
item: ListItem;
Expand Down Expand Up @@ -119,23 +120,39 @@ export function ListItemCheckBox({ item, listPath }: Props) {
};

return (
<div className="ListItem">
<Form.Check
type="checkbox"
id={`checkbox-${item.id}`}
aria-label={`Mark ${item.name} as purchased.`}
value={item.id}
checked={isChecked}
onChange={handleCheckChange}
aria-checked={isChecked}
disabled={isChecked}
/>
<ItemQuantityForm saveItemQuantity={editItemQuantity} item={item} /> x{" "}
{item.name}{" "}
<span>
<div className="d-flex flex-column justify-content-center mt-4">
<span className="UrgencyStatus text-nowrap ms-5 px-5">
{getUrgencyStatus(item)}
<Button onClick={() => deleteItemHandler()}>Delete Item</Button>
</span>
<section className="ListItemBox d-flex p-2 m-1">
<section className="d-flex flex-grow-1 PurchaseItem">
<Form.Check
className="me-3"
type="checkbox"
id={`checkbox-${item.id}`}
aria-label={`Mark ${item.name} as purchased.`}
value={item.id}
checked={isChecked}
onChange={handleCheckChange}
aria-checked={isChecked}
disabled={isChecked}
/>
<h4 className="text-nowrap me-1 mb-0"> {item.name} </h4>
</section>

<section className="EditItem d-flex gap-sm-4 align-items-end">
<ItemQuantityForm saveItemQuantity={editItemQuantity} item={item} />

<Button
className="DeleteButton mt-auto w-auto ms-2 "
variant="danger"
onClick={() => deleteItemHandler()}
>
<span className="d-none d-md-inline">Delete</span>
<MdOutlineDeleteForever className=" d-block d-md-none" />
</Button>
</section>
</section>
</div>
);
}
35 changes: 25 additions & 10 deletions src/components/forms/ItemQuantityForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { ListItem } from "../../api";
import { toast } from "react-hot-toast";
import Button from "react-bootstrap/Button";
import Form from "react-bootstrap/Form";
import { FaEdit } from "react-icons/fa";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome use of these icons! These are the icons i was thinking when using the about page with this meger will have to update! Thanks for the reminder!

import { IoMdCheckmark } from "react-icons/io";
import { GiCancel } from "react-icons/gi";

interface ItemQuantityFormProps {
saveItemQuantity: (quantity: number) => void;
Expand Down Expand Up @@ -43,8 +46,9 @@ export function ItemQuantityForm({
};

return (
<>
<div className="d-flex">
<Form.Control
className="me-3 w-auto"
id="item-quantity"
aria-label="Item quantity"
type="number"
Expand All @@ -55,14 +59,25 @@ export function ItemQuantityForm({
onChange={(e) => setItemQuantity(Number(e.target.value))}
disabled={!edit}
/>
{edit ? (
<span>
<Button onClick={updateItemQuantity}>Save!</Button>{" "}
<Button onClick={toggleEdit}>Cancel!</Button>
</span>
) : (
<Button onClick={toggleEdit}>Edit!</Button>
)}
</>
<div>
{edit ? (
<>
<Button onClick={updateItemQuantity}>
<span className="d-none d-md-inline"> Save </span>
<IoMdCheckmark className="d-block d-md-none" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love how you handled the switch between icons and words!

</Button>{" "}
<Button onClick={toggleEdit}>
<span className="d-none d-md-inline">Cancel</span>
<GiCancel className="d-block d-md-none" />
</Button>
</>
) : (
<Button onClick={toggleEdit}>
<span className="d-none d-md-inline">Edit</span>
<FaEdit className="d-block d-md-none" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of span elements to keep everything clean!

</Button>
)}
</div>
</div>
);
}
19 changes: 19 additions & 0 deletions src/views/authenticated/List.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@import "../../styles/variables";

.ListName {
color: $primary-beige;
background-color: $primary-blue;
text-align: center;
border-radius: 4px;
font-size: 2.5em;
max-width: 100%;
}

.Header {
text-align: center;
}

.ListContainer {
max-width: 100%;
width: fit-content;
}
30 changes: 18 additions & 12 deletions src/views/authenticated/List.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import "./List.scss";
import { useParams, useNavigate } from "react-router-dom";
import { useState, useMemo } from "react";
import { ListItemCheckBox } from "../../components/ListItem";
import { FilterListInput } from "../../components/FilterListInput";
import { ListItem, comparePurchaseUrgency } from "../../api";
import { Container } from "react-bootstrap";
import Button from "react-bootstrap/Button";

interface Props {
Expand All @@ -25,8 +27,10 @@ export function List({ data: unfilteredListItems, listPath }: Props) {

const Header = () => {
return (
<p>
Hello from the <code>/list</code> page!
<p className="Header">
For your ease, items are sorted by next purchase date. View and edit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice removal of that p element letting us know what page it is! Great use of "Header" class name here, rather than get caught up in elements!

shopping list items on the go. Mark items as purchased. Shopping has
never been easier.
</p>
);
};
Expand All @@ -38,9 +42,8 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
// Early return if the list is empty
if (unfilteredListItems.length === 0) {
return (
<>
<h2>{listName}</h2>
<Header />
<Container>
<h2 className="ListName">{listName}</h2>
<section>
<h3>
You haven’t added any items yet.
Expand All @@ -54,33 +57,36 @@ export function List({ data: unfilteredListItems, listPath }: Props) {
{"Get started!"}
</Button>
</section>
</>
</Container>
);
}

// Main content when list is not empty
return (
<>
<h2>{listName}</h2>

<Header />
<header>
<h2 className="ListName p-1 m-2 mt-2">{listName}</h2>
<Header />
</header>

<section className="sticky-top bg-dark">
<section className="d-flex sticky-top flex-nowrap align-items-center justify-content-center">
{unfilteredListItems.length > 0 && (
<FilterListInput
searchTerm={searchTerm}
setSearchTerm={setSearchTerm}
/>
)}
<h3>Want to add more items to your list?</h3>

<Button
className="ms-2"
onClick={() => navigate("/manage-list")}
aria-label="Navigate to add more items to your list"
>
{"Add items"}
</Button>
</section>
<section>

<section className="ListItemContainer">
{filteredListItems.map((item) => (
<ListItemCheckBox key={item.id} item={item} listPath={listPath} />
))}
Expand Down