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

chore(Toolbar): add different gap props to examples #11440

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Note: This example does not demonstrate responsive toolbar behavior. Responsive

You may adjust the space between toolbar items to arrange them into groups. Read our spacers documentation to learn more about using spacers.

Items are spaced “16px” apart by default via their parents' `gap` or `columnGap` property. You can set the property values at multiple breakpoints, including "default", "md", "lg", "xl", and "2xl".
Items are spaced “16px” apart by default and can be modified by changing their or their parents' `gap`, `columnGap`, and `rowGap` properties. You can set the property values at multiple breakpoints, including "default", "md", "lg", "xl", and "2xl".

```ts file="./ToolbarSpacers.tsx"

Expand Down
246 changes: 232 additions & 14 deletions packages/react-core/src/components/Toolbar/examples/ToolbarSpacers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,264 @@ import { Toolbar, ToolbarItem, ToolbarGroup, ToolbarContent } from '@patternfly/
import { Button } from '@patternfly/react-core';

export const ToolbarSpacers: React.FunctionComponent = () => {
const items = (
const groupGapItems = (
<React.Fragment>
<ToolbarGroup variant="action-group">
<ToolbarItem>
<Button variant="secondary">Action</Button>
<Button variant="secondary">Default Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Action</Button>
<Button variant="secondary">Default Gap</Button>
</ToolbarItem>
</ToolbarGroup>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarGroup variant="action-group" gap={{ default: 'gapNone' }}>
<ToolbarItem>
<Button variant="secondary">Action</Button>
<Button variant="secondary">No Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Action</Button>
<Button variant="secondary">No Gap</Button>
</ToolbarItem>
</ToolbarGroup>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarGroup variant="action-group" gap={{ lg: 'gapSm' }}>
<ToolbarGroup variant="action-group" gap={{ default: 'gapSm' }}>
<ToolbarItem>
<Button variant="secondary">Action</Button>
<Button variant="secondary">Small Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="primary">Action</Button>
<Button variant="secondary">Small Gap</Button>
</ToolbarItem>
</ToolbarGroup>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarGroup variant="action-group" gap={{ lg: 'gapLg' }}>
<ToolbarGroup variant="action-group" gap={{ default: 'gapXl' }}>
<ToolbarItem>
<Button variant="secondary">Extra Large Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Gap</Button>
</ToolbarItem>
</ToolbarGroup>
</React.Fragment>
);

const groupColumnGapItems = (
<React.Fragment>
<ToolbarGroup variant="action-group" columnGap={{ default: 'columnGapNone' }}>
<ToolbarItem className="pf-m-wrap">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we double check these classes? The ones on a ToolbarGroup should be fine, but not sure if we need them on all of the ToolbarItems (do see that for the row gap section it's being used to show off the row gap on ToolbarItem, though).

Also @mcoker, is the intent that only Toolbar subcomponents will be passed into a ToolbarGroup, or could, say, a plain div be passed and in that div are ToolbarItems? Right now there's no easier way to apply wrapping to a ToolbarGroup and better show the row gap in use than hardcoding this class name. Should there be a prop to apply wrapping?

<Button variant="secondary">No Column Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">No Column Gap</Button>
</ToolbarItem>
</ToolbarGroup>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarGroup variant="action-group" columnGap={{ default: 'columnGapSm' }}>
<ToolbarItem className="pf-m-wrap">
<Button variant="secondary">Small Column Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Small Column Gap</Button>
</ToolbarItem>
</ToolbarGroup>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarGroup variant="action-group" columnGap={{ default: 'columnGapXl' }}>
<ToolbarItem className="pf-m-wrap">
<Button variant="secondary">Extra Large Column Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Column Gap</Button>
</ToolbarItem>
</ToolbarGroup>
</React.Fragment>
);

const groupRowGapItems = (
<React.Fragment>
<ToolbarGroup className="pf-m-wrap" variant="action-group" rowGap={{ default: 'rowGapNone' }}>
<ToolbarItem>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem variant="separator"></ToolbarItem>
</ToolbarGroup>
<ToolbarGroup className="pf-m-wrap" variant="action-group" rowGap={{ default: 'rowGapSm' }}>
<ToolbarItem>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Action</Button>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Action</Button>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem variant="separator"></ToolbarItem>
</ToolbarGroup>
<ToolbarGroup className="pf-m-wrap" variant="action-group" rowGap={{ default: 'rowGapXl' }}>
<ToolbarItem>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
</ToolbarGroup>
</React.Fragment>
);

const itemGapItems = (
<React.Fragment>
<ToolbarGroup className="pf-m-wrap" variant="action-group">
<ToolbarItem gap={{ default: 'gapNone' }}>
<Button variant="secondary">No Gap</Button>
<Button variant="secondary">No Gap</Button>
</ToolbarItem>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarItem gap={{ default: 'gapSm' }}>
<Button variant="secondary">Small Gap</Button>
<Button variant="secondary">Small Gap</Button>
</ToolbarItem>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarItem gap={{ default: 'gapXl' }}>
<Button variant="secondary">Extra Large Gap</Button>
<Button variant="secondary">Extra Large Gap</Button>
</ToolbarItem>
</ToolbarGroup>
</React.Fragment>
);

const itemColumnGapItems = (
<React.Fragment>
<ToolbarGroup className="pf-m-wrap" variant="action-group">
<ToolbarItem columnGap={{ default: 'columnGapNone' }}>
<Button variant="secondary">No Column Gap</Button>
<Button variant="secondary">No Column Gap</Button>
</ToolbarItem>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarItem columnGap={{ default: 'columnGapSm' }}>
<Button variant="secondary">Small Column Gap</Button>
<Button variant="secondary">Small Column Gap</Button>
</ToolbarItem>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarItem columnGap={{ default: 'columnGapXl' }}>
<Button variant="secondary">Extra Large Column Gap</Button>
<Button variant="secondary">Extra Large Column Gap</Button>
</ToolbarItem>
</ToolbarGroup>
</React.Fragment>
);

const itemRowGapItems = (
<React.Fragment>
<ToolbarGroup variant="action-group">
<ToolbarItem className="pf-m-wrap" rowGap={{ default: 'rowGapNone' }}>
<Button variant="secondary">No Row Gap</Button>
<Button variant="secondary">No Row Gap</Button>
</ToolbarItem>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarItem className="pf-m-wrap" rowGap={{ default: 'rowGapSm' }}>
<Button variant="secondary">Small Row Gap</Button>
<Button variant="secondary">Small Row Gap</Button>
</ToolbarItem>
<ToolbarItem variant="separator"></ToolbarItem>
<ToolbarItem className="pf-m-wrap" rowGap={{ default: 'rowGapXl' }}>
<Button variant="secondary">Extra Large Row Gap</Button>
<Button variant="secondary">Extra Large Row Gap</Button>
</ToolbarItem>
</ToolbarGroup>
</React.Fragment>
);

return (
<Toolbar id="toolbar-spacers">
<ToolbarContent>{items}</ToolbarContent>
</Toolbar>
<>
<strong>Toolbar Group Spacing:</strong>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than the strong element, can we update this to use the h4 heading for this and the "Toolbar item spacing"? Could also add a "Using gap" above the first set similar to "Using column gap" and "Using row gap" for the other sets.

<br />
<br />
<Toolbar id="toolbar-spacers">
<ToolbarContent>{groupGapItems}</ToolbarContent>
</Toolbar>
<strong>Using column gap</strong>
<br />
<br />
<Toolbar id="toolbar-spacers">
<ToolbarContent>{groupColumnGapItems}</ToolbarContent>
</Toolbar>
<strong>Using row gap</strong>
<br />
<br />
<Toolbar id="toolbar-spacers">
<ToolbarContent>{groupRowGapItems}</ToolbarContent>
</Toolbar>
<br />
<strong>Toolbar Item Spacing:</strong>
<br />
<br />
<Toolbar id="toolbar-spacers">
<ToolbarContent>{itemGapItems}</ToolbarContent>
</Toolbar>
<strong>Using column gap</strong>
<br />
<br />
<Toolbar id="toolbar-spacers">
<ToolbarContent>{itemColumnGapItems}</ToolbarContent>
</Toolbar>
<strong>Using row gap</strong>
<br />
<br />
<Toolbar id="toolbar-spacers">
<ToolbarContent>{itemRowGapItems}</ToolbarContent>
</Toolbar>
</>
);
};
Loading