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

docs(Page): add example showing different type prop variants #10352

Merged
merged 3 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions packages/react-core/src/components/Page/examples/Page.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ To remove padding at specific breakpoints, pass in 'noPadding' at those breakpoi

```

### Main section variations

This example shows all types of page sections.

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

```

### Group section

To group page content sections, add 1 or more `<PageGroup>` components to a `<Page>`.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React from 'react';
import {
Page,
Masthead,
MastheadToggle,
MastheadMain,
MastheadBrand,
MastheadContent,
PageSidebar,
PageSidebarBody,
PageSection,
PageToggleButton,
Toolbar,
ToolbarContent,
ToolbarItem
} from '@patternfly/react-core';
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';

export const PageMainSectionPadding: React.FunctionComponent = () => {
const [isSidebarOpen, setIsSidebarOpen] = React.useState(true);

const onSidebarToggle = () => {
setIsSidebarOpen(!isSidebarOpen);
};

const headerToolbar = (
<Toolbar id="main-padding-toolbar">
<ToolbarContent>
<ToolbarItem>header-tools</ToolbarItem>
</ToolbarContent>
</Toolbar>
);

const header = (
<Masthead>
<MastheadToggle>
<PageToggleButton
variant="plain"
aria-label="Global navigation"
isSidebarOpen={isSidebarOpen}
onSidebarToggle={onSidebarToggle}
id="main-padding-nav-toggle"
>
<BarsIcon />
</PageToggleButton>
</MastheadToggle>
<MastheadMain>
<MastheadBrand href="https://patternfly.org" target="_blank">
Logo
</MastheadBrand>
</MastheadMain>
<MastheadContent>{headerToolbar}</MastheadContent>
</Masthead>
);

const sidebar = (
<PageSidebar isSidebarOpen={isSidebarOpen} id="main-padding-sidebar">
<PageSidebarBody>Navigation</PageSidebarBody>
</PageSidebar>
);

return (
<Page header={header} sidebar={sidebar}>
<PageSection type="subnav">
Section with <code>type="subnav"</code> for horizontal subnav navigation
</PageSection>
<PageSection type="nav">
Section with <code>type="nav"</code> for tertiary navigation
</PageSection>
<PageSection type="tabs">
Section with <code>type="tabs"</code> for tabs
</PageSection>
<PageSection type="breadcrumb">
Section with <code>type="breadcrumb"</code> for breadcrumbs
</PageSection>
<PageSection>
Section without <code>type</code> prop or <code>type="default"</code> for main sections
</PageSection>
<PageSection type="wizard">
Section with <code>type="wizard"</code> for wizards
</PageSection>
</Page>
);
};
Loading