-
Notifications
You must be signed in to change notification settings - Fork 377
feat(docked nav): add support for docked nav layout #12175
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
42b7e54
feat(docked nav): add support for docked nav layout
kmcfaul 454aa8c
pr updates from rabbit
kmcfaul 36a8927
revert some updates for build
kmcfaul e178dfc
remove dupe import
kmcfaul add8809
feedback
kmcfaul 9e10bdd
bump core, add arialabels
kmcfaul 2678d65
fix integration test
kmcfaul c43c253
Update packages/react-core/src/demos/examples/Page/PageDockedNav.tsx
mcoker 660a46d
Update packages/react-core/src/demos/examples/Page/PageDockedNav.tsx
mcoker 6c019f2
Update packages/react-core/src/components/Compass/examples/CompassDoc…
mcoker b0ff4c5
Update packages/react-core/src/components/Nav/Nav.tsx
mcoker 88f0e92
Update packages/react-core/src/demos/examples/Page/PageDockedNav.tsx
mcoker ded5c6c
chore: add toolbar isVertical test
mcoker 72833ae
chore: move compass docked under demos
mcoker 860f035
Added new ref prop for navitem anchors
thatblindgeye e09d1b6
chore: add not vertical test
mcoker a682a09
Added tooltips to docked tools
thatblindgeye 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
197 changes: 197 additions & 0 deletions
197
packages/react-core/src/components/Compass/examples/CompassDockDemo.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,197 @@ | ||
| import { useRef, useState } from 'react'; | ||
| import { | ||
| Compass, | ||
| CompassContent, | ||
| CompassMainHeader, | ||
| CompassPanel, | ||
| Title, | ||
| NavItem, | ||
| NavList, | ||
| Nav, | ||
| Brand, | ||
| MastheadLogo, | ||
| MastheadBrand, | ||
| MastheadContent, | ||
| MastheadMain, | ||
| Masthead, | ||
| Toolbar, | ||
| ToolbarContent, | ||
| ToolbarItem, | ||
| ToolbarGroup, | ||
| Dropdown, | ||
| DropdownList, | ||
| MenuToggle, | ||
| MenuToggleElement, | ||
| DropdownItem, | ||
| Button, | ||
| ButtonVariant, | ||
| Avatar, | ||
| Tooltip, | ||
| Divider | ||
| } from '@patternfly/react-core'; | ||
| import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon'; | ||
| import FolderIcon from '@patternfly/react-icons/dist/esm/icons/folder-icon'; | ||
| import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon'; | ||
| import CloudIcon from '@patternfly/react-icons/dist/esm/icons/cloud-icon'; | ||
| import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon'; | ||
| import pfLogo from '../../assets/PF-IconLogo-color.svg'; | ||
| import imgAvatar from '../../assets/avatarImg.svg'; | ||
|
|
||
| interface NavOnSelectProps { | ||
| groupId: number | string; | ||
| itemId: number | string; | ||
| to: string; | ||
| } | ||
|
|
||
| export const CompassDockDemo: React.FunctionComponent = () => { | ||
| const [activeItem, setActiveItem] = useState<number>(0); | ||
| const [isDropdownOpen, setIsDropdownOpen] = useState(false); | ||
|
|
||
| const onNavSelect = (_event: React.FormEvent<HTMLInputElement>, selectedItem: NavOnSelectProps) => { | ||
| typeof selectedItem.itemId === 'number' && setActiveItem(selectedItem.itemId); | ||
| }; | ||
|
|
||
| const onDropdownToggle = () => { | ||
| setIsDropdownOpen(!isDropdownOpen); | ||
| }; | ||
|
|
||
| const onDropdownSelect = () => { | ||
| setIsDropdownOpen(!isDropdownOpen); | ||
| }; | ||
|
|
||
| const userDropdownItems = [ | ||
| <> | ||
| <DropdownItem key="group 2 profile">My profile</DropdownItem> | ||
| <DropdownItem key="group 2 user">User management</DropdownItem> | ||
| <DropdownItem key="group 2 logout">Logout</DropdownItem> | ||
| </> | ||
| ]; | ||
|
|
||
| const navItem1Ref = useRef<HTMLAnchorElement>(null); | ||
| const navItem2Ref = useRef<HTMLAnchorElement>(null); | ||
| const navItem3Ref = useRef<HTMLAnchorElement>(null); | ||
| const navItem4Ref = useRef<HTMLAnchorElement>(null); | ||
| const dockContent = ( | ||
| <Masthead id="icon-router-link" variant="docked"> | ||
| <MastheadMain> | ||
| <MastheadBrand> | ||
| <MastheadLogo component={(props) => <a {...props} href="#" />}> | ||
| <Brand src={pfLogo} alt="PatternFly" heights={{ default: '36px' }} /> | ||
mcoker marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </MastheadLogo> | ||
| </MastheadBrand> | ||
| </MastheadMain> | ||
| <Divider /> | ||
| <MastheadContent> | ||
| <Toolbar id="toolbar" isVertical> | ||
| <ToolbarContent> | ||
| <ToolbarItem> | ||
| <Nav onSelect={onNavSelect} variant="docked" aria-label="Icon global" ouiaId="IconNav"> | ||
| <NavList> | ||
| <NavItem | ||
| key="nav-icon-link1" | ||
| preventDefault | ||
| id="nav-icon-link1" | ||
| to="#nav-icon-link1" | ||
| itemId={0} | ||
| isActive={activeItem === 0} | ||
| icon={<CubeIcon />} | ||
| ref={navItem1Ref} | ||
| aria-label="Link 1" | ||
| /> | ||
| <NavItem | ||
| key="nav-icon-link2" | ||
| preventDefault | ||
| id="nav-icon-link2" | ||
| to="#nav-icon-link2" | ||
| itemId={1} | ||
| isActive={activeItem === 1} | ||
| icon={<FolderIcon />} | ||
| ref={navItem2Ref} | ||
| aria-label="Link 2" | ||
| /> | ||
| <NavItem | ||
| key="nav-icon-link3" | ||
| preventDefault | ||
| id="nav-icon-link3" | ||
| to="#nav-icon-link3" | ||
| itemId={2} | ||
| isActive={activeItem === 2} | ||
| icon={<CloudIcon />} | ||
| ref={navItem3Ref} | ||
| aria-label="Link 3" | ||
| /> | ||
| <NavItem | ||
| key="nav-icon-link4" | ||
| preventDefault | ||
| id="nav-icon-link4" | ||
| to="#nav-icon-link4" | ||
| itemId={3} | ||
| isActive={activeItem === 3} | ||
| icon={<CodeIcon />} | ||
| ref={navItem4Ref} | ||
| aria-label="Link 4" | ||
| /> | ||
| </NavList> | ||
| </Nav> | ||
| <Tooltip triggerRef={navItem1Ref} content="Link 1"></Tooltip> | ||
| <Tooltip triggerRef={navItem2Ref} content="Link 2"></Tooltip> | ||
| <Tooltip triggerRef={navItem3Ref} content="Link 3"></Tooltip> | ||
| <Tooltip triggerRef={navItem4Ref} content="Link 4"></Tooltip> | ||
| </ToolbarItem> | ||
| <ToolbarGroup | ||
| variant="action-group-plain" | ||
| align={{ default: 'alignEnd' }} | ||
| gap={{ default: 'gapNone', md: 'gapMd' }} | ||
| > | ||
| <ToolbarGroup variant="action-group-plain" visibility={{ default: 'hidden', lg: 'visible' }}> | ||
| <ToolbarItem> | ||
| <Button aria-label="Settings" isSettings variant="plain" /> | ||
| </ToolbarItem> | ||
| <ToolbarItem> | ||
| <Button aria-label="Help" variant={ButtonVariant.plain} icon={<QuestionCircleIcon />} /> | ||
| </ToolbarItem> | ||
| </ToolbarGroup> | ||
| </ToolbarGroup> | ||
| <ToolbarItem> | ||
| <Dropdown | ||
| isOpen={isDropdownOpen} | ||
| onSelect={onDropdownSelect} | ||
| onOpenChange={(isOpen: boolean) => setIsDropdownOpen(isOpen)} | ||
| toggle={(toggleRef: React.Ref<MenuToggleElement>) => ( | ||
| <MenuToggle | ||
| ref={toggleRef} | ||
| onClick={onDropdownToggle} | ||
| isExpanded={isDropdownOpen} | ||
| icon={<Avatar src={imgAvatar} alt="" size="sm" />} | ||
| variant="plain" | ||
| aria-label="User menu" | ||
| ></MenuToggle> | ||
| )} | ||
| > | ||
| <DropdownList>{userDropdownItems}</DropdownList> | ||
| </Dropdown> | ||
| </ToolbarItem> | ||
| </ToolbarContent> | ||
| </Toolbar> | ||
| </MastheadContent> | ||
| </Masthead> | ||
| ); | ||
|
|
||
| const mainContent = ( | ||
| <> | ||
| <CompassMainHeader title={<Title headingLevel="h1">Content title</Title>} /> | ||
| <CompassContent> | ||
| <CompassPanel>Content</CompassPanel> | ||
| </CompassContent> | ||
| </> | ||
| ); | ||
|
|
||
| return ( | ||
| <Compass | ||
| dock={dockContent} | ||
| main={mainContent} | ||
| backgroundSrcDark="/assets/images/pf-background.svg" | ||
| backgroundSrcLight="/assets/images/pf-background.svg" | ||
| /> | ||
| ); | ||
| }; | ||
25 changes: 25 additions & 0 deletions
25
packages/react-core/src/components/Compass/examples/CompassDockLayout.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,25 @@ | ||
| import { | ||
| Compass, | ||
| CompassContent, | ||
| CompassMainHeader, | ||
| CompassPanel, | ||
| CompassMainHeaderContent | ||
| } from '@patternfly/react-core'; | ||
| import './compass.css'; | ||
|
|
||
| export const CompassBasic: React.FunctionComponent = () => { | ||
| const dockContent = <div>Content</div>; | ||
| const mainContent = ( | ||
| <CompassContent> | ||
| <CompassMainHeader> | ||
| <CompassPanel> | ||
| <CompassMainHeaderContent> | ||
| <div>Content title</div> | ||
| </CompassMainHeaderContent> | ||
| </CompassPanel> | ||
| </CompassMainHeader> | ||
| <div>Content</div> | ||
| </CompassContent> | ||
| ); | ||
| return <Compass dock={dockContent} main={mainContent} />; | ||
| }; | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.