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