Remove patch-restructure.sql
[mediawiki.git] / resources / src / mediawiki.ui / components / checkbox.less
blob6d6fdde6429f357cb8c622588ef9a99f9799bc4c
1 @import "mediawiki.mixins";
3 // Checkbox
4 //
5 // Styling checkboxes in a way that works cross browser is a tricky problem to solve.
6 // In MediaWiki UI put a checkbox and label inside a mw-ui-checkbox div.
7 // This renders in all browsers except IE6-8 which do not support the :checked selector;
8 // these are kept backwards-compatible using the :not(#noop) selector.
9 // You should give the checkbox and label matching "id" and "for" attributes, respectively.
11 // Markup:
12 // <div class="mw-ui-checkbox">
13 //   <input type="checkbox" id="kss-example-5"><label for="kss-example-5">Standard checkbox</label>
14 // </div>
15 // <div class="mw-ui-checkbox">
16 //   <input type="checkbox" id="kss-example-5-2" disabled><label for="kss-example-5-2">Disabled checkbox</label>
17 // </div>
19 // Styleguide 5.
20 .mw-ui-checkbox {
21         display: inline-block;
22         vertical-align: middle;
25 @checkboxSize: 24px;
27 // We use the not selector to cancel out styling on IE 8 and below
28 .mw-ui-checkbox:not(#noop) {
29         // Position relatively so we can make use of absolute pseudo elements
30         position: relative;
31         line-height: @checkboxSize;
33         * {
34                 vertical-align: middle;
35         }
37         input[type="checkbox"] {
38                 // we hide the input element as instead we will style the label that follows
39                 // we use opacity so that VoiceOver software can still identify it
40                 opacity: 0;
41                 // ensure the invisible checkbox takes up the required width
42                 width: @checkboxSize;
43                 height: @checkboxSize;
45                 // the pseudo before element of the label after the checkbox now looks like a checkbox
46                 & + label {
47                         &::before {
48                                                 content: '';
49                                                 position: absolute;
50                                                 left: 0;
51                                                 display: inline-block;
52                                                 border-radius: 2px;
53                                                 margin-right: 18px;
54                                                 width: @checkboxSize;
55                                                 height: @checkboxSize;
56                                                 background-color: #fff;
57                                                 cursor: pointer;
58                                                 border: 1px solid grey;
59                                         }
60                 }
62                 // when the input is checked, style the label pseudo before element that followed as a checked checkbox
63                 &:checked {
64                         + label {
65                                 &::before {
66                                         .background-image-svg('images/checked.svg', 'images/checked.png');
67                                         background-repeat: no-repeat;
68                                         background-position: center top;
69                                 }
70                         }
71                 }
73                 @focusBottomBorderSize: 3px;
74                 &:active,
75                 &:focus {
76                         + label {
77                                 &::after {
78                                         content: '';
79                                         position: absolute;
80                                         width: @checkboxSize;
81                                         height: @checkboxSize - @focusBottomBorderSize + 1; // offset by bottom border
82                                         // offset from the checkbox by 1px to account for left border
83                                         left: 1px;
84                                         border-bottom: solid @focusBottomBorderSize lightgrey;
85                                 }
86                         }
87                 }
89                 // disabled checked boxes have a gray background
90                 &:disabled + label::before {
91                         background-color: lightgrey;
92                 }
93         }