Skip to content

Commit 19dce27

Browse files
fix(dropdown-filter): refactor dropdown filter styles for improved layout
1 parent a2832af commit 19dce27

File tree

1 file changed

+80
-109
lines changed

1 file changed

+80
-109
lines changed

packages/modules/data-widgets/src/themesource/datawidgets/web/_datagrid-dropdown-filter.scss

Lines changed: 80 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,11 @@ $root: ".widget-dropdown-filter";
5050
--wdf-tag-padding: var(--wdf-spacing-tiny) var(--dropdown-outer-spacing, 10px);
5151

5252
&.form-control {
53-
padding: 0;
54-
position: relative;
55-
display: grid;
53+
display: flex;
5654
min-width: 65px;
55+
padding-block: var(--wdf-button-spacing);
56+
padding-inline-end: var(--wdf-button-spacing);
57+
padding-inline-start: var(--wdf-button-spacing);
5758
}
5859

5960
&-popover {
@@ -107,7 +108,9 @@ $root: ".widget-dropdown-filter";
107108

108109
&-input {
109110
border: none;
111+
flex: 1;
110112
margin: 0;
113+
min-width: 50px;
111114
padding: 0;
112115
}
113116

@@ -119,27 +122,29 @@ $root: ".widget-dropdown-filter";
119122

120123
&-input,
121124
&-toggle {
122-
text-align: start;
125+
color: var(--wdf-color);
126+
font-weight: normal;
123127
overflow: hidden;
124-
white-space: nowrap;
128+
text-align: start;
125129
text-overflow: ellipsis;
130+
white-space: nowrap;
126131
}
127132

128133
&-clear {
129-
position: absolute;
130-
padding: 3px 6px;
134+
@include btn-with-cross;
135+
align-items: center;
131136
align-self: center;
132-
justify-self: end;
133137
display: flex;
134-
margin-inline-end: var(--wdf-clear-margin);
135-
border-inline-end: 1px solid var(--gray, #787d87);
136-
@include btn-with-cross;
137-
}
138+
flex-shrink: 0;
139+
justify-self: end;
140+
margin-inline-end: var(--wdf-spacing);
141+
padding: 3px 6px;
142+
position: relative;
138143

139-
&-toggle,
140-
&-input {
141-
color: var(--wdf-color);
142-
font-weight: normal;
144+
&:has(+ #{$root}-state-icon),
145+
&:has(+ #{$root}-toggle) {
146+
border-inline-end: 1px solid var(--gray, #787d87);
147+
}
143148
}
144149

145150
&-state-icon {
@@ -151,10 +156,12 @@ $root: ".widget-dropdown-filter";
151156

152157
&-input-container {
153158
display: flex;
154-
gap: var(--wdf-spacing);
155159
flex-flow: row wrap;
160+
flex: 1;
156161
min-width: 0;
157162
overflow: hidden;
163+
padding: 0;
164+
position: relative;
158165
}
159166

160167
&-remove-icon {
@@ -171,6 +178,16 @@ $root: ".widget-dropdown-filter";
171178
inset-block: var(--wdf-button-spacing);
172179
width: 1px;
173180
}
181+
182+
&-state-icon,
183+
&-toggle {
184+
align-items: center;
185+
display: flex;
186+
flex-shrink: 0;
187+
justify-content: center;
188+
padding-inline-end: 0;
189+
padding-inline-start: 0;
190+
}
174191
}
175192

176193
:where([data-highlighted]) #{$root}-checkbox:not(:checked)::after {
@@ -181,23 +198,22 @@ $root: ".widget-dropdown-filter";
181198
/* Select variant */
182199
:where(#{$root}.variant-select) {
183200
#{$root}-toggle {
184-
padding-block: var(--wdf-button-spacing);
185-
padding-inline-start: var(--wdf-button-spacing);
186-
padding-inline-end: var(--wdf-toggle-inline-end);
187-
}
188-
189-
&:has(#{$root}-clear) #{$root}-toggle {
190-
padding-block: var(--wdf-button-spacing);
191-
padding-inline-start: var(--wdf-button-spacing);
192-
padding-inline-end: var(--wdf-toggle-inline-end-clearable);
201+
flex: 1;
202+
justify-content: flex-start;
203+
padding-inline-start: 0;
193204
}
194205

195206
#{$root}-state-icon {
196-
position: absolute;
197207
align-self: center;
208+
box-sizing: content-box;
198209
justify-self: end;
199210
pointer-events: none;
200-
margin-inline-end: var(--wdf-button-spacing);
211+
}
212+
213+
#{$root}-input-container {
214+
border: none;
215+
background-color: transparent;
216+
margin: 0;
201217
}
202218
}
203219

@@ -210,112 +226,63 @@ $root: ".widget-dropdown-filter";
210226

211227
/* Combobox variant */
212228
:where(#{$root}.variant-combobox) {
213-
& {
214-
grid-template-columns: 1fr var(--wdf-toggle-width);
215-
}
216-
217229
#{$root}-input {
218230
border-radius: inherit;
219-
padding-block: var(--wdf-button-spacing);
220-
padding-inline-start: var(--wdf-button-spacing);
231+
padding-inline-start: 0;
221232
padding-inline-end: 0;
222233
}
223-
224-
&:has(#{$root}-clear) #{$root}-input {
225-
padding-inline-end: var(--wdf-clear-width);
226-
}
227-
228-
#{$root}-toggle {
229-
padding-block: var(--wdf-button-spacing);
230-
padding-inline-start: 4px;
231-
padding-inline-end: var(--wdf-button-spacing);
232-
display: flex;
233-
align-items: center;
234-
}
235234
}
236235

237236
/* Tag Picker variant */
238237
:where(#{$root}.variant-tag-picker) {
239-
& {
240-
grid-template-columns: 1fr var(--wdf-toggle-width);
241-
}
242-
243-
#{$root}-input-container {
244-
padding-block: var(--wdf-button-spacing);
245-
padding-inline-start: var(--wdf-button-spacing);
246-
padding-inline-end: 0;
247-
}
248-
249-
&:has(#{$root}-clear) #{$root}-input-container {
250-
padding-inline-end: var(--wdf-clear-width);
251-
}
252-
253238
#{$root}-selected-item {
239+
align-items: center;
240+
background-color: var(--color-primary-lighter, #e6eaff);
241+
border-radius: 26px;
254242
color: #000;
255-
font-size: var(--font-size-small, 12px);
256-
line-height: 1.334;
257243
display: inline-flex;
258244
flex-flow: row nowrap;
259-
border-radius: 26px;
245+
font-size: var(--font-size-small, 12px);
246+
gap: 8px;
260247
justify-content: center;
248+
line-height: 1.334;
261249
padding: var(--wdf-tag-padding);
262-
align-items: center;
263-
gap: 8px;
264-
background-color: var(--color-primary-lighter, #e6eaff);
265250
&:focus-visible {
266251
outline: var(--brand-primary, #264ae5) auto 1px;
267252
}
268253
}
269254

270255
#{$root}-input {
271-
width: initial;
272256
flex-basis: 0;
273-
min-width: 75px;
257+
min-width: 50px;
258+
width: initial;
274259
}
275260

276261
#{$root}-clear {
277262
border-color: transparent;
278263
}
279-
280-
#{$root}-toggle {
281-
padding-block: var(--wdf-button-spacing);
282-
padding-inline-start: 4px;
283-
padding-inline-end: var(--wdf-button-spacing);
284-
display: flex;
285-
align-items: center;
286-
}
287264
}
288265

289266
/* Tag Picker variant text */
290267
:where(#{$root}.variant-tag-picker-text) {
291-
& {
292-
grid-template-columns: 1fr var(--wdf-toggle-width);
293-
}
294-
295-
#{$root}-input-container {
296-
padding-block: var(--wdf-button-spacing);
297-
padding-inline-start: var(--wdf-button-spacing);
298-
padding-inline-end: 0;
299-
}
300-
301-
&:has(#{$root}-clear) #{$root}-input-container {
302-
padding-inline-end: var(--wdf-clear-width);
303-
}
304-
305268
#{$root}-selected-item {
306-
display: inline-flex;
307-
align-items: center;
308-
color: var(--wdf-color);
309269
border-radius: 2px;
270+
color: var(--wdf-color);
271+
display: none;
272+
overflow: hidden;
273+
position: absolute;
274+
bottom: 0;
275+
left: 0;
276+
right: 0;
277+
top: 0;
278+
text-overflow: ellipsis;
279+
white-space: nowrap;
280+
z-index: 0;
310281

311282
&:focus-visible {
312283
outline: var(--brand-primary, #264ae5) solid 1px;
313284
outline-offset: 2px;
314285
}
315-
316-
&:has(+ #{$root}-selected-item)::after {
317-
content: ",";
318-
}
319286
}
320287

321288
#{$root}-remove-icon {
@@ -327,20 +294,24 @@ $root: ".widget-dropdown-filter";
327294
}
328295

329296
#{$root}-input {
330-
width: initial;
331-
flex-basis: 0;
332297
min-width: 75px;
333-
}
298+
opacity: 0;
299+
width: 100%;
300+
z-index: 1;
334301

335-
#{$root}-clear {
336-
border-color: transparent;
337-
}
302+
&:focus {
303+
opacity: 1;
304+
}
338305

339-
#{$root}-toggle {
340-
padding-block: var(--wdf-button-spacing);
341-
padding-inline-start: 4px;
342-
padding-inline-end: var(--wdf-button-spacing);
343-
display: flex;
344-
align-items: center;
306+
&:placeholder-shown,
307+
&:not(:focus) {
308+
& + #{$root}-selected-item {
309+
display: block;
310+
}
311+
}
312+
313+
&:not(:has(+ #{$root}-selected-item)) {
314+
opacity: 1;
315+
}
345316
}
346317
}

0 commit comments

Comments
 (0)