Skip to content

Commit 9d69c05

Browse files
committed
Moved docked demo to Nav docs
1 parent e732586 commit 9d69c05

3 files changed

Lines changed: 40 additions & 11 deletions

File tree

packages/react-core/src/demos/Nav.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ id: Navigation
33
section: components
44
---
55

6-
import { Fragment, useState } from 'react';
6+
import { Fragment, useState, useRef } from 'react';
77
import RhUiSettingsFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-settings-fill-icon';
88
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
99
import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
@@ -12,6 +12,13 @@ import RhUiNotificationFillIcon from '@patternfly/react-icons/dist/esm/icons/rh-
1212
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
1313
import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg';
1414
import pfLogo from '@patternfly/react-core/src/demos/assets/PF-HorizontalLogo-Color.svg';
15+
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
16+
import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon';
17+
import CloudIcon from '@patternfly/react-icons/dist/esm/icons/cloud-icon';
18+
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
19+
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
20+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
21+
import pfIconLogo from '@patternfly/react-core/src/demos/assets/PF-IconLogo-color.svg';
1522
import { DashboardBreadcrumb } from '@patternfly/react-core/dist/js/demos/DashboardWrapper';
1623
import { DashboardHeader } from '@patternfly/react-core/dist/js/demos/DashboardHeader';
1724

@@ -70,3 +77,33 @@ import { DashboardHeader } from '@patternfly/react-core/dist/js/demos/DashboardH
7077
```ts isFullscreen file="./examples/Nav/NavDrilldown.tsx"
7178

7279
```
80+
81+
### Docked nav
82+
83+
The docked navigation pattern provides a responsive vertical navigation layout that adapts between mobile and desktop viewports. On mobile, the navigation appears as an overlay, while on desktop it displays as a persistent vertical sidebar that can toggle between icon-only and text+icon modes.
84+
85+
**Key implementation requirements:**
86+
87+
1. **Page component**: Set `variant="docked"` to enable the docked layout. Pass `isDockExpanded` and `isDockTextExpanded` state props to control mobile overlay and desktop text visibility.
88+
89+
2. **Masthead structure**: Use two separate mastheads:
90+
- **Mobile masthead**: Set `display={{ default: 'inline' }}` so it only appears on mobile. Include a hamburger toggle button, logo, and any mobile-specific actions.
91+
- **Docked masthead**: Set `variant="docked"` for the vertical navigation sidebar. This contains the navigation toggle, nav items, and action buttons.
92+
93+
3. **Navigation component**: Set `variant="docked"` on Nav and pass `isTextExpanded={isDockTextExpanded}` to control text visibility. NavItems should include both icons and text children—the Nav component will handle showing/hiding text based on state.
94+
95+
4. **Buttons and toggles**: Use `isDocked` and `isTextExpanded` props on Button and MenuToggle components within the docked navigation. These props apply dock-specific styling that toggles between icon-only and text+icon display.
96+
97+
5. **Logo variants**: Use `isCompact` prop on MastheadLogo to show an icon-only logo when the dock is collapsed, and a full logo with text when expanded.
98+
99+
6. **Focus management**: Implement focus shifting between the mobile toggle button and docked nav toggle button when opening/closing the navigation for better keyboard accessibility.
100+
101+
7. **Tooltips**: Only render tooltips when text is hidden (icon-only mode) to avoid showing redundant information when text labels are already visible.
102+
103+
8. **State management**:
104+
- `isDockExpanded`: Controls whether the mobile overlay is shown
105+
- `isDockTextExpanded`: Controls whether text is displayed alongside icons on desktop
106+
107+
```ts file="./examples/Nav/NavDockedNav.tsx" isFullscreen
108+
109+
```

packages/react-core/src/demos/Page.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import CloudIcon from '@patternfly/react-icons/dist/esm/icons/cloud-icon';
1818
import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
1919
import pfLogo from '@patternfly/react-core/src/demos/assets/PF-HorizontalLogo-Color.svg';
2020
import pfIconLogo from '@patternfly/react-core/src/demos/assets/PF-IconLogo-color.svg';
21-
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
22-
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
2321

2422
- 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:
2523
1. Add an onNavToggle callback to PageHeader
@@ -54,9 +52,3 @@ When adding a context selector/perspective switcher in a `PageSidebar`, you must
5452
```ts file='./examples/Page/PageContextSelector.tsx' isFullscreen
5553

5654
```
57-
58-
### Docked nav
59-
60-
```ts file='./examples/Page/PageDockedNav.tsx' isFullscreen
61-
62-
```

packages/react-core/src/demos/examples/Page/PageDockedNav.tsx renamed to packages/react-core/src/demos/examples/Nav/NavDockedNav.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ interface NavOnSelectProps {
4545
to: string;
4646
}
4747

48-
export const PageDockedNav: React.FunctionComponent = () => {
48+
export const NavDockedNav: React.FunctionComponent = () => {
4949
const [activeItem, setActiveItem] = useState(1);
5050
const [isDockExpanded, setIsDockExpanded] = useState(false);
5151
const [isDockTextExpanded, setIsDockTextExpanded] = useState(false);
@@ -430,7 +430,7 @@ export const PageDockedNav: React.FunctionComponent = () => {
430430
isDockExpanded={isDockExpanded}
431431
isDockTextExpanded={isDockTextExpanded}
432432
masthead={mobileMasthead}
433-
dockedMasthead={dockedMasthead}
433+
dockContent={dockedMasthead}
434434
skipToContent={pageSkipToContent}
435435
breadcrumb={dashboardBreadcrumb}
436436
mainContainerId={mainContainerId}

0 commit comments

Comments
 (0)