Skip to content

Commit

Permalink
Merge pull request #3713 from grommet/filtering-docs
Browse files Browse the repository at this point in the history
Update Filtering docs
  • Loading branch information
britt6612 authored Feb 13, 2024
2 parents 7536908 + 7144ebf commit 14b049a
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 183 deletions.

This file was deleted.

105 changes: 105 additions & 0 deletions aries-site/src/examples/templates/filtering/QuickFilterToolbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import React, { useContext } from 'react';
import {
Data,
DataTable,
DataContext,
DataClearFilters,
DataFilter,
DataFilters,
DataSearch,
DataSummary,
SelectMultiple,
Heading,
Page,
PageContent,
Toolbar,
Pagination,
} from 'grommet';
import applications from '../../../data/mockData/applications.json';

const properties = {
title: { filter: false },
publisher: { label: 'Publisher' },
delivery: { label: 'Delivery', filter: false, badge: false },
pricing: { label: 'Pricing' },
rating: { label: 'Rating', range: { min: 0, max: 5 } },
};

const columns = [
{
property: 'title',
header: 'Title',
primary: true,
},
{
property: 'publisher',
header: 'Publisher',
size: 'small',
},
{
property: 'delivery',
header: 'Delivery',
},
{
property: 'pricing',
header: 'Pricing',
},
{
property: 'rating',
header: 'Rating',
},
];

export const QuickFilterToolbar = () => (
<Page>
<PageContent>
<Heading level={2} margin="none">
Storage
</Heading>

<Data data={applications} properties={properties}>
<ComposedToolbar />
<DataSummary />
<DataTable aria-describedby="storage-heading" columns={columns} />
<Pagination alignSelf="end" />
</Data>
</PageContent>
</Page>
);

const ComposedToolbar = () => {
const { view } = useContext(DataContext);
return (
<Toolbar gap="medium" align="end">
<Toolbar align="end">
<DataSearch />
<DataFilters updateOn="change" clearFilters={false}>
<DataFilter
property="delivery"
// override HPE theme margin to align with search + filter
contentProps={{ margin: { bottom: 'none', top: 'xsmall' } }}
// override Grommet theme margin to align with search + filter
margin="none"
>
<SelectMultiple
placeholder="Select delivery"
options={['Package manager', 'License key', 'Web application']}
name="delivery"
/>
</DataFilter>
</DataFilters>
<DataFilters layer clearFilters={false}>
{Object.keys(properties).map(k =>
properties[k].filter !== false ? (
<DataFilter key={k} property={k} />
) : undefined,
)}
</DataFilters>
{view?.properties !== undefined &&
Object.keys(view?.properties).length !== 0 ? (
<DataClearFilters />
) : null}
</Toolbar>
</Toolbar>
);
};
2 changes: 1 addition & 1 deletion aries-site/src/examples/templates/filtering/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './FilteringCards/index';
export * from './FilteringLists/index';
export * from './FilteringTable/index';
export * from './FilteringWithRangeSelector';
export * from './QuickFilterToolbar';
export * from './FilteringWithSelect';
export * from './PersistentFiltering';
Loading

0 comments on commit 14b049a

Please sign in to comment.