diff --git a/web/components/contract-search.tsx b/web/components/contract-search.tsx index 3d25dcdd..38fcb3d0 100644 --- a/web/components/contract-search.tsx +++ b/web/components/contract-search.tsx @@ -9,7 +9,14 @@ import { } from './contract/contracts-grid' import { ShowTime } from './contract/contract-details' import { Row } from './layout/row' -import { useEffect, useLayoutEffect, useRef, useMemo, ReactNode } from 'react' +import { + useEffect, + useLayoutEffect, + useRef, + useMemo, + ReactNode, + useState, +} from 'react' import { IS_PRIVATE_MANIFOLD } from 'common/envs/constants' import { useFollows } from 'web/hooks/use-follows' import { @@ -32,6 +39,11 @@ import { searchClient, searchIndexName, } from 'web/lib/service/algolia' +import { useIsMobile } from 'web/hooks/use-is-mobile' +import { AdjustmentsIcon, FilterIcon } from '@heroicons/react/solid' +import { Button } from './button' +import { Modal } from './layout/modal' +import { Title } from './title' export const SORTS = [ { label: 'Newest', value: 'newest' }, @@ -270,6 +282,8 @@ function ContractSearchControls(props: { } ) + const isMobile = useIsMobile() + const sortKey = `${persistPrefix}-search-sort` const savedSort = safeLocalStorage()?.getItem(sortKey) @@ -415,30 +429,30 @@ function ContractSearchControls(props: { className="input input-bordered w-full" autoFocus={autoFocus} /> - {!query && ( - + {!isMobile && ( + )} - {!hideOrderSelector && !query && ( - + {isMobile && ( + <> + + } + /> + )} @@ -481,3 +495,71 @@ function ContractSearchControls(props: { ) } + +export function SearchFilters(props: { + filter: string + selectFilter: (newFilter: filter) => void + hideOrderSelector: boolean | undefined + selectSort: (newSort: Sort) => void + sort: string + className?: string +}) { + const { + filter, + selectFilter, + hideOrderSelector, + selectSort, + sort, + className, + } = props + return ( +
+ + {!hideOrderSelector && ( + + )} +
+ ) +} + +export function MobileSearchBar(props: { children: ReactNode }) { + const { children } = props + const [openFilters, setOpenFilters] = useState(false) + return ( + <> + + + + + {children} + </Col> + </Modal> + </> + ) +}