forked from nervosnetwork/ckb-explorer-frontend
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(xudt): add filter to filter tags
- Loading branch information
Showing
9 changed files
with
267 additions
and
26 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { Link } from 'react-router-dom' | ||
import { Popover } from 'antd' | ||
import { ReactComponent as FilterIcon } from '../../assets/filter_icon.svg' | ||
import { ReactComponent as SelectedIcon } from '../../assets/selected-icon.svg' | ||
import { ReactComponent as NotSelectedIcon } from '../../assets/not-selected-icon.svg' | ||
import { ReactComponent as PartialSelectedIcon } from '../../assets/partial-selected-icon.svg' | ||
import { useSearchParams } from '../../hooks' | ||
import styles from './styles.module.scss' | ||
|
||
export function MultiFilterButton({ | ||
filteredList, | ||
isMobile, | ||
filterName, | ||
}: { | ||
filterName: string | ||
filteredList: { key: string; value: string; to: string; title: string | JSX.Element }[] | ||
isMobile?: boolean | ||
}) { | ||
const params = useSearchParams('tags') | ||
const types = params.tags?.split(',').filter(t => t !== '') ?? [] | ||
|
||
return ( | ||
<Popover | ||
className={styles.container} | ||
placement="bottomRight" | ||
trigger={isMobile ? 'click' : 'hover'} | ||
overlayClassName={styles.antPopover} | ||
content={ | ||
<div className={styles.filterItems}> | ||
<div className={styles.selectTitle}> | ||
<h2>Select</h2> | ||
{types.length > 0 ? ( | ||
<>{types.length === filteredList.length ? <SelectedIcon /> : <PartialSelectedIcon />}</> | ||
) : ( | ||
<NotSelectedIcon /> | ||
)} | ||
</div> | ||
{filteredList.map(f => ( | ||
<Link | ||
key={f.key} | ||
to={() => { | ||
let subTypes = types.map(t => t) | ||
if (subTypes.includes(f.value)) { | ||
subTypes = subTypes.filter(t => t !== f.value) | ||
} else { | ||
subTypes.push(f.value) | ||
} | ||
return `${f.to}?${filterName}=${subTypes.slice().join(',')}` | ||
}} | ||
data-is-active={types.includes(f.value)} | ||
> | ||
{f.title} | ||
{types.includes(f.value) ? <SelectedIcon /> : <NotSelectedIcon />} | ||
</Link> | ||
))} | ||
</div> | ||
} | ||
> | ||
<FilterIcon className={styles.filter} /> | ||
</Popover> | ||
) | ||
} | ||
|
||
MultiFilterButton.displayName = 'MultiFilterButton' | ||
|
||
export default MultiFilterButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
.container { | ||
appearance: none; | ||
border: none; | ||
outline: none; | ||
background: none; | ||
display: inline-flex; | ||
vertical-align: text-top; | ||
margin-left: 8px; | ||
cursor: pointer; | ||
} | ||
|
||
.antPopover { | ||
:global { | ||
/* stylelint-disable-next-line selector-class-pattern */ | ||
.ant-popover-inner { | ||
border-radius: 8px; | ||
box-shadow: 0 2px 10px 0 #eee; | ||
} | ||
|
||
/* stylelint-disable-next-line selector-class-pattern */ | ||
.ant-popover-inner-content { | ||
padding: 14px 24px 14px 16px; | ||
} | ||
} | ||
} | ||
|
||
.filter { | ||
margin-left: 8px; | ||
color: #999; | ||
} | ||
|
||
.filterItems { | ||
display: flex; | ||
flex-direction: column; | ||
width: 200px; | ||
|
||
.selectTitle { | ||
color: var(--primary-color); | ||
|
||
h2 { | ||
color: #333; | ||
font-size: 14px; | ||
font-style: normal; | ||
font-weight: 500; | ||
line-height: normal; | ||
} | ||
|
||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 10px; | ||
border-radius: 8px; | ||
} | ||
|
||
a { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 10px; | ||
border-radius: 8px; | ||
|
||
svg { | ||
color: var(--primary-color); | ||
} | ||
|
||
&:hover { | ||
background: var(--primary-hover-bg-color); | ||
cursor: pointer; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters