_checkboxes.scss 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* Checkboxes
  2. ========================================================================== */
  3. /* Remove default checkbox */
  4. [type="checkbox"]:not(:checked),
  5. [type="checkbox"]:checked {
  6. position: absolute;
  7. opacity: 0;
  8. pointer-events: none;
  9. }
  10. // Checkbox Styles
  11. [type="checkbox"] {
  12. // Text Label Style
  13. + span:not(.lever) {
  14. position: relative;
  15. padding-left: 35px;
  16. cursor: pointer;
  17. display: inline-block;
  18. height: 25px;
  19. line-height: 25px;
  20. font-size: 1rem;
  21. user-select: none;
  22. }
  23. /* checkbox aspect */
  24. + span:not(.lever):before,
  25. &:not(.filled-in) + span:not(.lever):after {
  26. content: '';
  27. position: absolute;
  28. top: 0;
  29. left: 0;
  30. width: 18px;
  31. height: 18px;
  32. z-index: 0;
  33. border: 2px solid $radio-empty-color;
  34. border-radius: 1px;
  35. margin-top: 3px;
  36. transition: .2s;
  37. }
  38. &:not(.filled-in) + span:not(.lever):after {
  39. border: 0;
  40. transform: scale(0);
  41. }
  42. &:not(:checked):disabled + span:not(.lever):before {
  43. border: none;
  44. background-color: $input-disabled-color;
  45. }
  46. // Focused styles
  47. &.tabbed:focus + span:not(.lever):after {
  48. transform: scale(1);
  49. border: 0;
  50. border-radius: 50%;
  51. box-shadow: 0 0 0 10px rgba(0,0,0,.1);
  52. background-color: rgba(0,0,0,.1);
  53. }
  54. }
  55. [type="checkbox"]:checked {
  56. + span:not(.lever):before {
  57. top: -4px;
  58. left: -5px;
  59. width: 12px;
  60. height: 22px;
  61. border-top: 2px solid transparent;
  62. border-left: 2px solid transparent;
  63. border-right: $radio-border;
  64. border-bottom: $radio-border;
  65. transform: rotate(40deg);
  66. backface-visibility: hidden;
  67. transform-origin: 100% 100%;
  68. }
  69. &:disabled + span:before {
  70. border-right: 2px solid $input-disabled-color;
  71. border-bottom: 2px solid $input-disabled-color;
  72. }
  73. }
  74. /* Indeterminate checkbox */
  75. [type="checkbox"]:indeterminate {
  76. + span:not(.lever):before {
  77. top: -11px;
  78. left: -12px;
  79. width: 10px;
  80. height: 22px;
  81. border-top: none;
  82. border-left: none;
  83. border-right: $radio-border;
  84. border-bottom: none;
  85. transform: rotate(90deg);
  86. backface-visibility: hidden;
  87. transform-origin: 100% 100%;
  88. }
  89. // Disabled indeterminate
  90. &:disabled + span:not(.lever):before {
  91. border-right: 2px solid $input-disabled-color;
  92. background-color: transparent;
  93. }
  94. }
  95. // Filled in Style
  96. [type="checkbox"].filled-in {
  97. // General
  98. + span:not(.lever):after {
  99. border-radius: 2px;
  100. }
  101. + span:not(.lever):before,
  102. + span:not(.lever):after {
  103. content: '';
  104. left: 0;
  105. position: absolute;
  106. /* .1s delay is for check animation */
  107. transition: border .25s, background-color .25s, width .20s .1s, height .20s .1s, top .20s .1s, left .20s .1s;
  108. z-index: 1;
  109. }
  110. // Unchecked style
  111. &:not(:checked) + span:not(.lever):before {
  112. width: 0;
  113. height: 0;
  114. border: 3px solid transparent;
  115. left: 6px;
  116. top: 10px;
  117. transform: rotateZ(37deg);
  118. transform-origin: 100% 100%;
  119. }
  120. &:not(:checked) + span:not(.lever):after {
  121. height: 20px;
  122. width: 20px;
  123. background-color: transparent;
  124. border: 2px solid $radio-empty-color;
  125. top: 0px;
  126. z-index: 0;
  127. }
  128. // Checked style
  129. &:checked {
  130. + span:not(.lever):before {
  131. top: 0;
  132. left: 1px;
  133. width: 8px;
  134. height: 13px;
  135. border-top: 2px solid transparent;
  136. border-left: 2px solid transparent;
  137. border-right: 2px solid $input-background;
  138. border-bottom: 2px solid $input-background;
  139. transform: rotateZ(37deg);
  140. transform-origin: 100% 100%;
  141. }
  142. + span:not(.lever):after {
  143. top: 0;
  144. width: 20px;
  145. height: 20px;
  146. border: 2px solid $secondary-color;
  147. background-color: $secondary-color;
  148. z-index: 0;
  149. }
  150. }
  151. // Focused styles
  152. &.tabbed:focus + span:not(.lever):after {
  153. border-radius: 2px;
  154. border-color: $radio-empty-color;
  155. background-color: rgba(0,0,0,.1);
  156. }
  157. &.tabbed:checked:focus + span:not(.lever):after {
  158. border-radius: 2px;
  159. background-color: $secondary-color;
  160. border-color: $secondary-color;
  161. }
  162. // Disabled style
  163. &:disabled:not(:checked) + span:not(.lever):before {
  164. background-color: transparent;
  165. border: 2px solid transparent;
  166. }
  167. &:disabled:not(:checked) + span:not(.lever):after {
  168. border-color: transparent;
  169. background-color: $input-disabled-solid-color;
  170. }
  171. &:disabled:checked + span:not(.lever):before {
  172. background-color: transparent;
  173. }
  174. &:disabled:checked + span:not(.lever):after {
  175. background-color: $input-disabled-solid-color;
  176. border-color: $input-disabled-solid-color;
  177. }
  178. }