web/src/components/things/SectionList.astro
151 lines · 3002 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(--foreground);
58 background: var(--accent);
59 color: var(--accent-fg);
60 width: fit-content;
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 }
70}
71
72.category-title {
73 text-decoration: none;
74 color: var(--foreground);
75 z-index: 2;
76 position: relative;
77 h3 {
78 font-family: "Lekton", sans-serif;
79 font-weight: bold;
80 margin: 0;
81 font-size: 1.8rem;
82 position: relative;
83 &:after {
84 background: none repeat scroll 0 0 transparent;
85 bottom: 0;
86 content: "";
87 display: block;
88 height: 3px;
89 left: 50%;
90 position: absolute;
91 background: var(--accent);
92 transition: width 0.3s ease 0s, left 0.3s ease 0s;
93 width: 0;
94 }
95 &:hover:after {
96 width: 80%;
97 left: 0;
98 }
99 }
100
101}
102
103ul {
104 list-style: circle;
105 padding-left: 1rem;
106 li {
107 margin: 0.5rem 0;
108 font-size: 1.25rem;
109 a {
110 text-decoration: none;
111 color: var(--foreground);
112 position: relative;
113 &:after {
114 background: none repeat scroll 0 0 transparent;
115 bottom: 0;
116 content: "";
117 display: block;
118 height: 2px;
119 left: 50%;
120 position: absolute;
121 background: var(--accent-3);
122 transition: width 0.15s ease 0s, left 0.15s ease 0s;
123 width: 0;
124 }
125 &:hover:after {
126 text-decoration: underline;
127 width: 80%;
128 left: 0;
129 }
130 }
131 .service-count {
132 color: var(--accent-3);
133 }
134 }
135}
136
137.section-icon {
138 position: absolute;
139 right: 0;
140 top: 0;
141 width: fit-content;
142 :global(svg) {
143 width: 2rem;
144 height: 2rem;
145 opacity: 0.5;
146 text-shadow: 3px 3px 0 black;
147 color: var(--accent-3);
148 transition: all 0.2s ease-in-out;
149 }
150}
151</style>