Skip to content
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 8 additions & 36 deletions src/components/FwbFileInput/FwbFileInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,15 @@
<div v-if="!dropzone">
<label>
<span :class="labelClasses">{{ label }}</span>
<input
:class="fileInpClasses"
:multiple="multiple"
type="file"
:accept="accept"
@change="handleChange"
>
<input :class="fileInpClasses" :multiple="multiple" type="file" :accept="accept" @change="handleChange" />
</label>
<slot />
</div>
<div
v-else
class="flex items-center justify-center"
@change="handleChange"
@dragover="dragOverHandler"
@drop="dropFileHandler"
>
<div v-else class="flex flex-col items-start justify-center" @change="handleChange" @dragover="dragOverHandler" @drop="dropFileHandler">
<span v-if="label !== ''" :class="labelClasses">{{ label }}</span>
<label :class="dropzoneLabelClasses">
<div :class="dropzoneWrapClasses">
<svg
aria-hidden="true"
class="w-8 h-8 text-gray-500 dark:text-gray-400"
fill="none"
viewBox="0 0 20 16"
xmlns="http://www.w3.org/2000/svg"
>
<svg aria-hidden="true" class="w-8 h-8 text-gray-500 dark:text-gray-400" fill="none" viewBox="0 0 20 16" xmlns="http://www.w3.org/2000/svg">
<path
d="M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"
stroke-linecap="round"
Expand All @@ -46,12 +29,7 @@
</div>
<p v-else>File: {{ dropZoneText }}</p>
</div>
<input
:multiple="multiple"
type="file"
:accept="accept"
class="hidden"
>
<input :multiple="multiple" type="file" :accept="accept" class="hidden" />
</label>
</div>
</div>
Expand All @@ -67,8 +45,8 @@ interface FileInputProps {
label?: string
modelValue?: File | File[] | null
multiple?: boolean
size?: string,
accept?:string,
size?: string
accept?: string
}

const props = withDefaults(defineProps<FileInputProps>(), {
Expand Down Expand Up @@ -138,11 +116,5 @@ const dragOverHandler = (event: Event) => {
event.preventDefault()
}

const {
fileInpClasses,
labelClasses,
dropzoneLabelClasses,
dropzoneWrapClasses,
dropzoneTextClasses,
} = useFileInputClasses(props.size)
const { fileInpClasses, labelClasses, dropzoneLabelClasses, dropzoneWrapClasses, dropzoneTextClasses } = useFileInputClasses(props.size)
</script>