web/src/components/things/SectionList.astro

131 lines · 2481 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	@use '../../styles/mixins' as *;
 56	.wrap {
 57		position: relative;
 58		&:hover {
 59			.section-icon :global(svg) {
 60				opacity: 1;
 61				transform: scale(1.2);
 62			}
 63		}
 64	}
 65
 66	h2 {
 67		font-family: var(--font-subtitle);
 68		font-size: var(--text-3xl);
 69		margin: -2rem 0 var(--space-lg) -2rem;
 70		box-shadow: var(--shadow-lg);
 71		border: var(--border-heavy);
 72		background: var(--accent);
 73		color: var(--accent-fg);
 74		width: fit-content;
 75		padding: var(--space-xs) var(--space-sm);
 76		display: flex;
 77		justify-content: center;
 78		gap: var(--space-md);
 79		:global(svg) {
 80			width: 2rem;
 81			height: 2rem;
 82			color: var(--accent-fg);
 83		}
 84	}
 85
 86	.category-title {
 87		text-decoration: none;
 88		color: var(--foreground);
 89		z-index: 2;
 90		position: relative;
 91		h3 {
 92			font-family: var(--font-subtitle);
 93			font-weight: bold;
 94			margin: 0;
 95			font-size: var(--text-2xl);
 96			@include underline-hover(var(--accent), 3px, 80%);
 97		}
 98	}
 99
100	ul {
101		list-style: circle;
102		padding-left: var(--space-md);
103		li {
104			margin: var(--space-sm) 0;
105			font-size: var(--text-md);
106			a {
107				text-decoration: none;
108				color: var(--foreground);
109				@include underline-hover(var(--accent-3), 2px, 80%, 0.15s);
110			}
111			.service-count {
112				color: var(--accent-3);
113			}
114		}
115	}
116
117	.section-icon {
118		position: absolute;
119		right: 0;
120		top: 0;
121		width: fit-content;
122		:global(svg) {
123			width: 2rem;
124			height: 2rem;
125			opacity: var(--opacity-dim);
126			text-shadow: 3px 3px 0 black;
127			color: var(--accent-3);
128			transition: var(--transition-normal);
129		}
130	}
131</style>