web/src/components/things/ServiceList.astro

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