mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
87 lines
2.2 KiB
SCSS
87 lines
2.2 KiB
SCSS
|
|
/**
|
|
* Toggle
|
|
* --------------------------------------------------
|
|
*/
|
|
|
|
/* the overall container of the toggle */
|
|
.toggle {
|
|
position: relative;
|
|
display: inline-block;
|
|
}
|
|
|
|
/* hide the actual input checkbox */
|
|
.toggle input {
|
|
display: none;
|
|
}
|
|
|
|
/* the track appearance when the toggle is "off" */
|
|
.toggle .track {
|
|
display: inline-block;
|
|
box-sizing: border-box;
|
|
width: $toggle-width;
|
|
height: $toggle-height;
|
|
border: solid $toggle-border-width $toggle-off-border-color;
|
|
border-radius: $toggle-border-radius;
|
|
background-color: $toggle-off-bg-color;
|
|
content: ' ';
|
|
cursor: pointer;
|
|
|
|
transition-timing-function: ease-in-out;
|
|
transition-duration: $toggle-transition-duration;
|
|
transition-property: background-color, border;
|
|
}
|
|
|
|
/* the handle (circle) thats inside the toggle's track area */
|
|
/* also the handle's appearance when it is "off" */
|
|
.toggle .handle {
|
|
@include transition($toggle-transition-duration ease-in-out);
|
|
position: absolute;
|
|
top: $toggle-border-width;
|
|
left: $toggle-border-width;
|
|
display: block;
|
|
width: $toggle-handle-width;
|
|
height: $toggle-handle-height;
|
|
border-radius: $toggle-handle-radius;
|
|
background-color: $toggle-handle-off-bg-color;
|
|
|
|
/* used to create a larger (but hidden) hit area to slide the handle */
|
|
&:before {
|
|
position: absolute;
|
|
top: -4px;
|
|
left: ( ($toggle-handle-width / 2) * -1) - 8;
|
|
padding: ($toggle-handle-height / 2) + 5 ($toggle-handle-width + 7);
|
|
content: " ";
|
|
}
|
|
}
|
|
|
|
/* the track when the toggle is "on" */
|
|
.toggle input:checked + .track {
|
|
border-color: $toggle-on-border-color;
|
|
background-color: $toggle-on-bg-color;
|
|
}
|
|
|
|
/* the handle when the toggle is "on" */
|
|
.toggle input:checked + .track .handle {
|
|
@include translate3d($toggle-width - $toggle-handle-width - ($toggle-border-width * 2), 0, 0);
|
|
background-color: $toggle-handle-on-bg-color;
|
|
}
|
|
|
|
/* make sure list item content have enough padding on right to fit the toggle */
|
|
.item-toggle {
|
|
padding-right: ($item-padding * 3) + $toggle-width;
|
|
|
|
&.active,
|
|
&:active {
|
|
box-shadow: none;
|
|
}
|
|
}
|
|
|
|
/* position the toggle to the right within a list item */
|
|
.item-toggle .toggle {
|
|
position: absolute;
|
|
top: $item-padding / 2;
|
|
right: $item-padding;
|
|
z-index: 3;
|
|
}
|