Skip to content

Commit 0b9982f

Browse files
CopilotGitHub Copilotmfranzke
authored
feat: adapt CustomSelect styles to native select ::picker pseudo-element (#5585)
* Initial plan * feat: adapt CustomSelect styles to native select picker Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com> * refactor: remove redundant overflow-y property Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com> * docs: improve comments for option height calculation Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: GitHub Copilot <copilot@github.com> Co-authored-by: mfranzke <787658+mfranzke@users.noreply.github.com>
1 parent 53bce15 commit 0b9982f

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

packages/components/src/components/select/select.scss

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@use "@db-ux/core-foundations/build/styles/colors";
44
@use "@db-ux/core-foundations/build/styles/icons";
55
@use "@db-ux/core-foundations/build/styles/fonts";
6+
@use "@db-ux/core-foundations/build/styles/helpers";
67
@use "../../styles/internal/form-components";
78
@use "../../styles/internal/component";
89
@use "../../styles/internal/select-components";
@@ -67,18 +68,64 @@
6768
/* stylelint-disable-next-line selector-pseudo-element-no-unknown */
6869
:is(::picker(select)) {
6970
@extend %default-card;
71+
72+
// Adapted from .db-custom-select-dropdown
73+
position: absolute;
74+
z-index: 32;
75+
box-shadow: variables.$db-elevation-md;
76+
min-inline-size: variables.$db-sizing-xl;
77+
max-inline-size: calc(
78+
100vw - 2 * #{variables.$db-spacing-fixed-sm}
79+
);
80+
81+
// Adapted from .db-card
82+
background-color: colors.$db-adaptive-bg-basic-level-1-default;
83+
padding: variables.$db-spacing-fixed-sm;
84+
85+
// Adapted from .db-custom-select-list
86+
overflow-block: auto;
87+
88+
/* (option height + padding) * 5.5 items (showing partial item to indicate more content) + list padding */
89+
max-block-size: calc(
90+
5.5 *
91+
(
92+
(
93+
#{form-components.$font-size-height} - 2 *
94+
#{variables.$db-border-width-3xs}
95+
) +
96+
2 * #{variables.$db-spacing-fixed-sm}
97+
) +
98+
(#{variables.$db-spacing-fixed-sm} * 2)
99+
);
70100
}
71101

72102
option {
103+
// Adapted from .db-custom-select-list-item
104+
position: relative;
105+
padding: variables.$db-spacing-fixed-sm;
106+
background-color: colors.$db-adaptive-bg-basic-transparent-full-default;
107+
border-radius: variables.$db-border-radius-xs;
108+
box-sizing: border-box;
73109
justify-content: space-between;
74-
110+
75111
// change order of the included text and pseudo-element within this flexbox item, to make sure the icon is always on the right
76112
flex-direction: row-reverse;
77113

78114
&:checked {
79115
font-weight: 700;
80116
}
81117

118+
// Hover states adapted from .db-custom-select-list-item
119+
&:not(:checked) {
120+
@include helpers.hover {
121+
background-color: colors.$db-adaptive-bg-basic-transparent-full-hovered;
122+
}
123+
124+
@include helpers.active {
125+
background-color: colors.$db-adaptive-bg-basic-transparent-full-pressed;
126+
}
127+
}
128+
82129
/* stylelint-disable-next-line selector-pseudo-element-no-unknown */
83130
:is(&::checkmark) {
84131
@extend %icon;

0 commit comments

Comments
 (0)