web/src/pages/all.astro

265 lines · 6723 bytes

  1---
  2
  3
  4import Layout from '@layouts/Layout.astro';
  5import ServiceCard from '@components/things/ServiceCard.astro';
  6import type { AwesomePrivacy, Section, Service } from '../types/Service';
  7import { fetchData, slugify } from '@utils/fetch-data';
  8import FontAwesome from '@components/form/FontAwesome.svelte';
  9
 10const categories = (await fetchData() as AwesomePrivacy)?.categories || [];
 11
 12---
 13
 14<script>
 15
 16const toggleSidebar = () => {
 17  const intro = document.querySelector('#welcome-to-all');
 18  const sidebar = document.querySelector('.sidebar');
 19  sidebar && sidebar.classList.toggle('hidden');
 20  intro && intro.classList.toggle('hidden');
 21  const button = document.querySelector('#toggle-sidebar');
 22  if (button) {
 23    button.textContent = (button.textContent === "Show Contents" ? "Hide Contents" : "Show Contents");
 24  }
 25};
 26
 27  const tgt = document.querySelector("#toggle-sidebar");
 28  tgt && tgt.addEventListener("click", () => {
 29    toggleSidebar();
 30  });
 31</script>
 32
 33<Layout title="Awesome Privacy">
 34    <main>
 35    <div id="content">
 36    <button id="toggle-sidebar">Show Contents</button>
 37    <div id="welcome-to-all" class="hidden">
 38      <p>
 39        Welcome to <a href="/">Awesome Privacy</a>!
 40        Here you'll find a summerized collection of all verified services we have listed.
 41        <br /><br />
 42        Click a section or category heading, to view more listings and privacy tips in that group,
 43        or a service title to view it's complete privacy report
 44        <br /><br />
 45        Looking for something specific? Try the <a href="/search">Search</a> page, or take a
 46        scroll through the <a href="/sitemap">Sitemap</a>
 47        <br /><br />
 48        If you want to make an edit, removal or submit an addition, then either click
 49        the Edit button within any sub-page, or visit our <a href="/about">About</a> page
 50        <br /><br />
 51        This project, all it's data as well as source code is freely availible
 52        on <a href="https://github.com/lissy93/awesome-privacy">GitHub</a>,
 53        licensed under MIT, (C) <a href="https://aliciasykes.com">Alicia Sykes</a> 2024
 54      </p>
 55    </div>
 56    <div class="sidebar hidden">
 57      <p class="sidebar-title">Contents</p>
 58      <ul>
 59        {categories.map((category) => (
 60          <li class="top-level">
 61            <a href={`#${slugify(category.name)}`}>{category.name}</a>  
 62          </li>
 63          <li>
 64            <ul>
 65              {category.sections.map((section: Section) => (
 66                <li>
 67                  <a href={`#${slugify(category.name)}-${slugify(section.name)}`}>{section.name}</a>
 68                </li>
 69              ))}
 70            </ul>
 71          </li>
 72        ))}
 73      </ul>
 74    </div>
 75    {categories.map((category) => (
 76      <h2  id={`${slugify(category.name)}`}>
 77        <FontAwesome iconName={slugify(category.name)} />
 78        <a href={`/${slugify(category.name)}`}>{category.name}</a>
 79      </h2>
 80      
 81        <article>
 82          {category.sections.map((section: Section) => (
 83            <h3 id={`${slugify(category.name)}-${slugify(section.name)}`}>
 84              <a href={`/${slugify(category.name)}/${slugify(section.name)}`}>{section.name}</a>
 85            </h3>
 86            <section class="section">
 87              { section.services.map((service: Service) => (
 88                <ServiceCard service={service} sectionName={section.name} categoryName={category.name}/>
 89              ))}
 90            </section>
 91            <div>
 92              {!section || !section.services || section.services.length === 0 ? (
 93                <div class="nothing-yet">
 94                  <p>
 95                    <strong>⚠️ This section is still a work in progress ⚠️</strong><br />
 96                    Check back soon, or help us complete it by submiting a pull request on GitHub.
 97                  </p>
 98                </div>
 99              ) : null}
100            </div>
101          ))}
102        </article>
103      
104    ))}
105    </div>
106  </main>
107  
108</Layout>
109
110<style lang="scss">
111
112main {
113  margin: 0 auto 2rem auto;
114  padding: 1rem;
115  width: 1200px;
116  max-width: calc(100% - 5rem);
117
118  display: flex;
119  justify-content: space-between;
120}
121
122// .narrow {
123//   width: 70%;
124// }
125
126.hidden {
127  display: none;
128}
129
130#content {
131  margin: 0 auto;
132}
133
134#welcome-to-all {
135  text-align: justify;
136  width: 600px;
137  margin: 0 auto;
138  background: #ffffff4d;
139  padding: 1rem;
140  border-radius: var(--curve-sm);
141}
142
143#toggle-sidebar {
144  // float: right;
145  background: none;
146  outline: none;
147  border: none;
148  cursor: pointer;
149  &:hover {
150    text-decoration: underline;
151  }
152}
153
154
155.sidebar {
156  border-radius: var(--curve-md);
157  .sidebar-title {
158    font-size: 1.6rem;
159    background: var(--accent-3);
160    color: var(--accent-fg);
161    border: 2px solid var(--foreground);
162    box-shadow: 6px 6px 0 var(--foreground);
163    border-radius: var(--curve-sm);
164    margin: 1rem auto;
165    text-align: center;
166  }
167  ul {
168    list-style: none;
169    padding-left: 1.6rem;
170    column-width: 16rem;
171    a {
172      text-decoration: none;
173      color: var(--foreground);
174      transition: all 0.18s ease-in-out;
175      &:hover {
176        color: var(--accent);
177        opacity: 1;
178      }
179    }
180    li ul {
181      list-style: circle;
182    }
183    .top-level {
184      font-weight: bold;
185      margin-top: 0.5rem;
186      &:hover a {
187        color: var(--accent-3);
188      }
189    }
190  } 
191}
192
193.section {
194  display: grid;
195  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
196  gap: 1rem;
197  width: 100%;
198  margin: 0 auto;
199}
200
201.card {
202  margin: 2rem auto 5rem auto;
203  padding: 0 2rem;
204  border: 2px solid var(--foreground);
205  box-shadow: 6px 6px 0 var(--foreground);
206  background: var(--accent-fg);
207}
208
209h2 {
210  margin: 2rem auto 0 auto;
211  font-size: 3rem;
212  text-align: center;
213  opacity: 0.6;
214  display: flex;
215  justify-content: center;
216  align-items: center;
217  gap: 1rem;
218  a {
219    color: var(--accent-3);
220    text-decoration: none;
221  }
222  :global(svg) {
223    width: 3rem;
224    height: 3rem;
225    color: var(--accent-3);
226  }
227}
228
229h3 {
230    font-size: 2rem;
231    margin: 2rem 0 1rem 0;
232    box-shadow: 6px 6px 0 var(--foreground);
233    background: var(--accent);
234    color: var(--accent-fg);
235    width: fit-content;
236    padding: 0.25rem 0.5rem;
237    a {
238      color: var(--accent-fg);
239      font-family: "Lekton", sans-serif;
240      text-decoration: none;
241    }
242  }
243
244  .nothing-yet {
245    width: 80vw;
246    margin: 0 auto;
247    background: var(--accent-fg);
248    border: 2px solid var(--foreground);
249    box-shadow: 6px 6px 0 var(--foreground);
250    border-radius: var(--curve-sm);
251
252    display: flex;
253    width: 80vw;
254    max-width: 28rem;
255    p {
256      font-size: 1.2rem;
257      opacity: 0.8;
258      font-style: italic;
259      text-align: center;
260      margin-bottom: 3rem;
261    }
262  }
263
264
265</style>