/
toggle.ios.scss
151 lines (99 loc) · 3.82 KB
/
toggle.ios.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
@import "./toggle";
@import "./toggle.ios.vars";
// iOS Toggle
// -----------------------------------------
:host {
--background: #{$toggle-ios-background-color-off};
--background-checked: #{ion-color(primary, base)};
--handle-background: #{$toggle-ios-handle-background-color};
--handle-background-checked: #{$toggle-ios-handle-background-color};
--border-radius: #{$toggle-ios-border-radius};
--handle-border-radius: #{$toggle-ios-handle-border-radius};
box-sizing: content-box;
position: relative;
width: $toggle-ios-width;
height: $toggle-ios-height;
contain: strict;
}
:host(.ion-color.toggle-checked) .toggle-icon {
background: current-color(base);
}
// iOS Toggle Background Track: Unchecked
// -----------------------------------------
.toggle-icon {
@include border-radius(var(--border-radius));
display: block;
position: relative;
width: 100%;
height: 100%;
// Needed to prevent visual glitch in safari/iOS
// See https://github.com/ionic-team/ionic/issues/14626
transform: translate3d(0,0,0);
transition: background-color $toggle-ios-transition-duration;
background: var(--background);
overflow: hidden;
pointer-events: none;
}
// iOS Toggle Inner Knob: Unchecked
// -----------------------------------------
.toggle-inner {
@include position($toggle-ios-border-width, null, null, $toggle-ios-border-width);
@include border-radius(var(--handle-border-radius));
position: absolute;
width: $toggle-ios-handle-width;
height: $toggle-ios-handle-height;
transition: transform $toggle-ios-transition-duration, width 120ms ease-in-out 80ms, left 110ms ease-in-out 80ms, right 110ms ease-in-out 80ms;
background: var(--handle-background);
box-shadow: $toggle-ios-handle-box-shadow;
will-change: transform;
contain: strict;
}
// iOS Toggle Background Track: Checked
// -----------------------------------------
:host(.toggle-checked) .toggle-icon {
background: var(--background-checked);
}
// iOS Toggle Background Oval: Activated or Checked
// -----------------------------------------
:host(.toggle-activated) .toggle-icon::before,
:host(.toggle-checked) .toggle-icon::before {
transform: scale3d(0, 0, 0);
}
// iOS Toggle Inner Knob: Checked
// -----------------------------------------
:host(.toggle-checked) .toggle-inner {
@include transform(translate3d($toggle-ios-width - $toggle-ios-handle-width - ($toggle-ios-border-width * 2), 0, 0));
background: var(--handle-background-checked);
}
// iOS Toggle Background Oval: Activated and Checked
// -----------------------------------------
:host(.toggle-activated.toggle-checked) .toggle-inner::before {
transform: scale3d(0, 0, 0);
}
// iOS Toggle Inner Knob: Activated and Unchecked
// -----------------------------------------
:host(.toggle-activated) .toggle-inner {
width: $toggle-ios-handle-width + 6;
}
// iOS Toggle Inner Knob: Activated and Checked
// -----------------------------------------
:host(.toggle-activated.toggle-checked) .toggle-inner {
// when pressing down on the toggle and IS checked
// make the knob wider and move it left a bit
@include position-horizontal($toggle-ios-border-width - 6, null);
}
// iOS Toggle: Disabled
// -----------------------------------------
// .item-ios.item-toggle-disabled ion-label
:host(.toggle-disabled) {
opacity: $toggle-ios-disabled-opacity;
}
// iOS Toggle Within An Item
// -----------------------------------------
:host(.in-item[slot]) {
@include margin($toggle-ios-media-margin);
@include padding($toggle-ios-item-end-padding-top, $toggle-ios-item-end-padding-end, $toggle-ios-item-end-padding-bottom, $toggle-ios-item-end-padding-start);
}
:host(.in-item[slot="start"]) {
@include padding($toggle-ios-item-start-padding-top, $toggle-ios-item-start-padding-end, $toggle-ios-item-start-padding-bottom, $toggle-ios-item-start-padding-start);
}