blurhash-svelte
is a Svelte component that decodes and displays BlurHash images. BlurHash is a compact representation of a placeholder for an image that can be displayed while the full image is loading.
To install the package, run:
npm install blurhash-svelte
Here is a basic example of how to use the BlurHash component in your Svelte application:
<script lang="ts">
import BlurHash from 'blurhash-svelte/BlurHash.svelte';
let hash = "LEHV6nWB2yk8pyo0adR*.7kCMdnj";
</script>
<BlurHash {hash} width={400} height={300} punch={1} />
The BlurHash component accepts the following props:
hash
(string): The BlurHash string.width
(number, optional, default: 400): The width of the canvas.height
(number, optional, default: 300): The height of the canvas.punch
(number, optional, default: 1): The punch value for enhancing the contrast.<script lang="ts">
import BlurHash from 'blurhash-svelte/BlurHash.svelte';
let hash = "LEHV6nWB2yk8pyo0adR*.7kCMdnj";
let width = 500;
let height = 350;
let punch = 2;
</script>
<BlurHash {hash} {width} {height} {punch} />
To develop and build the package locally, follow these steps:
git clone https://github.com/sondreal/blurhash-svelte.git
cd blurhash-svelte
npm install
npm run dev
npm run build
Contributions are welcome! Please follow these steps to contribute:
This project is licensed under the MIT License. See the LICENSE file for more details.