Skip to content

Commit 5d68491

Browse files
authored
Merge pull request #280 from US-CBP/feature/dropdown-caret-rotate
Update dropdown caret implementation and rotate on open.
2 parents 5925396 + 8baf2aa commit 5d68491

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

packages/web-components/src/components/cbp-dropdown/cbp-dropdown.scss

+20
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
cbp-dropdown {
7171
display: block;
7272

73+
// Adjustments for attached buttons e.g., pagination
7374
&:has([slot="cbp-dropdown-attached-button-start"]),
7475
&:has([slot="cbp-dropdown-attached-button-end"]) {
7576
--cbp-dropdown-chevron-down: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 320 512" fill="%231b1b1b"><path d="M137.4 374.6c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8L32 192c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z"/></svg>');
@@ -123,6 +124,21 @@ cbp-dropdown {
123124
button {
124125
appearance: none;
125126
white-space: nowrap;
127+
padding-inline-end: var(--cbp-space-9x);
128+
129+
&::before {
130+
box-sizing: border-box;
131+
content: '';
132+
position: absolute;
133+
top: 0;
134+
right: 0;
135+
display: block;
136+
border-radius: 0 var(--cbp-form-field-border-radius) var(--cbp-form-field-border-radius) 0;
137+
width: var(--cbp-space-9x);
138+
min-height: var(--cbp-space-9x);
139+
background: right calc( (var(--cbp-space-9x) / 2 ) - 8px) top calc( (var(--cbp-space-9x) / 2 ) - 8px) no-repeat var(--cbp-form-field-select-chevron),
140+
var(--cbp-form-field-color-border);
141+
}
126142

127143
.cbp-dropdown-label,
128144
.cbp-dropdown-placeholder {
@@ -207,6 +223,10 @@ cbp-dropdown {
207223
&[open] {
208224
--cbp-form-field-border-radius: var(--cbp-border-radius-soft) var(--cbp-border-radius-soft) 0 0;
209225

226+
button::before {
227+
transform: rotate(180deg);
228+
}
229+
210230
.cbp-dropdown-menu {
211231
display: block;
212232
}

packages/web-components/src/components/cbp-form-field/cbp-form-field.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ cbp-form-field {
238238
}
239239
}
240240

241-
select:not([multiple]):not([size]),
242-
cbp-dropdown .cbp-custom-form-control {
241+
// Selects do not allow ::before pseudo element for a faux-button, so this is implemented differently than cbp-dropdown.
242+
select:not([multiple]):not([size]) {
243243
// Simple chevron replacement, no background
244244
//background: right var(--cbp-space-2x) top var(--cbp-space-3x) no-repeat var(--cbp-form-field-color-bg) var(--cbp-form-field-select-chevron);
245245
//padding-inline-end: var(--cbp-space-5x);

0 commit comments

Comments
 (0)