-
Notifications
You must be signed in to change notification settings - Fork 23
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
Svelte component example #10
Comments
Thanks @Joshimello! |
Sure! No problem! Heres a typed version <script lang="ts">
import { minidenticon } from "minidenticons"
let {
username,
saturation = 95,
lightness = 45,
...others
} : {
username: string,
saturation?: number | string,
lightness?: number | string,
[key: string]: any
} = $props()
let svgURI: string = $derived(
'data:image/svg+xml;utf8,' +
encodeURIComponent(minidenticon(username, saturation, lightness))
)
</script>
<img
src={svgURI}
alt={username}
{...others}
/> And an untyped version <script>
import { minidenticon } from "minidenticons"
let {
username,
saturation = 95,
lightness = 45,
...others
} = $props()
let svgURI = $derived(
'data:image/svg+xml;utf8,' +
encodeURIComponent(minidenticon(username, saturation, lightness))
)
</script>
<img
src={svgURI}
alt={username}
{...others}
/> |
Thanks again @Joshimello 👍 |
Update: I’m actually waiting for React 19 to be officially released (not the beta) to revamp the docs. |
@Joshimello Svelte 5 was just released, I’ll try to include your example soon. |
Awesome library!
Just wanted to share a component method for anyone using svelte :D
Only the username prop is required.
Component:
Example usage with class props:
The text was updated successfully, but these errors were encountered: