Filter by Search and Chips
Write the code, see it run, pass the checks.
The problem
- medium
- Code
The Recipes component gets a recipes prop: a list of { name, tag } objects (the preview uses Pancakes and Porridge tagged Breakfast, Tomato Soup and Pea Soup tagged Lunch, and Lentil Curry and Fish Pie tagged Dinner). Add a text input labelled "Search" and one toggle button per tag, named with the tag ("Breakfast", "Lunch", "Dinner"), using aria-pressed to show whether it's on; all start off. A recipe shows when its name contains the search text (ignoring upper and lower case) and, if any tags are on, its tag is one of them; with none on, every tag counts. Show the matching names as list items in their original order, then a line like "Showing 2 of 6", and "No recipes match" when none do. A "Clear filters" button empties the search and turns every tag off.
Your code must pass
- Shows every recipe with every tag off at first
- Tags filter the list, and several can be on
- Search and tags combine
- Clear filters resets the search and the tags