Skip to content

Commit

Permalink
feat: add more list to autocomplete navbar alphabetically
Browse files Browse the repository at this point in the history
  • Loading branch information
kyziq committed Jan 7, 2024
1 parent 8efa708 commit 39d8a8f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/components/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ import {
} from '@nextui-org/react';
import { Link } from 'react-router-dom';
import { FaSearch } from 'react-icons/fa';
import { abstractsList } from '../data/list';
import { matchSorter } from 'match-sorter';
import { allLists } from '../data/list';

const sortedAbstractsList = matchSorter(abstractsList, '', { keys: ['name'] });
const SearchAutocomplete = () => (
const SearchAutocomplete = ({ allLists }) => (
<Autocomplete
defaultItems={sortedAbstractsList}
defaultItems={allLists}
aria-label="Search for Artworks"
classNames={{
base: 'max-w-lg',
listboxWrapper: 'max-h-[320px]',
Expand Down Expand Up @@ -111,14 +110,16 @@ const UserProfileDropdown = () => (
);

const NavbarComponent = () => {
const allItems = Object.values(allLists).flat();
const sortedAllList = allItems.sort((a, b) => a.name.localeCompare(b.name));
return (
<Navbar maxWidth={'full'} isBordered shouldHideOnScroll>
<Link to="/artistry-hub/" reloadDocument>
<Image src="./logo.png" alt="Logo" width={40} height={40} isZoomed />
</Link>
<NavbarContent justify="start">
<NavbarBrand>
<SearchAutocomplete />
<SearchAutocomplete allLists={sortedAllList} />
</NavbarBrand>
</NavbarContent>
<NavbarContent as="div" className="items-center" justify="end">
Expand Down

0 comments on commit 39d8a8f

Please sign in to comment.