Skip to content

Commit

Permalink
add match counter
Browse files Browse the repository at this point in the history
  • Loading branch information
timogasda committed Aug 10, 2023
1 parent 3d78d7f commit 545cf46
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pages/app-layout/with-table-collection-select-filter.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export default function () {
const [usePropertyFilter, setUsePropertyFilter] = useState(true);
const [customControl, setCustomControl] = useState(true);
const [customAction, setCustomAction] = useState(true);
const [matches, setMatches] = useState(false);
const [textfilter, setTextfilter] = useState('');
const [query, setQuery] = useState<PropertyFilterProps.Query>({ operation: 'and', tokens: [] });

const { items, actions, paginationProps, propertyFilterProps } = useCollection(allItems, {
Expand Down Expand Up @@ -99,6 +101,9 @@ export default function () {
<Checkbox checked={customAction} onChange={e => setCustomAction(e.detail.checked)}>
Custom action
</Checkbox>
<Checkbox checked={matches} onChange={e => setMatches(e.detail.checked)}>
Show match count
</Checkbox>
</SpaceBetween>
}
>
Expand Down Expand Up @@ -127,13 +132,14 @@ export default function () {
filteringProperties={filteringProperties}
customControl={customControl && <Button>Filter action</Button>}
additionalActions={customAction && <Button>Filter action</Button>}
countText={matches ? '11 matches' : undefined}
/>
) : (
<Input
data-testid="input-filter"
type="search"
value={''}
onChange={() => {}}
value={textfilter}
onChange={e => setTextfilter(e.detail.value)}
placeholder="Find instances"
clearAriaLabel="clear"
/>
Expand Down Expand Up @@ -163,6 +169,7 @@ export default function () {
/>
</FormField>
</div>
{matches && !usePropertyFilter && <span style={{ lineHeight: '3rem' }}>11 matches</span>}
</div>
}
columnDefinitions={columnDefinitions.slice(0, 7)}
Expand Down

0 comments on commit 545cf46

Please sign in to comment.