web/src/components/things/ServiceCard.svelte
69 lines · 1986 bytes
1<script lang="ts">
2 import FontAwesome from '@components/form/FontAwesome.svelte';
3 import SaveListing from '@components/things/SaveListing.svelte';
4 import { slugify } from '@utils/fetch-data';
5 import { formatLink } from '@utils/parse-markdown';
6 import type { Service } from 'src/types/Service';
7
8 export let service: Service;
9 export let categoryName: string;
10 export let sectionName: string;
11
12 // Computed values based on props
13 let serviceRef = slugify(service.name);
14 let categorySlug = slugify(categoryName);
15 let sectionSlug = slugify(sectionName);
16</script>
17
18<div class="service" id={serviceRef}>
19 <div class="service-head">
20 <a class="service-title" href={`/${categorySlug}/${sectionSlug}/${serviceRef}`}>
21 <h4>{service.name}</h4>
22 </a>
23 {#if service.followWith}
24 <p class="follow-with">({service.followWith})</p>
25 {/if}
26 </div>
27
28 <div class="save-listing">
29 <SaveListing
30 categoryName={categoryName}
31 sectionName={sectionName}
32 serviceName={service.name}
33 />
34 </div>
35
36 <div class="service-body">
37 <img
38 width="40"
39 height="40"
40 loading="lazy"
41 decoding="async"
42 class="service-icon"
43 alt={`${service.name} Icon`}
44 data-service-url={formatLink(service.url)}
45 src={service.icon || `https://icon.horse/icon/${formatLink(service.url)}`}
46 />
47 <div class="service-body">
48 <p>{@html service.description}</p>
49 </div>
50 </div>
51
52 <div class="service-links">
53 <a class="link" href={service.url}>
54 <FontAwesome iconName="website" /> <span>{formatLink(service.url)}</span>
55 </a>
56 {#if service.github}
57 <a class="link" href={`https://github.com/${service.github}`}>
58 <FontAwesome iconName="sourceCode" /> GitHub
59 </a>
60 {/if}
61 <a href={`/${categorySlug}/${sectionSlug}/${serviceRef}`}>
62 <FontAwesome iconName="viewReport" /> View Report ➔
63 </a>
64 </div>
65</div>
66
67<style lang="scss">
68 @import './service-card.scss';
69</style>