-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FCT 1187 - enable filter selection in filters (#2971)
* feat(filter selects): use new appearance:filter and optionStyle:checkbox props for select input * feat(filters): [publish_preview] insure that options and option groups are handled by the 'add filters' select input * chore(rebase): update yarn.lock * feat(filters): add aria-labels to fixture inputs for better ability to find them in tests, add aria-label to ul containing filter chips in TriggerButton for a11y/easier test targeting, add more complete tests for Footer, TriggerButton, and FilterMenu * test(filters): add tests * feat(filters): add aria-live=polite to filtersList container and selected filter values containers * feat(filters): add aria-label to add filter select in filters, use radix dialog to find filter inputs instead of looking for combobox in filters.spec.tsx * feat(filter selects): use new appearance:filter and optionStyle:checkbox props for select input * fix(deps): add proptypes back in * feat(filter selects): use new appearance:filter and optionStyle:checkbox props for select input * feat(filters stories): clean up story code a bit * feat(filters stories): rebase and clean up readmes/icons * feat(filters): update visible filters if number of persisted filters changes * feat(filters): remove todo comments from jsdoc blocks in filters * feat(filters): update filter-menu to apply custom styling to select wrappers when parent of custom select menu to allow the select input's options menu to scroll, add max-height to filter-menu dropdowns, update usage example to be more readable and add comments, update story to open filters by default so user doesn't have to click on the filters button to see the list, add filters-with-state fixture for use in VRT, add defaultOpen prop to filters so that the filters list can mount on first render, add VRTs for various open/closed states * feat(filters): add changeset, update readme with more helpful description * FCT-1187 - Filter Selection tests (#2979) * feat(filters): implement filters selection tests, add test helpers * feat(vrt): only defaultOpen a filterMenu if it isnt persisted and there are more locally visible filters than there are visible filters from props --------- Co-authored-by: Byron Wall <[email protected]> * chore(filters): restore spec files * fix(add filter button): add role of button to wrapping div that receives forwarded ref from radix trigger popover * fix(filters divider): divider is 1px * feat(filter selects): use new appearance:filter and optionStyle:checkbox props for select input * fix(add filter button): remove button role, since wrapper is wrapping a button * feat(operators): add new filter.operatorLabel type/prop to handle display of the selected operator value in the trigger menu, add test to ensure operator label displays in trigger button, make radio option text 14px --------- Co-authored-by: Valorie <[email protected]> Co-authored-by: Valorie <[email protected]>
- Loading branch information
1 parent
f723065
commit 4ee54f3
Showing
30 changed files
with
2,540 additions
and
1,232 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@commercetools-uikit/filters': minor | ||
--- | ||
|
||
Adds filters component to UI Kit |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
The `Filters` component displays all active filters. It also allows for adding and removing filters. | ||
The `Filters` component pattern is a component that provides the controls to filter the items in a table or list. | ||
|
||
This description is a stub and shold be expanded as development continues. | ||
- Available filter controls are configured in the `filters` array. Each `filter` object includes a `filterMenuConfiguration` object, in which the inputs that allow the user to select a value for that filter are defined. | ||
|
||
- The selected values for each filter are passed to the component in the `appliedFilters` array. Values in the `appliedFilters` array will be displayed in each filter's menu button. |
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 |
---|---|---|
@@ -1,6 +1,75 @@ | ||
import Filters from '@commercetools-uikit/filters'; | ||
|
||
/**TODO: EXPAND THIS */ | ||
const Example = () => <Filters />; | ||
/** Input for a specific filter, provided by parent application */ | ||
import FirstFilterInput from 'path/to/first/filter/input'; // eslint-disable-line import/no-unresolved | ||
|
||
export default Example; | ||
/** Input for search query, provided by parent application */ | ||
import SearchInput from 'path/to/search/input'; // eslint-disable-line import/no-unresolved | ||
|
||
/** Input for a specific filter, provided by parent application */ | ||
import SecondFilterInput from 'path/to/second/filter/input'; // eslint-disable-line import/no-unresolved | ||
|
||
/** Filter and search state, provided by parent application (does not have to be hook) | ||
see storybook code block for more in depth example of simple state management */ | ||
import useFilterState from 'path/to/your/filter/state'; // eslint-disable-line import/no-unresolved | ||
|
||
const FiltersExample = () => { | ||
const { | ||
// change handler for FirstFilterInput | ||
onFirstFilterInputChange, | ||
// callback to clear FirstFilterInput value | ||
onClearFirstFilterInput, | ||
// value of FirstFilterInput | ||
firstFilterInputValue, | ||
// change handler for SecondFilterInput | ||
onSecondFilterInputChange, | ||
// callback to clear SecondFilterInput value | ||
onClearSecondFilterInput, | ||
// value of SecondFilterInput | ||
secondFilterInputValue, | ||
// callback to clear all filter inputs and selected values | ||
onClearAllFilters, | ||
// selected/applied values of all filters | ||
selectedFilterValues, | ||
} = useFilterState(); | ||
|
||
const filters = [ | ||
{ | ||
key: 'firstFilter', | ||
label: 'First Filter', | ||
filterMenuConfiguration: { | ||
renderMenuBody: () => ( | ||
<FirstFilterInput | ||
onChange={onFirstFilterInputChange} | ||
value={firstFilterInputValue} | ||
/> | ||
), | ||
onClearRequest: onClearFirstFilterInput, | ||
}, | ||
}, | ||
{ | ||
key: 'secondFilter', | ||
label: 'Second Filter', | ||
filterMenuConfiguration: { | ||
renderMenuBody: () => ( | ||
<SecondFilterInput | ||
onChange={onSecondFilterInputChange} | ||
value={secondFilterInputValue} | ||
/> | ||
), | ||
onClearRequest: onClearSecondFilterInput, | ||
}, | ||
}, | ||
]; | ||
|
||
return ( | ||
<Filters | ||
appliedFilters={selectedFilterValues} | ||
filters={filters} | ||
onClearAllRequest={onClearAllFilters} | ||
renderSearchComponent={<SearchInput />} | ||
/> | ||
); | ||
}; | ||
|
||
export default FiltersExample; |
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
Oops, something went wrong.