Merge "Revert "Don't check namespace in SpecialWantedtemplates""
[lhc/web/wiklou.git] / resources / src / mediawiki.ui / components / radio.less
1 @import "mediawiki.mixins";
2 @import "mediawiki.ui/variables";
3
4 // Radio
5 //
6 // Styling radios in a way that works cross browser is a tricky problem to solve.
7 // In MediaWiki UI put a radio and label inside a mw-ui-radio div.
8 // This renders in all browsers except IE6-8 which do not support the :checked selector;
9 // these are kept backwards-compatible using the :not(#noop) selector.
10 // You should give the radio and label matching "id" and "for" attributes, respectively.
11 //
12 // Markup:
13 // <div class="mw-ui-radio">
14 // <input type="radio" id="kss-example-4" name="kss-example-4">
15 // <label for="kss-example-4">Standard radio</label>
16 // </div>
17 // <div class="mw-ui-radio">
18 // <input type="radio" id="kss-example-4-checked" name="kss-example-4" checked>
19 // <label for="kss-example-4-checked">Standard checked radio</label>
20 // </div>
21 // <div class="mw-ui-radio">
22 // <input type="radio" id="kss-example-4-disabled" name="kss-example-4-disabled" disabled>
23 // <label for="kss-example-4-disabled">Disabled radio</label>
24 // </div>
25 // <div class="mw-ui-radio">
26 // <input type="radio" id="kss-example-4-disabled-checked" name="kss-example-4-disabled" disabled checked>
27 // <label for="kss-example-4-disabled-checked">Disabled checked radio</label>
28 // </div>
29 //
30 // Styleguide 4.
31 .mw-ui-radio {
32 display: inline-block;
33 vertical-align: middle;
34 }
35
36 @radioSize: 2em;
37
38 // We use the not selector to cancel out styling on IE 8 and below.
39 // We also disable this styling on javascript disabled devices. This fixes the issue with
40 // Opera Mini where checking/unchecking doesn't apply styling but potentially leaves other
41 // more capable browsers with unstyled radio buttons.
42 .client-js .mw-ui-radio:not(#noop) {
43 // Position relatively so we can make use of absolute pseudo elements
44 position: relative;
45 line-height: @radioSize;
46
47 * {
48 // reset font sizes (see bug 72727)
49 font: inherit;
50 vertical-align: middle;
51 }
52
53 input[type="radio"] {
54 // we hide the input element as instead we will style the label that follows
55 // we use opacity so that VoiceOver software can still identify it
56 opacity: 0;
57 // ensure the invisible radio takes up the required width
58 width: @radioSize;
59 height: @radioSize;
60 // This is needed for Firefox mobile (See bug 71750 to workaround default Firefox stylesheet)
61 max-width: none;
62 margin-right: 0.4em;
63
64 // the pseudo before element of the label after the radio now looks like a radio
65 & + label::before {
66 content: '';
67 cursor: pointer;
68 .box-sizing(border-box);
69 position: absolute;
70 left: 0;
71 border-radius: 100%;
72 width: @radioSize;
73 height: @radioSize;
74 background-color: #fff;
75 border: 1px solid @colorGray7;
76 .background-image-svg('images/radio_checked.svg', 'images/radio_checked.png');
77 .background-size( @radioSize, @radioSize );
78 background-repeat: no-repeat;
79 background-position: center center;
80 background-origin: border-box;
81 background-size: 0 0;
82 }
83
84 // when the input is checked, style the label pseudo before element that followed as a checked radio
85 &:checked + label::before {
86 background-size: 100% 100%;
87 }
88
89 &:active + label::before {
90 background-color: @colorGray13;
91 border-color: @colorGray13;
92 }
93
94 &:focus + label::before {
95 border-width: 2px;
96 }
97
98 &:focus:hover + label::before,
99 &:hover + label::before {
100 border-bottom-width: 3px;
101 }
102
103 // disabled radios have a gray background
104 &:disabled + label::before {
105 cursor: default;
106 background-color: @colorGray14;
107 border-color: @colorGray14;
108 }
109
110 // disabled and checked radios have a white circle
111 &:disabled:checked + label::before {
112 .background-image-svg('images/radio_disabled.svg', 'images/radio_disabled.png');
113 }
114 }
115 }