summaryrefslogtreecommitdiff
path: root/src/components/Global
diff options
context:
space:
mode:
authorSurenNeware <sneware9@in.ibm.com>2020-09-03 16:05:21 +0300
committerDerick Montague <derick.montague@ibm.com>2020-11-23 20:27:01 +0300
commit978807de2d5a11860b74f1f97dc0d915ee5c9a5e (patch)
tree4db3c16b4f2afe3cc393df442be8155dae5eed95 /src/components/Global
parent8da32b5c42ca7f35676a11f257adac83215dd99c (diff)
downloadwebui-vue-978807de2d5a11860b74f1f97dc0d915ee5c9a5e.tar.xz
Add new style for form file component
- Now only add file button will be visible. - And selected file name will come down to the button. - Changed form file component from custom type to plain. Signed-off-by: Suren Neware <sneware9@in.ibm.com> Change-Id: Ib59135691495c4dddfdbbae0e4228b55cdfda2a8
Diffstat (limited to 'src/components/Global')
-rw-r--r--src/components/Global/FormFile.vue90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/components/Global/FormFile.vue b/src/components/Global/FormFile.vue
new file mode 100644
index 00000000..30af00d7
--- /dev/null
+++ b/src/components/Global/FormFile.vue
@@ -0,0 +1,90 @@
+<template>
+ <div class="custom-form-file-container">
+ <label>
+ <b-form-file
+ :id="id"
+ v-model="file"
+ :accept="accept"
+ :disabled="disabled"
+ :state="state"
+ plain
+ @input="$emit('input', file)"
+ >
+ </b-form-file>
+ <span class="add-file-btn btn btn-primary">
+ {{ $t('global.fileUpload.browseText') }}
+ </span>
+ <slot name="invalid"></slot>
+ </label>
+ <div v-if="file" class="clear-selected-file px-3 py-2 mt-2">
+ {{ file ? file.name : '' }}
+ <b-button variant="light" class="px-2 ml-auto" @click="file = null"
+ ><icon-close :title="$t('global.fileUpload.clearSelectedFile')"
+ /></b-button>
+ </div>
+ </div>
+</template>
+
+<script>
+import { BFormFile } from 'bootstrap-vue';
+import IconClose from '@carbon/icons-vue/es/close/20';
+
+export default {
+ name: 'FormFile',
+ components: { BFormFile, IconClose },
+ props: {
+ id: {
+ type: String,
+ default: '',
+ },
+ disabled: {
+ type: Boolean,
+ default: false,
+ },
+ accept: {
+ type: String,
+ default: '',
+ },
+ state: {
+ type: Boolean,
+ default: true,
+ },
+ },
+ data() {
+ return {
+ file: null,
+ };
+ },
+};
+</script>
+
+<style lang="scss" scoped>
+.form-control-file {
+ opacity: 0;
+ height: 0;
+ &:focus + span {
+ box-shadow: inset 0 0 0 3px theme-color('primary'), inset 0 0 0 5px $white;
+ }
+}
+
+// Get mouse pointer on complete element
+.add-file-btn {
+ position: relative;
+}
+
+.clear-selected-file {
+ display: flex;
+ align-items: center;
+ background-color: theme-color('light');
+ .btn {
+ width: 36px;
+ height: 36px;
+ display: flex;
+ align-items: center;
+
+ &:focus {
+ box-shadow: inset 0 0 0 2px theme-color('primary');
+ }
+ }
+}
+</style>