-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@leav/ui): explorer numeric, text and rich text filter (#662)
Co-authored-by: emile <[email protected]>
- Loading branch information
Showing
16 changed files
with
683 additions
and
206 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
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
70 changes: 70 additions & 0 deletions
70
libs/ui/src/components/Explorer/display-view-filters/ExplorerFilterBar.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,70 @@ | ||
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06 | ||
// This file is released under LGPL V3 | ||
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt | ||
import styled from 'styled-components'; | ||
import {useViewSettingsContext} from '../manage-view-settings/store-view-settings/useViewSettingsContext'; | ||
import {KitButton, KitDivider, KitFilter, KitSpace} from 'aristid-ds'; | ||
import {FunctionComponent} from 'react'; | ||
import {FilterDropDown} from '../manage-view-settings/filter-items/filter-type/FilterDropDown'; | ||
import {FaTrash} from 'react-icons/fa'; | ||
import {useSharedTranslation} from '_ui/hooks/useSharedTranslation'; | ||
|
||
const FilterStyled = styled(KitFilter)` | ||
flex: 0 0 auto; | ||
`; | ||
|
||
const ExplorerFilterBarStyledDiv = styled.div` | ||
overflow: auto; | ||
padding: 0 calc(var(--general-spacing-xxs) * 1px); | ||
padding-bottom: calc(var(--general-spacing-m) * 1px); | ||
`; | ||
|
||
const ExplorerBarItemsListDiv = styled.div` | ||
display: flex; | ||
flex-wrap: nowrap; | ||
align-items: center; | ||
gap: 0; | ||
white-space: nowrap; | ||
padding-top: calc(var(--general-spacing-xs) * 1px); | ||
`; | ||
|
||
const DividerStyled = styled(KitDivider)` | ||
height: 2em; | ||
`; | ||
|
||
export const ExplorerFilterBar: FunctionComponent = () => { | ||
const {t} = useSharedTranslation(); | ||
|
||
const { | ||
view: {filters} | ||
} = useViewSettingsContext(); | ||
|
||
if (filters.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<ExplorerFilterBarStyledDiv> | ||
<ExplorerBarItemsListDiv> | ||
<KitSpace size="s"> | ||
{filters.map(filter => ( | ||
<FilterStyled | ||
key={filter.id} | ||
expandable | ||
label={filter.attribute.label} | ||
values={filter.value === null ? [] : [filter.value]} | ||
dropDownProps={{ | ||
placement: 'bottomLeft', | ||
dropdownRender: () => <FilterDropDown filter={filter} /> | ||
}} | ||
/> | ||
))} | ||
</KitSpace> | ||
<DividerStyled type="vertical" /> | ||
<FilterStyled as={KitButton} type="secondary" size="s" danger icon={<FaTrash />} disabled> | ||
{t('explorer.delete-filters')} | ||
</FilterStyled> | ||
</ExplorerBarItemsListDiv> | ||
</ExplorerFilterBarStyledDiv> | ||
); | ||
}; |
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
21 changes: 21 additions & 0 deletions
21
.../src/components/Explorer/manage-view-settings/filter-items/filter-type/FilterDropDown.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,21 @@ | ||
// Copyright LEAV Solutions 2017 until 2023/11/05, Copyright Aristid from 2023/11/06 | ||
// This file is released under LGPL V3 | ||
// License text available at https://www.gnu.org/licenses/lgpl-3.0.txt | ||
import {IFilterDropDownProps} from '_ui/components/Explorer/_types'; | ||
import {AttributeFormat} from '_ui/_gqlTypes'; | ||
import {FunctionComponent} from 'react'; | ||
import {SimpleFilterDropdown} from './SimpleFilterDropDown'; | ||
import {TextAttributeDropDown} from './TextAttributeDropDown'; | ||
import {NumericAttributeDropDown} from './NumericAttributeDropDown'; | ||
|
||
export const FilterDropDown: FunctionComponent<IFilterDropDownProps> = ({filter}) => { | ||
switch (filter.attribute.format) { | ||
case AttributeFormat.numeric: | ||
return <NumericAttributeDropDown filter={filter} />; | ||
case AttributeFormat.text: | ||
case AttributeFormat.rich_text: | ||
return <TextAttributeDropDown filter={filter} />; | ||
default: | ||
return <SimpleFilterDropdown filter={filter} />; | ||
} | ||
}; |
Oops, something went wrong.