summaryrefslogtreecommitdiffstats
path: root/WebContent/VAADIN/themes/valo/components/_combobox.scss
blob: 0b756126ffeed7e315b1207e0bc9ea8b3eb67bf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
/**
 * Outputs the selectors and properties for the ComboBox component.
 *
 * @param {string} $primary-stylename (v-filterselect) - the primary style name for the selectors
 * @param {bool} $include-additional-styles - should the mixin output all the different style variations of the component
 *
 * @group combobox
 */
@mixin valo-combobox ($primary-stylename: v-filterselect, $include-additional-styles: contains($v-included-additional-styles, combobox)) {

  .#{$primary-stylename} {
    position: relative;
    width: $v-default-field-width;
    @include valo-combobox-style;
    white-space: nowrap;

    .v-icon {
      position: absolute;
      pointer-events: none;
    }
  }

  .#{$primary-stylename}-error {
    .#{$primary-stylename}-input {
      @include valo-textfield-error-style;
    }

    .#{$primary-stylename}-button {
      color: $v-error-indicator-color;
      border-color: $v-error-indicator-color;
    }
  }

  .#{$primary-stylename}-suggestpopup {
    @include valo-combobox-popup-style;
  }

  .#{$primary-stylename}-no-input {
    @include valo-combobox-no-input-style;
  }


  @if $include-additional-styles {
    .#{$primary-stylename}-borderless {
      .#{$primary-stylename}-input {
        @include valo-textfield-borderless-style;
      }
      .#{$primary-stylename}-button {
        border: none;
        color: inherit;
        @include opacity(.5);
      }
      &.#{$primary-stylename}-prompt .#{$primary-stylename}-input {
        @include valo-textfield-prompt-style(transparent);
      }
    }

    .#{$primary-stylename}-align-right input {
      text-align: right;
    }

    .#{$primary-stylename}-align-center input {
      text-align: center;
    }

    .#{$primary-stylename}-tiny {
      @include valo-combobox-style($unit-size: $v-unit-size--tiny, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal);
      font-size: $v-font-size--tiny;
    }

    .#{$primary-stylename}-compact,
    .#{$primary-stylename}-small {
      @include valo-combobox-style($unit-size: $v-unit-size--small, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal);
    }

    .#{$primary-stylename}-small {
      font-size: $v-font-size--small;
    }

    .#{$primary-stylename}-large {
      @include valo-combobox-style($unit-size: $v-unit-size--large, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal);
      font-size: $v-font-size--large;
    }

    .#{$primary-stylename}-huge {
      @include valo-combobox-style($unit-size: $v-unit-size--huge, $bevel: null, $shadow: null, $gradient: null, $border: null, $border-radius: null, $background-color: null, $states: normal);
      font-size: $v-font-size--huge;
    }
  }
}


/**
 * Outputs the styles for a combobox variant.
 *
 * @param {size} $unit-size ($v-unit-size) - The sizing of the combobox, which corresponds its height
 * @param {color} $font-color (null) - The font color of the combobox. Computed from the $background-color by default.
 * @param {number} $font-weight (max(400, $v-font-weight)) - The font weight of the combobox
 * @param {size} $font-size (null) - The font size of the combobox. Inherited from the parent by default.
 * @param {color} $background-color ($v-textfield-background-color) - The background color of the combobox
 * @param {list} $border ($v-textfield-border) - The border of the combobox
 * @param {size} $border-radius ($v-textfield-border-radius) - The border-radius of the combobox
 * @param {list} $gradient (none) - Valo specific gradient value. See the documentation for $v-gradient.
 * @param {list} $bevel ($v-textfield-bevel) - Box-shadow value according to $v-bevel documentation
 * @param {list} $shadow ($v-textfield-shadow) - Box-shadow value according to $v-shadow documentation
 * @param {list} $states (normal focus disabled) - The combobox states for which to output corresponding styles
 *
 * @group combobox
 */
@mixin valo-combobox-style (
    $unit-size: $v-unit-size,

    $font-color: null,
    $font-weight: max(400, $v-font-weight),
    $font-size: null,

    $background-color: $v-textfield-background-color,
    $border: $v-textfield-border,
    $border-radius: $v-textfield-border-radius,

    $gradient: none,
    $bevel: $v-textfield-bevel,
    $shadow: $v-textfield-shadow,

    $states: normal focus disabled
  ) {

    height: $unit-size;
    border-radius: $border-radius;

  [class*="input"] {
    @include valo-combobox-input-style(
          $unit-size: $unit-size,
          $gradient: $gradient,
          $bevel: $bevel,
          $shadow: $shadow,
          $border: $border,
          $border-radius: $border-radius,
          $background-color: $background-color,
          $font-color: $font-color,
          $font-size: $font-size,
          $font-weight: $font-weight,
          $states: $states);
  }

  .v-icon + [class*="input"] {
    padding-left: $unit-size;
  }

  img.v-icon {
    $padding-width: ceil($unit-size/6);
    max-height: $unit-size;
    @if $border-radius {
      $padding-width: $padding-width + ceil($border-radius/3);
    }
    margin-left: $padding-width;
  }

  span.v-icon {
    color: valo-font-color($background-color);
    width: $unit-size;
    line-height: 1;
    padding-top: .12em;
  }

  &[class*="prompt"] > [class*="input"] {
    @include valo-textfield-prompt-style($background-color);
  }

  [class$="button"] {
    @include valo-combobox-button-style($unit-size: $unit-size, $bevel: $bevel, $background-color: $background-color, $border-radius: $border-radius, $border: $border);
  }

  &.v-disabled  {
    @include opacity($v-textfield-disabled-opacity);
    & [class$="button"] {
      cursor: default;
      pointer-events: none;
      &:active:after {
        display: none;
      }
    }
  }

  &.v-readonly {
    [class*="input"] {
      @include valo-textfield-readonly-style;
    }

    [class$="button"] {
      cursor: default;
      pointer-events: none;
      &:active:after {
        display: none;
      }
    }
  }
}


/**
 * Outputs the styles for a combobox variant input element.
 * 
 * @param {size} $unit-size ($v-unit-size) - The sizing of the input (affects the padding only, width and height are 100%)
 * @param {size | list} $padding (null) - The padding of the input. Computed from other parameters by default.
 * @param {color} $font-color (null) - The font color of the input. Computed from the $background-color by default.
 * @param {number} $font-weight (null) - The font weight of the input. Inherited from the parent by default.
 * @param {size} $font-size (null) - The font size of the combobox. Inherited from the parent by default.
 * @param {color} $background-color ($v-textfield-background-color) - The background color of the input
 * @param {list} $border ($v-textfield-border) - The border of the input
 * @param {size} $border-radius ($v-textfield-border-radius) - The border-radius of the input
 * @param {list} $gradient (none) - Valo specific gradient value. See the documentation for $v-gradient.
 * @param {list} $bevel ($v-textfield-bevel) - Box-shadow value according to $v-bevel documentation
 * @param {list} $shadow ($v-textfield-shadow) - Box-shadow value according to $v-shadow documentation
 * @param {list} $states (normal focus disabled) - The combobox states for which to output corresponding styles
 *
 * @group combobox
 */
@mixin valo-combobox-input-style (
    $unit-size: $v-unit-size,
    $padding: null,

    $font-color: null,
    $font-weight: null,
    $font-size: null,

    $background-color: $v-textfield-background-color,
    $border: $v-textfield-border,
    $border-radius: $v-textfield-border-radius,

    $gradient: none,
    $bevel: $v-bevel,
    $shadow: $v-shadow,

    $states: normal focus disabled
) {
  @include box-sizing(border-box);
  @include valo-textfield-style($unit-size: $unit-size,
                                $padding: $padding,
                                $font-color: $font-color,
                                $font-weight: $font-weight,
                                $font-size: $font-size,
                                $background-color: $background-color,
                                $border: $border,
                                $border-radius: $border-radius,
                                $gradient: $gradient,
                                $bevel: $bevel,
                                $shadow: $shadow,
                                $states: $states);
  width: 100% !important; // Need to override calculated inline style which is sometimes added
  height: 100%;
  padding-right: round($unit-size * 1.2);
  border-radius: inherit;
}


/**
 * Outputs the styles for a combobox variant button element.
 * 
 * @param {size} $unit-size ($v-unit-size) - The sizing of the button, which corresponds its width.
 * @param {list} $bevel ($v-textfield-bevel) - Box-shadow value according to $v-bevel documentation
 * @param {color} $background-color ($v-textfield-background-color) - The background color of the input, which affects the font color of the button
 * @param {size} $border-radius ($v-textfield-border-radius) - The border-radius of the input, which affects the border-radius of the button
 * @param {list} $border ($v-textfield-border) - The border of the input, which affects the border of the button
 *
 * @group combobox
 */
@mixin valo-combobox-button-style ($unit-size: $v-unit-size, $bevel: $v-bevel, $background-color: $v-textfield-background-color, $border-radius: $v-border-radius, $border: $v-textfield-border) {
  $border-width: first-number($v-textfield-border) or 0;
  @include valo-tappable;
  position: absolute;
  top: $border-width;
  right: $border-width;
  bottom: $border-width;
  width: $unit-size;
  cursor: pointer;

  @if type-of($background-color) == color {
    border-left: valo-border($color: $background-color, $border: $v-textfield-border, $strength: 0.5);
    color: mix($background-color, valo-font-color($background-color));

    .v-ie8 & {
      background-color: $background-color;
    }
  }

  @if $v-border-radius > 0 {
    $br: $v-border-radius - $border-width;
    border-radius: 0 $br $br 0;
  }

  &:before {
    @include valo-combobox-button-icon-style;

    @if $v-animations-enabled {
      @include transition(color 140ms);
    }
    position: absolute;
    width: $unit-size;
    text-align: center;
    top: 50%;
    line-height: 1;
    margin-top: -.47em;
  }

  @if $v-hover-styles-enabled and type-of($background-color) == color {
    &:hover:before {
      color: valo-font-color($background-color);
    }
  }

  &:active:after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border-radius: inherit;
    @if type-of($background-color) == color {
      @include valo-button-active-style($background-color);
    }
  }
}


/**
 * Outputs the font icon styles for the combobox drop down button.
 *
 * @group combobox
 */
@mixin valo-combobox-button-icon-style {
  font-family: FontAwesome;
  content: "\f078";
}


/**
 * Outputs the styles for a combobox popup.
 *
 * @group combobox
 */
@mixin valo-combobox-popup-style {

  @if $v-animations-enabled {
    @if $v-overlay-animate-in {
      &[class*="animate-in"] {
        @include animation($v-overlay-animate-in);
      }
    }
    // No animate-out since that will currently prevent the dropdown from
    // closing when the user selects an item
  }

  [class$="suggestmenu"] {
    @include valo-selection-overlay-style($animate-in: false, $animate-out: false);
    @include box-sizing(border-box);
    position: relative;
    z-index: 1;

    &[style*="height"] {
      @include box-sizing(content-box);
    }
  }

   margin-top: ceil($v-unit-size/8) !important;

  table,
  tbody,
  tr,
  td {
    display: block;
  }

  .gwt-MenuItem {
    @include valo-selection-item-style;
  }

  .gwt-MenuItem-selected {
    @include valo-selection-item-selected-style;
  }

  [class$="status"] {
    position: absolute;
    right: $v-border-radius;
    $bg: scale-color($v-background-color, $lightness: -15%);
    background: transparentize($bg, .1);
    color: valo-font-color($bg);
    border-radius: 0 0 $v-border-radius $v-border-radius;
    height: ceil($v-unit-size*0.6);
    bottom: -(ceil($v-unit-size*0.6));
    font-size: ceil($v-font-size*0.73);
    line-height: ceil($v-unit-size*0.6);
    padding: 0 ceil($v-unit-size/7);
    cursor: default;
    pointer-events: none;

    @if $v-animations-enabled {
       @include animation(valo-animate-in-slide-down 200ms 80ms backwards);
    }

    > * {
      color: valo-font-color($bg);
      text-decoration: none;
    }
  }

  div[class*="page"] {
    position: absolute;
    z-index: 3;
    right: 0;
    @include opacity(.2);
    cursor: pointer;
    @include transition( all 200ms );
    width: ceil($v-unit-size/1.5);
    height: ceil($v-unit-size/1.5);
    line-height: ceil($v-unit-size/1.5);
    text-align: center;
    font-family: FontAwesome;
    @include transform( scale(.8) );

    color: valo-font-color($v-background-color);

    &:after {
      // Extend click target when hovering over (popup width might change between pages)
      content: "";
      position: absolute;
      display: block;
      border-radius: 50%;
    }

    &:hover {
      @include opacity(1);
      background: rgba($v-background-color, .5);

      &:after {
        top: -10px;
        bottom: -10px;
        left: -20px;
        right: -20px;
      }
    }

    span {
      // Hide text
      display: none;
    }
  }

  &:hover div[class*="page"] {
    @include transform( scale(1) );
  }

  div[class*="prev"] {
    top: 0;
    @include transform-origin( 100% 0% );
    border-radius: 0 $v-border-radius 0 $v-border-radius;
    &:before {
      content: "\f0d8";
    }

  }

  div[class*="next"] {
    bottom: 0;
    @include transform-origin( 100% 100% );
    border-radius: $v-border-radius 0 $v-border-radius 0;
    &:before {
      content: "\f0d7";
    }
  }

  div[class*="-off"] {
    display: none;
  }
}

@mixin valo-combobox-no-input-style {
  cursor: pointer;
  text-shadow: valo-text-shadow();

  @if $v-border-radius != $v-textfield-border-radius {
    border-radius: $v-border-radius;
  }

  [class*="input"] {
    @include user-select(none);
    @include valo-gradient;
    cursor: inherit;
    @include box-shadow(valo-bevel-and-shadow($bevel: $v-bevel, $shadow: $v-shadow, $gradient: $v-gradient));
    @include valo-border-with-gradient($border: $v-border, $color: $v-background-color, $gradient: $v-gradient);
    text-shadow: inherit;
    text-overflow: ellipsis;
    border-radius: inherit;

    &:focus {
      @include valo-textfield-focus-style($bevel: $v-bevel, $shadow: $v-shadow, $gradient: $v-gradient, $background-color: $v-background-color);
    }
  }

  [class$="button"] {
    border-left: none !important;
  }

  &:hover [class$="button"]:before {
    color: inherit;
  }
}