_switches.scss 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Switch
  2. ========================================================================== */
  3. .switch,
  4. .switch * {
  5. -webkit-tap-highlight-color: transparent;
  6. user-select: none;
  7. }
  8. .switch label {
  9. cursor: pointer;
  10. }
  11. .switch label input[type=checkbox] {
  12. opacity: 0;
  13. width: 0;
  14. height: 0;
  15. &:checked + .lever {
  16. background-color: $switch-checked-lever-bg;
  17. &:before, &:after {
  18. left: 18px;
  19. }
  20. &:after {
  21. background-color: $switch-bg-color;
  22. }
  23. }
  24. }
  25. .switch label .lever {
  26. content: "";
  27. display: inline-block;
  28. position: relative;
  29. width: 36px;
  30. height: 14px;
  31. background-color: $switch-unchecked-lever-bg;
  32. border-radius: $switch-radius;
  33. margin-right: 10px;
  34. transition: background 0.3s ease;
  35. vertical-align: middle;
  36. margin: 0 16px;
  37. &:before, &:after {
  38. content: "";
  39. position: absolute;
  40. display: inline-block;
  41. width: 20px;
  42. height: 20px;
  43. border-radius: 50%;
  44. left: 0;
  45. top: -3px;
  46. transition: left 0.3s ease, background .3s ease, box-shadow 0.1s ease, transform .1s ease;
  47. }
  48. &:before {
  49. background-color: transparentize($switch-bg-color, .85);
  50. }
  51. &:after {
  52. background-color: $switch-unchecked-bg;
  53. box-shadow: 0px 3px 1px -2px rgba(0, 0, 0, 0.2), 0px 2px 2px 0px rgba(0, 0, 0, 0.14), 0px 1px 5px 0px rgba(0, 0, 0, 0.12);
  54. }
  55. }
  56. // Switch active style
  57. input[type=checkbox]:checked:not(:disabled) ~ .lever:active::before,
  58. input[type=checkbox]:checked:not(:disabled).tabbed:focus ~ .lever::before {
  59. transform: scale(2.4);
  60. background-color: transparentize($switch-bg-color, .85);
  61. }
  62. input[type=checkbox]:not(:disabled) ~ .lever:active:before,
  63. input[type=checkbox]:not(:disabled).tabbed:focus ~ .lever::before {
  64. transform: scale(2.4);
  65. background-color: rgba(0,0,0,.08);
  66. }
  67. // Disabled Styles
  68. .switch input[type=checkbox][disabled] + .lever {
  69. cursor: default;
  70. background-color: rgba(0,0,0,.12);
  71. }
  72. .switch label input[type=checkbox][disabled] + .lever:after,
  73. .switch label input[type=checkbox][disabled]:checked + .lever:after {
  74. background-color: $input-disabled-solid-color;
  75. }