_toggle.scss 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /**
  2. * Toggle
  3. * --------------------------------------------------
  4. */
  5. .item-toggle {
  6. pointer-events: none;
  7. }
  8. .toggle {
  9. // set the color defaults
  10. @include toggle-style($toggle-on-default-border, $toggle-on-default-bg);
  11. position: relative;
  12. display: inline-block;
  13. pointer-events: auto;
  14. margin: -$toggle-hit-area-expansion;
  15. padding: $toggle-hit-area-expansion;
  16. &.dragging {
  17. .handle {
  18. background-color: $toggle-handle-dragging-bg-color !important;
  19. }
  20. }
  21. }
  22. .toggle {
  23. &.toggle-light {
  24. @include toggle-style($toggle-on-light-border, $toggle-on-light-bg);
  25. }
  26. &.toggle-stable {
  27. @include toggle-style($toggle-on-stable-border, $toggle-on-stable-bg);
  28. }
  29. &.toggle-positive {
  30. @include toggle-style($toggle-on-positive-border, $toggle-on-positive-bg);
  31. }
  32. &.toggle-calm {
  33. @include toggle-style($toggle-on-calm-border, $toggle-on-calm-bg);
  34. }
  35. &.toggle-assertive {
  36. @include toggle-style($toggle-on-assertive-border, $toggle-on-assertive-bg);
  37. }
  38. &.toggle-balanced {
  39. @include toggle-style($toggle-on-balanced-border, $toggle-on-balanced-bg);
  40. }
  41. &.toggle-energized {
  42. @include toggle-style($toggle-on-energized-border, $toggle-on-energized-bg);
  43. }
  44. &.toggle-royal {
  45. @include toggle-style($toggle-on-royal-border, $toggle-on-royal-bg);
  46. }
  47. &.toggle-dark {
  48. @include toggle-style($toggle-on-dark-border, $toggle-on-dark-bg);
  49. }
  50. }
  51. .toggle input {
  52. // hide the actual input checkbox
  53. display: none;
  54. }
  55. /* the track appearance when the toggle is "off" */
  56. .toggle .track {
  57. @include transition-timing-function(ease-in-out);
  58. @include transition-duration($toggle-transition-duration);
  59. @include transition-property((background-color, border));
  60. display: inline-block;
  61. box-sizing: border-box;
  62. width: $toggle-width;
  63. height: $toggle-height;
  64. border: solid $toggle-border-width $toggle-off-border-color;
  65. border-radius: $toggle-border-radius;
  66. background-color: $toggle-off-bg-color;
  67. content: ' ';
  68. cursor: pointer;
  69. pointer-events: none;
  70. }
  71. /* Fix to avoid background color bleeding */
  72. /* (occurred on (at least) Android 4.2, Asus MeMO Pad HD7 ME173X) */
  73. .platform-android4_2 .toggle .track {
  74. -webkit-background-clip: padding-box;
  75. }
  76. /* the handle (circle) thats inside the toggle's track area */
  77. /* also the handle's appearance when it is "off" */
  78. .toggle .handle {
  79. @include transition($toggle-transition-duration cubic-bezier(0, 1.1, 1, 1.1));
  80. @include transition-property((background-color, transform));
  81. position: absolute;
  82. display: block;
  83. width: $toggle-handle-width;
  84. height: $toggle-handle-height;
  85. border-radius: $toggle-handle-radius;
  86. background-color: $toggle-handle-off-bg-color;
  87. top: $toggle-border-width + $toggle-hit-area-expansion;
  88. left: $toggle-border-width + $toggle-hit-area-expansion;
  89. box-shadow: 0 2px 7px rgba(0,0,0,.35), 0 1px 1px rgba(0,0,0,.15);
  90. &:before {
  91. // used to create a larger (but hidden) hit area to slide the handle
  92. position: absolute;
  93. top: -4px;
  94. left: ( ($toggle-handle-width / 2) * -1) - 8;
  95. padding: ($toggle-handle-height / 2) + 5 ($toggle-handle-width + 7);
  96. content: " ";
  97. }
  98. }
  99. .toggle input:checked + .track .handle {
  100. // the handle when the toggle is "on"
  101. @include translate3d($toggle-width - $toggle-handle-width - ($toggle-border-width * 2), 0, 0);
  102. background-color: $toggle-handle-on-bg-color;
  103. }
  104. .item-toggle.active {
  105. box-shadow: none;
  106. }
  107. .item-toggle,
  108. .item-toggle.item-complex .item-content {
  109. // make sure list item content have enough padding on right to fit the toggle
  110. padding-right: ($item-padding * 3) + $toggle-width;
  111. }
  112. .item-toggle.item-complex {
  113. padding-right: 0;
  114. }
  115. .item-toggle .toggle {
  116. // position the toggle to the right within a list item
  117. position: absolute;
  118. top: ($item-padding / 2) + 2;
  119. right: $item-padding;
  120. z-index: $z-index-item-toggle;
  121. }
  122. .toggle input:disabled + .track {
  123. opacity: .6;
  124. }
  125. .toggle-small {
  126. .track {
  127. border: 0;
  128. width: 34px;
  129. height: 15px;
  130. background: #9e9e9e;
  131. }
  132. input:checked + .track {
  133. background: rgba(0,150,137,.5);
  134. }
  135. .handle {
  136. top: 2px;
  137. left: 4px;
  138. width: 21px;
  139. height: 21px;
  140. box-shadow: 0 2px 5px rgba(0,0,0,.25);
  141. }
  142. input:checked + .track .handle {
  143. @include translate3d(16px, 0, 0);
  144. background: rgb(0,150,137);
  145. }
  146. &.item-toggle .toggle {
  147. top: 19px;
  148. }
  149. .toggle-light {
  150. @include toggle-small-style($toggle-on-light-bg);
  151. }
  152. .toggle-stable {
  153. @include toggle-small-style($toggle-on-stable-bg);
  154. }
  155. .toggle-positive {
  156. @include toggle-small-style($toggle-on-positive-bg);
  157. }
  158. .toggle-calm {
  159. @include toggle-small-style($toggle-on-calm-bg);
  160. }
  161. .toggle-assertive {
  162. @include toggle-small-style($toggle-on-assertive-bg);
  163. }
  164. .toggle-balanced {
  165. @include toggle-small-style($toggle-on-balanced-bg);
  166. }
  167. .toggle-energized {
  168. @include toggle-small-style($toggle-on-energized-bg);
  169. }
  170. .toggle-royal {
  171. @include toggle-small-style($toggle-on-royal-bg);
  172. }
  173. .toggle-dark {
  174. @include toggle-small-style($toggle-on-dark-bg);
  175. }
  176. }