~james/core

core/web/src/lib/components/landing/NotFound.svelte -rw-r--r-- 5.5 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<script lang="ts">
	import "#lib/components/landing/landing.css";
	import "#lib/components/landing/material.css";
	import { resolve } from "$app/paths";
	import EmbossFilter from "#lib/components/landing/EmbossFilter.svelte";
	import Navbar from "#lib/components/landing/shell/Navbar.svelte";
	import ArrowRight from "$icon/arrow-right";
	import Container from "#lib/components/landing/ui/Container.svelte";

	/**
	 * The 404 page, drawn with the landing's tokens: the side grids, the
	 * navbar, and two cut ends of the thread, one trailing in from the top left and one out to
	 * the bottom right, around the copy. Signed-in visitors keep the app's shell, so the navbar
	 * is left out there (`navbar`).
	 *
	 * On arrival the copy rises in and the two ends draw in from the page's corners, fraying
	 * where they meet the gap. Hovering the way home nudges them towards each other.
	 *
	 * Every class carries `nf-`: the landing's section styles (features.css) are global under
	 * `.landing`, and preloading `/` from any link here brings them in.
	 */
	interface Props {
		/** Draw the landing navbar (signed-out visitors, where the page owns the shell). */
		navbar?: boolean;
	}

	let { navbar = true }: Props = $props();

	/*
	 * The strands, as placed in the 1440px frame: each vector's centre (x, y), its size
	 * unrotated (w, h), its turn and which end of the thread it belongs to (`a` the top left,
	 * `b` the bottom right). The frayed ends share one vector. Both lines run from their
	 * vector's bottom edge to the fray, so one sweep draws either in.
	 */
	const STRANDS = [
		{ part: "line", end: "a", x: 227.09, y: 205.5, w: 108.95, h: 283.19, turn: 120 },
		{ part: "fray", end: "a", x: 316.94, y: 319.28, w: 12.46, h: 15.11, turn: 120 },
		{ part: "fray", end: "b", x: 824.3, y: 469.77, w: 12.46, h: 15.11, turn: -60 },
		{ part: "line", end: "b", x: 1061.45, y: 675.77, w: 189.01, h: 621.08, turn: -60 }
	] as const;
</script>

<div class={["landing", "nf", !navbar && "nf-embedded"]}>
	<div class="page-grid l" aria-hidden="true"></div>
	<div class="page-grid r" aria-hidden="true"></div>
	<EmbossFilter />
	{#if navbar}
		<Navbar />
	{/if}
	<main class="nf-stage">
		<div class="nf-art" aria-hidden="true">
			{#each STRANDS as strand, i (i)}
				<i
					class={["nf-strand", `nf-${strand.part}`, `nf-${strand.end}`]}
					style:--x="{strand.x}px"
					style:--y="{strand.y}px"
					style:--w="{strand.w}px"
					style:--h="{strand.h}px"
					style:--turn="{strand.turn}deg"
				></i>
			{/each}
		</div>
		<Container class="nf-copy">
			<div class="nf-text">
				<h1
					data-testid="errorTitle"
					data-status="404"
					class="l-heading l-heading-section l-heading-break"
				>
					<span class="solid nf-rise" style:--delay="0.1s">404</span>
					<span class="dim nf-rise" style:--delay="0.2s">This page doesn’t exist.</span>
				</h1>
				<p data-testid="errorMessage" class="l-body l-trim nf-rise" style:--delay="0.3s">
					It may have moved, or the link may be wrong.
				</p>
			</div>
			<div class="nf-action nf-rise" style:--delay="0.4s">
				<a
					href={resolve("/")}
					class="inline-flex w-fit items-center gap-2xs border-b border-border-strong pb-0.5 text-foreground-default hover:border-foreground-default"
				>
					Go to the homepage
					<ArrowRight class="size-4" aria-hidden="true" />
				</a>
			</div>
		</Container>
	</main>
</div>

<style>
	.nf {
		display: flex;
		flex-direction: column;
	}
	.nf-embedded {
		flex: 1;
		min-height: 0;
	}

	.nf-stage {
		position: relative;
		display: flex;
		flex: 1;
		flex-direction: column;
		justify-content: center;
		overflow: clip;
		padding-block: 96px;
	}

	/* The art's frame, 1440 × 828, centred on the page, with the copy's middle on the stage's. */
	.nf-art {
		position: absolute;
		top: calc(50% - 423.5px);
		left: calc(50% - 720px);
		width: 1440px;
		height: 828px;
		pointer-events: none;

		@media (width < 64rem) {
			display: none;
		}
	}

	.nf-strand {
		position: absolute;
		top: calc(var(--y) - var(--h) / 2);
		left: calc(var(--x) - var(--w) / 2);
		width: var(--w);
		height: var(--h);
		background: var(--thread);
		mask: var(--part) center / 100% 100% no-repeat;
		rotate: var(--turn);
		transition: translate 0.6s var(--ease-out);
	}
	.nf-strand.nf-line.nf-a {
		--part: url("./assets/not-found/strand-top.svg");
	}
	.nf-strand.nf-line.nf-b {
		--part: url("./assets/not-found/strand-bottom.svg");
	}
	.nf-strand.nf-fray {
		--part: url("./assets/not-found/strand-end.svg");
	}

	/* Arriving: each line sweeps in from the corner, then its frayed end springs out. */
	.nf-line {
		animation: nf-draw 1.2s var(--ease-in-out) 0.2s both;
	}
	.nf-fray {
		animation: nf-fray 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 1.25s both;
	}

	/* Heading home: the two ends lean in towards each other. */
	.nf-stage:has(.nf-action :global(a:is(:hover, :focus-visible))) {
		.nf-a {
			translate: 10px 8px;
		}
		.nf-b {
			translate: -10px -8px;
		}
	}

	.nf-stage :global(.nf-copy) {
		display: flex;
		flex-direction: column;
		align-items: flex-start;
		gap: 48px;

		@media (width >= 64rem) {
			padding-inline-start: 188px;
		}
	}

	.nf-text {
		display: flex;
		flex-direction: column;
		gap: 20px;
	}
	.nf-text p {
		max-width: 420px;
	}

	.nf-rise {
		animation: nf-rise 0.7s var(--ease-out) var(--delay, 0s) both;
	}

	@keyframes nf-rise {
		from {
			opacity: 0;
			translate: 0 10px;
		}
	}
	@keyframes nf-draw {
		from {
			clip-path: inset(100% 0 0 0);
		}
		to {
			clip-path: inset(0);
		}
	}
	@keyframes nf-fray {
		from {
			opacity: 0;
			scale: 0.3;
		}
	}
</style>