web/src/components/things/ServiceCard.svelte
69 lines · 2073 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
21 class="service-title"
22 href={`/${categorySlug}/${sectionSlug}/${serviceRef}`}
23 >
24 <h4>{service.name}</h4>
25 </a>
26 {#if service.followWith}
27 <p class="follow-with">({service.followWith})</p>
28 {/if}
29 </div>
30
31 <div class="save-listing">
32 <SaveListing {categoryName} {sectionName} serviceName={service.name} />
33 </div>
34
35 <div class="service-body">
36 <img
37 width="40"
38 height="40"
39 loading="lazy"
40 decoding="async"
41 class="service-icon"
42 alt={`${service.name} Icon`}
43 data-service-url={formatLink(service.url)}
44 src={service.icon || `https://icon.horse/icon/${formatLink(service.url)}`}
45 />
46 <div class="service-body">
47 <!-- eslint-disable-next-line svelte/no-at-html-tags -- description is from curated YAML data, not user input -->
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 @use './service-card.scss';
69</style>