Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dropdownmenu): css changes and data attrs #2387

Merged
merged 4 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/eleven-peaches-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@digdir/designsystemet-css": patch
"@digdir/designsystemet-react": patch
---

dropdownmenu: Style using data attributes
44 changes: 15 additions & 29 deletions packages/css/dropdownmenu.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
.ds-dropdownmenu {
--dsc-dropdownmenu-background: var(--ds-color-neutral-background-default);
--dsc-dropdownmenu-padding: var(--ds-spacing-2);
--dsc-dropdownmenu-border-radius: min(1rem, var(--ds-border-radius-md));
--dsc-dropdownmenu-border: 1px solid var(--ds-color-neutral-border-subtle);
--dsc-dropdownmenu-min-width: 260px;
--dsc-dropdownmenu-shadow: var(--ds-shadow-md);
--dsc-dropdownmenu-hr-border-color: var(--ds-color-neutral-border-subtle);
--dsc-dropdownmenu-padding: var(--ds-spacing-3) var(--ds-spacing-2);
--dsc-dropdownmenu-min-width: 16rem;
--dsc-dropdownmenu-item-padding: 0 var(--ds-spacing-4);
--dsc-dropdownmenu-header-padding: var(--ds-spacing-2) var(--ds-spacing-4);

Expand All @@ -14,30 +9,21 @@
z-index: 1500;
margin: 0;
list-style: none;
border-radius: var(--dsc-dropdownmenu-border-radius);
box-shadow: var(--dsc-dropdownmenu-shadow);
background-color: var(--dsc-dropdownmenu-background);
border: var(--dsc-dropdownmenu-border);
border-radius: min(1rem, var(--ds-border-radius-md));
box-shadow: var(--ds-shadow-md);
background-color: var(--ds-color-neutral-background-default);
border: 1px solid var(--ds-color-neutral-border-subtle);
min-width: var(--dsc-dropdownmenu-min-width);
}

.ds-dropdownmenu--sm {
--dsc-dropdownmenu-padding: var(--ds-spacing-2);
--dsc-dropdownmenu-min-width: 240px;
}

.ds-dropdownmenu--md {
--dsc-dropdownmenu-padding: var(--ds-spacing-3) var(--ds-spacing-2);
--dsc-dropdownmenu-min-width: 260px;
}

.ds-dropdownmenu--lg {
--dsc-dropdownmenu-padding: var(--ds-spacing-4) var(--ds-spacing-2);
--dsc-dropdownmenu-min-width: 280px;
}
&[data-size='sm'] {
--dsc-dropdownmenu-padding: var(--ds-spacing-2);
--dsc-dropdownmenu-min-width: 15rem;
}

.ds-dropdownmenu > hr {
border-color: var(--dsc-dropdownmenu-hr-border-color) !important;
&[data-size='lg'] {
--dsc-dropdownmenu-padding: var(--ds-spacing-4) var(--ds-spacing-2);
--dsc-dropdownmenu-min-width: 18rem;
}
}

.ds-dropdownmenu__item {
Expand All @@ -46,7 +32,7 @@
width: 100%;
}

.ds-dropdownmenu__section {
.ds-dropdownmenu__group {
margin: 0;
padding: 0;
list-style: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ export const DropdownMenuContent = forwardRef<
ref: floatingRef,
tabIndex: undefined,
})}
className={cl(
'ds-dropdownmenu',
`ds-dropdownmenu--${size}`,
className,
)}
className={cl('ds-dropdownmenu', className)}
data-size={size}
{...rest}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const DropdownMenuGroup = forwardRef<
{...(heading ? { 'aria-labelledby': headingId } : {})}
ref={ref}
role='group'
className={'ds-dropdownmenu__section'}
className={'ds-dropdownmenu__group'}
Barsnes marked this conversation as resolved.
Show resolved Hide resolved
{...rest}
>
{heading && (
Expand Down
Loading