-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a58c75f
commit 402086e
Showing
2 changed files
with
32 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Heading } from '@utrecht/component-library-react'; | ||
import type { HeadingProps } from '@utrecht/component-library-react'; | ||
import { DetailedHTMLProps, ForwardedRef, HTMLAttributes, PropsWithChildren } from 'react'; | ||
import { forwardRef, useId } from 'react'; | ||
|
||
export interface NavProps extends DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> { | ||
label?: string; | ||
headingLevel?: number; | ||
headingRestProps?: HeadingProps; | ||
} | ||
|
||
export const Nav = forwardRef( | ||
( | ||
{ children, label, headingLevel = 3, className, headingRestProps, ...restProps }: PropsWithChildren<NavProps>, | ||
ref: ForwardedRef<HTMLElement>, | ||
) => { | ||
const headingId = label ? useId() : undefined; | ||
|
||
return ( | ||
<nav ref={ref} className={className} aria-labelledby={headingId} {...restProps}> | ||
{label && ( | ||
<Heading id={headingId} level={headingLevel} aria-hidden="true" hidden {...headingRestProps}> | ||
{label} | ||
</Heading> | ||
)} | ||
{children} | ||
</nav> | ||
); | ||
}, | ||
); | ||
Nav.displayName = 'SocialMediaNav'; |
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