diff --git a/app/src/WardrobePage.js b/app/src/WardrobePage.js
index 1319d37..767dcdd 100644
--- a/app/src/WardrobePage.js
+++ b/app/src/WardrobePage.js
@@ -1,39 +1,78 @@
import React from "react";
import {
Box,
- Flex,
- Grid,
- Heading,
- IconButton,
- Image,
- Stack,
- PseudoBox,
Editable,
EditablePreview,
EditableInput,
+ Flex,
+ Grid,
+ Heading,
+ Icon,
+ IconButton,
+ Image,
+ Input,
+ InputGroup,
+ InputLeftElement,
+ InputRightElement,
+ PseudoBox,
+ Stack,
+ Text,
} from "@chakra-ui/core";
import useOutfitState from "./useOutfitState.js";
+import { ITEMS } from "./data";
function WardrobePage() {
+ const [data, wearItem] = useOutfitState();
+ const [searchQuery, setSearchQuery] = React.useState("");
+
return (
-
+
-
+
+
+
+
+
+
-
+ {searchQuery ? (
+
+ ) : (
+
+ )}
@@ -58,9 +97,70 @@ function OutfitPreview() {
);
}
-function ItemsPanel() {
- const [zonesAndItems, wearItem] = useOutfitState();
+function SearchToolbar({ query, onChange }) {
+ return (
+
+
+
+
+ onChange(e.target.value)}
+ />
+ {query && (
+
+ onChange("")}
+ />
+
+ )}
+
+ );
+}
+function SearchPanel({ query, wornItemIds, onWearItem }) {
+ const normalize = (s) => s.toLowerCase();
+ const results = ITEMS.filter((item) =>
+ normalize(item.name).includes(normalize(query))
+ );
+ results.sort((a, b) => a.name.localeCompare(b.name));
+
+ const resultsSection =
+ results.length > 0 ? (
+
+ ) : (
+
+ We couldn't find any matching items{" "}
+
+ 🤔
+ {" "}
+ Try again?
+
+ );
+
+ return (
+
+
+ Searching for "{query}"
+
+ {resultsSection}
+
+ );
+}
+
+function ItemsPanel({ zonesAndItems, onWearItem }) {
return (
@@ -71,7 +171,7 @@ function ItemsPanel() {
zoneName={zoneName}
items={items}
wornItemId={wornItemId}
- onWearItem={wearItem}
+ onWearItem={onWearItem}
/>
))}
@@ -126,21 +226,31 @@ function ItemsForZone({ zoneName, items, wornItemId, onWearItem }) {
{zoneName}
-
- {items.map((item) => (
-
- - onWearItem(item.id)}
- />
-
- ))}
-
+
);
}
+function ItemList({ items, wornItemIds, onWearItem }) {
+ return (
+
+ {items.map((item) => (
+
+ - onWearItem(item.id)}
+ />
+
+ ))}
+
+ );
+}
+
function Item({ item, isWorn, onWear }) {
return (