/
toggle.ios.scss
204 lines (157 loc) · 5.42 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
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
@import "./toggle";
@import "./toggle.ios.vars";
// iOS Toggle
// -----------------------------------------
:host {
--track-background: #{$toggle-ios-background-color-off};
--track-background-checked: #{ion-color(primary, base)};
--border-radius: #{$toggle-ios-border-radius};
--handle-background: #{$toggle-ios-handle-background-color};
--handle-background-checked: #{$toggle-ios-handle-background-color};
--handle-border-radius: #{$toggle-ios-handle-border-radius};
--handle-box-shadow: #{$toggle-ios-handle-box-shadow};
--handle-height: #{$toggle-ios-handle-height};
--handle-max-height: #{$toggle-ios-handle-max-height};
--handle-width: #{$toggle-ios-handle-width};
--handle-spacing: #{$toggle-ios-border-width};
--handle-transition: #{$toggle-ios-transition};
}
:host(.legacy-toggle) {
width: $toggle-ios-width;
height: $toggle-ios-height;
contain: strict;
overflow: hidden;
}
// Toggle Native Wrapper
// ----------------------------------------------------------------
.native-wrapper .toggle-icon {
width: $toggle-ios-width;
height: $toggle-ios-height;
/**
* The handle box shadow should not
* overflow outside of the track container.
*/
overflow: hidden;
}
:host(.ion-color.toggle-checked) .toggle-icon {
background: current-color(base);
}
:host(.toggle-activated) .toggle-switch-icon {
opacity: 0;
}
// iOS Toggle Background Track: Unchecked
// ----------------------------------------------------------
.toggle-icon {
// 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;
}
// iOS Toggle Inner Knob: Unchecked
// ----------------------------------------------------------
.toggle-inner {
will-change: transform;
}
// iOS Toggle On/Off Labels
// ----------------------------------------------------------
.toggle-switch-icon {
position: absolute;
top: 50%;
width: 11px;
height: 11px;
transform: translateY(-50%);
transition: opacity $toggle-ios-transition-duration, color $toggle-ios-transition-duration;
}
.toggle-switch-icon {
position: absolute;
color: var(--ion-color-dark);
}
:host(.toggle-ltr) .toggle-switch-icon {
/* stylelint-disable-next-line property-disallowed-list */
right: 6px;
}
:host(.toggle-rtl) .toggle-switch-icon {
/* stylelint-disable property-disallowed-list */
right: initial;
left: 6px;
/* stylelint-enable property-disallowed-list */
}
:host(.toggle-checked) .toggle-switch-icon.toggle-switch-icon-checked {
// The color contrast of iOS default on/off labels fails to meet WCAG 2.0.
// We use Ionic's color contrast variables to meet the WCAG 2.0 standard (AAA).
color: var(--ion-color-contrast, $toggle-ios-on-off-label-checked-color);
}
:host(.toggle-checked) .toggle-switch-icon:not(.toggle-switch-icon-checked) {
opacity: 0;
}
.toggle-switch-icon-checked {
position: absolute;
width: 15px;
height: 15px;
transform: translateY(-50%) rotate(90deg);
}
:host(.toggle-ltr) .toggle-switch-icon-checked {
/* stylelint-disable property-disallowed-list */
right: initial;
left: 4px;
/* stylelint-enable property-disallowed-list */
}
:host(.toggle-rtl) .toggle-switch-icon-checked {
/* stylelint-disable-next-line property-disallowed-list */
right: 4px;
}
// 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 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: calc(var(--handle-width) + 6px);
}
// iOS Toggle Inner Knob: Activated and Checked
// ----------------------------------------------------------
// when pressing down on the toggle and it IS checked
// the knob is wider so move it left by 6px in the transform
:host(.toggle-ltr.toggle-activated.toggle-checked) .toggle-icon-wrapper {
// transform by 100% - handle width - 6px (width addition on activated)
transform: translate3d(calc(100% - var(--handle-width) - 6px), 0, 0);
}
:host(.toggle-rtl.toggle-activated.toggle-checked) .toggle-icon-wrapper {
// transform by -100% + handle width + 6px (width addition on activated)
transform: translate3d(calc(-100% + var(--handle-width) + 6px), 0, 0);
}
// iOS Toggle: Disabled
// ----------------------------------------------------------
// The toggle and label should use the
// same opacity and match the other form
// controls
:host(.toggle-disabled) {
opacity: $toggle-ios-disabled-opacity;
}
// iOS Toggle Within An Item
// ----------------------------------------------------------
:host(.in-item.legacy-toggle) {
@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.legacy-toggle[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
);
}