Skip to content

Commit

Permalink
Docs: Get random kittens from unsplash instead of placekitten.com.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitschpatrol committed May 13, 2024
1 parent eb43ae0 commit fc1fedb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lib/control/Image.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,20 @@ position="inline">`.
import { Button, Image } from 'svelte-tweakpane-ui';
let source = 'placeholder';
let kittenIndex = 1;
async function getRandomKittenUrl() {
const { url } = await fetch(
'https://source.unsplash.com/800x800/?kitten',
{ method: 'HEAD', redirect: 'follow' }
);
return url;
}
</script>
<Image bind:value={source} fit="contain" label="Image" />
<Button
on:click={() => {
source = `https://placekitten.com/1024/1024?image=${kittenIndex}`;
kittenIndex = (kittenIndex % 16) + 1;
on:click={async () => {
source = await getRandomKittenUrl();
}}
label="Random Placeholder"
title="Load Kitten"
Expand Down

0 comments on commit fc1fedb

Please sign in to comment.