Commit 0991c323b6
Unsigned
Layout: unified · split
web/src/components/things/SectionList.astro +44 −2
| @@ -1,5 +1,7 @@ | ||
| 1 | 1 | --- |
| 2 | 2 | |
| 3 | ||
| 4 | import FontAwesome from '@components/form/FontAwesome.svelte'; | |
| 3 | 5 | import { slugify } from '../../utils/fetch-data'; |
| 4 | 6 | |
| 5 | 7 | import type { Section } from '../../types/Service'; |
| @@ -14,14 +16,18 @@ const { title, sections, bigTitle } = Astro.props; | ||
| 14 | 16 | |
| 15 | 17 | --- |
| 16 | 18 | |
| 19 | <div class="wrap"> | |
| 20 | ||
| 17 | 21 | { bigTitle ? |
| 18 | <h2>{title}</h2> : | |
| 22 | <h2><FontAwesome iconName={slugify(title)} />{title} </h2> : | |
| 19 | 23 | <a class="category-title" href={`/${slugify(title)}`}><h3>{title}</h3></a> |
| 20 | 24 | } |
| 21 | 25 | |
| 26 | { !bigTitle && <span class="section-icon"><FontAwesome iconName={slugify(title)} /></span> } | |
| 27 | ||
| 22 | 28 | <ul> |
| 23 | 29 | {sections.map((section) => ( |
| 24 | <li> | |
| 30 | <li class="section"> | |
| 25 | 31 | <a href={`/${slugify(title)}/${slugify(section.name)}`}> |
| 26 | 32 | <span>{section.name}</span> |
| 27 | 33 | <span class="service-count">({section.services ? section.services.length : 0})</span> |
| @@ -29,10 +35,21 @@ const { title, sections, bigTitle } = Astro.props; | ||
| 29 | 35 | </li> |
| 30 | 36 | ))} |
| 31 | 37 | </ul> |
| 38 | </div> | |
| 32 | 39 | |
| 33 | 40 | |
| 34 | 41 | <style lang="scss"> |
| 35 | 42 | |
| 43 | .wrap { | |
| 44 | position: relative; | |
| 45 | &:hover { | |
| 46 | .section-icon :global(svg){ | |
| 47 | opacity: 1; | |
| 48 | transform: scale(1.2); | |
| 49 | } | |
| 50 | } | |
| 51 | } | |
| 52 | ||
| 36 | 53 | h2 { |
| 37 | 54 | font-family: "Lekton", sans-serif; |
| 38 | 55 | font-size: 2rem; |
| @@ -42,11 +59,21 @@ h2 { | ||
| 42 | 59 | color: var(--accent-fg); |
| 43 | 60 | width: fit-content; |
| 44 | 61 | 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 | } | |
| 45 | 70 | } |
| 46 | 71 | |
| 47 | 72 | .category-title { |
| 48 | 73 | text-decoration: none; |
| 49 | 74 | color: var(--foreground); |
| 75 | z-index: 2; | |
| 76 | position: relative; | |
| 50 | 77 | h3 { |
| 51 | 78 | font-family: "Lekton", sans-serif; |
| 52 | 79 | font-weight: bold; |
| @@ -70,4 +97,19 @@ ul { | ||
| 70 | 97 | } |
| 71 | 98 | } |
| 72 | 99 | } |
| 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 | } | |
| 73 | 115 | </style> |
web/src/components/things/ServiceList.astro +119 −6
| @@ -3,11 +3,31 @@ | ||
| 3 | 3 | import Button from '@components/form/Button.astro'; |
| 4 | 4 | import { parseMarkdown, formatLink } from '@utils/parse-markdown'; |
| 5 | 5 | import type { Service } from 'src/types/Service'; |
| 6 | import FontAwesome from '@components/form/FontAwesome.svelte'; | |
| 6 | 7 | |
| 7 | const { title, services, subHeading, buttonLink } = Astro.props; | |
| 8 | import GitHubMetrics from '@components/things/ItemGitHubMetrics.astro'; | |
| 9 | ||
| 10 | const { services, subHeading, buttonLink, noGitHubMetrics } = Astro.props; | |
| 8 | 11 | |
| 9 | 12 | --- |
| 10 | 13 | |
| 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 | ||
| 11 | 31 | |
| 12 | 32 | <section> |
| 13 | 33 | {services ? ( |
| @@ -15,14 +35,59 @@ const { title, services, subHeading, buttonLink } = Astro.props; | ||
| 15 | 35 | {services.map((service: Service) => ( |
| 16 | 36 | <li> |
| 17 | 37 | <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 | ||
| 20 | 49 | {subHeading ? <h4>{service.name}</h4> : <h3>{service.name}</h3>} |
| 21 | 50 | {service.followWith && <p class="follow-with">({service.followWith})</p> } |
| 22 | 51 | <a class="service-link" href={service.url}>{formatLink(service.url)}</a> |
| 23 | 52 | </div> |
| 24 | 53 | <div class="service-body"> |
| 25 | 54 | <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> | |
| 26 | 91 | </div> |
| 27 | 92 | </li> |
| 28 | 93 | ))} |
| @@ -34,7 +99,7 @@ const { title, services, subHeading, buttonLink } = Astro.props; | ||
| 34 | 99 | </p> |
| 35 | 100 | )} |
| 36 | 101 | |
| 37 | {buttonLink && ( <Button text="View All" url={buttonLink} /> )} | |
| 102 | {buttonLink && ( <Button text="View More..." url={buttonLink} /> )} | |
| 38 | 103 | </section> |
| 39 | 104 | |
| 40 | 105 | |
| @@ -70,8 +135,14 @@ const { title, services, subHeading, buttonLink } = Astro.props; | ||
| 70 | 135 | margin: 0; |
| 71 | 136 | font-size: 1.6rem; |
| 72 | 137 | } |
| 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); | |
| 75 | 146 | } |
| 76 | 147 | .follow-with { |
| 77 | 148 | opacity: 0.7; |
| @@ -96,6 +167,48 @@ const { title, services, subHeading, buttonLink } = Astro.props; | ||
| 96 | 167 | color: var(--foregorund); |
| 97 | 168 | } |
| 98 | 169 | } |
| 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 | } | |
| 99 | 212 | } |
| 100 | 213 | } |
| 101 | 214 | } |