You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
4.0 KiB

  1. /**********************************************************************************
  2. *
  3. * Copyright (c) 2017-2019 MuK IT GmbH.
  4. *
  5. * This file is part of MuK Web Utils
  6. * (see https://mukit.at).
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. **********************************************************************************/
  22. .switch {
  23. font-size: $font-size-base;
  24. position: relative;
  25. input {
  26. position: absolute;
  27. height: 1px;
  28. width: 1px;
  29. background: none;
  30. border: 0;
  31. clip: rect(0 0 0 0);
  32. clip-path: inset(50%);
  33. overflow: hidden;
  34. padding: 0;
  35. + label {
  36. position: relative;
  37. min-width: calc(#{$switch-height} * 2);
  38. border-radius: $switch-border-radius;
  39. height: $switch-height;
  40. line-height: $switch-height;
  41. display: inline-block;
  42. cursor: pointer;
  43. outline: none;
  44. user-select: none;
  45. vertical-align: middle;
  46. text-indent: calc(calc(#{$switch-height} * 2) + .5rem);
  47. }
  48. + label::before,
  49. + label::after {
  50. content: '';
  51. position: absolute;
  52. top: 0;
  53. left: 0;
  54. width: calc(#{$switch-height} * 2);
  55. bottom: 0;
  56. display: block;
  57. }
  58. + label::before {
  59. right: 0;
  60. background-color: $switch-bg;
  61. border-radius: $switch-border-radius;
  62. transition: $switch-transition;
  63. }
  64. + label::after {
  65. top: $switch-thumb-padding;
  66. left: $switch-thumb-padding;
  67. width: calc(#{$switch-height} - calc(#{$switch-thumb-padding} * 2));
  68. height: calc(#{$switch-height} - calc(#{$switch-thumb-padding} * 2));
  69. border-radius: $switch-thumb-border-radius;
  70. background-color: $switch-thumb-bg;
  71. transition: $switch-transition;
  72. }
  73. &:checked + label::before {
  74. background-color: $switch-checked-bg;
  75. }
  76. &:checked + label::after {
  77. margin-left: $switch-height;
  78. }
  79. &:focus + label::before {
  80. outline: none;
  81. box-shadow: $switch-focus-box-shadow;
  82. }
  83. &:disabled + label {
  84. color: $switch-disabled-color;
  85. cursor: not-allowed;
  86. }
  87. &:disabled + label::before {
  88. background-color: $switch-disabled-bg;
  89. }
  90. }
  91. &.switch-sm {
  92. font-size: $font-size-sm;
  93. input {
  94. + label {
  95. min-width: calc(#{$switch-height-sm} * 2);
  96. height: $switch-height-sm;
  97. line-height: $switch-height-sm;
  98. text-indent: calc(calc(#{$switch-height-sm} * 2) + .5rem);
  99. }
  100. + label::before {
  101. width: calc(#{$switch-height-sm} * 2);
  102. }
  103. + label::after {
  104. width: calc(#{$switch-height-sm} - calc(#{$switch-thumb-padding} * 2));
  105. height: calc(#{$switch-height-sm} - calc(#{$switch-thumb-padding} * 2));
  106. }
  107. &:checked + label::after {
  108. margin-left: $switch-height-sm;
  109. }
  110. }
  111. }
  112. &.switch-lg {
  113. font-size: $font-size-lg;
  114. input {
  115. + label {
  116. min-width: calc(#{$switch-height-lg} * 2);
  117. height: $switch-height-lg;
  118. line-height: $switch-height-lg;
  119. text-indent: calc(calc(#{$switch-height-lg} * 2) + .5rem);
  120. }
  121. + label::before {
  122. width: calc(#{$switch-height-lg} * 2);
  123. }
  124. + label::after {
  125. width: calc(#{$switch-height-lg} - calc(#{$switch-thumb-padding} * 2));
  126. height: calc(#{$switch-height-lg} - calc(#{$switch-thumb-padding} * 2));
  127. }
  128. &:checked + label::after {
  129. margin-left: $switch-height-lg;
  130. }
  131. }
  132. }
  133. + .switch {
  134. margin-left: 1rem;
  135. }
  136. }