_bootstrap-switch.scss 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /**
  2. * bootstrap-switch - Turn checkboxes and radio buttons into toggle switches.
  3. *
  4. * @version v3.4 (MODDED)
  5. * @homepage https://bttstrp.github.io/bootstrap-switch
  6. * @author Mattia Larentis <mattia@larentis.eu> (http://larentis.eu)
  7. * @license MIT
  8. */
  9. $bootstrap-switch-border-radius: $btn-border-radius;
  10. $bootstrap-switch-handle-border-radius: .1rem;
  11. .bootstrap-switch {
  12. border: $input-border-width solid $input-border-color;
  13. border-radius: $bootstrap-switch-border-radius;
  14. cursor: pointer;
  15. direction: ltr;
  16. display: inline-block;
  17. line-height: .5rem;
  18. overflow: hidden;
  19. position: relative;
  20. text-align: left;
  21. transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
  22. user-select: none;
  23. vertical-align: middle;
  24. z-index: 0;
  25. .bootstrap-switch-container {
  26. border-radius: $bootstrap-switch-border-radius;
  27. display: inline-block;
  28. top: 0;
  29. transform: translate3d(0, 0, 0);
  30. }
  31. &:focus-within {
  32. box-shadow: $input-btn-focus-box-shadow;
  33. }
  34. .bootstrap-switch-handle-on,
  35. .bootstrap-switch-handle-off,
  36. .bootstrap-switch-label {
  37. box-sizing: border-box;
  38. cursor: pointer;
  39. display: table-cell;
  40. font-size: 1rem;
  41. font-weight: 500;
  42. line-height: 1.2rem;
  43. padding: .25rem .5rem;
  44. vertical-align: middle;
  45. }
  46. .bootstrap-switch-handle-on,
  47. .bootstrap-switch-handle-off {
  48. text-align: center;
  49. z-index: 1;
  50. &.bootstrap-switch-default {
  51. background: $gray-200;
  52. color: color-yiq($gray-200);
  53. }
  54. @each $name, $color in $theme-colors {
  55. &.bootstrap-switch-#{$name} {
  56. background: $color;
  57. color: color-yiq($color);
  58. }
  59. }
  60. @each $name, $color in $colors {
  61. &.bootstrap-switch-#{$name} {
  62. background: $color;
  63. color: color-yiq($color);
  64. }
  65. }
  66. }
  67. .bootstrap-switch-handle-on {
  68. border-bottom-left-radius: $bootstrap-switch-handle-border-radius;
  69. border-top-left-radius: $bootstrap-switch-handle-border-radius;
  70. }
  71. .bootstrap-switch-handle-off {
  72. border-bottom-right-radius: $bootstrap-switch-handle-border-radius;
  73. border-top-right-radius: $bootstrap-switch-handle-border-radius;
  74. }
  75. input[type='radio'],
  76. input[type='checkbox'] {
  77. filter: alpha(opacity=0);
  78. left: 0;
  79. margin: 0;
  80. opacity: 0;
  81. position: absolute;
  82. top: 0;
  83. visibility: hidden;
  84. z-index: -1;
  85. }
  86. &.bootstrap-switch-mini {
  87. .bootstrap-switch-handle-on,
  88. .bootstrap-switch-handle-off,
  89. .bootstrap-switch-label {
  90. font-size: .875rem;
  91. line-height: 1.5;
  92. padding: .1rem .3rem;
  93. }
  94. }
  95. &.bootstrap-switch-small {
  96. .bootstrap-switch-handle-on,
  97. .bootstrap-switch-handle-off,
  98. .bootstrap-switch-label {
  99. font-size: .875rem;
  100. line-height: 1.5;
  101. padding: .2rem .4rem;
  102. }
  103. }
  104. &.bootstrap-switch-large {
  105. .bootstrap-switch-handle-on,
  106. .bootstrap-switch-handle-off,
  107. .bootstrap-switch-label {
  108. font-size: 1.25rem;
  109. line-height: 1.3333333rem;
  110. padding: .3rem .5rem;
  111. }
  112. }
  113. &.bootstrap-switch-disabled,
  114. &.bootstrap-switch-readonly,
  115. &.bootstrap-switch-indeterminate {
  116. cursor: default;
  117. .bootstrap-switch-handle-on,
  118. .bootstrap-switch-handle-off,
  119. .bootstrap-switch-label {
  120. cursor: default;
  121. filter: alpha(opacity=50);
  122. opacity: .5;
  123. }
  124. }
  125. &.bootstrap-switch-animate .bootstrap-switch-container {
  126. transition: margin-left .5s;
  127. }
  128. &.bootstrap-switch-inverse {
  129. .bootstrap-switch-handle-on {
  130. border-radius: 0 $bootstrap-switch-handle-border-radius $bootstrap-switch-handle-border-radius 0;
  131. }
  132. .bootstrap-switch-handle-off {
  133. border-radius: $bootstrap-switch-handle-border-radius 0 0 $bootstrap-switch-handle-border-radius;
  134. }
  135. }
  136. // &.bootstrap-switch-focused {
  137. // border-color: $input-btn-focus-color;
  138. // box-shadow: $input-btn-focus-box-shadow;
  139. // outline: 0;
  140. // }
  141. &.bootstrap-switch-on .bootstrap-switch-label,
  142. &.bootstrap-switch-inverse.bootstrap-switch-off .bootstrap-switch-label {
  143. border-bottom-right-radius: $bootstrap-switch-handle-border-radius;
  144. border-top-right-radius: $bootstrap-switch-handle-border-radius;
  145. }
  146. &.bootstrap-switch-off .bootstrap-switch-label,
  147. &.bootstrap-switch-inverse.bootstrap-switch-on .bootstrap-switch-label {
  148. border-bottom-left-radius: $bootstrap-switch-handle-border-radius;
  149. border-top-left-radius: $bootstrap-switch-handle-border-radius;
  150. }
  151. }
  152. @include dark-mode () {
  153. .bootstrap-switch {
  154. border-color: $gray-600;
  155. .bootstrap-switch-handle-off.bootstrap-switch-default,
  156. .bootstrap-switch-handle-on.bootstrap-switch-default {
  157. background-color: lighten($dark, 2.5%);
  158. color: $white;
  159. border-color: lighten($dark, 7.5%);
  160. }
  161. .bootstrap-switch-handle-on,
  162. .bootstrap-switch-handle-off {
  163. @each $name, $color in $theme-colors-alt {
  164. &.bootstrap-switch-#{$name} {
  165. background: $color;
  166. color: color-yiq($color);
  167. }
  168. }
  169. @each $name, $color in $colors-alt {
  170. &.bootstrap-switch-#{$name} {
  171. background: $color;
  172. color: color-yiq($color);
  173. }
  174. }
  175. }
  176. }
  177. }