-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from flo-bit/main
update demos
- Loading branch information
Showing
3 changed files
with
135 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<script lang="ts"> | ||
import { CardSwiper } from '$lib/CardSwiper'; | ||
import { fade } from 'svelte/transition'; | ||
let swipe: (direction?: 'left' | 'right') => void; | ||
let people = [ | ||
{ | ||
name: 'Lucas', | ||
age: 40, | ||
description: 'Loves to dance in the rain.' | ||
}, | ||
{ | ||
name: 'Benjamin', | ||
age: 28, | ||
description: 'Eats pizza with a fork.' | ||
}, | ||
{ | ||
name: 'Noah', | ||
age: 49, | ||
description: 'Talks to plants.' | ||
}, | ||
{ | ||
name: 'Emily', | ||
age: 45, | ||
description: 'Sleeps with socks on.' | ||
}, | ||
{ | ||
name: 'Ava', | ||
age: 43, | ||
description: 'Thinks they can speak to animals.' | ||
}, | ||
{ | ||
name: 'Sophia', | ||
age: 23, | ||
description: 'Obsessed with organizing.' | ||
}, | ||
{ | ||
name: 'Charlotte', | ||
age: 41, | ||
description: 'Afraid of shadows.' | ||
}, | ||
{ | ||
name: 'Olivia', | ||
age: 23, | ||
description: 'Collects rare pebbles.' | ||
}, | ||
{ | ||
name: 'Isabella', | ||
age: 42, | ||
description: 'Always forgets why they walked into a room.' | ||
}, | ||
{ | ||
name: 'Jacob', | ||
age: 24, | ||
description: 'Can recite movies backwards.' | ||
} | ||
]; | ||
let thresholdPassed = 0; | ||
let classes = ''; | ||
export { classes as class} | ||
</script> | ||
|
||
<div class="h-full w-full p-2 flex items-center justify-center relative overflow-hidden {classes}"> | ||
<div class="w-full h-full max-w-xl relative"> | ||
<CardSwiper | ||
bind:swipe | ||
cardData={(index) => { | ||
let i = Math.floor(Math.random() * people.length); | ||
let j = Math.floor(Math.random() * people.length); | ||
return { | ||
title: people[i].name + ', ' + people[i].age, | ||
description: people[j].description, | ||
image: `/svelte-swiper-cards/profiles/${index % 14}.png` | ||
}; | ||
}} | ||
on:swiped={(e) => { | ||
console.log(e.detail); | ||
}} | ||
bind:thresholdPassed | ||
/> | ||
|
||
<button | ||
class="absolute bottom-1 left-1 p-3 px-4 bg-white/50 backdrop-blur-sm rounded-full z-10 text-3xl" | ||
on:click={() => swipe('left')} | ||
> | ||
π | ||
</button> | ||
<button | ||
class="absolute bottom-1 right-1 p-3 px-4 bg-white/50 backdrop-blur-sm rounded-full z-10 text-3xl" | ||
on:click={() => swipe('right')} | ||
> | ||
π | ||
</button> | ||
</div> | ||
|
||
{#if thresholdPassed !== 0} | ||
<div | ||
transition:fade={{ duration: 200 }} | ||
class="absolute w-full h-full inset-0 bg-white/20 backdrop-blur-sm flex items-center justify-center text-9xl pointer-events-none" | ||
> | ||
{thresholdPassed > 0 ? 'π' : 'π'} | ||
</div> | ||
{/if} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.