Skip to content

Commit 9409df8

Browse files
committed
refactor(theme): use only a min-block-size for .dropdown-item
The largest item in a menu item is the badge, so extend line-height to that and adjust padding instead. There's no longer a requirement for a fixed height, rather a min height so that items w/o text content get the proper height
1 parent 0c68442 commit 9409df8

4 files changed

Lines changed: 21 additions & 15 deletions

File tree

projects/element-ng/content-action-bar/si-content-action-bar.component.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
@use 'sass:map';
12
@use '@siemens/element-theme/src/styles/variables/semantic-tokens';
23
@use '@siemens/element-theme/src/styles/bootstrap/variables' as bootstrap-variables;
4+
@use '@siemens/element-theme/src/styles/variables/spacers';
35

46
div > [si-content-action-bar-toggle] {
57
// The siAutoCollapsableList directive reserves space for the overflow toggle by reading its
@@ -10,7 +12,7 @@ div > [si-content-action-bar-toggle] {
1012
// items and preventing resize-triggered expand/collapse from reaching a stable state.
1113
// The fixed inline-size guarantees a deterministic clientWidth at all times so the reserved
1214
// space matches the toggle's actual footprint the moment it becomes visible.
13-
inline-size: calc(1.25rem + 2 * bootstrap-variables.$dropdown-item-padding-y);
15+
inline-size: calc(1.25rem + 2 * map.get(spacers.$spacers, 4));
1416
justify-content: center;
1517
border-radius: semantic-tokens.$element-button-radius;
1618
}

projects/element-theme/src/styles/bootstrap/_badges.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
padding-inline: variables.$badge-padding-x;
2121
margin-block: 0;
2222
margin-inline: map.get(spacers.$spacers, 4);
23-
line-height: 1.25rem;
23+
line-height: variables.$badge-line-height;
2424
flex-shrink: 0;
2525
font-size: typography.$si-font-size-body;
2626
font-weight: typography.$si-font-weight-body;
2727
max-inline-size: 24.5ch;
2828
// Make min-inline-size equal the badge height to create a circular badge when there's only one character.
29-
min-inline-size: calc(1.25rem + 2 * #{variables.$badge-padding-y}); // 1.75rem = same as height
29+
min-inline-size: variables.$badge-height;
3030
text-overflow: ellipsis;
3131
overflow: hidden;
3232
text-align: center;

projects/element-theme/src/styles/bootstrap/_dropdowns.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
display: flex;
9191
flex-wrap: nowrap;
9292
align-items: center;
93-
block-size: calc(1lh + 2 * bootstrap-variables.$dropdown-item-padding-y);
93+
min-block-size: calc(1lh + 2 * bootstrap-variables.$dropdown-item-padding-y);
9494
inline-size: 100%;
9595
padding-block: bootstrap-variables.$dropdown-item-padding-y;
9696
padding-inline: bootstrap-variables.$dropdown-item-padding-x;
@@ -169,6 +169,7 @@
169169
white-space: nowrap; // as with > li > a
170170
font-size: typography.$si-font-size-h5;
171171
font-weight: typography.$si-font-weight-h5;
172+
line-height: bootstrap-variables.$dropdown-line-height;
172173
}
173174

174175
.dropdown-divider {

projects/element-theme/src/styles/bootstrap/_variables.scss

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,17 @@ $nav-tabs-link-hover-border-color: transparent transparent $nav-tabs-border-colo
434434
$nav-tabs-link-active-color: semantic-tokens.$element-action-secondary-text-hover !default;
435435
$nav-tabs-link-active-bg: transparent !default;
436436

437+
// Badges
438+
$badge-font-size: typography.$si-font-size-body;
439+
$badge-font-weight: typography.$si-font-weight-body;
440+
$badge-color: semantic-tokens.$element-text-inverse !default;
441+
$badge-padding-y: map.get(spacers.$spacers, 1);
442+
$badge-padding-x: map.get(spacers.$spacers, 4);
443+
$badge-border-radius: 0.75rem;
444+
$badge-dot-size: 0.625rem;
445+
$badge-line-height: 1.25rem;
446+
$badge-height: calc($badge-line-height + 2 * $badge-padding-y);
447+
437448
// Dropdowns
438449
//
439450
// Dropdown menu container and contents.
@@ -442,7 +453,8 @@ $dropdown-padding-x: 0 !default;
442453
$dropdown-padding-y: map.get(spacers.$spacers, 4) !default;
443454
$dropdown-spacer: 0.125rem !default;
444455
$dropdown-font-size: $font-size-base !default;
445-
$dropdown-line-height: $line-height-base;
456+
// this is to have room for icon and badges
457+
$dropdown-line-height: $badge-height;
446458
$dropdown-color: $body-color !default;
447459
$dropdown-bg: semantic-tokens.$element-base-1 !default;
448460
$dropdown-border-radius: semantic-tokens.$element-radius-2 !default;
@@ -451,7 +463,7 @@ $dropdown-divider-margin-y: 4px !default;
451463
$dropdown-box-shadow: elevation.$element-elevation-2 !default;
452464
$dropdown-link-color: semantic-tokens.$element-text-primary !default;
453465
$dropdown-link-disabled-color: semantic-tokens.$element-text-disabled !default;
454-
$dropdown-item-padding-y: map.get(spacers.$spacers, 4);
466+
$dropdown-item-padding-y: map.get(spacers.$spacers, 2);
455467
$dropdown-item-padding-x: map.get(spacers.$spacers, 5);
456468
$dropdown-header-color: semantic-tokens.$element-text-primary !default;
457469

@@ -517,15 +529,6 @@ $popover-arrow-color: $popover-bg !default;
517529

518530
$popover-arrow-outer-color: $popover-border-color !default;
519531

520-
// Badges
521-
$badge-font-size: typography.$si-font-size-body;
522-
$badge-font-weight: typography.$si-font-weight-body;
523-
$badge-color: semantic-tokens.$element-text-inverse !default;
524-
$badge-padding-y: map.get(spacers.$spacers, 1);
525-
$badge-padding-x: map.get(spacers.$spacers, 4);
526-
$badge-border-radius: 0.75rem;
527-
$badge-dot-size: 0.625rem;
528-
529532
// Modals
530533

531534
// Padding applied to the modal body

0 commit comments

Comments
 (0)