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.

_checkbox.scss 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /**
  2. * Outputs the selectors and properties for the CheckBox component.
  3. *
  4. * @param {string} $primary-stylename (v-checkbox) - the primary style name for the selectors
  5. * @param {bool} $include-additional-styles - should the mixin output all the different style variations of the component
  6. *
  7. * @group checkbox
  8. */
  9. @mixin valo-checkbox ($primary-stylename: v-checkbox, $include-additional-styles: contains($v-included-additional-styles, checkbox)) {
  10. .#{$primary-stylename} {
  11. @include valo-checkbox-style;
  12. }
  13. @if $include-additional-styles {
  14. .#{$primary-stylename}-small {
  15. @include valo-checkbox-style($unit-size: $v-unit-size--small);
  16. font-size: $v-font-size--small;
  17. }
  18. .#{$primary-stylename}-large {
  19. @include valo-checkbox-style($unit-size: $v-unit-size--large);
  20. font-size: $v-font-size--large;
  21. }
  22. }
  23. }
  24. /**
  25. * Outputs the font icon to indicate the checked state.
  26. *
  27. * @group checkbox
  28. */
  29. @mixin valo-checkbox-icon-style {
  30. content: "\f00c";
  31. font-family: ThemeIcons;
  32. }
  33. /**
  34. * Outputs the styles for a checkbox variant.
  35. *
  36. * @param {color} $background-color ($v-background-color) - The background color of the checkbox
  37. * @param {size} $unit-size ($v-unit-size) - The sizing of the checkbox. The width and height of the checkbox will be the unit-size divided by 2.
  38. * @param {color} $selection-color ($v-selection-color) - The color of the checked state icon
  39. *
  40. * @group checkbox
  41. */
  42. @mixin valo-checkbox-style ($background-color: $v-background-color, $unit-size: $v-unit-size, $selection-color: $v-selection-color) {
  43. // So that we can use the same 'unit-size' for all component sizes
  44. $size: $unit-size/2;
  45. position: relative;
  46. line-height: round($size);
  47. white-space: nowrap;
  48. &.v-has-width label {
  49. white-space: normal;
  50. }
  51. :root & {
  52. padding-left: round($size*1.33);
  53. label {
  54. @include valo-tappable;
  55. display: inline-block;
  56. }
  57. }
  58. :root & > input {
  59. position: absolute;
  60. clip: rect(0,0,0,0);
  61. left: .2em;
  62. top: .2em;
  63. z-index: 0;
  64. margin: 0;
  65. &:focus ~ label:before {
  66. @include valo-button-focus-style($background-color: $background-color, $border-fallback: null);
  67. @include box-shadow(valo-bevel-and-shadow($background-color: $background-color, $bevel: $v-bevel, $shadow: $v-shadow, $gradient: $v-gradient, $include-focus: true));
  68. }
  69. & ~ label:before,
  70. & ~ label:after {
  71. content: "";
  72. display: inline-block;
  73. @include box-sizing(border-box);
  74. width: round($size);
  75. height: round($size);
  76. position: absolute;
  77. top: 0;
  78. left: 0;
  79. border-radius: min(round($size/3), $v-border-radius);
  80. font-size: round($v-font-size * 0.8 * ($size*2/$v-unit-size));
  81. text-align: center;
  82. }
  83. & ~ label:before {
  84. @include valo-button-style($background-color: $background-color, $unit-size: $size, $border-radius: min(round($size/3), $v-border-radius), $states: normal);
  85. padding: 0;
  86. height: round($size);
  87. }
  88. & ~ label:after {
  89. @include valo-checkbox-icon-style;
  90. color: transparent;
  91. @if $v-animations-enabled {
  92. @include transition(color 100ms);
  93. }
  94. }
  95. &:active ~ label:after {
  96. @include valo-button-active-style($background-color: $background-color);
  97. }
  98. &:checked ~ label:after {
  99. color: $selection-color;
  100. }
  101. }
  102. & > .v-icon,
  103. & > label .v-icon {
  104. margin: 0 round($size/3) 0 round($size/6);
  105. min-width: 1em;
  106. cursor: pointer;
  107. }
  108. &.v-disabled {
  109. > label,
  110. > .v-icon {
  111. cursor: default;
  112. @include opacity($v-disabled-opacity);
  113. }
  114. > label > .v-icon {
  115. cursor: default;
  116. }
  117. :root & > input:active ~ label:after {
  118. background: transparent;
  119. }
  120. }
  121. &.v-readonly {
  122. > label,
  123. > .v-icon {
  124. cursor: default;
  125. }
  126. > label > .v-icon {
  127. cursor: default;
  128. }
  129. :root & > input:active ~ label:after {
  130. background: transparent;
  131. }
  132. :root & > input ~ label:after {
  133. @include opacity($v-disabled-opacity);
  134. }
  135. }
  136. }