Skip to content

Commit b0b85b3

Browse files
authored
Merge pull request #67 from the-collab-lab/ma/designing-responsive-listview
Issue # 56. Designing responsive list component for the list page
2 parents 101c350 + e56ab5c commit b0b85b3

File tree

17 files changed

+311
-130
lines changed

17 files changed

+311
-130
lines changed

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"react-bootstrap": "^2.10.5",
1717
"react-dom": "^18.3.1",
1818
"react-hot-toast": "^2.4.1",
19+
"react-icons": "^5.3.0",
1920
"react-router-dom": "^6.26.2"
2021
},
2122
"devDependencies": {

src/components/FilterListInput.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ export function FilterListInput({
2525
};
2626

2727
return (
28-
<Form onSubmit={handleSubmit}>
29-
<InputGroup>
30-
<Form.Label htmlFor="filterList">Filter List:</Form.Label>
28+
<Form className="w-100 w-lg-auto" onSubmit={handleSubmit}>
29+
<InputGroup className="d-flex align-items-center mt-1">
30+
<Form.Label htmlFor="filterList" className="me-2 mb-0">
31+
<span className="fw-bold">Filter List:</span>
32+
</Form.Label>
3133
<Form.Control
3234
type="text"
3335
onChange={handleChange}
@@ -37,8 +39,9 @@ export function FilterListInput({
3739
placeholder="Search items..."
3840
/>
3941
<Button className="custom-button" onClick={handleClear}>
40-
x
42+
Clear
4143
</Button>
44+
4245
</InputGroup>
4346
</Form>
4447
);

src/components/ListItem.scss

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,66 @@
1-
.ListItem {
1+
@import "../styles/_variables";
2+
3+
.ListItemBox {
24
align-items: baseline;
3-
display: flex;
4-
flex-direction: row;
5-
font-size: 1.2em;
5+
font-size: 1.5em;
66
justify-content: space-between;
7+
background-color: $primary-blue;
8+
color: $primary-beige;
9+
border-radius: 4px;
10+
max-width: 100%;
11+
box-sizing: border-box;
12+
}
13+
14+
.UrgencyStatus {
15+
display: block;
16+
background-color: $secondary-blue;
17+
color: $primary-beige;
18+
font-size: 1.25em;
19+
max-width: 50%;
20+
width: 80%;
21+
border-radius: 4px;
22+
23+
// Default styles for urgency status
24+
font-weight: bold;
25+
26+
&.inactive {
27+
color: gray;
28+
}
29+
30+
&.overdue {
31+
color: red;
32+
}
33+
34+
&.soon {
35+
color: orange;
36+
}
37+
38+
&.kind-of-soon {
39+
color: yellow;
40+
}
41+
42+
&.not-soon {
43+
color: green;
44+
}
45+
}
46+
47+
.DeleteButton {
48+
width: fit-content;
749
}
850

9-
.ListItem-checkbox {
10-
accent-color: var(--color-accent);
51+
.custom-borders {
52+
border: 2px solid $secondary-blue !important;
53+
border-radius: 4px !important;
54+
padding: 20px;
55+
margin-top: 20px;
56+
position: relative;
1157
}
1258

13-
.ListItem-label {
14-
margin-left: 0.2em;
59+
@media (max-width: 576px) {
60+
.EditItem {
61+
flex-direction: column;
62+
}
63+
.PurchaseItem {
64+
font-size: 0.75em;
65+
}
1566
}

src/components/ListItem.tsx

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { moreThan24HoursPassed, getDaysBetweenDates } from "../utils";
66
import { ItemQuantityForm } from "./forms/ItemQuantityForm";
77
import Button from "react-bootstrap/Button";
88
import Form from "react-bootstrap/Form";
9+
import { MdOutlineDeleteForever } from "react-icons/md";
910

1011
interface Props {
1112
item: ListItem;
@@ -63,6 +64,8 @@ export function ListItemCheckBox({ item, listPath }: Props) {
6364
return "kind of soon";
6465
};
6566

67+
const urgencyStatus = getUrgencyStatus(item);
68+
6669
const handleCheckChange = async (e: React.ChangeEvent<HTMLInputElement>) => {
6770
const newCheckedState = e.target.checked;
6871

@@ -119,25 +122,41 @@ export function ListItemCheckBox({ item, listPath }: Props) {
119122
};
120123

121124
return (
122-
<div className="ListItem">
123-
<Form.Check
124-
type="checkbox"
125-
id={`checkbox-${item.id}`}
126-
aria-label={`Mark ${item.name} as purchased.`}
127-
value={item.id}
128-
checked={isChecked}
129-
onChange={handleCheckChange}
130-
aria-checked={isChecked}
131-
disabled={isChecked}
132-
/>
133-
<ItemQuantityForm saveItemQuantity={editItemQuantity} item={item} /> x{" "}
134-
{item.name}{" "}
135-
<span>
136-
{getUrgencyStatus(item)}
137-
<Button className="custom-button" onClick={() => deleteItemHandler()}>
138-
Delete Item
139-
</Button>
125+
<div className="d-flex flex-column justify-content-center mt-5">
126+
<span
127+
className={`UrgencyStatus text-center text-nowrap ms-5 w-auto p-1 ${urgencyStatus.replace(/\s/g, "-")}`}
128+
>
129+
{urgencyStatus}
140130
</span>
131+
<section className="ListItemBox custom-borders d-flex p-2 m-1 align-items-center">
132+
<section className="PurchaseItem d-flex flex-grow-1">
133+
<Form.Check
134+
className="me-3"
135+
type="checkbox"
136+
id={`checkbox-${item.id}`}
137+
aria-label={`Mark ${item.name} as purchased.`}
138+
value={item.id}
139+
checked={isChecked}
140+
onChange={handleCheckChange}
141+
aria-checked={isChecked}
142+
disabled={isChecked}
143+
/>
144+
<Form.Label>{item.name}</Form.Label>
145+
</section>
146+
147+
<section className="EditItem d-flex gap-2 align-items-end">
148+
<ItemQuantityForm saveItemQuantity={editItemQuantity} item={item} />
149+
150+
<Button
151+
className="DeleteButton w-auto"
152+
variant="danger"
153+
onClick={() => deleteItemHandler()}
154+
>
155+
<span className="d-none d-md-inline">Delete</span>
156+
<MdOutlineDeleteForever className=" d-block d-md-none" />
157+
</Button>
158+
</section>
159+
</section>
141160
</div>
142161
);
143162
}

src/components/NavBar.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
color: $secondary-blue;
3030
}
3131
}
32+
}
3233

33-
.navbar .navbar-toggler {
34-
background-color: $primary-beige;
35-
}
34+
.navbar .navbar-toggler {
35+
background-color: $primary-beige;
3636
}
3737

3838
.navbar button {

src/components/authenticated/AuthenticatedNavBar.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,7 @@ export function AuthenticatedNavBar() {
2424
<Nav.Link as={NavLink} to="/" aria-label="Home" eventKey={"1"}>
2525
Home
2626
</Nav.Link>
27-
<Nav.Link
28-
as={NavLink}
29-
to="/manage-list"
30-
aria-label="Manage List"
31-
eventKey={"2"}
32-
>
33-
Manage List
34-
</Nav.Link>
27+
3528
<Nav.Link
3629
as={NavLink}
3730
to="/about"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@import "../../styles/variables";
2+
3+
.custom-borders {
4+
border: 2px solid $secondary-blue !important;
5+
border-radius: 4px !important;
6+
padding: 20px;
7+
margin-top: 20px;
8+
position: relative;
9+
}
10+
11+
.legend-text {
12+
font-weight: bold;
13+
padding: 0 10px; /* Creates space between the border and text */
14+
color: #001f3f; /* Optional: text color */
15+
position: relative;
16+
top: -40px;
17+
left: 60px;
18+
background-color: rgb(241, 230, 204);
19+
width: 60%;
20+
}

0 commit comments

Comments
 (0)