web/src/pages/all.astro

267 lines · 6912 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                    <br />
 98                    <span class="quick-submit">Or submit an entry <a href="/submit">here</a></span>
 99                  </p>
100                </div>
101              ) : null}
102            </div>
103          ))}
104        </article>
105      
106    ))}
107    </div>
108  </main>
109  
110</Layout>
111
112<style lang="scss">
113
114main {
115  margin: 0 auto 2rem auto;
116  padding: 1rem;
117  width: 1200px;
118  max-width: calc(100% - 5rem);
119
120  display: flex;
121  justify-content: space-between;
122}
123
124.hidden {
125  display: none;
126}
127
128#content {
129  margin: 0 auto;
130}
131
132#welcome-to-all {
133  text-align: justify;
134  width: 600px;
135  margin: 0 auto;
136  background: var(--background-form);
137  padding: 1rem;
138  border-radius: var(--curve-sm);
139}
140
141#toggle-sidebar {
142  // float: right;
143  background: none;
144  outline: none;
145  border: none;
146  cursor: pointer;
147  color: var(--accent);
148  &:hover {
149    text-decoration: underline;
150  }
151}
152
153
154.sidebar {
155  border-radius: var(--curve-md);
156  .sidebar-title {
157    font-size: 1.6rem;
158    background: var(--accent-3);
159    color: var(--accent-fg);
160    border: 2px solid var(--box-outline);
161    box-shadow: 6px 6px 0 var(--box-outline);
162    border-radius: var(--curve-sm);
163    margin: 1rem auto;
164    text-align: center;
165  }
166  ul {
167    list-style: none;
168    padding-left: 1.6rem;
169    column-width: 16rem;
170    a {
171      text-decoration: none;
172      color: var(--foreground);
173      transition: all 0.18s ease-in-out;
174      &:hover {
175        color: var(--accent);
176        opacity: 1;
177      }
178    }
179    li ul {
180      list-style: circle;
181    }
182    .top-level {
183      font-weight: bold;
184      margin-top: 0.5rem;
185      &:hover a {
186        color: var(--accent-3);
187      }
188    }
189  } 
190}
191
192.section {
193  display: grid;
194  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
195  gap: 1rem;
196  width: 100%;
197  margin: 0 auto;
198}
199
200.card {
201  margin: 2rem auto 5rem auto;
202  padding: 0 2rem;
203  border: 2px solid var(--box-outline);
204  box-shadow: 6px 6px 0 var(--box-outline);
205  background: var(--accent-fg);
206}
207
208h2 {
209  margin: 2rem auto 0 auto;
210  font-size: 3rem;
211  text-align: center;
212  opacity: 0.6;
213  display: flex;
214  justify-content: center;
215  align-items: center;
216  gap: 1rem;
217  a {
218    color: var(--accent-3);
219    text-decoration: none;
220  }
221  :global(svg) {
222    width: 3rem;
223    height: 3rem;
224    color: var(--accent-3);
225  }
226}
227
228h3 {
229    font-size: 2rem;
230    margin: 2rem 0 1rem 0;
231    box-shadow: 6px 6px 0 var(--box-outline);
232    background: var(--accent);
233    color: var(--accent-fg);
234    width: fit-content;
235    padding: 0.25rem 0.5rem;
236    a {
237      color: var(--accent-fg);
238      font-family: "Lekton", sans-serif;
239      text-decoration: none;
240    }
241  }
242
243  .nothing-yet {
244    width: 100%;
245    margin: 0 auto;
246    background: var(--accent-fg);
247    border: 2px solid var(--box-outline);
248    box-shadow: 6px 6px 0 var(--box-outline);
249    border-radius: var(--curve-sm);
250    display: flex;
251
252    p {
253      font-size: 1.2rem;
254      opacity: 0.8;
255      font-style: italic;
256      text-align: center;
257      margin: 4rem auto;
258    }
259    .quick-submit {
260      margin-top: 1rem;
261      font-size: 0.8rem;
262      opacity: 0.8;
263    }
264  }
265
266
267</style>