UNPKG

7.58 kBSCSSView Raw
1@import "../../themes/ionic.globals.ios";
2
3// iOS Toggle
4// --------------------------------------------------
5
6/// @prop - Width of the toggle
7$toggle-ios-width: 51px !default;
8
9/// @prop - Height of the toggle
10$toggle-ios-height: 32px !default;
11
12/// @prop - Border width of the toggle
13$toggle-ios-border-width: 2px !default;
14
15/// @prop - Border radius of the toggle
16$toggle-ios-border-radius: $toggle-ios-height / 2 !default;
17
18/// @prop - Background color of the unchecked toggle
19$toggle-ios-background-color-off: $list-ios-background-color !default;
20
21/// @prop - Border color of the unchecked toggle
22$toggle-ios-border-color-off: grayscale(lighten($list-ios-border-color, 11%)) !default;
23
24/// @prop - Background color of the checked toggle
25$toggle-ios-background-color-on: color($colors-ios, primary) !default;
26
27/// @prop - Width of the toggle handle
28$toggle-ios-handle-width: $toggle-ios-height - ($toggle-ios-border-width * 2) !default;
29
30/// @prop - Height of the toggle handle
31$toggle-ios-handle-height: $toggle-ios-handle-width !default;
32
33/// @prop - Border radius of the toggle handle
34$toggle-ios-handle-border-radius: $toggle-ios-handle-height / 2 !default;
35
36/// @prop - Box shadow of the toggle handle
37$toggle-ios-handle-box-shadow: 0 3px 12px rgba(0, 0, 0, .16), 0 3px 1px rgba(0, 0, 0, .1) !default;
38
39/// @prop - Background color of the toggle handle
40$toggle-ios-handle-background-color: $toggle-ios-background-color-off !default;
41
42/// @prop - Margin of the toggle handle
43$toggle-ios-media-margin: 0 !default;
44
45/// @prop - Transition duration of the toggle icon
46$toggle-ios-transition-duration: 300ms !default;
47
48/// @prop - Opacity of the disabled toggle
49$toggle-ios-disabled-opacity: .3 !default;
50
51// deprecated
52$toggle-ios-item-left-padding: null !default;
53
54/// @prop - Padding top of the toggle positioned on the start in an item
55$toggle-ios-item-start-padding-top: 6px !default;
56
57/// @prop - Padding end of the toggle positioned on the start in an item
58$toggle-ios-item-start-padding-end: 16px !default;
59
60/// @prop - Padding bottom of the toggle positioned on the start in an item
61$toggle-ios-item-start-padding-bottom: 5px !default;
62
63/// @prop - Padding start of the toggle positioned on the start in an item
64$toggle-ios-item-start-padding-start: 0 !default;
65
66// deprecated
67$toggle-ios-item-right-padding: null !default;
68
69/// @prop - Padding top of the toggle positioned on the end in an item
70$toggle-ios-item-end-padding-top: 6px !default;
71
72/// @prop - Padding end of the toggle positioned on the end in an item
73$toggle-ios-item-end-padding-end: ($item-ios-padding-end / 2) !default;
74
75/// @prop - Padding bottom of the toggle positioned on the end in an item
76$toggle-ios-item-end-padding-bottom: 5px !default;
77
78/// @prop - Padding start of the toggle positioned on the end in an item
79$toggle-ios-item-end-padding-start: $item-ios-padding-start !default;
80
81// iOS Toggle
82// -----------------------------------------
83
84.toggle-ios {
85 position: relative;
86 display: block;
87
88 width: $toggle-ios-width;
89 height: $toggle-ios-height;
90
91 box-sizing: content-box;
92
93 contain: strict;
94}
95
96
97// iOS Toggle Background Track: Unchecked
98// -----------------------------------------
99
100.toggle-ios .toggle-icon {
101 @include border-radius($toggle-ios-border-radius);
102
103 position: relative;
104 display: block;
105
106 width: 100%;
107 height: 100%;
108
109 background-color: $toggle-ios-border-color-off;
110 transition: background-color $toggle-ios-transition-duration;
111
112 pointer-events: none;
113}
114
115
116// iOS Toggle Background Oval: Unchecked
117// -----------------------------------------
118
119.toggle-ios .toggle-icon::before {
120 @include position($toggle-ios-border-width, $toggle-ios-border-width, $toggle-ios-border-width, $toggle-ios-border-width);
121 @include border-radius($toggle-ios-border-radius);
122
123 position: absolute;
124
125 background-color: $toggle-ios-background-color-off;
126
127 content: "";
128 transform: scale3d(1, 1, 1);
129 transition: transform $toggle-ios-transition-duration;
130}
131
132
133// iOS Toggle Inner Knob: Unchecked
134// -----------------------------------------
135
136.toggle-ios .toggle-inner {
137 @include position($toggle-ios-border-width, null, null, $toggle-ios-border-width);
138 @include border-radius($toggle-ios-handle-border-radius);
139
140 position: absolute;
141
142 width: $toggle-ios-handle-width;
143 height: $toggle-ios-handle-height;
144
145 background-color: $toggle-ios-handle-background-color;
146 box-shadow: $toggle-ios-handle-box-shadow;
147
148 transition: transform $toggle-ios-transition-duration, width 120ms ease-in-out 80ms, left 110ms ease-in-out 80ms, right 110ms ease-in-out 80ms;
149
150 will-change: transform;
151 contain: strict;
152}
153
154
155// iOS Toggle Background Track: Checked
156// -----------------------------------------
157
158.toggle-ios.toggle-checked .toggle-icon {
159 background-color: $toggle-ios-background-color-on;
160}
161
162
163// iOS Toggle Background Oval: Activated or Checked
164// -----------------------------------------
165
166.toggle-ios.toggle-activated .toggle-icon::before,
167.toggle-ios.toggle-checked .toggle-icon::before {
168 transform: scale3d(0, 0, 0);
169}
170
171
172// iOS Toggle Inner Knob: Checked
173// -----------------------------------------
174
175.toggle-ios.toggle-checked .toggle-inner {
176 @include transform(translate3d($toggle-ios-width - $toggle-ios-handle-width - ($toggle-ios-border-width * 2), 0, 0));
177}
178
179
180// iOS Toggle Background Oval: Activated and Checked
181// -----------------------------------------
182
183.toggle-ios.toggle-activated.toggle-checked .toggle-inner::before {
184 transform: scale3d(0, 0, 0);
185}
186
187
188// iOS Toggle Inner Knob: Activated and Unchecked
189// -----------------------------------------
190
191.toggle-ios.toggle-activated .toggle-inner {
192 width: $toggle-ios-handle-width + 6;
193}
194
195
196// iOS Toggle Inner Knob: Activated and Checked
197// -----------------------------------------
198
199.toggle-ios.toggle-activated.toggle-checked .toggle-inner {
200 // when pressing down on the toggle and IS checked
201 // make the knob wider and move it left a bit
202 @include position-horizontal($toggle-ios-border-width - 6, null);
203}
204
205
206// iOS Toggle: Disabled
207// -----------------------------------------
208
209.toggle-ios.toggle-disabled,
210.item-ios.item-toggle-disabled ion-label {
211 opacity: $toggle-ios-disabled-opacity;
212
213 pointer-events: none;
214}
215
216
217// iOS Toggle Within An Item
218// -----------------------------------------
219
220.item-ios .toggle-ios {
221 @include margin($toggle-ios-media-margin);
222
223 @include deprecated-variable(padding, $toggle-ios-item-right-padding) {
224 @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);
225 }
226}
227
228.item-ios .toggle-ios[item-left], // deprecated
229.item-ios .toggle-ios[item-start] {
230 @include deprecated-variable(padding, $toggle-ios-item-left-padding) {
231 @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);
232 }
233}
234
235
236// iOS Toggle Color Mixin
237// --------------------------------------------------
238
239@mixin ios-toggle-theme($color-name, $color-base) {
240
241 .toggle-ios-#{$color-name}.toggle-checked .toggle-icon {
242 background-color: $color-base;
243 }
244
245}
246
247
248// Generate iOS Toggle Colors
249// --------------------------------------------------
250
251@each $color-name, $color-base, $color-contrast in get-colors($colors-ios) {
252 @include ios-toggle-theme($color-name, $color-base);
253}