Commit 0991c323b6

0991c323b65c3a53626bdc1384898866802229e6

parent: e543ccbbd1

Unsigned

Alicia Sykes <alicia@omg.lol> · 2024-02-19 23:36 UTC

Layout, styling and logic for service and section list

Layout: unified · split

web/src/components/things/SectionList.astro +44 −2
@@ -1,5 +1,7 @@
11---
22
3
4import FontAwesome from '@components/form/FontAwesome.svelte';
35import { slugify } from '../../utils/fetch-data';
46
57import type { Section } from '../../types/Service';
@@ -14,14 +16,18 @@ const { title, sections, bigTitle } = Astro.props;
1416
1517---
1618
19<div class="wrap">
20
1721{ bigTitle ?
18 <h2>{title}</h2> :
22 <h2><FontAwesome iconName={slugify(title)} />{title} </h2> :
1923 <a class="category-title" href={`/${slugify(title)}`}><h3>{title}</h3></a>
2024}
2125
26{ !bigTitle && <span class="section-icon"><FontAwesome iconName={slugify(title)} /></span> }
27
2228<ul>
2329 {sections.map((section) => (
24 <li>
30 <li class="section">
2531 <a href={`/${slugify(title)}/${slugify(section.name)}`}>
2632 <span>{section.name}</span>
2733 <span class="service-count">({section.services ? section.services.length : 0})</span>
@@ -29,10 +35,21 @@ const { title, sections, bigTitle } = Astro.props;
2935 </li>
3036 ))}
3137</ul>
38</div>
3239
3340
3441<style lang="scss">
3542
43.wrap {
44 position: relative;
45 &:hover {
46 .section-icon :global(svg){
47 opacity: 1;
48 transform: scale(1.2);
49 }
50 }
51}
52
3653h2 {
3754 font-family: "Lekton", sans-serif;
3855 font-size: 2rem;
@@ -42,11 +59,21 @@ h2 {
4259 color: var(--accent-fg);
4360 width: fit-content;
4461 padding: 0.25rem 0.5rem;
62 display: flex;
63 justify-content: center;
64 gap: 1rem;
65 :global(svg) {
66 width: 2rem;
67 height: 2rem;
68 color: var(--accent-fg);
69 }
4570}
4671
4772.category-title {
4873 text-decoration: none;
4974 color: var(--foreground);
75 z-index: 2;
76 position: relative;
5077 h3 {
5178 font-family: "Lekton", sans-serif;
5279 font-weight: bold;
@@ -70,4 +97,19 @@ ul {
7097 }
7198 }
7299}
100
101.section-icon {
102 position: absolute;
103 right: 0;
104 top: 0;
105 width: fit-content;
106 :global(svg) {
107 width: 2rem;
108 height: 2rem;
109 opacity: 0.5;
110 text-shadow: 3px 3px 0 black;
111 color: var(--accent-3);
112 transition: all 0.2s ease-in-out;
113 }
114}
73115</style>
web/src/components/things/ServiceList.astro +119 −6
@@ -3,11 +3,31 @@
33import Button from '@components/form/Button.astro';
44import { parseMarkdown, formatLink } from '@utils/parse-markdown';
55import type { Service } from 'src/types/Service';
6import FontAwesome from '@components/form/FontAwesome.svelte';
67
7const { title, services, subHeading, buttonLink } = Astro.props;
8import GitHubMetrics from '@components/things/ItemGitHubMetrics.astro';
9
10const { services, subHeading, buttonLink, noGitHubMetrics } = Astro.props;
811
912---
1013
14<script>
15 document.addEventListener('DOMContentLoaded', (event) => {
16 const serviceIcons = document.querySelectorAll('.service-icon');
17 const broke = '/broken-image.png'
18
19 serviceIcons.forEach(function(icon) {
20 icon.onerror = function() {
21 const serviceUrl = this.getAttribute('data-service-url');
22 const newSrcAttribute = (this.src.includes('on.ho') ? broke : `https://icon.horse/icon/${serviceUrl}`);
23 this.src = this.src !== newSrcAttribute ? newSrcAttribute : broke;
24 this.onerror = null;
25 };
26 });
27 });
28</script>
29
30
1131
1232<section>
1333 {services ? (
@@ -15,14 +35,59 @@ const { title, services, subHeading, buttonLink } = Astro.props;
1535 {services.map((service: Service) => (
1636 <li>
1737 <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" />
38 <img
39 width="40"
40 height="40"
41 loading="lazy"
42 decoding="async"
43 class="service-icon"
44 alt={`${service.name} Icon`}
45 data-service-url={formatLink(service.url)}
46 src={service.icon || `https://icon.horse/icon/${formatLink(service.url)}`}
47 />
48
2049 {subHeading ? <h4>{service.name}</h4> : <h3>{service.name}</h3>}
2150 {service.followWith && <p class="follow-with">({service.followWith})</p> }
2251 <a class="service-link" href={service.url}>{formatLink(service.url)}</a>
2352 </div>
2453 <div class="service-body">
2554 <p set:html={parseMarkdown(service.description)}></p>
55 <div class="service-stats">
56 { service.securityAudited && (
57 <span class="meta-item great" title={`${service.name} has been security audited by an accredited auditor, with results published publicly`}>
58 <FontAwesome iconName="securityAudited" /> Security Audited
59 </span>
60 )}
61 { service.acceptsCrypto && (
62 <span class="meta-item great" title={`${service.name} accepts anonymous payment methods`}>
63 <FontAwesome iconName="cryptoAccepted" /> Crypto Payments Accepted
64 </span>
65 )}
66 { service.securityAudited === false && (
67 <span class="meta-item warning" title={`${service.name} has not been audited`}>
68 <FontAwesome iconName="notSecurityAudited" /> No Security Audit
69 </span>
70 )}
71 { (service.openSource === false) && (
72 <span class="warning">
73 <FontAwesome iconName="closedSource" />
74 Not Open Source
75 </span>
76 )}
77 { service.openSource || (service.github && service.openSource !== false) ? (
78 <span class="meta-item great" title={`${service.name} is open source`}>
79 <FontAwesome iconName="openSource" /> Open Source
80 </span>
81 ) : null }
82 { service.github && !noGitHubMetrics && <GitHubMetrics github={service.github} /> }
83 { service.github && noGitHubMetrics && (
84 <span class="meta-item" title={`View ${service.name} on GitHub`}>
85 <a href={`https://github.com/${service.github}`}>
86 <FontAwesome iconName="github" /> {service.github}
87 </a>
88 </span>
89 ) }
90 </div>
2691 </div>
2792 </li>
2893 ))}
@@ -34,7 +99,7 @@ const { title, services, subHeading, buttonLink } = Astro.props;
3499 </p>
35100 )}
36101
37 {buttonLink && ( <Button text="View All" url={buttonLink} /> )}
102 {buttonLink && ( <Button text="View More..." url={buttonLink} /> )}
38103</section>
39104
40105
@@ -70,8 +135,14 @@ const { title, services, subHeading, buttonLink } = Astro.props;
70135 margin: 0;
71136 font-size: 1.6rem;
72137 }
73 img {
74 border-radius: 4px;
138 .service-icon {
139 width: 2.5rem;
140 height: 2.5rem;
141 border-radius: var(--curve-sm);
142
143 font-size: 10px;
144 overflow: hidden;
145 color: var(--accent);
75146 }
76147 .follow-with {
77148 opacity: 0.7;
@@ -96,6 +167,48 @@ const { title, services, subHeading, buttonLink } = Astro.props;
96167 color: var(--foregorund);
97168 }
98169 }
170 .service-stats {
171 display: flex;
172 gap: 1rem;
173 }
174 .meta-item, .warning {
175 display: flex;
176 align-items: center;
177 // justify-content: center;
178 gap: 0.25rem;
179 opacity: 0.6;
180 font-size: 0.9rem;
181 padding: 0.5rem 0;
182 :global(svg) {
183 color: var(--foreground);
184 width: 1.2rem;
185 height: 1.2rem;
186 }
187 a {
188 text-decoration: none;
189 color: var(--foreground);
190 display: flex;
191 gap: 0.25rem;
192 &:hover {
193 color: var(--accent-3);
194 :global(svg) {
195 color: var(--accent-3);
196 }
197 }
198 }
199 }
200 .warning {
201 color: var(--danger);
202 :global(svg) {
203 color: var(--danger);
204 }
205 }
206 .great {
207 color: #007930; // var(--success);
208 :global(svg) {
209 color: #007930; // var(--success);
210 }
211 }
99212 }
100213 }
101214 }