Commit 0889d4487a

0889d4487a9970530f6e915a93ea620f821884ce

parent: c57efee823

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-02-17 16:44 UTC

Compentized common functionalities

Layout: unified · split

web/src/components/things/SectionList.astro added +73
@@ -0,0 +1,73 @@
1---
2
3import { slugify } from '../../utils/fetch-data';
4
5import type { Section } from '../../types/Service';
6
7interface Props {
8 title: string;
9 sections: Section[];
10 bigTitle?: boolean;
11}
12
13const { title, sections, bigTitle } = Astro.props;
14
15---
16
17{ bigTitle ?
18 <h2>{title}</h2> :
19 <a class="category-title" href={`/${slugify(title)}`}><h3>{title}</h3></a>
20}
21
22<ul>
23 {sections.map((section) => (
24 <li>
25 <a href={`/${slugify(title)}/${slugify(section.name)}`}>
26 <span>{section.name}</span>
27 <span class="service-count">({section.services ? section.services.length : 0})</span>
28 </a>
29 </li>
30 ))}
31</ul>
32
33
34<style lang="scss">
35
36h2 {
37 font-family: "Lekton", sans-serif;
38 font-size: 2rem;
39 margin: -2rem 0 2rem -2rem;
40 box-shadow: 6px 6px 0 var(--foreground);
41 background: var(--accent);
42 color: var(--accent-fg);
43 width: fit-content;
44 padding: 0.25rem 0.5rem;
45}
46
47.category-title {
48 text-decoration: none;
49 color: var(--foreground);
50 h3 {
51 font-family: "Lekton", sans-serif;
52 font-weight: bold;
53 margin: 0;
54 font-size: 1.8rem;
55 }
56}
57
58ul {
59 list-style: circle;
60 padding-left: 1rem;
61 li {
62 margin: 0.5rem 0;
63 font-size: 1.25rem;
64 a {
65 text-decoration: none;
66 color: var(--foreground);
67 }
68 .service-count {
69 color: var(--accent-3);
70 }
71 }
72}
73</style>
web/src/components/things/ServiceList.astro added +111
@@ -0,0 +1,111 @@
1---
2
3import Button from '@components/form/Button.astro';
4import { parseMarkdown, formatLink } from '@utils/parse-markdown';
5import type { Service } from 'src/types/Service';
6
7const { title, services, subHeading, buttonLink } = Astro.props;
8
9---
10
11
12<section>
13 {services ? (
14 <ul>
15 {services.map((service: Service) => (
16 <li>
17 <div class="service-head">
18 <img src={service.icon || `https://icon.horse/icon/${formatLink(service.url)}`}
19 width="24" height="24" alt="icon" loading="lazy" decoding="async" />
20 {subHeading ? <h4>{service.name}</h4> : <h3>{service.name}</h3>}
21 {service.followWith && <p class="follow-with">({service.followWith})</p> }
22 <a class="service-link" href={service.url}>{formatLink(service.url)}</a>
23 </div>
24 <div class="service-body">
25 <p set:html={parseMarkdown(service.description)}></p>
26 </div>
27 </li>
28 ))}
29 </ul>
30 ) : (
31 <p class="nothing-yet">
32 <strong>⚠️ This section is still a work in progress ⚠️</strong><br />
33 Check back soon, or help us complete it by submiting a pull request on GitHub.
34 </p>
35 )}
36
37 {buttonLink && ( <Button text="View All" url={buttonLink} /> )}
38</section>
39
40
41<style lang="scss">
42
43 section {
44 padding: 1rem 0;
45 position: relative;
46 &:not(:last-child) {
47 border-bottom: 2px solid var(--accent-3);
48 }
49 }
50
51 .nothing-yet {
52 font-size: 1.4rem;
53 opacity: 0.8;
54 font-style: italic;
55 text-align: center;
56 margin-bottom: 3rem;
57 }
58
59 ul {
60 list-style: none;
61 padding: 0;
62 margin: 0 0 3rem 0;
63 li {
64 margin-bottom: 1rem;
65 .service-head {
66 display: flex;
67 align-items: center;
68 gap: 0.5rem;
69 h3, h4 {
70 margin: 0;
71 font-size: 1.6rem;
72 }
73 img {
74 border-radius: 4px;
75 }
76 .follow-with {
77 opacity: 0.7;
78 font-style: italic;
79 margin: 0;
80 }
81 .service-link {
82 max-width: 300px;
83 text-overflow: ellipsis;
84 overflow: hidden;
85 white-space: nowrap;
86 }
87 }
88
89 .service-body {
90 margin: 0.5rem 0 2rem;
91 opacity: 0.8;
92 :global(p) {
93 margin: 0;
94 font-size: 1.2rem;
95 :global(a) {
96 color: var(--foregorund);
97 }
98 }
99 }
100 }
101 }
102
103section :global(.button) {
104 width: fit-content;
105 position: absolute;
106 right: 1rem;
107 margin-top: -2.5rem;
108 background: var(--accent-3);
109}
110
111</style>