-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(web-react): Introduce Vertical Navigation #DS-1627
- Loading branch information
Showing
17 changed files
with
282 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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
55 changes: 55 additions & 0 deletions
55
packages/web-react/src/components/Navigation/demo/NavigationHorizontalWithDropdown.tsx
This file contains 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,55 @@ | ||
import React, { ElementType, forwardRef } from 'react'; | ||
import { PolymorphicRef, SpiritNavigationActionProps } from '../../../types'; | ||
import Dropdown from '../../Dropdown/Dropdown'; | ||
import DropdownPopover from '../../Dropdown/DropdownPopover'; | ||
import DropdownTrigger from '../../Dropdown/DropdownTrigger'; | ||
import { Icon } from '../../Icon'; | ||
import { Item } from '../../Item'; | ||
import Navigation from '../Navigation'; | ||
import NavigationAction from '../NavigationAction'; | ||
import NavigationItem from '../NavigationItem'; | ||
|
||
/* We need an exception for components exported with forwardRef */ | ||
/* eslint no-underscore-dangle: ['error', { allow: ['_NavigationActionAsDropdownTrigger'] }] */ | ||
const _NavigationActionAsDropdownTrigger = <E extends ElementType = 'a'>( | ||
props: SpiritNavigationActionProps<E>, | ||
ref: PolymorphicRef<E>, | ||
): JSX.Element => { | ||
return <NavigationAction ref={ref} {...props} elementType="button" />; | ||
}; | ||
|
||
const NavigationActionAsDropdownTrigger = forwardRef<HTMLButtonElement, SpiritNavigationActionProps<ElementType>>( | ||
_NavigationActionAsDropdownTrigger, | ||
); | ||
|
||
const NavigationHorizontalWithDropdown = () => { | ||
const [isNavigationActionDropdownOpen, setIsNavigationActionDropdownOpen] = React.useState(false); | ||
|
||
return ( | ||
<Navigation aria-label="Main Navigation"> | ||
<NavigationItem> | ||
<NavigationAction href="/">Link</NavigationAction> | ||
</NavigationItem> | ||
<NavigationItem> | ||
<Dropdown | ||
alignmentX="stretch" | ||
alignmentY="stretch" | ||
id="dropdown-navigation" | ||
isOpen={isNavigationActionDropdownOpen} | ||
onToggle={() => setIsNavigationActionDropdownOpen(!isNavigationActionDropdownOpen)} | ||
> | ||
<DropdownTrigger elementType={NavigationActionAsDropdownTrigger as unknown as HTMLButtonElement}> | ||
Dropdown | ||
<Icon name={`chevron-${isNavigationActionDropdownOpen ? 'up' : 'down'}`} boxSize={20} /> | ||
</DropdownTrigger> | ||
<DropdownPopover> | ||
<Item elementType="a" href="#" label="My Account" /> | ||
<Item elementType="a" href="#" label="Settings" /> | ||
<Item elementType="a" href="#" label="Log out" /> | ||
</DropdownPopover> | ||
</Dropdown> | ||
</NavigationItem> | ||
</Navigation> | ||
); | ||
}; | ||
export default NavigationHorizontalWithDropdown; |
12 changes: 12 additions & 0 deletions
12
packages/web-react/src/components/Navigation/demo/NavigationVertical.tsx
This file contains 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,12 @@ | ||
import React from 'react'; | ||
import Navigation from '../Navigation'; | ||
import NavigationItem from '../NavigationItem'; | ||
|
||
const NavigationVertical = () => { | ||
return ( | ||
<Navigation aria-label="Main Navigation" direction="vertical"> | ||
<NavigationItem>Item</NavigationItem> | ||
</Navigation> | ||
); | ||
}; | ||
export default NavigationVertical; |
25 changes: 25 additions & 0 deletions
25
packages/web-react/src/components/Navigation/demo/NavigationVerticalWithAction.tsx
This file contains 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 React from 'react'; | ||
import Navigation from '../Navigation'; | ||
import NavigationAction from '../NavigationAction'; | ||
import NavigationItem from '../NavigationItem'; | ||
|
||
const NavigationVerticalWithAction = () => { | ||
return ( | ||
<Navigation aria-label="Main Navigation" direction="vertical"> | ||
<NavigationItem> | ||
<NavigationAction href="/">Link</NavigationAction> | ||
</NavigationItem> | ||
<NavigationItem> | ||
<NavigationAction href="/" aria-current="page" isSelected> | ||
Selected | ||
</NavigationAction> | ||
</NavigationItem> | ||
<NavigationItem> | ||
<NavigationAction href="/" isDisabled> | ||
Disabled | ||
</NavigationAction> | ||
</NavigationItem> | ||
</Navigation> | ||
); | ||
}; | ||
export default NavigationVerticalWithAction; |
20 changes: 20 additions & 0 deletions
20
packages/web-react/src/components/Navigation/demo/NavigationVerticalWithButtons.tsx
This file contains 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,20 @@ | ||
import React from 'react'; | ||
import { ButtonLink } from '../../ButtonLink'; | ||
import Navigation from '../Navigation'; | ||
import NavigationItem from '../NavigationItem'; | ||
|
||
const NavigationVerticalWithButtons = () => { | ||
return ( | ||
<Navigation aria-label="Navigation with Buttons" direction="vertical"> | ||
<NavigationItem> | ||
<ButtonLink href="#">Button</ButtonLink> | ||
</NavigationItem> | ||
<NavigationItem> | ||
<ButtonLink href="#" color="secondary"> | ||
Button | ||
</ButtonLink> | ||
</NavigationItem> | ||
</Navigation> | ||
); | ||
}; | ||
export default NavigationVerticalWithButtons; |
37 changes: 37 additions & 0 deletions
37
packages/web-react/src/components/Navigation/demo/NavigationVerticalWithCollapse.tsx
This file contains 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,37 @@ | ||
import React from 'react'; | ||
import { Collapse, useCollapse } from '../../Collapse'; | ||
import { Icon } from '../../Icon'; | ||
import Navigation from '../Navigation'; | ||
import NavigationAction from '../NavigationAction'; | ||
import NavigationItem from '../NavigationItem'; | ||
|
||
const NavigationVerticalWithCollapse = () => { | ||
const { isOpen, toggleHandler } = useCollapse(true); | ||
|
||
return ( | ||
<Navigation aria-label="Vertical Navigation With Collapse" direction="vertical"> | ||
<NavigationItem> | ||
<NavigationAction href="/">Link</NavigationAction> | ||
</NavigationItem> | ||
<NavigationItem> | ||
<NavigationAction elementType="button" onClick={toggleHandler} aria-expanded="true" isSelected> | ||
Menu | ||
<Icon name={`chevron-${isOpen ? 'up' : 'down'}`} size="small" /> | ||
</NavigationAction> | ||
<Collapse id="collapse-navigation" isOpen={isOpen}> | ||
<ul> | ||
<NavigationItem> | ||
<NavigationAction href="/">Nested Link</NavigationAction> | ||
</NavigationItem> | ||
<NavigationItem> | ||
<NavigationAction href="/" isSelected aria-current="page"> | ||
Nested Selected | ||
</NavigationAction> | ||
</NavigationItem> | ||
</ul> | ||
</Collapse> | ||
</NavigationItem> | ||
</Navigation> | ||
); | ||
}; | ||
export default NavigationVerticalWithCollapse; |
Oops, something went wrong.