-
Notifications
You must be signed in to change notification settings - Fork 6
Vlad week1 React #6
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
base: main
Are you sure you want to change the base?
Conversation
sarlam
left a comment
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.
Really well crafted! The way you separated the utils as well as the component will make it easier for you to iterate over this codebase and add features.
| <Category | ||
| items={categoryItems} | ||
| activeCategory={selectedCategory} | ||
| onItemClick={setSelectedCategory} | ||
| /> | ||
| <Product items={filteredProducts} /> |
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.
Well done on separating the rendering in different component, it makes your code easier to maintain in the long run and easier to read as well
| const [selectedCategory, setSelectedCategory] = useState("All"); | ||
|
|
||
| const categoryItems = ["All", ...categories]; | ||
|
|
||
| const filteredProducts = filterCategory(allProducts, selectedCategory); |
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.
If you want to go one step further, you could ask yourself how you would change this code to have the categories being toggles, or even, have multiple filters selected at the same time
| .category-items.active { | ||
| background: #000000; | ||
| color: #fff; | ||
| border-color: #000000; | ||
| } |
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.
It would be a plus to change those values to be able to see which category is the selected one
https://reactvlaad.netlify.app/