Merge "mediawiki.ui: Explicitly define input text color"
[lhc/web/wiklou.git] / resources / src / mediawiki.ui / components / inputs.less
1 // Inputs
2
3 @import "mediawiki.mixins";
4 @import "mediawiki.ui/variables";
5 @import "mediawiki.ui/mixins";
6
7 // Text inputs
8 //
9 // Apply the mw-ui-input class to input and textarea fields.
10 //
11 // Styleguide 1.
12
13 // mw-ui-input
14 //
15 // Style an input using MediaWiki UI.
16 // Currently in draft status and subject to change.
17 // When focused a progressive highlight appears to the left of the field.
18 //
19 // Markup:
20 // <input class="mw-ui-input" placeholder="Enter your name">
21 // <textarea class="mw-ui-input">Text here</textarea>
22 //
23 // Styleguide 1.1.
24 .mw-ui-input {
25 background-color: #fff;
26 color: @colorGray1;
27 .box-sizing( border-box );
28 display: block;
29 width: 100%;
30 border: 1px solid @colorFieldBorder;
31 border-radius: @borderRadius;
32 padding: 0.3em 0.3em 0.3em 0.6em;
33 // necessary for smooth transition
34 box-shadow: inset 0 0 0 0.1em #fff;
35 font-family: inherit;
36 font-size: inherit;
37 line-height: inherit;
38 vertical-align: middle;
39
40 // Normalize & style placeholder text, see T139034
41 // Placeholder styles can't be grouped, otherwise they're ignored as invalid.
42
43 // Placeholder mixin
44 .mixin-placeholder() {
45 color: @colorGray7;
46 font-style: italic;
47 }
48 // Firefox 4-18
49 &:-moz-placeholder { // stylelint-disable-line selector-no-vendor-prefix
50 .mixin-placeholder;
51 opacity: 1;
52 }
53 // Firefox 19-
54 &::-moz-placeholder { // stylelint-disable-line selector-no-vendor-prefix
55 .mixin-placeholder;
56 opacity: 1;
57 }
58 // Internet Explorer 10-11
59 &:-ms-input-placeholder { // stylelint-disable-line selector-no-vendor-prefix
60 .mixin-placeholder;
61 }
62 // WebKit, Blink, Edge
63 // Don't set `opacity < 1`, see https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/3901363/
64 &::-webkit-input-placeholder { // stylelint-disable-line selector-no-vendor-prefix
65 .mixin-placeholder;
66 }
67 // W3C Standard Selectors Level 4
68 &:placeholder-shown {
69 .mixin-placeholder;
70 }
71
72 // Firefox: Remove red outline when `required` attribute set and invalid content.
73 // See https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid
74 // This should come before `:focus` so latter rules take preference.
75 &:invalid {
76 box-shadow: none;
77 }
78
79 &:hover {
80 border-color: @colorGray7;
81 }
82
83 &:focus {
84 border-color: @colorProgressive;
85 box-shadow: inset 0 0 0 1px @colorProgressive;
86 outline: 0;
87 }
88
89 // `:not()` is used exclusively for `transition`s as both are not supported by IE < 9.
90 &:not( :disabled ) {
91 .transition( ~'color 100ms, border-color 100ms, box-shadow 100ms' );
92 }
93
94 &:disabled {
95 border-color: @colorGray14;
96 color: @colorGray12;
97 }
98
99 // Normalize styling for `<input type="search">`
100 &[type="search"] {
101 // Correct the odd appearance in Chrome and Safari 5
102 -webkit-appearance: textfield;
103
104 // Remove proprietary clear button in IE 10-11, Edge 12+
105 &::-ms-clear {
106 display: none;
107 }
108
109 // Remove the inner padding and cancel buttons in Chrome on OS X and Safari on OS X
110 &::-webkit-search-cancel-button,
111 &::-webkit-search-decoration {
112 -webkit-appearance: none;
113 }
114 }
115 }
116
117 textarea.mw-ui-input {
118 min-height: 8em;
119 }
120
121 // mw-ui-input-inline
122 //
123 // Use mw-ui-input-inline with mw-ui-input in cases where you want a button to line up with the input.
124 //
125 // Markup:
126 // <input class="mw-ui-input mw-ui-input-inline">
127 // <button class="mw-ui-button mw-ui-progressive">Submit</button>
128 //
129 // Styleguide 1.2.
130 input[type="number"],
131 .mw-ui-input-inline {
132 display: inline-block;
133 width: auto;
134 // Make sure we limit `width` to parent element because
135 // in case of text `input` fields, `width: auto;` equals `size` attribute.
136 max-width: 100%;
137 }
138
139 // mw-ui-input-large
140 //
141 // Use mw-ui-input-large with mw-ui-input in cases where there are multiple inputs on a screen and you
142 // want to draw attention to one instance. For example, replying with a subject line and more text.
143 // Currently in draft status and subject to change. When used on an input field, the text is styled
144 // in a large font. When used alongside another mw-ui-input large they are pushed together to form one
145 // contiguous block.
146 //
147 // Markup:
148 // <input value="input" class="mw-ui-input mw-ui-input-large" value="input" placeholder="Enter subject">
149 // <textarea class="mw-ui-input mw-ui-input-large" placeholder="Provide additional details"></textarea>
150 //
151 // Styleguide 1.3.
152 .mw-ui-input-large {
153 margin-top: 0;
154 margin-bottom: 0;
155
156 // When two large inputs are together, we make them flush by hiding one of the borders
157 & + .mw-ui-input-large {
158 margin-top: -1px;
159 }
160 // When focusing, make the input relative to raise it above any attached inputs to unhide its borders
161 &:focus {
162 position: relative;
163 }
164 }
165
166 input.mw-ui-input-large {
167 font-size: 1.75em;
168 font-weight: bold;
169 line-height: 1.25em;
170 }