diff --git a/packages/web/components/templates/library/LibrarySearchBar.tsx b/packages/web/components/templates/library/LibrarySearchBar.tsx index a723de3de..6afc07875 100644 --- a/packages/web/components/templates/library/LibrarySearchBar.tsx +++ b/packages/web/components/templates/library/LibrarySearchBar.tsx @@ -1,13 +1,38 @@ -import { HStack, SpanBox, VStack } from './../../elements/LayoutPrimitives' import { useState } from 'react' +import { Sliders, X } from 'phosphor-react' +import Downshift from 'downshift' + +import { HStack, VStack } from './../../elements/LayoutPrimitives' import { FormInput } from '../../elements/FormElements' import { Button } from '../../elements/Button' -import { Sliders, SlidersHorizontal, X } from 'phosphor-react' -import { theme } from '../../tokens/stitches.config' +import { styled, theme } from '../../tokens/stitches.config' import { SearchCoordinator } from './LibraryContainer' +// Styles + +const List = styled('ul', { + width: '65%', + alignSelf: 'center', + color: '#0A0806CC', + fontSize: 24, + fontWeight: '700', + '@smDown': { + fontSize: 16, + }, +}) + +const Item = styled('li', { + listStyleType: 'none', +}) + export type LibrarySearchBarProps = { coordinator: SearchCoordinator + options?: OptionType[] + onChange?: (selectedItem: string) => void // this is for later +} + +type OptionType = { + value?: string } // export type searchHistoryProps = { @@ -15,98 +40,154 @@ export type LibrarySearchBarProps = { // index: number // } - export function LibrarySearchBar(props: LibrarySearchBarProps): JSX.Element { - const [searchTerm, setSearchTerm] = useState('') - //const [recentSearches, setRecentSearches] = useState(Array()) + const [searchTerm, setSearchTerm] = useState('') + const [recentSearches, setRecentSearches] = useState(['apple', 'pear', 'orange', 'grape', 'banana']) return ( <> - - -
{ - event.preventDefault() - // props.applySearchQuery(searchTerm || '') - // inputRef.current?.blur() - }} - > - { - setSearchTerm(event.target.value) - }} - /> - - {!searchTerm && ( - - )} - {searchTerm && ( - + + + + {({ + getInputProps, + getRootProps, + getMenuProps, + getItemProps, + getToggleButtonProps, + isOpen, + highlightedIndex, + }) => ( +
+
{ + event.preventDefault() + // props.applySearchQuery(searchTerm || '') + // inputRef.current?.blur() + }} + {...getRootProps()} + > + { + setSearchTerm(event.target.value) + }} + {...getInputProps()} + /> + + + {isOpen && + props.options?.map((item, index) => ( + + {item.value} + + ))} + + +
+ )} +
+ + {!searchTerm && ( - - -
- )} -
+ + + +
+ )} +
) -} \ No newline at end of file +}