|
1 | 1 | <script lang="ts"> |
2 | | - import { inview, type Options, type ObserverEventDetails } from "svelte-inview"; |
3 | 2 | import { fly } from "svelte/transition"; |
4 | 3 |
|
5 | 4 | const { avatar, name, github }: { avatar: string; name: string; github?: string } = $props(); |
6 | | -
|
7 | | - let isInView = $state(false); |
8 | 5 | const animDelay = Math.random() * 200; |
9 | | -
|
10 | | - const inviewOpts: Options = { |
11 | | - unobserveOnEnter: true, |
12 | | - rootMargin: "-20%", |
13 | | - }; |
14 | | -
|
15 | | - const inviewChange = ({ detail }: CustomEvent<ObserverEventDetails>) => { |
16 | | - isInView = detail.inView; |
17 | | - }; |
18 | 6 | </script> |
19 | 7 |
|
20 | 8 | {#if github} |
21 | | - <div |
22 | | - class="flex flex-col items-center justify-center" |
23 | | - use:inview={inviewOpts} |
24 | | - oninview_change={inviewChange} |
| 9 | + <a |
| 10 | + in:fly={{ x: 20, delay: animDelay }} |
| 11 | + href="https://github.com/{github}" |
| 12 | + target="_blank" |
| 13 | + class="flex flex-col items-center justify-start bg-slate-9 py-4 w-full rounded-lg transition-all hover:scale-110 hover:bg-slate-8 cursor-pointer decoration-none color-white" |
25 | 14 | > |
26 | | - {#if isInView} |
27 | | - <a |
28 | | - in:fly={{ x: 20, delay: animDelay }} |
29 | | - href="https://github.com/{github}" |
30 | | - target="_blank" |
31 | | - class="flex flex-col items-center justify-start bg-slate-9 py-4 w-full h-full rounded-lg transition-all hover:scale-110 hover:bg-slate-8 cursor-pointer decoration-none color-white" |
32 | | - > |
33 | | - <img class="w-60 rounded-lg h-60 object-cover object-top" src={avatar} alt={name} /> |
34 | | - <p class="text-lg font-bold mb-0">{name}</p> |
35 | | - <p class="mt-0 color-blue-3">@{github}</p> |
36 | | - </a> |
37 | | - {:else} |
38 | | - <div class="w-full h-full"></div> |
39 | | - {/if} |
40 | | - </div> |
| 15 | + <img class="w-60 rounded-lg h-60 object-cover object-top" src={avatar} alt={name} /> |
| 16 | + <p class="text-lg font-bold mb-0">{name}</p> |
| 17 | + <p class="mt-0 color-blue-3">@{github}</p> |
| 18 | + </a> |
41 | 19 | {:else} |
42 | 20 | <div |
43 | | - class="flex flex-col items-center justify-center" |
44 | | - use:inview={inviewOpts} |
45 | | - oninview_change={inviewChange} |
| 21 | + in:fly={{ x: 20, delay: animDelay }} |
| 22 | + class="w-full flex flex-col items-center justify-start bg-slate-9 py-4 rounded-lg decoration-none color-white" |
46 | 23 | > |
47 | | - {#if isInView} |
48 | | - <div |
49 | | - in:fly={{ x: 20, delay: animDelay }} |
50 | | - class="w-full h-full flex flex-col items-center justify-start bg-slate-9 py-4 rounded-lg decoration-none color-white" |
51 | | - > |
52 | | - <img class="w-60 rounded-lg h-60 object-cover object-top" src={avatar} alt={name} /> |
53 | | - <p class="text-lg font-bold mb-0">{name}</p> |
54 | | - </div> |
55 | | - {:else} |
56 | | - <div class="w-full h-full"></div> |
57 | | - {/if} |
| 24 | + <img class="w-60 rounded-lg h-60 object-cover object-top" src={avatar} alt={name} /> |
| 25 | + <p class="text-lg font-bold mb-0">{name}</p> |
58 | 26 | </div> |
59 | 27 | {/if} |
0 commit comments