Skip to content
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
36 changes: 24 additions & 12 deletions packages/react-core/src/components/Page/examples/Page.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ The `<MastheadMain>` component includes the smaller area that typically contains
- 1 or more `<PageSidebarBody>` components inside `<PageSidebar>` for vertical navigation or other sidebar content
- 1 or more `<PageSection>` components

### Page header and footer

To use a page header instead of passing a [masthead](/components/masthead) directly, pass a `<PageHeader>` to the `masthead` property. `<PageHeader>` should only be used to wrap custom header content.

`<PageFooter>` can be passed to the `footer` property, and should be used to wrap custom footer content.

When using a custom `<PageHeader>` and `<PageFooter>`, the `isPlain` flag should be passed to `<Page>`. This will remove styling on the main container, the height constraints on the page wrapper (so it can grow beyond the viewport), and remove the scroll management from the content section so the window will be what scrolls.

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

```

### Vertical navigation

To add a vertical sidebar to a `<Page>`, pass a `<PageSidebar>` component into the `sidebar` property. To render navigation in the sidebar, pass a `<PageSidebarBody>` component to `<PageSidebar>`.
Expand Down Expand Up @@ -162,3 +150,27 @@ In this example, a scroll event listener on the scroll parent container toggles
```ts file="./PageDynamicStickySection.tsx"

```

### Custom header

To use a page header instead of passing a [masthead](/components/masthead) directly, pass a `<PageHeader>` to the `masthead` property. `<PageHeader>` should only be used to wrap custom header content.

```ts isBeta file="./PageCustomHeader.tsx"

```

### Footer

`<PageFooter>` can be passed to the `footer` property, and should be used to wrap custom footer content.

```ts isBeta file="./PageCustomFooter.tsx"

```

### Plain page

When a page should not have the default content area background or overflow scrolling, pass the `isPlain` property to `<Page>`.

```ts isBeta file="./PagePlain.tsx"

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { useState } from 'react';
import {
Masthead,
MastheadMain,
MastheadToggle,
MastheadBrand,
MastheadLogo,
MastheadContent,
Page,
PageFooter,
PageSection,
PageSidebar,
PageSidebarBody,
PageToggleButton
} from '@patternfly/react-core';

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

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

const masthead = (
<Masthead>
<MastheadMain>
<MastheadToggle>
<PageToggleButton
aria-label="Global navigation"
isSidebarOpen={isSidebarOpen}
onSidebarToggle={onSidebarToggle}
id="custom-footer-body-nav-toggle"
isHamburgerButton
/>
</MastheadToggle>
<MastheadBrand>
<MastheadLogo href="https://patternfly.org" target="_blank">
Logo
</MastheadLogo>
</MastheadBrand>
</MastheadMain>
<MastheadContent>Content</MastheadContent>
</Masthead>
);

const sidebar = (
<PageSidebar isSidebarOpen={isSidebarOpen} id="custom-footer-vertical-sidebar">
<PageSidebarBody>Navigation</PageSidebarBody>
</PageSidebar>
);

return (
<Page footer={<PageFooter>Page footer</PageFooter>} masthead={masthead} sidebar={sidebar}>
<PageSection aria-labelledby="custom-footer-section">
<h2 id="custom-footer-section">Page content</h2>
</PageSection>
</Page>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Page, PageHeader, PageSection, PageSidebar, PageSidebarBody } from '@patternfly/react-core';

export const PageCustomHeader: React.FunctionComponent = () => {
const sidebar = (
<PageSidebar isSidebarOpen id="custom-header-vertical-sidebar">
<PageSidebarBody>Navigation</PageSidebarBody>
</PageSidebar>
);

return (
<Page masthead={<PageHeader>Custom page header</PageHeader>} sidebar={sidebar}>
<PageSection aria-labelledby="custom-header-section">
<h2 id="custom-header-section">Page content</h2>
</PageSection>
</Page>
);
};

This file was deleted.

58 changes: 58 additions & 0 deletions packages/react-core/src/components/Page/examples/PagePlain.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { useState } from 'react';
import {
Masthead,
MastheadMain,
MastheadToggle,
MastheadBrand,
MastheadLogo,
MastheadContent,
Page,
PageSection,
PageSidebar,
PageSidebarBody,
PageToggleButton
} from '@patternfly/react-core';

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

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

const masthead = (
<Masthead>
<MastheadMain>
<MastheadToggle>
<PageToggleButton
aria-label="Global navigation"
isSidebarOpen={isSidebarOpen}
onSidebarToggle={onSidebarToggle}
id="plain-page-body-nav-toggle"
isHamburgerButton
/>
</MastheadToggle>
<MastheadBrand>
<MastheadLogo href="https://patternfly.org" target="_blank">
Logo
</MastheadLogo>
</MastheadBrand>
</MastheadMain>
<MastheadContent>Content</MastheadContent>
</Masthead>
);

const sidebar = (
<PageSidebar isSidebarOpen={isSidebarOpen} id="plain-page-vertical-sidebar">
<PageSidebarBody>Navigation</PageSidebarBody>
</PageSidebar>
);

return (
<Page isPlain masthead={masthead} sidebar={sidebar}>
<PageSection aria-labelledby="plain-page-section">
Comment thread
coderabbitai[bot] marked this conversation as resolved.
<h2 id="plain-page-section">Page content</h2>
</PageSection>
</Page>
);
};
2 changes: 1 addition & 1 deletion packages/react-core/src/demos/CardView/CardView.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ section: patterns
import { Fragment, useState } from 'react';
import RhUiTrashFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-trash-fill-icon';
import RhUiAddCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-add-circle-fill-icon';
import pfIcon from '../assets/pf-logo-small.svg';
import pfIcon from '@patternfly/react-core/src/demos/assets/PF-IconLogo.svg';
import activeMQIcon from '../assets/activemq-core_200x150.png';
import avroIcon from '../assets/camel-avro_200x150.png';
import dropBoxIcon from '../assets/camel-dropbox_200x150.png';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
} from '@patternfly/react-core';
import RhUiTrashFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-trash-fill-icon';
import RhUiAddCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-add-circle-fill-icon';
import pfIcon from './assets/pf-logo-small.svg';
import pfIcon from '@patternfly/react-core/src/demos/assets/PF-IconLogo.svg';
import activeMQIcon from './assets/activemq-core_200x150.png';
import avroIcon from './assets/camel-avro_200x150.png';
import dropBoxIcon from './assets/camel-dropbox_200x150.png';
Expand Down
27 changes: 25 additions & 2 deletions packages/react-core/src/demos/Page.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,27 @@ import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.sv
import RhUiMenuBarsIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-menu-bars-icon';
import LightbulbIcon from '@patternfly/react-icons/dist/esm/icons/lightbulb-icon';
import RhUiEllipsisVerticalFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-ellipsis-vertical-fill-icon';
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
import RhUiContainerIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-container-icon';
import RhUiCloudFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-cloud-fill-icon';
import RhUiPortIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-port-icon';
import RhUiAutomationIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-automation-icon';
import RhUiConnectedIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-connected-icon';
import RhUiArrowRightIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-arrow-right-icon';
import RhUiAddCircleFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-add-circle-fill-icon';
import RhUiTrashFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-trash-fill-icon';
import RhUiThumbnailViewSmallFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-thumbnail-view-small-fill-icon';
import pfLogo from '@patternfly/react-core/src/demos/assets/PF-HorizontalLogo-Color.svg';
import pfIconLogo from '@patternfly/react-core/src/demos/assets/PF-IconLogo-color.svg';
import pfIcon from '@patternfly/react-core/src/demos/assets/PF-IconLogo.svg';
import activeMQIcon from '@patternfly/react-core/src/demos/assets/activemq-core_200x150.png';
import avroIcon from '@patternfly/react-core/src/demos/assets/camel-avro_200x150.png';
import dropBoxIcon from '@patternfly/react-core/src/demos/assets/camel-dropbox_200x150.png';
import infinispanIcon from '@patternfly/react-core/src/demos/assets/camel-infinispan_200x150.png';
import saxonIcon from '@patternfly/react-core/src/demos/assets/camel-saxon_200x150.png';
import sparkIcon from '@patternfly/react-core/src/demos/assets/camel-spark_200x150.png';
import swaggerIcon from '@patternfly/react-core/src/demos/assets/camel-swagger-java_200x150.png';
import azureIcon from '@patternfly/react-core/src/demos/assets/FuseConnector_Icons_AzureServices.png';
import restIcon from '@patternfly/react-core/src/demos/assets/FuseConnector_Icons_REST.png';
import { data } from '@patternfly/react-core/src/demos/CardView/examples/CardViewData.jsx';

- All examples set the `isManagedSidebar` prop on the Page component to have the sidebar automatically close for smaller screen widths. You can also manually control this behavior by not adding the `isManagedSidebar` prop and instead:
1. Add an onNavToggle callback to PageHeader
Expand Down Expand Up @@ -50,3 +67,9 @@ When adding a context selector/perspective switcher in a `PageSidebar`, you must
```ts file='./examples/Page/PageContextSelector.tsx' isFullscreen

```

### Plain

```ts file='./examples/Page/PagePlain.tsx' isFullscreen

```
Loading
Loading