Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add filter layer side drawer guidance #3637

Merged
merged 12 commits into from
Feb 14, 2024
32 changes: 20 additions & 12 deletions aries-site/src/examples/components/button/ToolbarButtonExample.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
import React from 'react';
import { Menu } from 'grommet';
import {
FilterControls,
FiltersProvider,
} from '../../templates/FilterControls';
Box,
Data,
Toolbar,
DataSearch,
DataFilters,
Menu,
DataSummary,
} from 'grommet';
import applications from '../../../data/mockData/applications.json';

export const ToolbarButtonExample = () => (
<FiltersProvider>
<FilterControls
actions={<Menu label="Actions" kind="toolbar" />}
data={[]}
filters={[]}
searchFilter={{ placeholder: 'Search' }}
/>
</FiltersProvider>
<Box>
<Data data={applications}>
<Toolbar>
<DataSearch />
<DataFilters layer />
<Box flex />
<Menu label="Actions" kind="toolbar" />
</Toolbar>
<DataSummary />
</Data>
</Box>
);
93 changes: 37 additions & 56 deletions aries-site/src/examples/components/layer/ConfigurationForm.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/* eslint-disable react/prop-types */
import React, { useContext, useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import {
Box,
Button,
Data,
DataTable,
Form,
FormField,
Expand All @@ -13,13 +13,12 @@ import {
TextInput,
CheckBoxGroup,
AnnounceContext,
Toolbar,
DataSearch,
DataFilters,
DataSummary,
} from 'grommet';
import { LayerHeader } from 'aries-core';
import {
useFilters,
FiltersProvider,
FilterControls,
} from '../../templates/FilterControls';
import applications from '../../../data/mockData/applications.json';
import {
ConfirmationContext,
Expand Down Expand Up @@ -155,72 +154,54 @@ export const LayerForm = ({ ...rest }) => {
);
};

const columns = [
{
property: 'title',
header: 'Title',
},
{
property: 'publisher',
header: 'Publisher',
},
{
property: 'pricing',
header: 'Pricing',
},
];

const ApplicationsPage = () => {
const { setShowLayer } = useConfirmation();
return (
<FiltersProvider>
<Page>
<PageContent>
<Box gap="medium">
<Heading id="applications-heading" level={2} margin="none">
Applications
</Heading>
<FilterControls
data={applications}
filters={[]}
primaryKey="title"
searchFilter={{ placeholder: 'Search' }}
actions={
<Data data={applications}>
<Toolbar>
<DataSearch />
<DataFilters layer />
<Box flex />
<Button
label="Add application"
secondary
onClick={() => setShowLayer(true)}
/>
}
/>
<ApplicationResults />
</Toolbar>
<DataSummary />
<Box height={{ max: 'medium' }} alignSelf="start" overflow="auto">
<DataTable
aria-describedby="applications-heading"
columns={columns}
pin
primaryKey="title"
sortable
/>
</Box>
</Data>
</Box>
</PageContent>
</Page>
</FiltersProvider>
);
};

const columns = [
{
property: 'title',
header: 'Title',
},
{
property: 'publisher',
header: 'Publisher',
},
{
property: 'pricing',
header: 'Pricing',
},
];

const ApplicationResults = ({ height = { max: 'medium' } }) => {
// const breakpoint = useContext(ResponsiveContext);
const { filteredResults, selected, setSelected } = useFilters();

return (
<Box alignSelf="start" height={height} overflow="auto">
<DataTable
aria-describedby="applications-heading"
data={filteredResults}
columns={columns}
pin
primaryKey="title"
sortable
onSelect={nextSelected => setSelected(nextSelected)}
select={selected}
/>
</Box>
);
};

ApplicationResults.propTypes = {
height: PropTypes.string,
};
19 changes: 19 additions & 0 deletions aries-site/src/examples/components/layer/DataFiltersAnatomy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { Data, DataFilters } from 'grommet';
import applications from '../../../data/mockData/applications.json';

export const DataFiltersAnatomy = () => {
return (
<Data
data={applications}
properties={{
publisher: { label: 'Publisher ' },
pricing: { label: 'Pricing' },
delivery: { label: 'Delivery' },
rating: { label: 'Rating' },
}}
>
<DataFilters layer />
</Data>
);
};
1 change: 1 addition & 0 deletions aries-site/src/examples/components/layer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export * from './ActionableLayerClose';
export * from './CenterInformational';
export * from './CenterLayerAnatomy';
export * from './ConfigurationForm';
export * from './DataFiltersAnatomy';
export * from './DoubleConfirmationAnatomy';
export * from './DoubleConfirmationBestPractice';
export * from './FullscreenLayerAnatomy';
Expand Down
108 changes: 50 additions & 58 deletions aries-site/src/examples/components/menu/MenuBatchActionsExample.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,62 @@
import PropTypes from 'prop-types';
import { useContext, useEffect } from 'react';
import { Box, DataTable, Menu, ResponsiveContext, Text } from 'grommet';
import { useContext, useState, useEffect } from 'react';
import {
Box,
Data,
DataFilters,
DataTable,
DataSearch,
DataSummary,
Menu,
ResponsiveContext,
Text,
Toolbar,
} from 'grommet';
import {
StatusWarningSmall,
StatusCriticalSmall,
StatusGoodSmall,
StatusUnknownSmall,
} from 'grommet-icons';

import {
FilterControls,
FiltersProvider,
useFilters,
} from '../../templates/FilterControls';

const { servers } = require('../../../data/mockData/servers.json');

const filtersConfig = [];

export const MenuBatchActionsExample = ({ containerRef }) => {
// containerRef is for demonstration purposes on this site. Most
// implementations should likely remove.

const layerProps = {
// containerRef is for demonstration purposes on this site. Most
// implementations should likely remove.
target: containerRef && containerRef.current,
taysea marked this conversation as resolved.
Show resolved Hide resolved
};

return (
<FiltersProvider>
<Box gap="medium">
<FilterControls
// only need a subset of records for this example
data={servers.items.slice(3, 12)}
filters={filtersConfig}
layerProps={layerProps}
searchFilter={{ placeholder: 'Search' }}
actions={
<Menu
label="Actions"
kind="toolbar"
open
items={[
[
{ label: 'Power on', onClick: () => {} },
{ label: 'Power off', onClick: () => {} },
{ label: 'Reset', onClick: () => {} },
{ label: 'Update firmware', onClick: () => {} },
],
[{ label: 'Add to group', onClick: () => {} }],
]}
dropAlign={{ top: 'bottom', right: 'right' }}
/>
}
/>
<ServerResults />
</Box>
</FiltersProvider>
);
};
export const MenuBatchActionsExample = () => (
<Data
data={servers.items.slice(3, 12)}
views={[
{ name: 'All', properties: { status: ['Ready', 'Paused'] } },
{ name: 'Paused', properties: { status: ['Paused'] } },
{ name: 'Ready', properties: { status: ['Ready'] } },
]}
>
<Toolbar gap="medium">
<Toolbar>
<DataSearch responsive />
<DataFilters layer />
</Toolbar>
{/* Flex Box added for spacing between Button */}
<Box flex />
<Menu
label="Actions"
kind="toolbar"
open
items={[
[
{ label: 'Power on', onClick: () => {} },
{ label: 'Power off', onClick: () => {} },
{ label: 'Reset', onClick: () => {} },
{ label: 'Update firmware', onClick: () => {} },
],
[{ label: 'Add to group', onClick: () => {} }],
]}
dropAlign={{ top: 'bottom', right: 'right' }}
/>
</Toolbar>
<DataSummary />
<ServerResults />
</Data>
);

MenuBatchActionsExample.propTypes = {
containerRef: PropTypes.object,
};

const columns = [
{
Expand Down Expand Up @@ -95,7 +88,7 @@ const statusIcons = {

const ServerResults = () => {
const breakpoint = useContext(ResponsiveContext);
const { filteredResults, selected, setSelected } = useFilters();
const [selected, setSelected] = useState([]);

useEffect(() => {
setSelected([
Expand All @@ -109,7 +102,6 @@ const ServerResults = () => {
<Box height="medium" overflow="auto">
<DataTable
aria-describedby="servers-heading"
data={filteredResults}
columns={[
{
property: 'hardware.health.summary',
Expand Down
15 changes: 14 additions & 1 deletion aries-site/src/pages/components/layer/side-drawer-layer.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Notification } from 'grommet';
import { Example } from '../../../layouts';
import {
ConfigurationForm,
DataFiltersAnatomy,
SideDrawerLayerAnatomy,
FilteringTable,
LayerStickyExample,
Expand Down Expand Up @@ -58,6 +58,19 @@ When data has been edited or changed and the user tries to close the layer, a do

Learn more about the anatomy and implementation of a [double confirmation](/components/layer#double-confirmations) on the main layer page since this behavior applies to all layer types.

### Filters

A filter layer is an exception to the above rules. Even though filtering requires action from the user, it is not essential that the user fills out the filtering form. Because of this, a filter layer can be closed by the following interactions:

1. Clicking the "Apply filters" button, which will apply the current filter selections and close the layer.
1. Clicking the close button in the layer header.
1. Clicking outside of the layer, `onClickOutside`.
1. Pressing the Escape key, `onEsc`.

<Example height="auto">
<DataFiltersAnatomy />
</Example>

## Scroll behavior

The default behavior of the layer is to allow all of the content to scroll, but this behavior can be modified depending on the layer's contents.
Expand Down
Loading
Loading