| 1 |
import styles from '@patternfly/react-styles/css/components/Wizard/wizard'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
|
| 4 |
export interface WizardNavProps extends Omit<React.HTMLProps<HTMLOListElement>, 'type' | 'ref'> { |
| 5 |
/** children should be WizardNavItem components */ |
| 6 |
children?: any; |
| 7 |
/** Aria-label applied to the navigation element */ |
| 8 |
'aria-label'?: string; |
| 9 |
/** Sets the aria-labelledby attribute on the navigation element */ |
| 10 |
'aria-labelledby'?: string; |
| 11 |
/** Whether the navigation is expanded */ |
| 12 |
isExpanded?: boolean; |
| 13 |
/** True to return the inner list without the wrapping navigation element */ |
| 14 |
isInnerList?: boolean; |
| 15 |
/** Additional classes spread to the wizard nav */ |
| 16 |
className?: string; |
| 17 |
} |
| 18 |
|
| 19 |
export const WizardNav: React.FunctionComponent<WizardNavProps> = ({ |
| 20 |
children, |
| 21 |
'aria-label': ariaLabel, |
| 22 |
'aria-labelledby': ariaLabelledBy, |
| 23 |
isExpanded = false, |
| 24 |
isInnerList = false, |
| 25 |
className, |
| 26 |
...props |
| 27 |
}: WizardNavProps) => { |
| 28 |
if (isInnerList) { |
| 29 |
return ( |
| 30 |
<ol className={css(styles.wizardNavList, className)} role="list" {...props}> |
| 31 |
{children} |
| 32 |
</ol> |
| 33 |
); |
| 34 |
} |
| 35 |
|
| 36 |
return ( |
| 37 |
<nav |
| 38 |
className={css(styles.wizardNav, isExpanded && styles.modifiers.expanded, className)} |
| 39 |
aria-label={ariaLabel} |
| 40 |
aria-labelledby={ariaLabelledBy} |
| 41 |
{...props} |
| 42 |
> |
| 43 |
<ol className={css(styles.wizardNavList)} role="list"> |
| 44 |
{children} |
| 45 |
</ol> |
| 46 |
</nav> |
| 47 |
); |
| 48 |
}; |
| 49 |
|
| 50 |
WizardNav.displayName = 'WizardNav'; |