Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add accept prop to NeFileInput #58

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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'
}
}