|
6 | 6 | .#{$ray-class-prefix}checkbox { |
7 | 7 | @include no-select; |
8 | 8 | display: flex; |
| 9 | + position: relative; |
9 | 10 |
|
10 | 11 | &__label { |
11 | | - padding-left: $ray-spacing-md; |
12 | 12 | line-height: $ray-field-line-height; |
13 | 13 | cursor: pointer; |
14 | | - } |
15 | | - |
16 | | - &__input { |
17 | | - appearance: none; |
18 | | - background-color: $ray-color-white; |
19 | | - border: $ray-radio-checkbox-border-width double $ray-color-black; |
20 | | - width: $ray-radio-checkbox-width; |
21 | | - height: $ray-radio-checkbox-width; |
22 | | - position: relative; |
23 | | - top: ($ray-field-line-height - $ray-field-font-size) / 2; |
24 | | - cursor: pointer; |
| 14 | + display: flex; |
25 | 15 |
|
26 | | - &::after { |
| 16 | + &::before { |
| 17 | + box-sizing: border-box; |
27 | 18 | content: ''; |
28 | | - width: calc( |
29 | | - #{$ray-radio-checkbox-width} - 2 * #{$ray-radio-checkbox-border-width} |
30 | | - ); |
31 | | - height: calc( |
32 | | - #{$ray-radio-checkbox-width} - 2 * #{$ray-radio-checkbox-border-width} |
33 | | - ); |
34 | | - background: $ray-color-white; |
35 | | - display: block; |
36 | | - transition: $ray-transition; |
| 19 | + background-color: $ray-color-white; |
| 20 | + border: $ray-radio-checkbox-border-width double $ray-color-black; |
| 21 | + width: $ray-radio-checkbox-width; |
| 22 | + height: $ray-radio-checkbox-width; |
| 23 | + position: relative; |
| 24 | + transition: box-shadow 0.15s ease; |
| 25 | + display: inline-block; |
| 26 | + margin-right: 1rem; |
| 27 | + top: 4px; |
37 | 28 | } |
38 | 29 |
|
39 | | - &:checked { |
40 | | - border-color: $ray-color-blue-50; |
| 30 | + &:focus { |
| 31 | + outline: none; |
41 | 32 |
|
42 | | - &::after { |
43 | | - background: $ray-color-blue-50; |
| 33 | + &::before { |
| 34 | + outline: 0; |
| 35 | + box-shadow: 0 0 0 0.25rem $ray-color-blue-20; |
44 | 36 | } |
| 37 | + } |
| 38 | + } |
45 | 39 |
|
46 | | - &:hover { |
47 | | - border-color: $ray-color-blue-70; |
| 40 | + &__input { |
| 41 | + appearance: none; |
| 42 | + width: 0; |
| 43 | + height: 0; |
| 44 | + opacity: 0; |
| 45 | + |
| 46 | + &:focus { |
| 47 | + + .#{$ray-class-prefix}checkbox__label, |
| 48 | + + .#{$ray-class-prefix}radio__label { |
| 49 | + &::before { |
| 50 | + outline: 0; |
| 51 | + box-shadow: 0 0 0 0.25rem $ray-color-blue-20; |
| 52 | + } |
| 53 | + } |
| 54 | + } |
| 55 | + |
| 56 | + &:checked + .#{$ray-class-prefix}checkbox__label, |
| 57 | + &:checked + .#{$ray-class-prefix}radio__label { |
| 58 | + &::before { |
| 59 | + border-color: $ray-color-blue-50; |
| 60 | + background-color: $ray-color-blue-50 !important; |
| 61 | + } |
48 | 62 |
|
49 | | - &::after { |
50 | | - background: $ray-color-blue-70; |
| 63 | + &:hover + .#{$ray-class-prefix}checkbox__label, |
| 64 | + &:hover + .#{$ray-class-prefix}radio__label { |
| 65 | + &::before { |
| 66 | + border-color: $ray-color-blue-70; |
| 67 | + background-color: $ray-color-blue-70; |
51 | 68 | } |
52 | 69 | } |
53 | 70 | } |
54 | 71 |
|
55 | 72 | &:not(:checked) { |
56 | | - &:hover { |
57 | | - &::after { |
58 | | - background: $ray-color-blue-10; |
| 73 | + &:hover + .#{$ray-class-prefix}checkbox__label, |
| 74 | + &:hover + .#{$ray-class-prefix}radio__label { |
| 75 | + &::before { |
| 76 | + border-color: $ray-color-blue-50; |
| 77 | + background-color: $ray-color-blue-10; |
59 | 78 | } |
60 | 79 | } |
61 | 80 | } |
62 | 81 |
|
63 | 82 | &[disabled] { |
64 | | - border-color: $ray-color-gray-30; |
65 | | - |
66 | | - &:hover { |
67 | | - &::after { |
68 | | - background: $ray-color-white; |
| 83 | + &:hover + .#{$ray-class-prefix}checkbox__label, |
| 84 | + &:hover + .#{$ray-class-prefix}radio__label { |
| 85 | + &::before { |
| 86 | + background-color: $ray-color-white; |
69 | 87 | } |
70 | 88 | } |
71 | 89 |
|
72 | 90 | + .#{$ray-class-prefix}radio__label, |
73 | 91 | + .#{$ray-class-prefix}checkbox__label { |
74 | 92 | cursor: not-allowed; |
75 | 93 | color: $ray-color-gray-30; |
| 94 | + |
| 95 | + &::before { |
| 96 | + border-color: $ray-color-gray-30; |
| 97 | + } |
76 | 98 | } |
77 | 99 | } |
78 | 100 | } |
79 | 101 | } |
80 | 102 |
|
81 | | - .#{$ray-class-prefix}radio__input { |
| 103 | + /** |
| 104 | + * Radio |
| 105 | + */ |
| 106 | + .#{$ray-class-prefix}radio__label { |
82 | 107 | border-radius: 50%; |
83 | 108 | box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); |
84 | 109 | transition: box-shadow 0.15s ease; |
|
88 | 113 | box-shadow: 0 0 0 0.25rem $ray-color-blue-20; |
89 | 114 | } |
90 | 115 |
|
91 | | - &::after { |
| 116 | + &::before { |
92 | 117 | border-radius: 50%; |
93 | 118 | } |
94 | 119 | } |
95 | 120 |
|
96 | | - .#{$ray-class-prefix}checkbox__input { |
| 121 | + /** |
| 122 | + * Checkbox |
| 123 | + */ |
| 124 | + .#{$ray-class-prefix}checkbox__label::before { |
97 | 125 | border-radius: $ray-border-radius; |
98 | 126 | } |
99 | 127 | } |
0 commit comments