-
Notifications
You must be signed in to change notification settings - Fork 13.5k
/
Copy pathitem.scss
717 lines (533 loc) · 17.8 KB
/
item.scss
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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
@import "./item.vars";
// Item
// --------------------------------------------------
// TODO: FW-4955
:host {
/**
* @prop --background: Background of the item
* @prop --background-activated: Background of the item when pressed. Note: setting this will interfere with the Material Design ripple.
* @prop --background-activated-opacity: Opacity of the item background when pressed
* @prop --background-focused: Background of the item when focused with the tab key
* @prop --background-focused-opacity: Opacity of the item background when focused with the tab key
* @prop --background-hover: Background of the item on hover
* @prop --background-hover-opacity: Opacity of the background of the item on hover
*
* @prop --border-color: Color of the item border
* @prop --border-radius: Radius of the item border
* @prop --border-style: Style of the item border
* @prop --border-width: Width of the item border
*
* @prop --color: Color of the item
* @prop --color-activated: Color of the item when pressed
* @prop --color-focused: Color of the item when focused with the tab key
* @prop --color-hover: Color of the item on hover
*
* @prop --detail-icon-color: Color of the item detail icon
* @prop --detail-icon-opacity: Opacity of the item detail icon
* @prop --detail-icon-font-size: Font size of the item detail icon
*
* @prop --inner-border-width: Width of the item inner border
* @prop --inner-box-shadow: Box shadow of the item inner
* @prop --inner-padding-top: Top padding of the item inner
* @prop --inner-padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the item inner
* @prop --inner-padding-bottom: Bottom padding of the item inner
* @prop --inner-padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the item inner
*
* @prop --min-height: Minimum height of the item
*
* @prop --padding-bottom: Bottom padding of the item
* @prop --padding-end: Right padding if direction is left-to-right, and left padding if direction is right-to-left of the item
* @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the item
* @prop --padding-top: Top padding of the item
*
* @prop --transition: Transition of the item
*
* @prop --ripple-color: Color of the item ripple effect
*
* @prop --highlight-height: The height of the highlight on the item. Only applies to inputs and textareas using the legacy form syntax. DEPRECATED: Highlights can be styled on `ion-input` or `ion-textarea` when using the modern form syntax.
* @prop --highlight-color-focused: The color of the highlight on the item when focused. Only applies to inputs and textareas using the legacy form syntax. DEPRECATED: Highlights can be styled on `ion-input` or `ion-textarea` when using the modern form syntax.
* @prop --highlight-color-valid: The color of the highlight on the item when valid. Only applies to inputs and textareas using the legacy form syntax. DEPRECATED: Highlights can be styled on `ion-input` or `ion-textarea` when using the modern form syntax.
* @prop --highlight-color-invalid: The color of the highlight on the item when invalid. Only applies to inputs and textareas using the legacy form syntax. DEPRECATED: Highlights can be styled on `ion-input` or `ion-textarea` when using the modern form syntax.
*/
/**
* We change the minimum width as the
* font size changes. Using a fixed minimum
* width means that fewer and fewer characters
* can be displayed in the same space as the
* text grows.
*/
--inner-min-width: 4rem;
--border-radius: 0px;
--border-width: 0px;
--border-style: solid;
--padding-top: 0px;
--padding-bottom: 0px;
--padding-end: 0px;
--padding-start: 0px;
--inner-border-width: 0px;
--inner-padding-top: 0px;
--inner-padding-bottom: 0px;
--inner-padding-start: 0px;
--inner-padding-end: 0px;
--inner-box-shadow: none;
--show-full-highlight: 0;
--show-inset-highlight: 0;
--detail-icon-color: initial;
--detail-icon-font-size: 1.25em;
--detail-icon-opacity: 0.25;
--color-activated: var(--color);
--color-focused: var(--color);
--color-hover: var(--color);
--ripple-color: currentColor;
@include font-smoothing();
display: block;
position: relative;
align-items: center;
justify-content: space-between;
outline: none;
color: var(--color);
font-family: $font-family-base;
text-align: initial;
text-decoration: none;
overflow: hidden;
box-sizing: border-box;
}
// Item: Color
// --------------------------------------------------
:host(.ion-color:not(.item-fill-solid):not(.item-fill-outline)) .item-native {
background: current-color(base);
color: current-color(contrast);
}
:host(.ion-color:not(.item-fill-solid):not(.item-fill-outline)) .item-native,
:host(.ion-color:not(.item-fill-solid):not(.item-fill-outline)) .item-inner {
border-color: current-color(shade);
}
// Item: Activated
// --------------------------------------------------
:host(.ion-activated) .item-native {
color: var(--color-activated);
&::after {
background: var(--background-activated);
opacity: var(--background-activated-opacity);
}
}
:host(.ion-color.ion-activated) .item-native {
color: current-color(contrast);
}
// Item: Focused
// --------------------------------------------------
:host(.ion-focused) .item-native {
color: var(--color-focused);
&::after {
background: var(--background-focused);
opacity: var(--background-focused-opacity);
}
}
:host(.ion-color.ion-focused) .item-native {
color: current-color(contrast);
&::after {
background: current-color(contrast);
}
}
// Item: Hover
// --------------------------------------------------
@media (any-hover: hover) {
:host(.ion-activatable:not(.ion-focused):hover) .item-native {
color: var(--color-hover);
&::after {
background: var(--background-hover);
opacity: var(--background-hover-opacity);
}
}
:host(.ion-color.ion-activatable:not(.ion-focused):hover) .item-native {
color: #{current-color(contrast)};
&::after {
background: #{current-color(contrast)};
}
}
}
// Item: Interactive
// --------------------------------------------------
:host(.item-has-interactive-control) {
cursor: pointer;
}
// Item: Disabled
// --------------------------------------------------
:host(.item-interactive-disabled:not(.item-multiple-inputs)) {
cursor: default;
pointer-events: none;
}
:host(.item-disabled) {
cursor: default;
opacity: .3;
pointer-events: none;
}
// Native Item
// --------------------------------------------------
.item-native {
@include border-radius(var(--border-radius));
@include margin(0);
@include padding(var(--padding-top), null, var(--padding-bottom));
@include text-inherit();
/* stylelint-disable */
@include ltr() {
padding-right: var(--padding-end);
padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
}
@include rtl() {
padding-right: calc(var(--padding-start) + var(--ion-safe-area-right, 0px));
padding-left: var(--padding-end);
}
/* stylelint-enable */
display: flex;
position: relative;
// Flex wrap is required here in order to wrap
// the start slot + .item-inner content that
// doesn't fit on the same line
flex-wrap: wrap;
align-items: inherit;
justify-content: inherit;
width: 100%;
min-height: var(--min-height);
transition: var(--transition);
border-width: var(--border-width);
border-style: var(--border-style);
border-color: var(--border-color);
outline: none;
background: var(--background);
overflow: inherit;
z-index: 1;
box-sizing: border-box;
}
// TODO(FW-5289): remove
:host(.item-legacy) .item-native {
flex-wrap: unset;
}
.item-native::-moz-focus-inner {
border: 0;
}
.item-native::after {
@include button-state();
transition: var(--transition);
z-index: -1;
}
button, a {
cursor: pointer;
user-select: none;
-webkit-user-drag: none;
}
// Inner Item
// --------------------------------------------------
.item-inner {
@include margin(0);
@include padding(var(--inner-padding-top), null, var(--inner-padding-bottom));
/* stylelint-disable */
@include ltr() {
padding-right: calc(var(--ion-safe-area-right, 0px) + var(--inner-padding-end));
padding-left: var(--inner-padding-start);
}
@include rtl() {
padding-right: var(--inner-padding-start);
padding-left: calc(var(--ion-safe-area-left, 0px) + var(--inner-padding-end));
}
/* stylelint-enable */
display: flex;
// This is required to work with an inset highlight
position: relative;
// This flex property is required in order to make
// the elements wrap when there is a slotted start
// element and a label
flex: 1 0 0;
flex-direction: inherit;
// Flex wrap is required here in order to wrap
// .input-wrapper content + the end slot that
// doesn't fit on the same line
flex-wrap: wrap;
align-items: inherit;
align-self: stretch;
/**
* The min-width defines when the
* content in the default slot should
* stop wrapping/truncating within its own
* container. At this point the entire
* container will wrap to the next line.
*/
min-width: var(--inner-min-width);
// Max width must be set to 100%, otherwise the
// elements will overflow this container instead
// of wrapping
max-width: 100%;
min-height: inherit;
border-width: var(--inner-border-width);
border-style: var(--border-style);
border-color: var(--border-color);
box-shadow: var(--inner-box-shadow);
overflow: inherit;
box-sizing: border-box;
}
// TODO(FW-5289): remove
:host(.item-legacy) .item-inner {
flex: 1;
flex-wrap: unset;
max-width: unset;
}
// Item Bottom
// --------------------------------------------------
.item-bottom {
@include margin(0);
@include padding(0, null);
/* stylelint-disable */
@include ltr() {
padding-left: calc(var(--padding-start) + var(--ion-safe-area-left, 0px));
padding-right: calc(var(--inner-padding-end) + var(--ion-safe-area-right, 0px));
}
@include rtl() {
padding-left: calc(var(--inner-padding-end) + var(--ion-safe-area-left, 0px));
padding-right: calc(var(--padding-start) + var(--ion-safe-area-right, 0px));
}
/* stylelint-enable */
display: flex;
justify-content: space-between;
}
// Item Detail Icon
// --------------------------------------------------
.item-detail-icon {
/**
* IonItem applies its own end padding. However,
* all IonIcons have the same bounding box meaning
* there may be white space for narrow icons. As
* a result, the white space gives the appearance
* that there is too much end margin. We move the default
* chevron icon over to account for this extra whitespace.
*/
@include margin(null, -6px, null, calc(var(--inner-padding-end) / 2));
color: var(--detail-icon-color);
font-size: var(--detail-icon-font-size);
opacity: var(--detail-icon-opacity);
}
// Item Slots
// --------------------------------------------------
::slotted(ion-icon) {
font-size: 1.6em;
}
::slotted(ion-button) {
--margin-top: 0;
--margin-bottom: 0;
--margin-start: 0;
--margin-end: 0;
z-index: 1;
}
::slotted(ion-label:not([slot="end"])) {
flex: 1;
// Setting width to min-content allows the label to
// shrink and wrap its text instead of moving to its
// own row if there are slotted elements next to it
width: min-content;
/**
* We allow labels in the default
* slot to grow. However, we do not
* want them to grow indefinitely.
*/
max-width: 100%;
}
// Item Input
// --------------------------------------------------
:host(.item-input) {
align-items: center;
}
.input-wrapper {
display: flex;
// This flex property is required in order to keep
// the label from shrinking when there are wide
// elements next to it
flex: 1 0 auto;
flex-direction: inherit;
// Flex wrap is required here in order to wrap
// content in the default slot (such as a label
// and a button) that doesn't fit on the same line
flex-wrap: wrap;
align-items: inherit;
align-self: stretch;
// Max width must be set to 100%, otherwise the
// elements will overflow this container instead
// of wrapping
max-width: 100%;
text-overflow: ellipsis;
overflow: inherit;
box-sizing: border-box;
}
// TODO(FW-5289): remove
:host(.item-legacy) .input-wrapper {
flex: 1;
flex-wrap: unset;
max-width: unset;
}
:host(.item-label-stacked),
:host(.item-label-floating) {
align-items: start;
}
:host(.item-label-stacked) .input-wrapper,
:host(.item-label-floating) .input-wrapper {
flex: 1;
flex-direction: column;
}
// Item Input Highlight
// --------------------------------------------------
.item-highlight,
.item-inner-highlight {
@include position(0, 0, 0, 0);
@include border-radius(inherit);
position: absolute;
width: 100%;
height: 100%;
transform: scaleX(0);
transition: transform 200ms, border-bottom-width 200ms;
z-index: 2;
box-sizing: border-box;
pointer-events: none;
}
// Item Input Focused
// --------------------------------------------------
:host(.item-interactive.ion-focused),
:host(.item-interactive.item-has-focus),
:host(.item-interactive.ion-touched.ion-invalid) {
// If the item has a full border and highlight is enabled, show the full item highlight
--full-highlight-height: #{calc(var(--highlight-height) * var(--show-full-highlight))};
// If the item has an inset border and highlight is enabled, show the inset item highlight
--inset-highlight-height: #{calc(var(--highlight-height) * var(--show-inset-highlight))};
}
:host(.ion-focused) .item-highlight,
:host(.ion-focused) .item-inner-highlight,
:host(.item-has-focus) .item-highlight,
:host(.item-has-focus) .item-inner-highlight {
transform: scaleX(1);
border-style: var(--border-style);
border-color: var(--highlight-background);
}
:host(.ion-focused) .item-highlight,
:host(.item-has-focus) .item-highlight {
border-width: var(--full-highlight-height);
opacity: var(--show-full-highlight);
}
:host(.ion-focused) .item-inner-highlight,
:host(.item-has-focus) .item-inner-highlight {
border-bottom-width: var(--inset-highlight-height);
opacity: var(--show-inset-highlight);
}
:host(.ion-focused.item-fill-solid) .item-highlight,
:host(.item-has-focus.item-fill-solid) .item-highlight {
border-width: calc(var(--full-highlight-height) - 1px);
}
:host(.ion-focused) .item-inner-highlight,
:host(.ion-focused:not(.item-fill-outline)) .item-highlight,
:host(.item-has-focus) .item-inner-highlight,
:host(.item-has-focus:not(.item-fill-outline)) .item-highlight {
border-top: none;
border-right: none;
border-left: none;
}
// Item Input Focus
// --------------------------------------------------
:host(.item-interactive.ion-focused),
:host(.item-interactive.item-has-focus) {
--highlight-background: var(--highlight-color-focused);
}
// Item Input Valid
// --------------------------------------------------
:host(.item-interactive.ion-valid) {
--highlight-background: var(--highlight-color-valid);
}
// Item Input Invalid
// --------------------------------------------------
:host(.item-interactive.ion-invalid) {
--highlight-background: var(--highlight-color-invalid);
}
:host(.item-interactive.ion-invalid) ::slotted([slot="helper"]) {
display: none;
}
::slotted([slot="error"]) {
display: none;
color: var(--highlight-color-invalid);
}
:host(.item-interactive.ion-invalid) ::slotted([slot="error"]) {
display: block;
}
// Item Select
// --------------------------------------------------
:host(:not(.item-label)) ::slotted(ion-select.legacy-select) {
--padding-start: 0;
max-width: none;
}
:host(.item-label-stacked) ::slotted(ion-select.legacy-select),
:host(.item-label-floating) ::slotted(ion-select.legacy-select) {
--padding-top: 8px;
--padding-bottom: 8px;
--padding-start: 0;
align-self: stretch;
width: 100%;
max-width: 100%;
}
// Item Datetime
// --------------------------------------------------
:host(:not(.item-label)) ::slotted(ion-datetime) {
--padding-start: 0;
}
:host(.item-label-stacked) ::slotted(ion-datetime),
:host(.item-label-floating) ::slotted(ion-datetime) {
--padding-start: 0;
width: 100%;
}
// Item w/ Multiple Inputs
// --------------------------------------------------
// Multiple inputs in an item should have the input
// cover relative to themselves instead of the item
:host(.item-multiple-inputs) ::slotted(ion-checkbox),
:host(.item-multiple-inputs) ::slotted(ion-datetime),
:host(.item-multiple-inputs) ::slotted(ion-radio),
:host(.item-multiple-inputs) ::slotted(ion-select.legacy-select) {
position: relative;
}
// Item Textarea
// --------------------------------------------------
:host(.item-textarea) {
align-items: stretch;
}
// Item Reorder
// --------------------------------------------------
::slotted(ion-reorder[slot]) {
@include margin(0, null);
}
// Item Button Ripple effect
// --------------------------------------------------
ion-ripple-effect {
color: var(--ripple-color);
}
:host(.item-fill-solid) ::slotted([slot="start"]),
:host(.item-fill-solid) ::slotted([slot="end"]),
:host(.item-fill-outline) ::slotted([slot="start"]),
:host(.item-fill-outline) ::slotted([slot="end"]) {
align-self: center;
}
::slotted([slot="helper"]),
::slotted([slot="error"]),
.item-counter {
padding-top: 5px;
font-size: dynamic-font(12px);
z-index: 1;
}
// Item Max Length Counter
// --------------------------------------------------
.item-counter {
@include margin-horizontal(auto, null);
color: #{$background-color-step-550};
white-space: nowrap;
padding-inline-start: 16px;
}
// Item: Reduced Motion
// --------------------------------------------------
@media (prefers-reduced-motion: reduce) {
.item-highlight,
.item-inner-highlight {
transition: none;
}
}