Skip to content

Commit

Permalink
feat(@clayui/css): Dropdown adds dropdown-menu-width-shrink
Browse files Browse the repository at this point in the history
    - The `dropdown-menu` should only be as wide as the text inside and maxes out at 240px wide. This forces `dropdown-item` text to be on one line.
  • Loading branch information
pat270 committed Dec 15, 2021
1 parent a314710 commit b5f9a8d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/clay-css/src/scss/components/_dropdowns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@

// Dropdown Menu Width

.dropdown-menu-width-shrink {
@include clay-dropdown-menu-variant($dropdown-menu-width-shrink);
}

.dropdown-menu-width-full {
@include clay-css($dropdown-menu-width-full);
}
Expand Down
35 changes: 34 additions & 1 deletion packages/clay-css/src/scss/variables/_dropdowns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,23 @@ $dropdown-item-base: map-deep-merge(
c-kbd-inline: (
line-height: $dropdown-font-size * $line-height-base,
),
'&.autofit-row': (
padding-left: 1rem,
padding-right: 1rem,
autofit-col: (
padding-left: 0.25rem,
padding-right: 0.25rem,
),
),
autofit-row: (
margin-left: 0.25rem,
margin-right: 0.25rem,
width: auto,
autofit-col: (
padding-left: 0.25rem,
padding-right: 0.25rem,
),
),
),
$dropdown-item-base
);
Expand Down Expand Up @@ -736,7 +753,21 @@ $dropdown-full-wide-header-spacer-y: 20px !default;

$dropdown-wide-width: 500px !default;

// Dropdown Menu Width
// .dropdown-menu-width-shrink

$dropdown-menu-width-shrink: () !default;
$dropdown-menu-width-shrink: map-deep-merge(
(
min-width: 0,
white-space: nowrap,
dropdown-item: (
white-space: inherit,
),
),
$dropdown-menu-width-shrink
);

// .dropdown-menu-width-full

$dropdown-menu-width-full: () !default;
$dropdown-menu-width-full: map-merge(
Expand All @@ -750,6 +781,8 @@ $dropdown-menu-width-full: map-merge(
$dropdown-menu-width-full
);

// .dropdown-menu-width-sm

$dropdown-menu-width-sm: () !default;
$dropdown-menu-width-sm: map-merge(
(
Expand Down

0 comments on commit b5f9a8d

Please sign in to comment.