-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: seleceted facets functionality
- Loading branch information
Showing
3 changed files
with
93 additions
and
17 deletions.
There are no files selected for viewing
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
33 changes: 33 additions & 0 deletions
33
src/sections/collection/collection-items-panel/selected-facets/SelectedFacets.module.scss
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,33 @@ | ||
@use 'sass:color'; | ||
@import 'node_modules/@iqss/dataverse-design-system/src/lib/assets/styles/design-tokens/colors.module'; | ||
|
||
.selected-facets-container { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: 0.5rem; | ||
margin-bottom: 0.5rem; | ||
|
||
.selected-facet-btn { | ||
display: flex; | ||
align-items: center; | ||
padding-right: 2px; | ||
padding-block: 2px; | ||
color: $dv-primary-color; | ||
font-weight: 600; | ||
font-size: 80%; | ||
line-height: 1; | ||
background-color: color.adjust($dv-primary-color, $lightness: 50%); | ||
|
||
&:hover { | ||
background-color: color.adjust($dv-primary-color, $lightness: 40%); | ||
} | ||
|
||
&:active { | ||
color: $dv-primary-color; | ||
} | ||
|
||
svg { | ||
min-width: fit-content; | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/sections/collection/collection-items-panel/selected-facets/SelectedFacets.tsx
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,30 @@ | ||
import { Button } from '@iqss/dataverse-design-system' | ||
import { X as CloseIcon } from 'react-bootstrap-icons' | ||
import { FilterQuery } from '@/collection/domain/models/GetCollectionItemsQueryParams' | ||
import styles from './SelectedFacets.module.scss' | ||
|
||
interface SelectedFacetsProps { | ||
selectedFilterQueries: FilterQuery[] | ||
onRemoveFacet: (filterQuery: FilterQuery) => void | ||
} | ||
|
||
export const SelectedFacets = ({ selectedFilterQueries, onRemoveFacet }: SelectedFacetsProps) => { | ||
return ( | ||
<div className={styles['selected-facets-container']}> | ||
{selectedFilterQueries.map((filterQuery) => { | ||
const [_facetName, labelName] = filterQuery.split(':') | ||
|
||
return ( | ||
<Button | ||
size="sm" | ||
className={styles['selected-facet-btn']} | ||
onClick={() => onRemoveFacet(filterQuery)} | ||
aria-label={`Remove ${labelName} query filter`} | ||
key={filterQuery}> | ||
{labelName} <CloseIcon size={22} /> | ||
</Button> | ||
) | ||
})} | ||
</div> | ||
) | ||
} |