|
1 | | -//Checkbox - base style |
2 | | - |
3 | 1 | @mixin checkbox { |
| 2 | + $lineHeight: 2.125rem; |
| 3 | + $fontSize: 36px; |
| 4 | + // strip the units (expecting a px value, but remove so we've just got an int) |
| 5 | + $baseFont: ($fontSize) / ($fontSize * 0 + 1); |
| 6 | + // ensure our base is a rem val |
| 7 | + $base: ($lineHeight) / ($lineHeight * 0 + 1) * 1rem; |
| 8 | + // get our borderwidth in rems |
| 9 | + $borderWidth: (2 / (2 * 0 + 1) / $baseFont) * 1rem; |
| 10 | + $boxSize: $base/1.7; |
4 | 11 | .#{$prefix}checkbox { |
5 | | - position: relative; |
6 | | - display: block; |
7 | | - margin-bottom: 0.5rem; |
8 | | - border: 2px solid get('colors.gray.gray-dark.hex'); |
9 | | - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), |
10 | | - inset 0px -15px 10px -12px rgba(0, 0, 0, 0.05); |
11 | | - } |
12 | | - |
13 | | - .#{$prefix}checkbox.disabled .#{$prefix}-checkbox--label { |
14 | | - color: get('colors.gray.gray.hex'); |
15 | | - cursor: not-allowed; |
16 | | - } |
17 | | - |
18 | | - .#{$prefix}checkbox--label { |
19 | | - @include themify($themes) { |
20 | | - //color: themed('primary'); |
21 | | - color: 'orange'; |
22 | | - padding-left: 12px; |
23 | | - margin-bottom: 0; |
| 12 | + .#{$prefix}checkbox__label { |
24 | 13 | cursor: pointer; |
| 14 | + line-height: $base; |
| 15 | + position: relative; |
| 16 | + display: inline-block; |
| 17 | + padding-left: $base; |
| 18 | + font-family: Roboto, -apple-system, system-ui, BlinkMacSystemFont, |
| 19 | + Segoe UI, Open Sans, Helvetica Neue, Arial, sans-serif; |
| 20 | + margin-bottom: 0; |
| 21 | + &:before, |
| 22 | + &:after { |
| 23 | + box-sizing: border-box; |
| 24 | + line-height: $base; |
| 25 | + content: ' '; |
| 26 | + display: block; |
| 27 | + position: absolute; |
| 28 | + top: $base/4.75; |
| 29 | + left: 0; |
| 30 | + width: $boxSize; |
| 31 | + height: $boxSize; |
| 32 | + border-radius: 0; |
| 33 | + } |
| 34 | + &:before { |
| 35 | + cursor: pointer; |
| 36 | + width: ($boxSize) + $borderWidth * 2; |
| 37 | + height: ($boxSize) + $borderWidth * 2; |
| 38 | + margin: -$borderWidth; |
| 39 | + border: 2px solid get('colors.gray.gray.hex'); |
| 40 | + border-radius: 0; |
| 41 | + } |
25 | 42 | } |
26 | | - } |
27 | 43 |
|
28 | | - .#{$prefix}checkbox--input { |
29 | | - position: absolute; |
30 | | - margin-top: 0.25rem; |
31 | | - margin-left: -1.25rem; |
32 | | - } |
33 | | - |
34 | | - .#{$prefix}checkbox--input:only-child { |
35 | | - position: static; |
36 | | - } |
37 | | - |
38 | | - .#{$prefix}checkbox--inline { |
39 | | - display: inline-block; |
40 | | - } |
41 | | - |
42 | | - .#{$prefix}checkbox--inline .#{$prefix}checkbox--label { |
43 | | - vertical-align: middle; |
44 | | - } |
45 | | - |
46 | | - .#{$prefix}checkbox--inline + .#{$prefix}checkbox--inline { |
47 | | - margin-left: 0.75rem; |
| 44 | + /* hide the input element */ |
| 45 | + .#{$prefix}checkbox__input { |
| 46 | + opacity: 0; |
| 47 | + &:disabled + .#{$prefix}checkbox__label:before { |
| 48 | + cursor: not-allowed; |
| 49 | + background: get('colors.gray.grayLighter.hex'); |
| 50 | + border: 2px solid get('colors.gray.gray.hex'); |
| 51 | + } |
| 52 | + &:disabled + .#{$prefix}checkbox__label { |
| 53 | + cursor: not-allowed; |
| 54 | + } |
| 55 | + &:checked + .#{$prefix}checkbox__label:before { |
| 56 | + font-family: zepicons; |
| 57 | + content: '\f112'; |
| 58 | + //content: '\2713'; |
| 59 | + display: inline-block; |
| 60 | + background: get('colors.gray.white.hex'); |
| 61 | + line-height: $boxSize + $borderWidth; |
| 62 | + font-size: 18px; |
| 63 | + text-align: center; |
| 64 | + transform: scale(1); |
| 65 | + @include themify($themes) { |
| 66 | + color: themed('primary'); |
| 67 | + } |
| 68 | + } |
| 69 | + &:checked:focus + .#{$prefix}checkbox__label:before { |
| 70 | + @include themify($themes) { |
| 71 | + box-shadow: 0 0 5px 1px themed('primary'); |
| 72 | + background: get('colors.gray.white.hex'); |
| 73 | + } |
| 74 | + } |
| 75 | + &:active + .#{$prefix}checkbox__label:before { |
| 76 | + @include themify($themes) { |
| 77 | + background: themed('hover'); |
| 78 | + } |
| 79 | + } |
| 80 | + } |
48 | 81 | } |
49 | 82 | } |
50 | 83 |
|
|
0 commit comments