UNPKG

9.41 kBSCSSView Raw
1// Name: Search
2// Description: Component to create the search
3//
4// Component: `uk-search`
5//
6// Sub-objects: `uk-search-input`
7// `uk-search-toggle`
8//
9// Adopted: `uk-search-icon`
10//
11// Modifier: `uk-search-default`
12// `uk-search-navbar`
13// `uk-search-large`
14//
15// ========================================================================
16
17
18// Variables
19// ========================================================================
20
21$search-color: $global-color !default;
22$search-placeholder-color: $global-muted-color !default;
23
24$search-icon-color: $global-muted-color !default;
25
26$search-default-width: 180px !default;
27$search-default-height: $global-control-height !default;
28$search-default-padding-horizontal: 6px !default;
29$search-default-background: $global-muted-background !default;
30$search-default-focus-background: $search-default-background !default;
31
32$search-default-icon-width: $global-control-height !default;
33
34$search-navbar-width: 400px !default;
35$search-navbar-height: 40px !default;
36$search-navbar-background: transparent !default;
37$search-navbar-font-size: $global-large-font-size !default;
38
39$search-navbar-icon-width: 40px !default;
40
41$search-large-width: 500px !default;
42$search-large-height: 80px !default;
43$search-large-background: transparent !default;
44$search-large-font-size: $global-xxlarge-font-size !default;
45
46$search-large-icon-width: 80px !default;
47
48$search-toggle-color: $global-muted-color !default;
49$search-toggle-hover-color: $global-color !default;
50
51
52/* ========================================================================
53 Component: Search
54 ========================================================================== */
55
56/*
57 * 1. Container fits its content
58 * 2. Create position context
59 * 3. Prevent content overflow
60 * 4. Reset `form`
61 */
62
63.uk-search {
64 /* 1 */
65 display: inline-block;
66 /* 2 */
67 position: relative;
68 /* 3 */
69 max-width: 100%;
70 /* 4 */
71 margin: 0;
72}
73
74
75/* Input
76 ========================================================================== */
77
78/*
79 * Remove the inner padding and cancel buttons in Chrome on OS X and Safari on OS X.
80 */
81
82.uk-search-input::-webkit-search-cancel-button,
83.uk-search-input::-webkit-search-decoration { -webkit-appearance: none; }
84
85/*
86 * Removes placeholder transparency in Firefox.
87 */
88
89.uk-search-input::-moz-placeholder { opacity: 1; }
90
91/*
92 * 1. Define consistent box sizing.
93 * 2. Address margins set differently in Firefox/IE and Chrome/Safari/Opera.
94 * 3. Remove `border-radius` in iOS.
95 * 4. Change font properties to `inherit` in all browsers
96 * 5. Show the overflow in Edge.
97 * 6. Remove default style in iOS.
98 * 7. Vertical alignment
99 * 8. Take the full container width
100 * 9. Style
101 */
102
103.uk-search-input {
104 /* 1 */
105 box-sizing: border-box;
106 /* 2 */
107 margin: 0;
108 /* 3 */
109 border-radius: 0;
110 /* 4 */
111 font: inherit;
112 /* 5 */
113 overflow: visible;
114 /* 6 */
115 -webkit-appearance: none;
116 /* 7 */
117 vertical-align: middle;
118 /* 8 */
119 width: 100%;
120 /* 9 */
121 border: none;
122 color: $search-color;
123 @if(mixin-exists(hook-search-input)) {@include hook-search-input();}
124}
125
126.uk-search-input:focus { outline: none; }
127
128/* Placeholder */
129.uk-search-input:-ms-input-placeholder { color: $search-placeholder-color !important; }
130.uk-search-input::placeholder { color: $search-placeholder-color; }
131
132
133/* Icon (Adopts `uk-icon`)
134 ========================================================================== */
135
136/*
137 * Remove default focus style
138 */
139
140.uk-search-icon:focus { outline: none; }
141
142/*
143 * Position above input
144 * 1. Set position
145 * 2. Center icon vertically and horizontally
146 * 3. Style
147 */
148
149.uk-search .uk-search-icon {
150 /* 1 */
151 position: absolute;
152 top: 0;
153 bottom: 0;
154 left: 0;
155 /* 2 */
156 display: inline-flex;
157 justify-content: center;
158 align-items: center;
159 /* 3 */
160 color: $search-icon-color;
161}
162
163/*
164 * Required for `a`.
165 */
166
167.uk-search .uk-search-icon:hover { color: $search-icon-color; }
168
169/*
170 * Make `input` element clickable through icon, e.g. if it's a `span`
171 */
172
173.uk-search .uk-search-icon:not(a):not(button):not(input) { pointer-events: none; }
174
175/*
176 * Position modifier
177 */
178
179.uk-search .uk-search-icon-flip {
180 right: 0;
181 left: auto;
182}
183
184
185/* Default modifier
186 ========================================================================== */
187
188.uk-search-default { width: $search-default-width; }
189
190/*
191 * Input
192 */
193
194.uk-search-default .uk-search-input {
195 height: $search-default-height;
196 padding-left: $search-default-padding-horizontal;
197 padding-right: $search-default-padding-horizontal;
198 background: $search-default-background;
199 @if(mixin-exists(hook-search-default-input)) {@include hook-search-default-input();}
200}
201
202/* Focus */
203.uk-search-default .uk-search-input:focus {
204 background-color: $search-default-focus-background;
205 @if(mixin-exists(hook-search-default-input-focus)) {@include hook-search-default-input-focus();}
206}
207
208/*
209 * Icon
210 */
211
212.uk-search-default .uk-search-icon { width: $search-default-icon-width; }
213
214.uk-search-default .uk-search-icon:not(.uk-search-icon-flip) ~ .uk-search-input { padding-left: ($search-default-icon-width); }
215.uk-search-default .uk-search-icon-flip ~ .uk-search-input { padding-right: ($search-default-icon-width); }
216
217
218/* Navbar modifier
219 ========================================================================== */
220
221.uk-search-navbar { width: $search-navbar-width; }
222
223/*
224 * Input
225 */
226
227.uk-search-navbar .uk-search-input {
228 height: $search-navbar-height;
229 background: $search-navbar-background;
230 font-size: $search-navbar-font-size;
231 @if(mixin-exists(hook-search-navbar-input)) {@include hook-search-navbar-input();}
232}
233
234/*
235 * Icon
236 */
237
238.uk-search-navbar .uk-search-icon { width: $search-navbar-icon-width; }
239
240.uk-search-navbar .uk-search-icon:not(.uk-search-icon-flip) ~ .uk-search-input { padding-left: ($search-navbar-icon-width); }
241.uk-search-navbar .uk-search-icon-flip ~ .uk-search-input { padding-right: ($search-navbar-icon-width); }
242
243
244/* Large modifier
245 ========================================================================== */
246
247.uk-search-large { width: $search-large-width; }
248
249/*
250 * Input
251 */
252
253.uk-search-large .uk-search-input {
254 height: $search-large-height;
255 background: $search-large-background;
256 font-size: $search-large-font-size;
257 @if(mixin-exists(hook-search-large-input)) {@include hook-search-large-input();}
258}
259
260/*
261 * Icon
262 */
263
264.uk-search-large .uk-search-icon { width: $search-large-icon-width; }
265
266.uk-search-large .uk-search-icon:not(.uk-search-icon-flip) ~ .uk-search-input { padding-left: ($search-large-icon-width); }
267.uk-search-large .uk-search-icon-flip ~ .uk-search-input { padding-right: ($search-large-icon-width); }
268
269
270/* Toggle
271 ========================================================================== */
272
273.uk-search-toggle {
274 color: $search-toggle-color;
275 @if(mixin-exists(hook-search-toggle)) {@include hook-search-toggle();}
276}
277
278/* Hover + Focus */
279.uk-search-toggle:hover,
280.uk-search-toggle:focus {
281 color: $search-toggle-hover-color;
282 @if(mixin-exists(hook-search-toggle-hover)) {@include hook-search-toggle-hover();}
283}
284
285
286// Hooks
287// ========================================================================
288
289@if(mixin-exists(hook-search-misc)) {@include hook-search-misc();}
290
291// @mixin hook-search-input(){}
292// @mixin hook-search-default-input(){}
293// @mixin hook-search-default-input-focus(){}
294// @mixin hook-search-navbar-input(){}
295// @mixin hook-search-large-input(){}
296
297// @mixin hook-search-toggle(){}
298// @mixin hook-search-toggle-hover(){}
299
300// @mixin hook-search-misc(){}
301
302
303// Inverse
304// ========================================================================
305
306$inverse-search-color: $inverse-global-color !default;
307$inverse-search-placeholder-color: $inverse-global-muted-color !default;
308
309$inverse-search-icon-color: $inverse-global-muted-color !default;
310
311$inverse-search-default-background: $inverse-global-muted-background !default;
312$inverse-search-default-focus-background: $inverse-search-default-background !default;
313
314$inverse-search-navbar-background: transparent !default;
315
316$inverse-search-large-background: transparent !default;
317
318$inverse-search-toggle-color: $inverse-global-muted-color !default;
319$inverse-search-toggle-hover-color: $inverse-global-color !default;
320
321
322
323// @mixin hook-inverse-search-default-input(){}
324// @mixin hook-inverse-search-default-input-focus(){}
325// @mixin hook-inverse-search-navbar-input(){}
326// @mixin hook-inverse-search-large-input(){}
327// @mixin hook-inverse-search-toggle(){}
328// @mixin hook-inverse-search-toggle-hover(){}