-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 11 commits
566bd0b
ac390b5
d708574
fa4ebea
6640516
348974e
fff0edf
882d546
34cfb7b
9e37b04
ead409b
f76004b
df827f3
10a5d95
ea845fb
6cfaca2
e1ce2a0
d0a4684
6844c90
52db7a1
b998305
6d8843b
d1a41de
1a8a0e8
f89fc80
cfc6a8e
430e5e2
e56ab5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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} | ||
|
@@ -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> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
); | ||
|
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; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
|
@@ -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" | ||
|
@@ -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" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice use of span elements to keep everything clean! |
||
</Button> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
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; | ||
} |
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 { | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
); | ||
}; | ||
|
@@ -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. | ||
|
@@ -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} /> | ||
))} | ||
|
There was a problem hiding this comment.
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!