Make generic placeholder pseudo-class browser-prefix mixin
[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 /* stylelint-disable indentation */
42 .mixin-placeholder( {
43 color: @colorGray7;
44 opacity: 1;
45 // TODO: Is italic necessary? T147808
46 font-style: italic;
47 } );
48 /* stylelint-enable indentation */
49
50 // Firefox: Remove red outline when `required` attribute set and invalid content.
51 // See https://developer.mozilla.org/en-US/docs/Web/CSS/:invalid
52 // This should come before `:focus` so latter rules take preference.
53 &:invalid {
54 box-shadow: none;
55 }
56
57 &:hover {
58 border-color: @colorGray7;
59 }
60
61 &:focus {
62 border-color: @colorProgressive;
63 box-shadow: inset 0 0 0 1px @colorProgressive;
64 outline: 0;
65 }
66
67 // `:not()` is used exclusively for `transition`s as both are not supported by IE < 9.
68 &:not( :disabled ) {
69 .transition( ~'color 100ms, border-color 100ms, box-shadow 100ms' );
70 }
71
72 &:disabled {
73 border-color: @colorGray14;
74 color: @colorGray12;
75 }
76
77 // Normalize styling for `<input type="search">`
78 &[type="search"] {
79 // Correct the odd appearance in Chrome and Safari 5
80 -webkit-appearance: textfield;
81
82 // Remove proprietary clear button in IE 10-11, Edge 12+
83 &::-ms-clear {
84 display: none;
85 }
86
87 // Remove the inner padding and cancel buttons in Chrome on OS X and Safari on OS X
88 &::-webkit-search-cancel-button,
89 &::-webkit-search-decoration {
90 -webkit-appearance: none;
91 }
92 }
93 }
94
95 textarea.mw-ui-input {
96 min-height: 8em;
97 }
98
99 // mw-ui-input-inline
100 //
101 // Use mw-ui-input-inline with mw-ui-input in cases where you want a button to line up with the input.
102 //
103 // Markup:
104 // <input class="mw-ui-input mw-ui-input-inline">
105 // <button class="mw-ui-button mw-ui-progressive">Submit</button>
106 //
107 // Styleguide 1.2.
108 input[type="number"],
109 .mw-ui-input-inline {
110 display: inline-block;
111 width: auto;
112 // Make sure we limit `width` to parent element because
113 // in case of text `input` fields, `width: auto;` equals `size` attribute.
114 max-width: 100%;
115 }
116
117 // mw-ui-input-large
118 //
119 // Use mw-ui-input-large with mw-ui-input in cases where there are multiple inputs on a screen and you
120 // want to draw attention to one instance. For example, replying with a subject line and more text.
121 // Currently in draft status and subject to change. When used on an input field, the text is styled
122 // in a large font. When used alongside another mw-ui-input large they are pushed together to form one
123 // contiguous block.
124 //
125 // Markup:
126 // <input value="input" class="mw-ui-input mw-ui-input-large" value="input" placeholder="Enter subject">
127 // <textarea class="mw-ui-input mw-ui-input-large" placeholder="Provide additional details"></textarea>
128 //
129 // Styleguide 1.3.
130 .mw-ui-input-large {
131 margin-top: 0;
132 margin-bottom: 0;
133
134 // When two large inputs are together, we make them flush by hiding one of the borders
135 & + .mw-ui-input-large {
136 margin-top: -1px;
137 }
138 // When focusing, make the input relative to raise it above any attached inputs to unhide its borders
139 &:focus {
140 position: relative;
141 }
142 }
143
144 input.mw-ui-input-large {
145 font-size: 1.75em;
146 font-weight: bold;
147 line-height: 1.25em;
148 }