-
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.
Fix(web-react): HeaderDialogLink now accept a NextLink #DS-1003
- Loading branch information
1 parent
48bb80b
commit 5bf52c1
Showing
4 changed files
with
53 additions
and
41 deletions.
There are no files selected for viewing
23 changes: 16 additions & 7 deletions
23
packages/web-react/src/components/Header/HeaderDialogLink.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 |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import React from 'react'; | ||
import React, { ElementType, forwardRef } from 'react'; | ||
import classNames from 'classnames'; | ||
import { useStyleProps } from '../../hooks'; | ||
import { HeaderDialogLinkProps } from '../../types'; | ||
import { PolymorphicRef, SpiritDialogHeaderLinkProps } from '../../types'; | ||
import { useHeaderStyleProps } from './useHeaderStyleProps'; | ||
|
||
const HeaderDialogLink = (props: HeaderDialogLinkProps) => { | ||
const { children, isCurrent, ...restProps } = props; | ||
|
||
/* We need an exception for components exported with forwardRef */ | ||
/* eslint no-underscore-dangle: ['error', { allow: ['_HeaderDialogLink'] }] */ | ||
const _HeaderDialogLink = <E extends ElementType = 'a'>( | ||
props: SpiritDialogHeaderLinkProps<E>, | ||
ref: PolymorphicRef<E>, | ||
): JSX.Element => { | ||
const { elementType: ElementTag = 'a', children, isCurrent, ...restProps } = props; | ||
const { classProps } = useHeaderStyleProps({ isCurrentLink: isCurrent }); | ||
const { styleProps, props: otherProps } = useStyleProps(restProps); | ||
|
||
return ( | ||
<a | ||
<ElementTag | ||
{...otherProps} | ||
className={classNames(classProps.headerDialogLink, styleProps.className)} | ||
style={styleProps.style} | ||
ref={ref} | ||
> | ||
{children} | ||
</a> | ||
</ElementTag> | ||
); | ||
}; | ||
|
||
export const HeaderDialogLink = forwardRef<HTMLAnchorElement, SpiritDialogHeaderLinkProps<ElementType>>( | ||
_HeaderDialogLink, | ||
); | ||
|
||
export default HeaderDialogLink; |
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