Commit 15dd02fe authored by lynn's avatar lynn Committed by GitHub

refactor: filter panel (#5103)

* init

* remove unnecessary chagnes

* fix comments
parent 562a386d
...@@ -2,7 +2,8 @@ import { AnimatedBox, Box } from 'nft/components/Box' ...@@ -2,7 +2,8 @@ import { AnimatedBox, Box } from 'nft/components/Box'
import { Column, Row } from 'nft/components/Flex' import { Column, Row } from 'nft/components/Flex'
import { XMarkIcon } from 'nft/components/icons' import { XMarkIcon } from 'nft/components/icons'
import { Checkbox } from 'nft/components/layout/Checkbox' import { Checkbox } from 'nft/components/layout/Checkbox'
import { buttonTextSmall, headlineSmall } from 'nft/css/common.css' import { Input } from 'nft/components/layout/Input'
import { subhead } from 'nft/css/common.css'
import { themeVars } from 'nft/css/sprinkles.css' import { themeVars } from 'nft/css/sprinkles.css'
import { useFiltersExpanded, useIsMobile, useWalletCollections } from 'nft/hooks' import { useFiltersExpanded, useIsMobile, useWalletCollections } from 'nft/hooks'
import { WalletCollection } from 'nft/types' import { WalletCollection } from 'nft/types'
...@@ -16,8 +17,6 @@ export const FilterSidebar = () => { ...@@ -16,8 +17,6 @@ export const FilterSidebar = () => {
const setCollectionFilters = useWalletCollections((state) => state.setCollectionFilters) const setCollectionFilters = useWalletCollections((state) => state.setCollectionFilters)
const walletCollections = useWalletCollections((state) => state.walletCollections) const walletCollections = useWalletCollections((state) => state.walletCollections)
const listFilter = useWalletCollections((state) => state.listFilter)
const setListFilter = useWalletCollections((state) => state.setListFilter)
const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded() const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded()
const isMobile = useIsMobile() const isMobile = useIsMobile()
...@@ -44,9 +43,6 @@ export const FilterSidebar = () => { ...@@ -44,9 +43,6 @@ export const FilterSidebar = () => {
width={{ sm: 'full', md: 'auto' }} width={{ sm: 'full', md: 'auto' }}
> >
<Row width="full" justifyContent="space-between"> <Row width="full" justifyContent="space-between">
<Row as="span" className={headlineSmall} color="textPrimary">
Filters
</Row>
{isMobile && ( {isMobile && (
<Box <Box
as="button" as="button"
...@@ -59,9 +55,6 @@ export const FilterSidebar = () => { ...@@ -59,9 +55,6 @@ export const FilterSidebar = () => {
</Box> </Box>
)} )}
</Row> </Row>
<Row marginTop="14" marginLeft="2" gap="6" flexWrap="wrap" width="276">
<ListStatusFilterButtons listFilter={listFilter} setListFilter={setListFilter} />
</Row>
<CollectionSelect <CollectionSelect
collections={walletCollections} collections={walletCollections}
collectionFilters={collectionFilters} collectionFilters={collectionFilters}
...@@ -97,23 +90,16 @@ const CollectionSelect = ({ ...@@ -97,23 +90,16 @@ const CollectionSelect = ({
return ( return (
<> <>
<Box className={headlineSmall} marginTop="20" marginBottom="12"> <Box className={subhead} marginTop="12" marginBottom="16" width="276">
Collections Collections
</Box> </Box>
<Box paddingBottom="12" paddingTop="0" borderRadius="8"> <Box paddingBottom="12" borderRadius="8">
<Column as="ul" paddingLeft="0" gap="10" style={{ maxHeight: '508px' }}> <Column as="ul" paddingLeft="0" gap="10" style={{ maxHeight: '80vh' }}>
<CollectionFilterSearch <CollectionFilterSearch
collectionSearchText={collectionSearchText} collectionSearchText={collectionSearchText}
setCollectionSearchText={setCollectionSearchText} setCollectionSearchText={setCollectionSearchText}
/> />
<Box <Box paddingBottom="8" overflowY="scroll" style={{ scrollbarWidth: 'none' }}>
background="backgroundSurface"
borderRadius="12"
paddingTop="8"
paddingBottom="8"
overflowY="scroll"
style={{ scrollbarWidth: 'none' }}
>
{displayCollections?.map((collection, index) => ( {displayCollections?.map((collection, index) => (
<CollectionItem <CollectionItem
key={index} key={index}
...@@ -137,19 +123,13 @@ const CollectionFilterSearch = ({ ...@@ -137,19 +123,13 @@ const CollectionFilterSearch = ({
setCollectionSearchText: Dispatch<SetStateAction<string>> setCollectionSearchText: Dispatch<SetStateAction<string>>
}) => { }) => {
return ( return (
<Box <Input
as="input" placeholder="Search"
borderColor={{ default: 'backgroundOutline', focus: 'genieBlue' }} marginTop="8"
borderWidth="1px" marginBottom="8"
borderStyle="solid" autoComplete="off"
borderRadius="8" position="static"
padding="12" width="full"
marginLeft="0"
marginBottom="24"
backgroundColor="backgroundSurface"
fontSize="14"
color={{ placeholder: 'textSecondary', default: 'textPrimary' }}
placeholder="Search collections"
value={collectionSearchText} value={collectionSearchText}
onChange={(e: FormEvent<HTMLInputElement>) => setCollectionSearchText(e.currentTarget.value)} onChange={(e: FormEvent<HTMLInputElement>) => setCollectionSearchText(e.currentTarget.value)}
/> />
...@@ -181,54 +161,46 @@ const CollectionItem = ({ ...@@ -181,54 +161,46 @@ const CollectionItem = ({
} }
return ( return (
<Row <Row
maxWidth="full"
overflowX="hidden"
overflowY="hidden"
fontWeight="normal"
className={styles.subRowHover}
justifyContent="space-between"
cursor="pointer" cursor="pointer"
paddingRight="14" paddingLeft="12"
height="44" paddingRight="16"
borderRadius="12"
style={{
paddingBottom: '22px',
paddingTop: '22px',
}}
maxHeight="44"
as="li" as="li"
background={hovered ? 'backgroundOutline' : undefined}
onMouseEnter={toggleHovered} onMouseEnter={toggleHovered}
onMouseLeave={toggleHovered} onMouseLeave={toggleHovered}
onClick={handleCheckbox} onClick={handleCheckbox}
> >
<Box as="img" borderRadius="round" marginLeft="16" width="20" height="20" src={collection.image} /> <Row>
<Box as="span" marginLeft="6" marginRight="auto" className={styles.collectionName}> <Box as="img" borderRadius="round" width="20" height="20" src={collection.image} />
{collection.name}{' '} <Box
</Box> as="span"
whiteSpace="nowrap"
textOverflow="ellipsis"
overflow="hidden"
paddingLeft="12"
paddingRight="14"
style={{ minHeight: 15, maxWidth: '180px' }}
>
{collection.name}{' '}
</Box>
</Row>
<Checkbox checked={isChecked(collection.address)} hovered={hovered} onChange={handleCheckbox}> <Checkbox checked={isChecked(collection.address)} hovered={hovered} onChange={handleCheckbox}>
<Box as="span" color="textSecondary" marginRight="12" marginLeft="auto"> <Box as="span" color="textTertiary" marginRight="12" marginLeft="auto">
{collection.count} {collection.count}
</Box> </Box>
</Checkbox> </Checkbox>
</Row> </Row>
) )
} }
const statusArray = ['All', 'Unlisted', 'Listed']
const ListStatusFilterButtons = ({
listFilter,
setListFilter,
}: {
listFilter: string
setListFilter: (value: string) => void
}) => {
return (
<>
{statusArray.map((value, index) => (
<Row
key={index}
borderRadius="12"
backgroundColor="backgroundOutline"
height="44"
className={value === listFilter ? styles.buttonSelected : null}
onClick={() => setListFilter(value)}
width="max"
padding="14"
cursor="pointer"
>
<Box className={buttonTextSmall}>{value}</Box>
</Row>
))}
</>
)
}
import { style } from '@vanilla-extract/css' import { style } from '@vanilla-extract/css'
import { subheadSmall } from 'nft/css/common.css'
import { sprinkles, vars } from '../../../css/sprinkles.css' import { sprinkles, themeVars, vars } from '../../../css/sprinkles.css'
export const section = style([ export const section = style([
sprinkles({ sprinkles({
...@@ -20,16 +21,12 @@ export const ethIcon = style({ ...@@ -20,16 +21,12 @@ export const ethIcon = style({
marginBottom: '-3px', marginBottom: '-3px',
}) })
export const collectionName = style([ export const subRowHover = style([
sprinkles({ subheadSmall,
fontWeight: 'normal',
overflow: 'hidden',
paddingRight: '14',
}),
{ {
textOverflow: 'ellipsis', ':hover': {
whiteSpace: 'nowrap', background: themeVars.colors.backgroundInteractive,
maxWidth: '180px', },
}, },
]) ])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment