Skip to content

Commit e127334

Browse files
committed
add ToolCard
1 parent 7a090ac commit e127334

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<script lang="ts">
2+
import type { Post } from '$lib/model';
3+
import Spinner from '$lib/components/ui/polish/spinner/Spinner.svelte';
4+
5+
export let post: Post;
6+
7+
async function getImageSource(slug: string) {
8+
const path = `/tools/${slug}/${slug}`;
9+
const gifPath = `${path}.gif`;
10+
const pngPath = `${path}.png`;
11+
12+
// Check if the gif exists
13+
14+
const gifExists = await fetch(gifPath)
15+
.then((res) => res.ok)
16+
.catch(() => false);
17+
18+
if (gifExists) return gifPath;
19+
return pngPath;
20+
}
21+
</script>
22+
23+
<a
24+
href="/tools/{post.slug}"
25+
class="flex flex-col gap-y-2 rounded-xl border-[2px] border-accent/75 bg-gradient-to-b from-background-800 via-background-800 via-40% to-background-500 px-4 py-4 shadow-[0px_0px_12px_12px_rgba(0,0,0,0.3)] shadow-black/50 transition-all duration-300 hover:shadow-white/20 [&_h1]:hover:text-xl [&_iconify-icon]:hover:text-4xl [&_iconify-icon]:hover:text-primary [&_p]:hover:text-sm"
26+
>
27+
<div class="flex h-64 flex-col">
28+
{#await getImageSource(post.slug)}
29+
<Spinner />
30+
{:then source}
31+
<div
32+
class="flex flex-grow"
33+
style="background-image:url({source}); background-size: cover; background-position: center"
34+
></div>
35+
{/await}
36+
<div class="bottom-0 grid min-h-[3lh] grid-cols-5 bg-black/50 p-2">
37+
<div class="col-span-4">
38+
<h1>{post.title}</h1>
39+
<p>{post.description}</p>
40+
</div>
41+
<iconify-icon
42+
class="flex flex-grow items-center text-3xl text-primary/50 transition-all duration-200"
43+
icon="iconamoon:arrow-right-6-circle"
44+
></iconify-icon>
45+
</div>
46+
</div>
47+
</a>
48+
49+
<style>
50+
h1 {
51+
@apply text-lg text-primary transition-all duration-200;
52+
}
53+
p {
54+
@apply text-xs transition-all duration-200;
55+
}
56+
</style>

0 commit comments

Comments
 (0)