Skip to content

Commit

Permalink
feat: add error status to DropdownMenuItem
Browse files Browse the repository at this point in the history
  • Loading branch information
ifrost1 committed Jun 9, 2022
1 parent cfd2e80 commit b4a4695
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/components/Card/Card.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ a.card {
*/
.card--raised {
box-shadow: var(--eds-box-shadow-md);
border-color: var(--eds-theme-color-background-neutral-default);
transition: border-color var(--eds-anim-fade-quick) var(--eds-anim-ease);

&:hover,
&:focus {
border-color: var(--eds-theme-color-border-neutral-subtle);
}
}

/**
Expand Down
8 changes: 6 additions & 2 deletions src/components/DropdownMenu/DropdownMenu.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
width: 100%;
padding: var(--eds-size-1-and-half) var(--eds-size-2);
text-align: left;
cursor: pointer;

color: var(--eds-theme-color-text-neutral-default);
transition: background var(--eds-anim-fade-quick) var(--eds-anim-ease);
transition: all var(--eds-anim-fade-quick) var(--eds-anim-ease);

&:hover,
&:focus {
Expand All @@ -88,4 +88,8 @@
.dropdown-menu__item--lined & {
border-bottom: 1px solid var(--eds-theme-color-border-neutral-subtle);
}

.dropdown-menu__item--error & {
color: var(--eds-theme-color-text-utility-error);
}
}
21 changes: 21 additions & 0 deletions src/components/DropdownMenu/DropdownMenu.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,24 @@ export const WithIcons = () => (
</DropdownMenuItem>
</DropdownMenu>
);

export const WithDeleteButton = () => (
<DropdownMenu>
<DropdownMenuItem>
<Icon name="schedule" purpose="decorative" size="1.25rem" />
Item 1
</DropdownMenuItem>
<DropdownMenuItem>
<Icon name="schedule" purpose="decorative" size="1.25rem" />
Item 2
</DropdownMenuItem>
<DropdownMenuItem>
<Icon name="schedule" purpose="decorative" size="1.25rem" />
Item 3
</DropdownMenuItem>
<DropdownMenuItem status="error">
<Icon name="schedule" purpose="decorative" size="1.25rem" />
Delete Item
</DropdownMenuItem>
</DropdownMenu>
);
11 changes: 10 additions & 1 deletion src/components/DropdownMenuItem/DropdownMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export interface Props {
* On hover handler for component
*/
onHover?: MouseEventHandler;
/**
* Status variant
* - **error** yields a dropdown item with red text
*/
status?: 'error';
/**
* Stylistic variations of the GridL
* - **lined** yields a dropdown item with a border bottom
Expand All @@ -45,7 +50,10 @@ export interface Props {
* Dropdown menu item within `DropdownMenu`
*/
export const DropdownMenuItem = React.forwardRef<HTMLLIElement, Props>(
({ align, className, href, children, variant, onClick, ...other }, ref) => {
(
{ align, className, href, children, variant, onClick, status, ...other },
ref,
) => {
const TagName = createTagName();

function createTagName() {
Expand All @@ -61,6 +69,7 @@ export const DropdownMenuItem = React.forwardRef<HTMLLIElement, Props>(
className,
align === 'top-left' && styles['dropdown-menu__item--align-top-left'],
variant === 'lined' && styles['dropdown-menu__item--lined'],
status === 'error' && styles['dropdown-menu__item--error'],
);

return (
Expand Down

0 comments on commit b4a4695

Please sign in to comment.