Skip to content

Commit

Permalink
feat: add accept prop to NeFileInput (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
andre8244 authored Jun 6, 2024
1 parent 7bdd4b9 commit 5faa252
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/components/NeFileInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface FileInputProps {
dropzoneLabel: string
progress: number
showProgress: boolean
accept: string | undefined
}

const props = withDefaults(defineProps<FileInputProps>(), {
Expand All @@ -24,7 +25,8 @@ const props = withDefaults(defineProps<FileInputProps>(), {
invalidMessage: '',
progress: 0,
showProgress: false,
dropzoneLabel: 'Drag and drop or click to upload'
dropzoneLabel: 'Drag and drop or click to upload',
accept: undefined
})

const emit = defineEmits(['update:modelValue', 'select'])
Expand Down Expand Up @@ -105,7 +107,7 @@ const dragOverHandler = (event: Event) => {
{{ dropZoneText }}
</p>
</div>
<input class="hidden" type="file" />
<input class="hidden" type="file" :accept="accept" />
<!-- progress bar -->
<NeProgressBar
v-if="showProgress"
Expand Down
16 changes: 15 additions & 1 deletion stories/NeFileInput.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const meta = {
progress: 0,
showProgress: false,
dropzoneLabel: 'Drag and drop or click to upload',
modelValue: null
modelValue: null,
accept: undefined
} // default values
} satisfies Meta<typeof NeFileInput>

Expand Down Expand Up @@ -57,3 +58,16 @@ export const Progress: Story = {
}),
args: { showProgress: true, progress: 75 }
}

export const Accept: Story = {
render: (args) => ({
components: { NeFileInput },
setup() {
return { args }
},
template: template
}),
args: {
accept: 'image/*,.pdf'
}
}

0 comments on commit 5faa252

Please sign in to comment.