_checkbox.scss 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /**
  2. * Checkbox
  3. * --------------------------------------------------
  4. */
  5. .checkbox {
  6. // set the color defaults
  7. @include checkbox-style($checkbox-off-border-default, $checkbox-on-bg-default, $checkbox-on-border-default);
  8. position: relative;
  9. display: inline-block;
  10. padding: ($checkbox-height / 4) ($checkbox-width / 4);
  11. cursor: pointer;
  12. }
  13. .checkbox-light {
  14. @include checkbox-style($checkbox-off-border-light, $checkbox-on-bg-light, $checkbox-off-border-light);
  15. }
  16. .checkbox-stable {
  17. @include checkbox-style($checkbox-off-border-stable, $checkbox-on-bg-stable, $checkbox-off-border-stable);
  18. }
  19. .checkbox-positive {
  20. @include checkbox-style($checkbox-off-border-positive, $checkbox-on-bg-positive, $checkbox-off-border-positive);
  21. }
  22. .checkbox-calm {
  23. @include checkbox-style($checkbox-off-border-calm, $checkbox-on-bg-calm, $checkbox-off-border-calm);
  24. }
  25. .checkbox-assertive {
  26. @include checkbox-style($checkbox-off-border-assertive, $checkbox-on-bg-assertive, $checkbox-off-border-assertive);
  27. }
  28. .checkbox-balanced {
  29. @include checkbox-style($checkbox-off-border-balanced, $checkbox-on-bg-balanced, $checkbox-off-border-balanced);
  30. }
  31. .checkbox-energized{
  32. @include checkbox-style($checkbox-off-border-energized, $checkbox-on-bg-energized, $checkbox-off-border-energized);
  33. }
  34. .checkbox-royal {
  35. @include checkbox-style($checkbox-off-border-royal, $checkbox-on-bg-royal, $checkbox-off-border-royal);
  36. }
  37. .checkbox-dark {
  38. @include checkbox-style($checkbox-off-border-dark, $checkbox-on-bg-dark, $checkbox-off-border-dark);
  39. }
  40. .checkbox input:disabled:before,
  41. .checkbox input:disabled + .checkbox-icon:before {
  42. border-color: $checkbox-off-border-light;
  43. }
  44. .checkbox input:disabled:checked:before,
  45. .checkbox input:disabled:checked + .checkbox-icon:before {
  46. background: $checkbox-on-bg-light;
  47. }
  48. .checkbox.checkbox-input-hidden input {
  49. display: none !important;
  50. }
  51. .checkbox input,
  52. .checkbox-icon {
  53. position: relative;
  54. width: $checkbox-width;
  55. height: $checkbox-height;
  56. display: block;
  57. border: 0;
  58. background: transparent;
  59. cursor: pointer;
  60. -webkit-appearance: none;
  61. &:before {
  62. // what the checkbox looks like when its not checked
  63. display: table;
  64. width: 100%;
  65. height: 100%;
  66. border-width: $checkbox-border-width;
  67. border-style: solid;
  68. border-radius: $checkbox-border-radius;
  69. background: $checkbox-off-bg-color;
  70. content: ' ';
  71. @include transition(background-color 20ms ease-in-out);
  72. }
  73. }
  74. .checkbox input:checked:before,
  75. input:checked + .checkbox-icon:before {
  76. border-width: $checkbox-border-width + 1;
  77. }
  78. // the checkmark within the box
  79. .checkbox input:after,
  80. .checkbox-icon:after {
  81. @include transition(opacity .05s ease-in-out);
  82. @include rotate(-45deg);
  83. position: absolute;
  84. top: 33%;
  85. left: 25%;
  86. display: table;
  87. width: ($checkbox-width / 2);
  88. height: ($checkbox-width / 4) - 1;
  89. border: $checkbox-check-width solid $checkbox-check-color;
  90. border-top: 0;
  91. border-right: 0;
  92. content: ' ';
  93. opacity: 0;
  94. }
  95. .platform-android .checkbox-platform input:before,
  96. .platform-android .checkbox-platform .checkbox-icon:before,
  97. .checkbox-square input:before,
  98. .checkbox-square .checkbox-icon:before {
  99. border-radius: 2px;
  100. width: 72%;
  101. height: 72%;
  102. margin-top: 14%;
  103. margin-left: 14%;
  104. border-width: 2px;
  105. }
  106. .platform-android .checkbox-platform input:after,
  107. .platform-android .checkbox-platform .checkbox-icon:after,
  108. .checkbox-square input:after,
  109. .checkbox-square .checkbox-icon:after {
  110. border-width: 2px;
  111. top: 19%;
  112. left: 25%;
  113. width: ($checkbox-width / 2) - 1;
  114. height: 7px;
  115. }
  116. .platform-android .item-checkbox-right .checkbox-square .checkbox-icon::after {
  117. top: 31%;
  118. }
  119. .grade-c .checkbox input:after,
  120. .grade-c .checkbox-icon:after {
  121. @include rotate(0);
  122. top: 3px;
  123. left: 4px;
  124. border: none;
  125. color: $checkbox-check-color;
  126. content: '\2713';
  127. font-weight: bold;
  128. font-size: 20px;
  129. }
  130. // what the checkmark looks like when its checked
  131. .checkbox input:checked:after,
  132. input:checked + .checkbox-icon:after {
  133. opacity: 1;
  134. }
  135. // make sure item content have enough padding on left to fit the checkbox
  136. .item-checkbox {
  137. padding-left: ($item-padding * 2) + $checkbox-width;
  138. &.active {
  139. box-shadow: none;
  140. }
  141. }
  142. // position the checkbox to the left within an item
  143. .item-checkbox .checkbox {
  144. position: absolute;
  145. top: 50%;
  146. right: $item-padding / 2;
  147. left: $item-padding / 2;
  148. z-index: $z-index-item-checkbox;
  149. margin-top: (($checkbox-height + ($checkbox-height / 2)) / 2) * -1;
  150. }
  151. .item-checkbox.item-checkbox-right {
  152. padding-right: ($item-padding * 2) + $checkbox-width;
  153. padding-left: $item-padding;
  154. }
  155. .item-checkbox-right .checkbox input,
  156. .item-checkbox-right .checkbox-icon {
  157. float: right;
  158. }