"use client"; import { Popover } from "components/Popover"; import { Checkbox } from "components/Checkbox"; import { Separator } from "components/Layout"; import { CloseTiny } from "components/Icons/CloseTiny"; import { Input } from "components/Input"; import { SearchTiny } from "components/Icons/SearchTiny"; import { SortSmall } from "components/Icons/SortSmall"; import { DashboardState, useDashboardState, useSetDashboardState, } from "./dashboardState"; export const PageSearch = (props: { searchValue: string; setSearchValueAction: (searchValue: string) => void; hasBackgroundImage: boolean; defaultDisplay: Exclude; hasPubs?: boolean; hasArchived?: boolean; }) => { let { display, sort } = useDashboardState(); display = display || props.defaultDisplay; let setState = useSetDashboardState(); return (
{props.hasPubs || props.hasArchived ? ( <> {" "} ) : null}
); }; const SortToggle = (props: { setState: (partial: Partial) => Promise; sort: string | undefined; }) => { return ( ); }; const DisplayToggle = (props: { setState: (partial: Partial) => Promise; display: string | undefined; }) => { return ( ); }; const FilterCheckboxes = (props: { hasPubs: boolean; hasArchived: boolean; }) => { let { filter } = useDashboardState(); let setState = useSetDashboardState(); let filterCount = Object.values(filter).filter(Boolean).length; return ( <> {props.hasPubs && ( <> setState({ filter: { ...filter, drafts: !!e.target.checked } }) } > Drafts setState({ filter: { ...filter, published: !!e.target.checked }, }) } > Published )} {props.hasArchived && ( setState({ filter: { ...filter, archived: !!e.target.checked } }) } > Archived )} setState({ filter: { ...filter, docs: !!e.target.checked } }) } > Docs
); }; const FilterOptions = (props: { hasPubs: boolean; hasArchived: boolean }) => { let { filter } = useDashboardState(); let filterCount = Object.values(filter).filter(Boolean).length; return ( Filter {filterCount > 0 && `(${filterCount})`}} > ); }; const MobileSearchControls = (props: { display: string; sort: string | undefined; setState: (partial: Partial) => Promise; hasPubs?: boolean; hasArchived?: boolean; }) => { let { filter } = useDashboardState(); let filterCount = Object.values(filter).filter(Boolean).length; return ( 0 ? "text-accent-2 bg-accent-1 rounded-md" : "text-secondary"}`} > } >
{(props.hasPubs || props.hasArchived) && ( <>
Filter
)}
); }; const SearchInput = (props: { searchValue: string; setSearchValue: (searchValue: string) => void; hasBackgroundImage: boolean; }) => { return (
{ props.setSearchValue(e.currentTarget.value); }} />
); };