forked from jgthms/bulma
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfile.html
More file actions
556 lines (516 loc) · 13.5 KB
/
Copy pathfile.html
File metadata and controls
556 lines (516 loc) · 13.5 KB
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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
---
title: File upload
layout: documentation
doc-tab: form
doc-subtab: file
breadcrumb:
- home
- documentation
- form
- form-file
file_name: "Screen Shot 2017-07-29 at 15.54.25.png"
variables_keys:
- $file-border-color
- $file-radius
- $file-cta-background-color
- $file-cta-color
- $file-cta-hover-color
- $file-cta-active-color
- $file-name-border-color
- $file-name-border-style
- $file-name-border-width
- $file-name-max-width
meta:
experimental: true
colors: true
sizes: true
variables: true
---
{% capture file %}
<div class="file">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose a file…
</span>
</span>
</label>
</div>
{% endcapture %}
{% capture file_name %}
<div class="file has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose a file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% capture file_name_right %}
<div class="file has-name is-right">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose a file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% capture file_name_fullwidth %}
<div class="file has-name is-fullwidth">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose a file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% capture file_boxed %}
<div class="file is-boxed">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose a file…
</span>
</span>
</label>
</div>
{% endcapture %}
{% capture file_boxed_name %}
<div class="file has-name is-boxed">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose a file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% capture file_colors_a %}
<div class="file is-primary">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Primary file…
</span>
</span>
</label>
</div>
{% endcapture %}
{% capture file_colors_b %}
<div class="file is-info has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Info file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% capture file_colors_c %}
<div class="file is-warning is-boxed">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-cloud-upload-alt"></i>
</span>
<span class="file-label">
Warning file…
</span>
</span>
</label>
</div>
{% endcapture %}
{% capture file_colors_d %}
<div class="file is-danger has-name is-boxed">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-cloud-upload-alt"></i>
</span>
<span class="file-label">
Danger file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% capture file_centered %}
<div class="file is-centered is-boxed is-success has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Centered file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% capture file_right %}
<div class="file is-right is-info">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Right file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% capture file_javascript %}
<div id="file-js-example" class="file has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
Choose a file…
</span>
</span>
<span class="file-name">
No file uploaded
</span>
</label>
</div>
<script>
const fileInput = document.querySelector('#file-js-example input[type=file]');
fileInput.onchange = () => {
if (fileInput.files.length > 0) {
const fileName = document.querySelector('#file-js-example .file-name');
fileName.textContent = fileInput.files[0].name;
}
}
</script>
{% endcapture %}
<!-- -->
<div class="content">
<p>
The <code>file</code> element is a simple <strong>interactive label</strong> that wraps an <code><input type="file"></code>. It comprises several sub-elements:
</p>
<ul>
<li>
<code>file</code> the main <strong>container</strong>
<ul>
<li>
<code>file-label</code> the actual <strong>interactive</strong> and clickable part of the element
<ul>
<li>
<code>file-input</code> the <strong>native</strong> file input, hidden for styling purposes
</li>
<li>
<code>file-cta</code> the upload <strong>call-to-action</strong>
<ul>
<li>
<code>file-icon</code> an optional <strong>upload</strong> icon
</li>
<li>
<code>file-label</code> the "Choose a file…" text
</li>
</ul>
</li>
<li>
<code>file-name</code> a container for the <strong>chosen file</strong> name
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
{% include elements/snippet.html content=file %}
{% include elements/anchor.html name="Modifiers" %}
<div class="columns">
<div class="column is-6">
<div class="content">
<p>
With the <code>has-name</code> modifier combined with the <code>file-name</code> element, you can add a <strong>placeholder</strong> for the selected file name.
</p>
</div>
<div class="bd-example">
{{ file_name }}
</div>
</div>
<div class="column is-6 bd-highlight-full">
{% highlight html %}{{ file_name }}{% endhighlight %}
</div>
</div>
<div class="columns">
<div class="column is-6">
<div class="content">
<p>
You can move the CTA to the <strong>right side</strong> with the <code>is-right</code> modifier.
</p>
</div>
<div class="bd-example">
{{ file_name_right }}
</div>
</div>
<div class="column is-6 bd-highlight-full">
{% highlight html %}{{ file_name_right }}{% endhighlight %}
</div>
</div>
<div class="columns">
<div class="column is-6">
<div class="content">
<p>
You can also <strong>expand</strong> the name to fill up the space with the <code>is-fullwidth</code> modifier.
</p>
</div>
<div class="bd-example">
{{ file_name_fullwidth }}
</div>
</div>
<div class="column is-6 bd-highlight-full">
{% highlight html %}{{ file_name_fullwidth }}{% endhighlight %}
</div>
</div>
<div class="columns">
<div class="column is-6">
<div class="content">
<p>
You can have a <strong>boxed block</strong> with the <code>is-boxed</code> modifier.
</p>
</div>
<div class="bd-example">
{{ file_boxed }}
</div>
</div>
<div class="column is-6 bd-highlight-full">
{% highlight html %}{{ file_boxed }}{% endhighlight %}
</div>
</div>
<div class="columns">
<div class="column is-6">
<div class="content">
<p>
You can <strong>combine</strong> <code>has-name</code> and <code>is-boxed</code>.
</p>
</div>
<div class="bd-example">
{{ file_boxed_name }}
</div>
</div>
<div class="column is-6 bd-highlight-full">
{% highlight html %}{{ file_boxed_name }}{% endhighlight %}
</div>
</div>
{% include elements/anchor.html name="Colors" %}
<div class="content">
<p>
You can style the file element by appending one of the <strong>{{ site.data.colors.derived | size }} color modifiers</strong>:
</p>
<ul>
{% for color in site.data.colors.derived %}
<li>
<code>is-{{ color.id }}</code>
</li>
{% endfor %}
</ul>
</div>
{% include elements/snippet.html content=file_colors_a %}
{% include elements/snippet.html content=file_colors_b %}
{% include elements/snippet.html content=file_colors_c %}
{% include elements/snippet.html content=file_colors_d %}
{% include elements/anchor.html name="Sizes" %}
<div class="content">
<p>
You can append one of the <strong>4 available sizes</strong>:
</p>
<ul>
<li>
<code>is-small</code>
</li>
<li>
<code>is-normal</code> (default)
</li>
<li>
<code>is-medium</code>
</li>
<li>
<code>is-large</code>
</li>
</ul>
</div>
{% for size in site.data.sizes %}
{% capture foobar %}
<div class="file is-{{ size }}">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
{{ size | capitalize }} file…
</span>
</span>
</label>
</div>
{% endcapture %}
{% include elements/snippet.html content=foobar %}
{% endfor %}
{% for size in site.data.sizes %}
{% capture foobar %}
<div class="file is-{{ size }} has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
{{ size | capitalize }} file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% include elements/snippet.html content=foobar %}
{% endfor %}
{% for size in site.data.sizes %}
{% capture foobar %}
<div class="file is-{{ size }} is-boxed">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
{{ size | capitalize }} file…
</span>
</span>
</label>
</div>
{% endcapture %}
{% include elements/snippet.html content=foobar %}
{% endfor %}
{% for size in site.data.sizes %}
{% capture foobar %}
<div class="file is-{{ size }} is-boxed has-name">
<label class="file-label">
<input class="file-input" type="file" name="resume">
<span class="file-cta">
<span class="file-icon">
<i class="fas fa-upload"></i>
</span>
<span class="file-label">
{{ size | capitalize }} file…
</span>
</span>
<span class="file-name">
{{ page.file_name }}
</span>
</label>
</div>
{% endcapture %}
{% include elements/snippet.html content=foobar %}
{% endfor %}
{% include elements/anchor.html name="Alignment" %}
<div class="content">
<p>
You can <strong>align</strong> the file input:
</p>
<ul>
<li>
to the <strong>center</strong> with the <code>is-centered</code> modifier
</li>
<li>
to the <strong>right</strong> with the <code>is-right</code> modifier
</li>
</ul>
</div>
{% include elements/snippet.html content=file_centered %}
{% include elements/snippet.html content=file_right %}
{% include elements/anchor.html name="JavaScript" %}
<div class="content">
<p>
A file upload input requires JavaScript to <strong>retrieve</strong> the <strong>selected file name</strong>.
Here is an example of how this could be done:
</p>
</div>
{% include elements/snippet.html horizontal=true content=file_javascript %}
{% include components/variables.html
type='element'
variables_keys=page.variables_keys
folder='elements'
file='form'
%}