import React from "react"; import { Box, Editable, EditablePreview, EditableInput, Flex, Grid, Heading, Icon, IconButton, Image, Input, InputGroup, InputLeftElement, InputRightElement, PseudoBox, Stack, Text, useToast, } from "@chakra-ui/core"; import ItemList from "./ItemList"; import useOutfitState from "./useOutfitState.js"; import { ITEMS } from "./data"; function WardrobePage() { const [data, wearItemRaw] = useOutfitState(); const [searchQuery, setSearchQuery] = React.useState(""); const toast = useToast(); const [hasSentToast, setHasSentToast] = React.useState(false); const wearItem = React.useCallback( (itemIdToAdd) => { wearItemRaw(itemIdToAdd); if (!hasSentToast) { setTimeout(() => { toast({ title: "So, the outfit didn't change 😅", description: "This is a prototype, and the outfit preview is static right " + "now! But the list animation is good, yeah? Nice and smooth 😊", status: "warning", isClosable: true, duration: 10000, position: window.innerWidth < 992 ? "top" : "bottom-left", }); }, 3000); setHasSentToast(true); } }, [toast, wearItemRaw, hasSentToast, setHasSentToast] ); return ( {searchQuery ? ( ) : ( )} ); } function OutfitPreview() { return ( ); } 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 ( {zonesAndItems.map(({ zoneName, items, wornItemId }) => ( {zoneName} ))} ); } function OutfitHeading() { return ( {({ isEditing, onRequestEdit }) => ( <> {!isEditing && ( )} )} ); } function OutfitNameEditButton({ onRequestEdit }) { return ( ); } function Heading1({ children, ...props }) { return ( {children} ); } function Heading2({ children, ...props }) { return ( {children} ); } export default WardrobePage;