web/src/components/things/ListingHero.astro
372 lines · 8195 bytes
1---
2import type { Section, Service } from '../../types/Service';
3import { slugify } from '@utils/fetch-data';
4import { parseMarkdown, formatLink } from '@utils/parse-markdown';
5import FontAwesome from '@components/form/FontAwesome.svelte';
6import SaveListing from '@components/things/SaveListing.svelte';
7import ServiceIcon from '@components/things/ServiceIcon.astro';
8
9interface Props {
10 service: Service;
11 parentSection: Section;
12 categoryName: string;
13 privacyPolicyLink: string | null;
14}
15
16const { service, parentSection, categoryName, privacyPolicyLink } = Astro.props;
17const {
18 name,
19 description,
20 url,
21 github,
22 tosdrId,
23 iosApp,
24 androidApp,
25 discordInvite,
26 subreddit,
27 icon,
28 followWith,
29 links,
30 securityAudited,
31 openSource,
32 acceptsCrypto,
33} = service;
34
35const catSlug = slugify(categoryName);
36const secSlug = slugify(parentSection.name);
37
38const otherServices = parentSection.services.filter(
39 (s: Service) => s.name !== name,
40);
41
42const infoLinks = [
43 url && { label: 'Homepage', href: url, text: formatLink(url) },
44 github && {
45 label: 'GitHub',
46 href: `https://github.com/${github}`,
47 text: `github.com/${github}`,
48 },
49 tosdrId && {
50 label: 'Privacy',
51 href: privacyPolicyLink,
52 text: formatLink(privacyPolicyLink || ''),
53 },
54 iosApp && { label: 'iOS App', href: iosApp, text: formatLink(iosApp) },
55 androidApp && {
56 label: 'Android App',
57 href: `https://play.google.com/store/apps/details?id=${androidApp}`,
58 text: `play.google.com/.../${androidApp}`,
59 },
60 discordInvite && {
61 label: 'Discord',
62 href: `https://discord.com/invite/${discordInvite}`,
63 text: discordInvite,
64 },
65 subreddit && {
66 label: 'Subreddit',
67 href: `https://reddit.com/r/${subreddit}`,
68 text: `r/${subreddit}`,
69 },
70 url && {
71 label: 'Web info',
72 href: `https://web-check.xyz/check/${formatLink(url)}`,
73 text: `web-check.xyz/check/${formatLink(url).split('/')[0]}`,
74 },
75 ...(links || []).map((link) => ({
76 label: link.title,
77 href: link.url,
78 text: link.url,
79 })),
80].filter(Boolean) as { label: string; href: string | null; text: string }[];
81
82const highlights = [
83 securityAudited && {
84 icon: 'securityAudited',
85 text: 'Security Audited',
86 cls: 'great',
87 title: `${name} has been security audited by an accredited auditor, with results published publicly`,
88 },
89 acceptsCrypto && {
90 icon: 'cryptoAccepted',
91 text: 'Crypto Payments Accepted',
92 cls: 'great',
93 title: `${name} accepts anonymous payment methods`,
94 },
95 securityAudited === false && {
96 icon: 'notSecurityAudited',
97 text: 'No Security Audit',
98 cls: 'warning',
99 title: `${name} has not been audited`,
100 },
101 openSource === false && {
102 icon: 'closedSource',
103 text: 'Not Open Source',
104 cls: 'warning',
105 title: `${name} is not open source`,
106 },
107 (openSource || (github && openSource !== false)) && {
108 icon: 'openSource',
109 text: 'Open Source',
110 cls: 'great',
111 title: `${name} is open source`,
112 },
113].filter(Boolean) as {
114 icon: string;
115 text: string;
116 cls: string;
117 title: string;
118}[];
119---
120
121<section class="hero-section">
122 <div class="service-head">
123 <h1>{name}</h1>
124 <span class="url-wrap">
125 <a class="service-url" href={url}>{formatLink(url)}</a>
126 <span class="follow-with">{followWith}</span>
127 </span>
128 </div>
129 <div class="breadcrumbs">
130 <span>
131 <a href="/">Awesome Privacy</a>
132 ➔ <a href={`/${catSlug}`}>{categoryName}</a>
133 ➔ <a href={`/${catSlug}/${secSlug}`}>{parentSection.name}</a>
134 ➔ <a href={`/${catSlug}/${secSlug}/${slugify(name)}`}>{name}</a>
135 </span>
136 </div>
137 <div class="save-listing">
138 <SaveListing
139 client:visible
140 categoryName={categoryName}
141 sectionName={parentSection.name}
142 serviceName={name}
143 showLabel={true}
144 />
145 </div>
146 <div class="intro">
147 <ServiceIcon name={name} url={url} icon={icon} size={60} />
148 <div>
149 <p class="description" set:html={parseMarkdown(description)} />
150 <ul>
151 {
152 infoLinks.map((link) => (
153 <li>
154 <b>{link.label}:</b>
155 <a href={link.href} target="_blank" rel="noopener noreferrer">
156 {link.text}
157 </a>
158 </li>
159 ))
160 }
161 </ul>
162 <div class="related">
163 {
164 (parentSection.alternativeTo || []).length > 0 && (
165 <div class="related-group">
166 <h4 class="avoid">
167 <FontAwesome iconName="faceBad" /> Avoid
168 </h4>
169 <ul>
170 {(parentSection.alternativeTo || []).map((alt: string) => (
171 <li>
172 <span>{alt}</span>
173 </li>
174 ))}
175 </ul>
176 </div>
177 )
178 }
179 {
180 otherServices.length > 0 && (
181 <div class="related-group">
182 <h4 class="consider">
183 <FontAwesome iconName="faceGood" /> Also Consider
184 </h4>
185 <ul>
186 {otherServices.map((s: Service) => (
187 <li>
188 <a href={`/${catSlug}/${secSlug}/${slugify(s.name)}`}>
189 {s.name}
190 </a>
191 </li>
192 ))}
193 </ul>
194 </div>
195 )
196 }
197 </div>
198 </div>
199 </div>
200 <div class="highlights">
201 {
202 highlights.map((h) => (
203 <span class={`meta-item ${h.cls}`} title={h.title}>
204 <FontAwesome iconName={h.icon} /> {h.text}
205 </span>
206 ))
207 }
208 </div>
209</section>
210
211<style lang="scss">
212 .hero-section {
213 margin: var(--space-md) 0 var(--space-2xl) 0;
214 padding: var(--space-md);
215 min-height: 8rem;
216 position: relative;
217 border: var(--border-heavy);
218 box-shadow: var(--shadow-lg);
219 background: var(--accent-fg);
220 }
221
222 .service-head {
223 h1 {
224 font-size: var(--text-4xl);
225 margin: 0;
226 @media (max-width: 768px) {
227 text-align: center;
228 }
229 }
230 .url-wrap {
231 display: flex;
232 align-items: center;
233 gap: var(--space-sm);
234 a {
235 font-size: var(--text-md);
236 }
237 .follow-with {
238 font-style: italic;
239 opacity: var(--opacity-muted);
240 }
241 @media (max-width: 768px) {
242 flex-direction: column;
243 }
244 }
245 }
246
247 .save-listing {
248 position: absolute;
249 top: var(--space-xl);
250 right: var(--space-md);
251 }
252
253 .intro {
254 font-size: var(--text-md);
255 font-style: italic;
256 opacity: 0.9;
257 display: flex;
258 gap: var(--space-sm);
259 @media (max-width: 768px) {
260 flex-direction: column;
261 }
262 :global(.service-icon-wrap) {
263 border-radius: var(--curve-md);
264 margin-top: var(--space-md);
265 @media (max-width: 768px) {
266 margin: var(--space-md) auto 0 auto;
267 }
268 }
269 ul {
270 padding-left: var(--space-md);
271 list-style: circle;
272 font-style: normal;
273 font-size: var(--text-base);
274 margin-top: 0;
275 b {
276 font-size: var(--text-base);
277 font-weight: 400;
278 min-width: 100px;
279 display: inline-block;
280 @media (max-width: 768px) {
281 width: auto;
282 display: block;
283 }
284 }
285 }
286 }
287
288 .related {
289 display: flex;
290 gap: var(--space-lg);
291 flex-wrap: wrap;
292 margin: var(--space-md) 0;
293 .related-group {
294 h4 {
295 font-size: var(--text-sm);
296 font-family: var(--font-subtitle);
297 text-transform: uppercase;
298 opacity: var(--opacity-muted);
299 margin: 0 0 var(--space-xs) 0;
300 display: flex;
301 align-items: center;
302 gap: var(--space-xs);
303 :global(svg) {
304 width: var(--text-sm);
305 height: var(--text-sm);
306 }
307 &.avoid :global(svg) {
308 color: var(--danger);
309 }
310 &.consider :global(svg) {
311 color: var(--success-muted);
312 }
313 }
314 ul {
315 list-style: none;
316 padding: 0;
317 margin: 0;
318 display: flex;
319 flex-wrap: wrap;
320 gap: var(--space-xs);
321 li {
322 font-size: var(--text-sm);
323 padding: var(--space-xs) var(--space-sm);
324 border: var(--border-light);
325 border-radius: var(--curve-pill);
326 a {
327 color: var(--foreground);
328 text-decoration: none;
329 &:hover {
330 color: var(--accent);
331 }
332 }
333 span {
334 opacity: var(--opacity-soft);
335 }
336 }
337 }
338 }
339 }
340
341 .highlights {
342 display: flex;
343 gap: var(--space-md);
344 flex-wrap: wrap;
345 align-items: center;
346 justify-content: end;
347 .meta-item {
348 display: flex;
349 align-items: center;
350 gap: var(--space-xs);
351 opacity: var(--opacity-muted);
352 font-size: var(--text-sm);
353 padding: var(--space-sm) 0;
354 :global(svg) {
355 width: var(--text-md);
356 height: var(--text-md);
357 }
358 }
359 .warning {
360 color: var(--danger);
361 :global(svg) {
362 color: var(--danger);
363 }
364 }
365 .great {
366 color: var(--success-muted);
367 :global(svg) {
368 color: var(--success-muted);
369 }
370 }
371 }
372</style>