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