-
Notifications
You must be signed in to change notification settings - Fork 46
/
Inputs.vue
375 lines (366 loc) · 12.7 KB
/
Inputs.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
<template>
<section :class="$style.component">
<FlexGrid tagName="section">
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<h2 id="inputcomponent">Inputs</h2>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<h3>
HTML5 provides a plethora of input types. AgnosticUI generally takes
a minimalistic and backseat approach to these various types.
</h3>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<p>
Generally, input types that somehow seem similar to a text input
like email, password, search, etc., will at least share the text
input's general appearance in terms of height, spacing, font size,
etc., if you've added AgnosticUI classes to it. But, we attempt to
be as unobtrusive as possible towards the underlying native
functionality. For example, we do not remove or replace the native
'X' or clear button for type search. If you're application needs
such mangling, we hope that AgnosticUI at least provides some
helpful scaffolding to build on top of.
</p>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<h4>Core Inputs</h4>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<p class="flex">
<AgInput
uniqueId="myUniqueId"
label="Default input"
value="This is a generic input with a predefined value :)"
/>
<AgInput isRounded uniqueId="myUniqueId2" label="Rounded" />
<AgInput size="small" uniqueId="myUniqueId5" label="Small" />
<AgInput size="large" uniqueId="myUniqueId6" label="Large" />
<AgInput disabled uniqueId="myUniqueId7" label="Disabled" />
</p>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<pre v-highlightjs><code class="html">
<div>
<label for="myUniqueId" class="label">Default input</label>
<input id="myUniqueId" type="text" class="input">
</div>
<div>
<label for="myUniqueId2" class="label">Rounded</label>
<input id="myUniqueId2" type="text" class="input input-rounded">
</div>
<div>
<label for="myUniqueId5" class="label label-small">Small</label>
<input id="myUniqueId5" type="text" class="input input-small">
</div>
<div>
<label for="myUniqueId6" class="label label-large">Large</label>
<input id="myUniqueId6" type="text" class="input input-large">
</div>
<div>
<label for="myUniqueId7" class="label">Disabled</label>
<input id="myUniqueId7" type="text" disabled="disabled" class="input">
</div>
</code></pre>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<h4>Underlined</h4>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<p class="flex">
<AgInput
isUnderlined
uniqueId="myUniqueId3"
label="Underlined input"
/>
<AgInput
isUnderlined
isUnderlinedWithBackground
uniqueId="myUniqueId4"
label="Underlined with background"
/>
</p>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<pre v-highlightjs><code class="html">
<div>
<label for="myUniqueId3" class="label">Underlined input</label>
<input id="myUniqueId3" type="text" class="input input-underlined">
</div>
<div>
<label for="myUniqueId4" class="label">Underlined with background</label>
<input id="myUniqueId4" type="text" class="input input-underlined input-underlined-bg">
</div>
</code></pre>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<h4>Help Text</h4>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<p class="flex">
<AgInput
helpText="Some useful help text."
uniqueId="myUniqueId8"
label="Help text"
/>
<AgInput
isInvalid
invalidText="This field has errors."
uniqueId="myUniqueId9"
label="Invalid text"
/>
</p>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<pre v-highlightjs><code class="html">
<div>
<label for="myUniqueId8" class="label">Help text</label>
<input id="myUniqueId8" type="text" class="input">
<span class="field-help">Some useful help text.</span>
</div>
<div>
<label for="myUniqueId9" class="label label-error">Invalid text</label>
<input id="myUniqueId9" type="text" class="input input-error">
<span class="field-error">This field has errors.</span>
</div>
</code></pre>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<h4>Other HTML5 Types</h4>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<p class="flex">
<AgInput
uniqueId="myUniqueId10"
type="search"
placeholder="Search"
label="Search"
/>
<AgInput
uniqueId="myUniqueId11"
type="tel"
placeholder="Tel"
label="Telephone"
/>
<AgInput
uniqueId="myUniqueId12"
type="url"
placeholder="URL"
label="URL"
/>
<AgInput
uniqueId="myUniqueId13"
type="number"
placeholder="Number"
label="Number"
/>
<AgInput
uniqueId="myUniqueId14"
type="email"
placeholder="Email"
label="Email"
/>
<AgInput
uniqueId="myUniqueId15"
type="password"
placeholder="Password"
label="Password"
/>
</p>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<pre v-highlightjs><code class="html">
<div>
<label for="myUniqueId10" class="label">Search</label>
<input id="myUniqueId10" type="search" placeholder="Search" class="input">
</div>
<div>
<label for="myUniqueId11" class="label">Telephone</label>
<input id="myUniqueId11" type="tel" placeholder="Tel" class="input">
</div>
<div>
<label for="myUniqueId12" class="label">URL</label>
<input id="myUniqueId12" type="url" placeholder="URL" class="input">
</div>
<div>
<label for="myUniqueId13" class="label">Number</label>
<input id="myUniqueId13" type="number" placeholder="Number" class="input">
</div>
<div>
<label for="myUniqueId14" class="label">Email</label>
<input id="myUniqueId14" type="email" placeholder="Email" class="input">
</div>
<div>
<label for="myUniqueId15" class="label">Password</label>
<input id="myUniqueId15" type="password" placeholder="Password" class="input">
</div>
</code></pre>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<h4>Input Addons</h4>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<p>
Input addons use named slots as you'll see in the example below. So,
you'll want to name the default imported <i>Input</i> to something
<a
href="https://vuejs.org/v2/style-guide/#Multi-word-component-names-essential"
>multi-word</a
>
to prevent conflicts with the native HTML <i>input</i> element. Here
we've used <i>AgInput</i> for example.
</p>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<p class="flex">
<AgInput
hasLeftAddon
hasRightAddon
uniqueId="inputWithAddons"
label="Input with addons"
>
<template v-slot:addonLeft>
<InputAddonItem addonLeft>
<svg
role="img"
class="input-addon-left demo-icon-check"
viewBox="0 0 16 16"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
>
<desc>Cross icon</desc>
<path
d="M14 2.5l-8.5 8.5-3.5-3.5-1.5 1.5 5 5 10-10z"
></path>
</svg>
</InputAddonItem>
</template>
<template v-slot:addonRight>
<InputAddonItem addonRight>
<svg
role="img"
class="input-addon-left demo-icon-cross"
viewBox="0 0 16 16"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
>
<desc>Checkmark icon</desc>
<path
d="M13.957 3.457l-1.414-1.414-4.543 4.543-4.543-4.543-1.414 1.414 4.543 4.543-4.543 4.543 1.414 1.414 4.543-4.543 4.543 4.543 1.414-1.414-4.543-4.543z"
></path>
</svg>
</InputAddonItem>
</template>
</AgInput>
</p>
</FlexCol>
</FlexRow>
<FlexRow v-bind:gutter="16">
<FlexCol v-bind:xs="12">
<pre v-highlightjs><code class="html">
<div>
<label for="inputWithAddons" class="label">Input with addons</label>
<div class="input-addon-container">
<div class="input-addon-left">
<span>L</span>
</div>
<input id="inputWithAddons" type="text" class="input input-has-left-addon input-has-right-addon">
<div class="input-addon-right">
<span>R</span>
</div>
</div>
</div>
</code></pre>
</FlexCol>
</FlexRow>
</FlexGrid>
</section>
</template>
<script>
// If we call this Input it works until we start using named slots for the input addons, so
// we just name it AgInput
import AgInput from "agnosticui/Input.vue";
import InputAddonItem from "agnosticui/InputAddonItem.vue";
import FlexGrid from "agnosticui/FlexGrid/FlexGrid";
import FlexRow from "agnosticui/FlexGrid/FlexRow";
import FlexCol from "agnosticui/FlexGrid/FlexCol";
export default {
name: "Inputs",
components: {
AgInput,
InputAddonItem,
FlexCol,
FlexGrid,
FlexRow,
},
};
</script>
<style module>
.component {
composes: component from "./partials.module.css";
}
.hotips {
composes: hotips from "./partials.module.css";
}
.tipcontent {
composes: tipcontent from "./partials.module.css";
}
.tip {
composes: tip from "./partials.module.css";
}
</style>
<style scoped>
.flex {
display: flex;
flex-wrap: wrap;
}
.flex > div {
margin-bottom: var(--Space-16);
}
.demo-icon-cross,
.demo-icon-check {
width: 14px;
height: 14px;
}
.demo-icon-cross {
fill: tomato;
}
.demo-icon-check {
fill: lightseagreen;
}
</style>