-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(Dropdown): extend Heading component and introduce Dropdown.Button (…
…#2694) - Fixes #2439 - Adds `Dropdown.Button` for more explicit API and alignment with `Pagination` and `Breadcrumbs` --------- Co-authored-by: Tobias Barsnes <[email protected]>
- Loading branch information
1 parent
d51732c
commit 519fe18
Showing
14 changed files
with
174 additions
and
109 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,6 @@ | ||
--- | ||
"@digdir/designsystemet-css": patch | ||
"@digdir/designsystemet-react": major | ||
--- | ||
|
||
Dropdown: Add `Dropdown.Button` for more explicit API |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { forwardRef } from 'react'; | ||
|
||
import { Button, type ButtonProps } from '../Button/Button'; | ||
|
||
export type DropdownButtonProps = Omit< | ||
ButtonProps, | ||
'variant' | 'size' | 'color' | ||
>; | ||
|
||
export const DropdownButton = forwardRef< | ||
HTMLButtonElement, | ||
DropdownButtonProps | ||
>(function DropdownButton({ className, ...rest }, ref) { | ||
return <Button ref={ref} variant='tertiary' {...rest} />; | ||
}); |
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,13 +1,11 @@ | ||
import cl from 'clsx/lite'; | ||
import { type HTMLAttributes, forwardRef } from 'react'; | ||
import { forwardRef } from 'react'; | ||
import { Heading, type HeadingProps } from '../Heading'; | ||
|
||
export type DropdownHeadingProps = HTMLAttributes<HTMLHeadingElement>; | ||
export type DropdownHeadingProps = HeadingProps; | ||
|
||
export const DropdownHeading = forwardRef< | ||
HTMLHeadingElement, | ||
DropdownHeadingProps | ||
>(function DropdownHeading({ className, ...rest }, ref) { | ||
return ( | ||
<h2 ref={ref} className={cl('ds-dropdown__heading', className)} {...rest} /> | ||
); | ||
return <Heading ref={ref} {...rest} />; | ||
}); |
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,21 +1,9 @@ | ||
import { forwardRef } from 'react'; | ||
import { type HTMLAttributes, forwardRef } from 'react'; | ||
|
||
import type { ButtonProps } from '../Button'; | ||
import { Button } from '../Button/Button'; | ||
export type DropdownItemProps = HTMLAttributes<HTMLLIElement>; | ||
|
||
export type DropdownItemProps = Omit<ButtonProps, 'variant' | 'size' | 'color'>; | ||
|
||
export const DropdownItem = forwardRef<HTMLButtonElement, DropdownItemProps>( | ||
function DropdownItem({ className, style, ...rest }, ref) { | ||
return ( | ||
<li className={className} style={style}> | ||
<Button | ||
className='ds-dropdown__item' | ||
ref={ref} | ||
variant='tertiary' | ||
{...rest} | ||
/> | ||
</li> | ||
); | ||
export const DropdownItem = forwardRef<HTMLLIElement, DropdownItemProps>( | ||
function DropdownItem({ className, ...rest }, ref) { | ||
return <li ref={ref} {...rest} />; | ||
}, | ||
); |
Oops, something went wrong.