web/src/components/things/SectionList.astro

152 lines · 3043 bytes

  1---
  2
  3
  4import FontAwesome from '@components/form/FontAwesome.svelte';
  5import { slugify } from '../../utils/fetch-data';
  6
  7import type { Section } from '../../types/Service';
  8
  9interface Props {
 10	title: string;
 11	sections: Section[];
 12  bigTitle?: boolean;
 13}
 14
 15const { title, sections, bigTitle } = Astro.props;
 16
 17---
 18
 19<div class="wrap">
 20
 21{ bigTitle ?
 22  <h2><FontAwesome iconName={slugify(title)} />{title} </h2> :
 23  <a class="category-title" href={`/${slugify(title)}`}><h3>{title}</h3></a>
 24}
 25
 26{ !bigTitle && <span class="section-icon"><FontAwesome iconName={slugify(title)} /></span> }
 27
 28<ul>
 29  {sections.map((section) => (
 30    <li class="section">
 31      <a href={`/${slugify(title)}/${slugify(section.name)}`}>
 32        <span>{section.name}</span> 
 33        <span class="service-count">({section.services ? section.services.length : 0})</span>
 34      </a>
 35    </li>
 36  ))}
 37</ul>
 38</div>
 39
 40
 41<style lang="scss">
 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
 53h2 {
 54  font-family: "Lekton", sans-serif;
 55  font-size: 2rem;
 56  margin: -2rem 0 2rem -2rem;
 57  box-shadow: 6px 6px 0 var(--box-outline);
 58  border: 2px solid var(--box-outline);
 59  background: var(--accent);
 60  color: var(--accent-fg);
 61  width: fit-content;
 62  padding: 0.25rem 0.5rem;
 63  display: flex;
 64  justify-content: center;
 65  gap: 1rem;
 66  :global(svg) {
 67    width: 2rem;
 68    height: 2rem;
 69    color: var(--accent-fg);
 70  }
 71}
 72
 73.category-title {
 74  text-decoration: none;
 75  color: var(--foreground);
 76  z-index: 2;
 77  position: relative;
 78  h3 {
 79    font-family: "Lekton", sans-serif;
 80    font-weight: bold;
 81    margin: 0;
 82    font-size: 1.8rem;
 83    position: relative;
 84    &:after {    
 85      background: none repeat scroll 0 0 transparent;
 86      bottom: 0;
 87      content: "";
 88      display: block;
 89      height: 3px;
 90      left: 50%;
 91      position: absolute;
 92      background: var(--accent);
 93      transition: width 0.3s ease 0s, left 0.3s ease 0s;
 94      width: 0;
 95    }
 96    &:hover:after { 
 97      width: 80%; 
 98      left: 0; 
 99    }
100  }
101  
102}
103
104ul {
105  list-style: circle;
106  padding-left: 1rem;
107  li {
108    margin: 0.5rem 0;
109    font-size: 1.25rem;
110    a {
111      text-decoration: none;
112      color: var(--foreground);
113      position: relative;
114      &:after {    
115        background: none repeat scroll 0 0 transparent;
116        bottom: 0;
117        content: "";
118        display: block;
119        height: 2px;
120        left: 50%;
121        position: absolute;
122        background: var(--accent-3);
123        transition: width 0.15s ease 0s, left 0.15s ease 0s;
124        width: 0;
125      }
126      &:hover:after {
127        text-decoration: underline;
128        width: 80%; 
129        left: 0; 
130      }
131    }
132    .service-count {
133      color: var(--accent-3);
134    }
135  }
136}
137
138.section-icon {
139  position: absolute;
140  right: 0;
141  top: 0;
142  width: fit-content;
143  :global(svg) {
144    width: 2rem;
145    height: 2rem;
146    opacity: 0.5;
147    text-shadow: 3px 3px 0 black;
148    color: var(--accent-3);
149    transition: all 0.2s ease-in-out;
150  }
151}
152</style>