Skip to content

Commit 55e22ff

Browse files
author
Pooya Parsa
committed
misc(form-file): update to BS 4.0.0
1 parent bdb5ab8 commit 55e22ff

File tree

4 files changed

+269
-332
lines changed

4 files changed

+269
-332
lines changed

src/components/form-file/README.md

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,13 @@ multiple files, and directory upload (for browsers that support directory mode)
66
```html
77
<template>
88
<div>
9-
<!-- Simple File -->
10-
<b-form-file id="file_input1" v-model="file"></b-form-file>
11-
<br> Selected file: {{file && file.name}}
12-
13-
<div class="mt-3">
14-
<!-- Customized labels -->
15-
<b-form-file id="file_input2" v-model="file2" choose-label="Attachment2"></b-form-file>
16-
<br> Selected file : {{file2 && file2.name}}
17-
</div>
9+
<!-- Styled -->
10+
<b-form-file v-model="file" placeholder="Choose a file..."></b-form-file>
11+
<div class="mt-3">Selected file: {{file && file.name}}</div>
12+
13+
<!-- Plain mode -->
14+
<b-form-file v-model="file2" class="mt-3" plain></b-form-file>
15+
<div class="mt-3">Selected file: {{file2 && file2.name}}</div>
1816
</div>
1917
</template>
2018

@@ -36,20 +34,17 @@ For cross browser consistency, Form file defaults to the Bootstrap custom file
3634
input to replace the browser defaults. They’re built on top of semantic and accessible
3735
markup, so it is a solid replacement for the default file input.
3836

39-
4037
## Single file (default)
4138
On single file mode, when no file is selected or user cancels Browse dialog, `v-model` is `null`
4239
indicating no file selected. When a file is selected the return value will be a javascript
4340
[`File`](https://developer.mozilla.org/en/docs/Web/API/File) object instance.
4441

45-
4642
## Multiple files
4743
Multiple file uploading is supported by adding `multiple` prop to component.
4844
In this case `v-model` is *always* an `Array`. When no files are selected, an empty array
4945
will be returned. When a file or files are selected the return value will be an array of
5046
javascript [`File`](https://developer.mozilla.org/en/docs/Web/API/File) object instances.
5147

52-
5348
## Directory mode
5449
By adding `directory` prop, the user can select directories instead of files.
5550
When a directory is selected, the directory and its entire hierarchy of contents are included in the set of selected items.
@@ -59,11 +54,9 @@ The selected file system entries can be obtained using the `webkitEntries` prope
5954
be relied for production.
6055
[Read more on MDN](https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory)
6156

62-
6357
## Drag and Drop
6458
Drop mode is enabled by default. it can disabled by setting the `no-drop` prop.
6559

66-
6760
## Limiting to certain file types
6861
You can limit the file types by setting the `accept` prop to a string containing the
6962
allowed file type(s). To specify more than one type, separate the values with a comma.
@@ -87,34 +80,19 @@ list of standard media types.
8780

8881
**Note:** Not all browsers support or respect the `accept` attribute on file inputs.
8982

90-
91-
## Customizations
92-
Language strings and chosen file name is injected using `data-` props to css `content`.
93-
Local customization can be easily done with provided props such as `placeholder`,
94-
`choose-label`, `selected-format` and `drop-label`. If you want to globally change
95-
labels, you can add something like this to your global stylesheets. Also it is advised
96-
to use [:lang()](https://developer.mozilla.org/en-US/docs/Web/CSS/:lang) for multi-language sites.
83+
## Customize browse label
84+
If you want to globally change `Browse` label, you can add something like this to your global stylesheets.
85+
Also it is advised to use [:lang()](https://developer.mozilla.org/en-US/docs/Web/CSS/:lang) for multi-language sites.
9786

9887
```css
99-
/* Globally localize BootstrapVue file upload labels */
100-
101-
.custom-file-control::after {
102-
content: 'No files selected' !important;
103-
}
104-
105-
.custom-file-control::before {
106-
content: 'Choose file' !important;
107-
}
108-
109-
.custom-file .drop-here::before {
110-
content: 'Drop files here' !important;
88+
.custom-file-input:lang(en)~.custom-file-label::after {
89+
content: "Browse";
11190
}
11291
```
11392

11493
## Non custom file input
11594
You can have `<b-form-file>` render a browser native file input by setting the `plain` prop.
11695

117-
11896
## Contextual state feedback
11997
Bootstrap includes validation styles for `valid` and `invalid` states
12098
on most form controls.
@@ -129,7 +107,6 @@ and want to encourage a user through the rest of the fields.
129107
To apply one of the contextual state icons on `<b-form-file`, set the `state` prop
130108
to `'invalid'` (or `false`), `'valid'` ( or `true`), or `null`.
131109

132-
133110
## Accessibility
134111
When using the custom version of `<b-form-file>` input which hides the original input, it is
135112
**highly recommended** that you supply a document unique ID string via the `id` prop. This will
@@ -168,10 +145,8 @@ window.app = new Vue({
168145
})
169146
```
170147

171-
172148
## Component alias
173149

174150
`<b-form-file>` can be used via the shorter component alians `<b-file>`.
175151

176-
177152
## Component Reference

0 commit comments

Comments
 (0)