web/src/components/things/ServiceList.astro
344 lines · 8156 bytes
1---
2import Button from '@components/form/Button.astro';
3import { parseMarkdown, formatLink } from '@utils/parse-markdown';
4import type { Service } from 'src/types/Service';
5import FontAwesome from '@components/form/FontAwesome.svelte';
6import DeleteListing from '@components/things/DeleteListing.svelte';
7import ServiceIcon from '@components/things/ServiceIcon.astro';
8import { slugify } from '@utils/fetch-data';
9
10import GitHubMetrics from '@components/things/ItemGitHubMetrics.astro';
11import SaveListing from '@components/things/SaveListing.svelte';
12
13interface Props {
14 services: Service[];
15 subHeading?: boolean;
16 buttonLink?: string;
17 noGitHubMetrics?: boolean;
18 sectionName: string;
19 categoryName: string;
20}
21
22const {
23 services,
24 subHeading,
25 buttonLink,
26 noGitHubMetrics,
27 sectionName,
28 categoryName,
29} = Astro.props;
30---
31
32<section>
33 {
34 services && services.length > 0 ? (
35 <ul>
36 {services.map((service: Service) => (
37 <li id={slugify(service.name)}>
38 <DeleteListing
39 client:load
40 categoryName={categoryName}
41 sectionName={sectionName}
42 serviceName={service.name}
43 />
44 <div class="save-listing">
45 <SaveListing
46 client:visible
47 categoryName={categoryName}
48 sectionName={sectionName}
49 serviceName={service.name}
50 />
51 </div>
52 <div class="service-head">
53 <ServiceIcon
54 name={service.name}
55 url={service.url}
56 icon={service.icon}
57 />
58
59 <a
60 class="service-title"
61 href={`/${slugify(categoryName)}/${slugify(sectionName)}/${slugify(service.name)}`}
62 >
63 {subHeading ? <h4>{service.name}</h4> : <h3>{service.name}</h3>}
64 </a>
65 {service.followWith && (
66 <p class="follow-with">({service.followWith})</p>
67 )}
68 <a class="service-link" href={service.url}>
69 {formatLink(service.url)}
70 </a>
71 </div>
72 <div class="service-body">
73 <p set:html={parseMarkdown(service.description)} />
74 <div class="service-stats">
75 <div class="left">
76 {service.securityAudited && (
77 <span
78 class="meta-item great"
79 title={`${service.name} has been security audited by an accredited auditor, with results published publicly`}
80 >
81 <FontAwesome iconName="securityAudited" /> Security
82 Audited
83 </span>
84 )}
85 {service.acceptsCrypto && (
86 <span
87 class="meta-item great"
88 title={`${service.name} accepts anonymous payment methods`}
89 >
90 <FontAwesome iconName="cryptoAccepted" /> Crypto Payments
91 Accepted
92 </span>
93 )}
94 {service.securityAudited === false && (
95 <span
96 class="meta-item warning"
97 title={`${service.name} has not been audited`}
98 >
99 <FontAwesome iconName="notSecurityAudited" /> No Security
100 Audit
101 </span>
102 )}
103 {service.openSource === false && (
104 <span class="warning">
105 <FontAwesome iconName="closedSource" />
106 Not Open Source
107 </span>
108 )}
109 {service.openSource ||
110 (service.github && service.openSource !== false) ? (
111 <span
112 class="meta-item great"
113 title={`${service.name} is open source`}
114 >
115 <FontAwesome iconName="openSource" /> Open Source
116 </span>
117 ) : null}
118 {service.github && !noGitHubMetrics && (
119 <GitHubMetrics github={service.github} />
120 )}
121 {service.github && noGitHubMetrics && (
122 <span
123 class="meta-item"
124 title={`View ${service.name} on GitHub`}
125 >
126 <a
127 href={`https://github.com/${service.github}`}
128 target="_blank"
129 >
130 <FontAwesome iconName="github" /> {service.github}
131 </a>
132 </span>
133 )}
134 </div>
135 <div class="view-service">
136 <a
137 href={`/${slugify(categoryName)}/${slugify(sectionName)}/${slugify(service.name)}`}
138 >
139 View {service.name} Report
140 </a>
141 </div>
142 </div>
143 </div>
144 </li>
145 ))}
146 </ul>
147 ) : (
148 <p class="nothing-yet">
149 <>
150 <strong>⚠️ This section is still a work in progress ⚠️</strong>
151 <br />
152 </>
153 Check back soon, or help us complete it by submiting a pull request on
154 GitHub.
155 <br />
156 <span class="quick-submit">
157 Or submit an entry <a href="/submit">here</a>
158 </span>
159 </p>
160 )
161 }
162
163 {
164 buttonLink && (
165 <Button
166 title={`View all ${categoryName}`}
167 className="view-all"
168 text="View More..."
169 url={buttonLink}
170 />
171 )
172 }
173</section>
174
175<style lang="scss">
176 @use '../../styles/mixins' as *;
177 section {
178 padding: var(--space-md) 0;
179 position: relative;
180 &:not(:last-child) {
181 border-bottom: 2px solid var(--accent-3);
182 }
183 }
184
185 .nothing-yet {
186 font-size: var(--text-lg);
187 opacity: var(--opacity-subtle);
188 font-style: italic;
189 text-align: center;
190 margin-bottom: var(--space-xl);
191 .quick-submit {
192 margin-top: var(--space-md);
193 font-size: var(--text-sm);
194 opacity: var(--opacity-subtle);
195 }
196 }
197
198 ul {
199 list-style: none;
200 padding: 0;
201 margin: 0 0 var(--space-xl) 0;
202 li {
203 margin-bottom: var(--space-md);
204 position: relative;
205 .save-listing {
206 position: absolute;
207 right: var(--space-md);
208 top: var(--space-md);
209 }
210 .service-head {
211 display: flex;
212 align-items: center;
213 gap: var(--space-sm);
214 flex-wrap: wrap;
215 .service-title {
216 text-decoration: none;
217 color: var(--foreground);
218 @include underline-hover(var(--accent-3));
219 h3,
220 h4 {
221 margin: 0;
222 font-size: var(--text-xl);
223 }
224 }
225
226 :global(.service-icon-wrap) {
227 width: 2.5rem;
228 height: 2.5rem;
229 border-radius: var(--curve-sm);
230 overflow: hidden;
231 color: var(--accent);
232 }
233 .follow-with {
234 opacity: var(--opacity-soft);
235 font-style: italic;
236 margin: 0;
237 }
238 .service-link {
239 max-width: 300px;
240 @include truncate;
241 }
242 }
243
244 .service-body {
245 margin: var(--space-sm) 0 var(--space-lg);
246 opacity: var(--opacity-subtle);
247 :global(p) {
248 margin: 0;
249 font-size: var(--text-md);
250 :global(a) {
251 color: var(--foregorund);
252 }
253 }
254 .service-stats {
255 .left {
256 display: flex;
257 gap: var(--space-md);
258 flex-wrap: wrap;
259 align-items: center;
260 }
261 display: flex;
262 gap: var(--space-md);
263 flex-wrap: wrap;
264 align-items: center;
265 justify-content: space-between;
266 }
267 .view-service {
268 transition: var(--transition-normal);
269 opacity: 0.95;
270 a {
271 padding: var(--space-xs) 0.6rem;
272 width: fit-content;
273 right: var(--space-md);
274 font-size: var(--text-sm);
275 background: var(--accent-3);
276 color: var(--accent-fg);
277 text-decoration: none;
278 border-radius: var(--curve-md);
279 }
280 &:hover {
281 opacity: 1;
282 transform: scale(1.05);
283 }
284 }
285
286 .meta-item,
287 .warning {
288 display: flex;
289 align-items: center;
290 gap: var(--space-xs);
291 font-size: var(--text-sm);
292 padding: var(--space-sm) 0;
293 :global(svg) {
294 color: var(--foreground);
295 width: 1.2rem;
296 height: 1.2rem;
297 }
298 a {
299 text-decoration: none;
300 color: var(--foreground);
301 display: flex;
302 gap: var(--space-xs);
303 &:hover {
304 color: var(--accent-3);
305 :global(svg) {
306 color: var(--accent-3);
307 }
308 }
309 }
310 }
311 .warning {
312 color: var(--danger);
313 :global(svg) {
314 color: var(--danger);
315 }
316 }
317 .great {
318 color: var(--success-muted);
319 :global(svg) {
320 color: var(--success-muted);
321 }
322 }
323 }
324 }
325 }
326
327 section :global(.view-all) {
328 width: fit-content;
329 position: absolute;
330 right: var(--space-md);
331 margin-top: -2.5rem;
332 background: var(--accent-3);
333 }
334
335 li:hover :global(.actions) {
336 opacity: var(--opacity-muted);
337 :global(a):hover {
338 opacity: 1;
339 }
340 }
341 :global(.actions a):hover {
342 opacity: 1;
343 }
344</style>