-
Notifications
You must be signed in to change notification settings - Fork 393
feat(Nav,Compass,Page): add support for expandable nav items in docked nav #12630
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
Open
kmcfaul
wants to merge
6
commits into
patternfly:main
Choose a base branch
from
kmcfaul:docked-exp-nav
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+459
−35
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
420a948
feat(Nav,Compass,Page): add support for expandable nav items in docke…
kmcfaul c98086f
fix spelling in Compass prop desc
kmcfaul 739aeea
update docs, add click/keydown handling, add tooltips, add aria-label…
kmcfaul 614620d
target page toggle button for mobile click handling instead of masthead
kmcfaul 7f71ec1
fix unfinished rebase
kmcfaul 282d609
fix tooltips showing up on expandable expanded
kmcfaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
packages/react-core/src/components/Nav/examples/NavDocked.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import { useState } from 'react'; | ||
| import { Nav, NavItem, NavList, NavExpandable } from '@patternfly/react-core'; | ||
| import RhUiCubesIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-cubes-icon'; | ||
| import RhUiFolderIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-folder-icon'; | ||
| import RhUiCodeIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-code-icon'; | ||
| import RhUiCloudIcon from '@patternfly/react-icons/dist/esm/icons/rh-ui-cloud-icon'; | ||
|
|
||
| export const NavDocked: React.FunctionComponent = () => { | ||
| const [activeItem, setActiveItem] = useState(0); | ||
| const [isGroupExpanded, setIsGroupExpanded] = useState(false); | ||
|
|
||
| const onSelect = (_event: React.FormEvent<HTMLInputElement>, result: { itemId: number | string }) => { | ||
| setActiveItem(result.itemId as number); | ||
| }; | ||
|
|
||
| const onToggle = ( | ||
| _event: React.MouseEvent<HTMLButtonElement>, | ||
| result: { groupId: number | string; isExpanded: boolean } | ||
| ) => { | ||
| setIsGroupExpanded(result.isExpanded); | ||
| }; | ||
|
|
||
| return ( | ||
| <Nav variant="docked" onSelect={onSelect} onToggle={onToggle} aria-label="Default global" ouiaId="DefaultNav"> | ||
| <NavList> | ||
| <NavItem | ||
| icon={<RhUiCubesIcon />} | ||
| preventDefault | ||
| id="nav-default-link1" | ||
| to="#nav-default-link1" | ||
| itemId={0} | ||
| isActive={activeItem === 0} | ||
| > | ||
| Default Link 1 | ||
| </NavItem> | ||
| <NavItem | ||
| icon={<RhUiCloudIcon />} | ||
| preventDefault | ||
| id="nav-default-link2" | ||
| to="#nav-default-link2" | ||
| itemId={1} | ||
| isActive={activeItem === 1} | ||
| > | ||
| Default Link 2 | ||
| </NavItem> | ||
| <NavItem | ||
| icon={<RhUiCodeIcon />} | ||
| preventDefault | ||
| id="nav-default-link3" | ||
| to="#nav-default-link3" | ||
| itemId={2} | ||
| isActive={activeItem === 2} | ||
| > | ||
| Default Link 3 | ||
| </NavItem> | ||
| <NavExpandable | ||
| title="Expandable Group 1" | ||
| groupId="nav-expandable-group-1" | ||
| icon={<RhUiFolderIcon />} | ||
| isExpanded={isGroupExpanded} | ||
| hasExpandableIcon | ||
| > | ||
| <NavItem | ||
| preventDefault | ||
| id="expandable-1" | ||
| to="#expandable-1" | ||
| groupId="nav-expandable-group-1" | ||
| itemId={3} | ||
| isActive={activeItem === 3} | ||
| > | ||
| Subnav 1 Link 1 | ||
| </NavItem> | ||
| <NavItem | ||
| preventDefault | ||
| id="expandable-2" | ||
| to="#expandable-2" | ||
| groupId="nav-expandable-group-1" | ||
| itemId={4} | ||
| isActive={activeItem === 4} | ||
| > | ||
| Subnav 1 Link 2 | ||
| </NavItem> | ||
| <NavItem | ||
| preventDefault | ||
| id="expandable-3" | ||
| to="#expandable-3" | ||
| groupId="nav-expandable-group-1" | ||
| itemId={5} | ||
| isActive={activeItem === 5} | ||
| > | ||
| Subnav 1 Link 3 | ||
| </NavItem> | ||
| </NavExpandable> | ||
| </NavList> | ||
| </Nav> | ||
| ); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Gate this modifier on
dockContent.The prop documentation says it applies only when dock content is passed, but Line 381 checks only
isDockExpandableExpanded. A dockedPagewithoutdockContentcan therefore apply expandable styling to an empty dock. The equivalent logic inpackages/react-core/src/components/Compass/Compass.tsxis inside thedock &&branch.Add a content guard and a regression test for a docked page without
dockContent.🤖 Prompt for AI Agents