Skip to content
Merged
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
625 changes: 10 additions & 615 deletions packages/react-core/src/components/Page/examples/Page.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react';
import {
Page,
Masthead,
MastheadToggle,
MastheadMain,
MastheadBrand,
MastheadContent,
PageSidebar,
PageSection,
PageToggleButton,
Toolbar,
ToolbarContent,
ToolbarItem,
Card,
CardBody
} from '@patternfly/react-core';
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';

export const PageCenteredSection: React.FunctionComponent = () => {
const [isNavOpen, setIsNavOpen] = React.useState(true);

const onNavToggle = () => {
setIsNavOpen(!isNavOpen);
};

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

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

const sidebar = <PageSidebar nav="Navigation" isNavOpen={isNavOpen} id="main-padding-sidebar" />;

return (
<Page header={header} sidebar={sidebar}>
<PageSection isWidthLimited isCenterAligned>
<Card>
<CardBody>
When a width limited page section is wider than the value of
<code>--pf-c-page--section--m-limit-width--MaxWidth</code>, the section will be centered in the main
section.
<br />
<br />
The content in this example is placed in a card to better illustrate how the section behaves when it is
centered. A card is not required to center a page section.
</CardBody>
</Card>
</PageSection>
</Page>
);
};
106 changes: 106 additions & 0 deletions packages/react-core/src/components/Page/examples/PageGroupSection.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import React from 'react';
import {
Page,
Masthead,
MastheadToggle,
MastheadMain,
MastheadBrand,
MastheadContent,
PageSidebar,
PageSection,
PageGroup,
PageBreadcrumb,
PageNavigation,
PageSectionVariants,
PageToggleButton,
Breadcrumb,
BreadcrumbItem,
Nav,
NavList,
NavItem,
Toolbar,
ToolbarContent,
ToolbarItem
} from '@patternfly/react-core';
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';

export const PageGroupSection: React.FunctionComponent = () => {
const [isNavOpen, setIsNavOpen] = React.useState(true);

const onNavToggle = () => {
setIsNavOpen(!isNavOpen);
};

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

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

const sidebar = <PageSidebar nav="Navigation" isNavOpen={isNavOpen} id="group-section-sidebar" />;

return (
<Page header={header} sidebar={sidebar}>
<PageGroup>
<PageNavigation>
<Nav aria-label="Group section navigation" variant="tertiary">
<NavList>
<NavItem href="#" itemId={0} isActive>
System panel
</NavItem>
<NavItem href="#" itemId={1}>
Policy
</NavItem>
<NavItem href="#" itemId={2}>
Authentication
</NavItem>
<NavItem href="#" itemId={3}>
Network services
</NavItem>
<NavItem href="#" itemId={4}>
Server
</NavItem>
</NavList>
</Nav>
</PageNavigation>
<PageBreadcrumb>
<Breadcrumb>
<BreadcrumbItem>Section home</BreadcrumbItem>
<BreadcrumbItem to="#">Section title</BreadcrumbItem>
<BreadcrumbItem to="#">Section title</BreadcrumbItem>
<BreadcrumbItem to="#" isActive>
Section landing
</BreadcrumbItem>
</Breadcrumb>
</PageBreadcrumb>
<PageSection variant={PageSectionVariants.light}>Grouped section</PageSection>
</PageGroup>
<PageSection variant={PageSectionVariants.dark}>Section 1</PageSection>
<PageSection variant={PageSectionVariants.dark}>Section 2</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import React from 'react';
import {
Page,
Masthead,
MastheadMain,
MastheadBrand,
MastheadContent,
PageSection,
PageSectionVariants,
Toolbar,
ToolbarContent,
ToolbarItem
} from '@patternfly/react-core';

export const PageHorizontalNav: React.FunctionComponent = () => {
const headerToolbar = (
<Toolbar id="horizontal-toolbar">
<ToolbarContent>
<ToolbarItem>Navigation</ToolbarItem>
<ToolbarItem>header-tools</ToolbarItem>
</ToolbarContent>
</Toolbar>
);

const header = (
<Masthead inset={{ default: 'insetXs' }}>
<MastheadMain>
<MastheadBrand href="https://patternfly.org" target="_blank">
Logo
</MastheadBrand>
</MastheadMain>
<MastheadContent>{headerToolbar}</MastheadContent>
</Masthead>
);

return (
<Page header={header}>
<PageSection variant={PageSectionVariants.darker}>Section with darker background</PageSection>
<PageSection variant={PageSectionVariants.dark}>Section with dark background</PageSection>
<PageSection variant={PageSectionVariants.light}>Section with light background</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import {
Page,
Masthead,
MastheadToggle,
MastheadMain,
MastheadBrand,
MastheadContent,
PageSidebar,
PageSection,
PageSectionVariants,
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 [isNavOpen, setIsNavOpen] = React.useState(true);

const onNavToggle = () => {
setIsNavOpen(!isNavOpen);
};

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"
isNavOpen={isNavOpen}
onNavToggle={onNavToggle}
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 nav="Navigation" isNavOpen={isNavOpen} id="main-padding-sidebar" />;

return (
<Page header={header} sidebar={sidebar}>
<PageSection>Section with default padding</PageSection>
<PageSection variant={PageSectionVariants.light} padding={{ default: 'noPadding' }}>
Section with no padding
</PageSection>
<PageSection padding={{ default: 'noPadding', md: 'padding', lg: 'padding' }}>
Section with padding only on medium/large
</PageSection>
<PageSection variant={PageSectionVariants.light} padding={{ md: 'noPadding' }}>
Section with no padding on medium
</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react';
import {
Page,
Masthead,
MastheadMain,
MastheadBrand,
MastheadContent,
PageSection,
PageSectionVariants,
Toolbar,
ToolbarContent,
ToolbarItem
} from '@patternfly/react-core';

export const PageTertiaryNav: React.FunctionComponent = () => {
const headerToolbar = (
<Toolbar id="tertiary-toolbar">
<ToolbarContent>
<ToolbarItem>header-tools</ToolbarItem>
</ToolbarContent>
</Toolbar>
);

const header = (
<Masthead display={{ default: 'stack' }} inset={{ default: 'insetXs' }}>
<MastheadMain>
<MastheadBrand href="https://patternfly.org" target="_blank">
Logo
</MastheadBrand>
</MastheadMain>
<MastheadContent>{headerToolbar}</MastheadContent>
</Masthead>
);

return (
<Page header={header} tertiaryNav="Navigation">
<PageSection variant={PageSectionVariants.darker}>Section with darker background</PageSection>
<PageSection variant={PageSectionVariants.dark}>Section with dark background</PageSection>
<PageSection variant={PageSectionVariants.light}>Section with light background</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import {
Page,
Masthead,
MastheadToggle,
MastheadMain,
MastheadBrand,
MastheadContent,
PageSidebar,
PageSection,
PageSectionVariants,
PageToggleButton,
Toolbar,
ToolbarContent,
ToolbarItem
} from '@patternfly/react-core';
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';

export const PageUncontrolledNav: React.FunctionComponent = () => {
const headerToolbar = (
<Toolbar id="uncontrolled-toolbar">
<ToolbarContent>
<ToolbarItem>header-tools</ToolbarItem>
</ToolbarContent>
</Toolbar>
);

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

const sidebar = <PageSidebar nav="Navigation" id="uncontrolled-sidebar" />;

return (
<Page isManagedSidebar header={header} sidebar={sidebar}>
<PageSection variant={PageSectionVariants.darker}>Section with darker background</PageSection>
<PageSection variant={PageSectionVariants.dark}>Section with dark background</PageSection>
<PageSection variant={PageSectionVariants.light}>Section with light background</PageSection>
</Page>
);
};
Loading