Tauri file drop handling component for Svelte.
npm install svelte-tauri-filedrop
<script lang="ts">
import FileDrop from 'svelte-tauri-filedrop'
function open(paths: string[]) {
// ...
}
</script>
<FileDrop extensions={['json']} handleFiles={open} let:files>
<div class="dropzone" class:droppable={files.length > 0}>
<h2>Drop JSON files</h2>
</div>
</FileDrop>
<style>
.dropzone {
margin: 20px;
padding: 20px;
background: #eee;
}
.droppable {
background: #d6dff0;
}
</style>
List of allowed file extensions. Disallowed files are filtered out. If it's null (default), all file extensions are allowed.
Handle a file drop of one or more files
Handle a file drop of a single file.
Note that handleFile()
is also called.
This is not called if any disallowed files were filtered out.
An array of the currently droppable files, excluding disallowed files.
You can use this variable through a let binding: let:files
.
- Install Node.js (v14 works)
- Install Rust (v1.50 works)
- Follow the Tauri setup guide
- Run
npm install
npm run dev
: Start in dev modenpm run package
: Build and package the componentnpm run lint
: Lintnpm run format
: Format
- Update
CHANGELOG.md
- Check for errors
npm run check
- Bump the version number
npm version --no-git-tag <version>
- Generate the package
npm run package
- Publish the package
npm publish ./package
- Commit with a tag in format "v#.#.#"
- Create GitHub release with release notes