|
7 | 7 | //
|
8 | 8 | // Base class takes care of all the key behavioral aspects.
|
9 | 9 |
|
10 |
| -.c-input { |
| 10 | +.custom-control { |
11 | 11 | position: relative;
|
12 | 12 | display: inline;
|
13 | 13 | padding-left: 1.5rem;
|
14 | 14 | color: #555;
|
15 |
| - cursor: pointer; |
16 | 15 |
|
17 |
| - > input { |
18 |
| - position: absolute; |
19 |
| - z-index: -1; // Put the input behind the label so it doesn't overlay text |
20 |
| - opacity: 0; |
| 16 | + + .custom-control { |
| 17 | + margin-left: 1rem; |
| 18 | + } |
| 19 | +} |
21 | 20 |
|
22 |
| - &:checked ~ .c-indicator { |
23 |
| - color: #fff; |
24 |
| - background-color: #0074d9; |
25 |
| - @include box-shadow(none); |
26 |
| - } |
| 21 | +.custom-control-input { |
| 22 | + position: absolute; |
| 23 | + z-index: -1; // Put the input behind the label so it doesn't overlay text |
| 24 | + opacity: 0; |
27 | 25 |
|
28 |
| - &:focus ~ .c-indicator { |
29 |
| - // the mixin is not used here to make sure there is feedback |
30 |
| - box-shadow: 0 0 0 .075rem #fff, 0 0 0 .2rem #0074d9; |
31 |
| - } |
| 26 | + &:checked ~ .custom-control-indicator { |
| 27 | + color: #fff; |
| 28 | + background-color: #0074d9; |
| 29 | + @include box-shadow(none); |
| 30 | + } |
32 | 31 |
|
33 |
| - &:active ~ .c-indicator { |
34 |
| - color: #fff; |
35 |
| - background-color: #84c6ff; |
36 |
| - @include box-shadow(none); |
37 |
| - } |
| 32 | + &:focus ~ .custom-control-indicator { |
| 33 | + // the mixin is not used here to make sure there is feedback |
| 34 | + box-shadow: 0 0 0 .075rem #fff, 0 0 0 .2rem #0074d9; |
38 | 35 | }
|
39 | 36 |
|
40 |
| - + .c-input { |
41 |
| - margin-left: 1rem; |
| 37 | + &:active ~ .custom-control-indicator { |
| 38 | + color: #fff; |
| 39 | + background-color: #84c6ff; |
| 40 | + @include box-shadow(none); |
| 41 | + } |
| 42 | + |
| 43 | + &:disabled { |
| 44 | + ~ .custom-control-indicator { |
| 45 | + cursor: not-allowed; |
| 46 | + background-color: $custom-form-bg-color-disabled; |
| 47 | + } |
| 48 | + |
| 49 | + ~ .custom-control-description { |
| 50 | + color: $custom-form-description-color-disabled; |
| 51 | + cursor: not-allowed; |
| 52 | + } |
42 | 53 | }
|
43 | 54 | }
|
44 | 55 |
|
45 | 56 | // Custom indicator
|
46 | 57 | //
|
47 | 58 | // Generates a shadow element to create our makeshift checkbox/radio background.
|
48 | 59 |
|
49 |
| -.c-indicator { |
| 60 | +.custom-control-indicator { |
50 | 61 | position: absolute;
|
51 |
| - top: 0; |
| 62 | + top: .0625rem; |
52 | 63 | left: 0;
|
53 | 64 | display: block;
|
54 | 65 | width: 1rem;
|
|
62 | 73 | background-repeat: no-repeat;
|
63 | 74 | background-position: center center;
|
64 | 75 | background-size: 50% 50%;
|
65 |
| - @include box-shadow(inset 0 .125rem .125rem rgba(0,0,0,.1)); |
| 76 | + @include box-shadow(inset 0 .25rem .25rem rgba(0,0,0,.1)); |
66 | 77 | }
|
67 | 78 |
|
68 | 79 | // Checkboxes
|
69 | 80 | //
|
70 | 81 | // Tweak just a few things for checkboxes.
|
71 | 82 |
|
72 |
| -.c-checkbox { |
73 |
| - .c-indicator { |
| 83 | +.custom-checkbox { |
| 84 | + .custom-control-indicator { |
74 | 85 | border-radius: .25rem;
|
75 | 86 | }
|
76 | 87 |
|
77 |
| - input:checked ~ .c-indicator { |
| 88 | + .custom-control-input:checked ~ .custom-control-indicator { |
78 | 89 | background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNy4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgOCA4IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA4IDgiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHBhdGggZmlsbD0iI0ZGRkZGRiIgZD0iTTYuNCwxTDUuNywxLjdMMi45LDQuNUwyLjEsMy43TDEuNCwzTDAsNC40bDAuNywwLjdsMS41LDEuNWwwLjcsMC43bDAuNy0wLjdsMy41LTMuNWwwLjctMC43TDYuNCwxTDYuNCwxeiINCgkvPg0KPC9zdmc+DQo=);
|
79 | 90 | }
|
80 | 91 |
|
81 |
| - input:indeterminate ~ .c-indicator { |
| 92 | + .custom-control-input:indeterminate ~ .custom-control-indicator { |
82 | 93 | background-color: #0074d9;
|
83 | 94 | background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNy4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB3aWR0aD0iOHB4IiBoZWlnaHQ9IjhweCIgdmlld0JveD0iMCAwIDggOCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgOCA4IiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxwYXRoIGZpbGw9IiNGRkZGRkYiIGQ9Ik0wLDN2Mmg4VjNIMHoiLz4NCjwvc3ZnPg0K);
|
84 | 95 | @include box-shadow(none);
|
85 | 96 | }
|
86 |
| - |
87 |
| - input:disabled { |
88 |
| - ~ .c-indicator { |
89 |
| - cursor: not-allowed; |
90 |
| - background-color: $custom-form-bg-color-disabled; |
91 |
| - } |
92 |
| - ~ .c-indicator-label { |
93 |
| - color: $custom-form-label-color-disabled; |
94 |
| - cursor: not-allowed; |
95 |
| - } |
96 |
| - } |
97 | 97 | }
|
98 | 98 |
|
99 | 99 | // Radios
|
100 | 100 | //
|
101 | 101 | // Tweak just a few things for radios.
|
102 | 102 |
|
103 |
| -.c-radio { |
104 |
| - .c-indicator { |
| 103 | +.custom-radio { |
| 104 | + .custom-control-indicator { |
105 | 105 | border-radius: 50%;
|
106 | 106 | }
|
107 | 107 |
|
108 |
| - input:checked ~ .c-indicator { |
| 108 | + .custom-control-input:checked ~ .custom-control-indicator { |
109 | 109 | background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNy4xLjAsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgOCA4IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA4IDgiIHhtbDpzcGFjZT0icHJlc2VydmUiPg0KPHBhdGggZmlsbD0iI0ZGRkZGRiIgZD0iTTQsMUMyLjMsMSwxLDIuMywxLDRzMS4zLDMsMywzczMtMS4zLDMtM1M1LjcsMSw0LDF6Ii8+DQo8L3N2Zz4NCg==);
|
110 | 110 | }
|
111 |
| - |
112 |
| - input:disabled { |
113 |
| - ~ .c-indicator { |
114 |
| - cursor: not-allowed; |
115 |
| - background-color: $custom-form-bg-color-disabled; |
116 |
| - } |
117 |
| - ~ .c-indicator-label { |
118 |
| - color: $custom-form-label-color-disabled; |
119 |
| - cursor: not-allowed; |
120 |
| - } |
121 |
| - } |
122 | 111 | }
|
123 | 112 |
|
124 | 113 |
|
|
127 | 116 | // By default radios and checkboxes are `inline-block` with no additional spacing
|
128 | 117 | // set. Use these optional classes to tweak the layout.
|
129 | 118 |
|
130 |
| -.c-inputs-stacked { |
131 |
| - .c-input { |
| 119 | +.custom-controls-stacked { |
| 120 | + .custom-control { |
132 | 121 | display: inline;
|
133 | 122 |
|
134 | 123 | &::after {
|
|
137 | 126 | content: "";
|
138 | 127 | }
|
139 | 128 |
|
140 |
| - + .c-input { |
| 129 | + + .custom-control { |
141 | 130 | margin-left: 0;
|
142 | 131 | }
|
143 | 132 | }
|
|
0 commit comments