UNPKG

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