docs/.vitepress/theme/components/themerepo/screens.ts
361 lines · 9124 bytes
26 symbols in this file
1export interface Shape {
2 tag: 'rect' | 'circle' | 'path'
3 attrs: Record<string, string | number>
4}
5
6export interface Screen {
7 id: string
8 title: string
9 shapes: Shape[]
10}
11
12const box = (
13 x: number,
14 y: number,
15 width: number,
16 height: number,
17 cls: string,
18 rx = 0
19): Shape => ({ tag: 'rect', attrs: { x, y, width, height, rx, class: cls } })
20
21const dot = (cx: number, cy: number, r: number, cls: string): Shape => ({
22 tag: 'circle',
23 attrs: { cx, cy, r, class: cls }
24})
25
26const bar = (
27 x: number,
28 y: number,
29 width: number,
30 height: number,
31 cls = 'label'
32) => box(x, y, width, height, cls, height / 2)
33
34const line = (x: number, y: number, width: number) =>
35 box(x, y, width, 1, 'separator')
36
37function pill(
38 x: number,
39 y: number,
40 width: number,
41 height: number,
42 cls = 'chip',
43 text = 'muted'
44) {
45 const inner = width * 0.6
46 return [
47 box(x, y, width, height, cls, height / 2),
48 bar(x + (width - inner) / 2, y + height / 2 - 5, inner, 10, text)
49 ]
50}
51
52const iconButton = (
53 cx: number,
54 cy: number
55) => [dot(cx, cy, 24, 'raised'), dot(cx, cy, 8, 'label')]
56
57const tabBar = (active: number) => {
58 const centers = [75, 162, 248, 334, 420]
59 return [
60 box(24, 930, 448, 70, 'glass', 35),
61 box(centers[active] - 47, 936, 94, 58, 'tertiary', 29),
62 ...centers.flatMap((x, i) => {
63 const cls = i === active ? 'accent' : 'label'
64 return [dot(x, 956, 11, cls), bar(x - 21, 977, 42, 8, cls)]
65 })
66 ]
67}
68
69const searchField = (trailing: Shape[] = []) => [
70 box(23, 135, 451, 48, 'secondary', 24),
71 dot(47, 159, 8, 'label'),
72 bar(68, 153, 122, 13, 'muted'),
73 ...trailing
74]
75
76const cover = (
77 x: number,
78 y: number,
79 width: number,
80 height: number,
81 cls: string,
82 rx: number
83) => [box(x, y, width, height, cls, rx), box(x, y, width, height, 'scrim', rx)]
84
85function libraryTile(x: number, y: number, i: number) {
86 return [
87 ...cover(x, y, 146, 218, i % 2 ? 'secondary' : 'tertiary', 12),
88 box(x + 118, y + 6, 24, 22, 'accent', 6),
89 bar(x + 10, y + 178, 122, 11),
90 bar(x + 10, y + 197, 90, 11)
91 ]
92}
93
94const content: Shape[] = [
95 box(0, 0, 497, 400, 'tertiary'),
96 box(0, 180, 497, 220, 'fade'),
97 ...iconButton(46, 46),
98 bar(32, 328, 430, 24),
99 bar(117, 360, 260, 24),
100
101 box(22, 407, 79, 31, 'info-chip', 15.5),
102 bar(36, 417, 51, 10, 'info'),
103 ...[[107, 76], [189, 58], [253, 66], [325, 82], [413, 100]].flatMap((
104 [x, w]
105 ) => pill(x, 407, w, 31)),
106
107 bar(96, 462, 72, 15),
108 bar(335, 462, 52, 15, 'muted'),
109 line(18, 494, 458),
110 box(18, 491, 228, 3, 'accent'),
111
112 box(22, 513, 450, 530, 'card', 28),
113 bar(41, 531, 86, 13, 'muted'),
114 bar(431, 532, 18, 2),
115 bar(433, 537, 14, 2),
116 bar(436, 542, 8, 2),
117 ...[0, 1, 2, 3, 4, 5, 6].flatMap((i) => {
118 const y = 581 + i * 69
119 return [
120 bar(61, y, 90, 15),
121 box(61, y + 24, 14, 10, 'muted', 2),
122 bar(78, y + 23, 60, 11, 'muted'),
123 line(45, y + 51, 404)
124 ]
125 }),
126
127 box(22, 937, 389, 49, 'accent', 24.5),
128 bar(133, 954, 168, 15, 'on-accent'),
129 dot(447, 961, 25, 'raised-tertiary'),
130 box(439, 953, 16, 16, 'label', 5),
131 bar(159, 1010, 176, 5)
132]
133
134const library: Shape[] = [
135 box(294, 15, 180, 48, 'raised', 24),
136 ...[320, 382, 446].map(x => dot(x, 39, 12, 'label')),
137 box(374, 12, 36, 18, 'destructive', 9),
138
139 bar(23, 88, 125, 30),
140 ...searchField(),
141
142 ...pill(18, 196, 71, 38),
143 ...pill(97, 196, 112, 38),
144 ...pill(225, 196, 142, 38, 'accent', 'on-accent'),
145 ...pill(377, 196, 120, 38),
146
147 ...[0, 1, 2, 3].flatMap(row =>
148 [18, 175, 331].flatMap((x, column) =>
149 libraryTile(x, 247 + row * 230, row + column)
150 )
151 ),
152
153 ...[328, 390, 453].flatMap(x => iconButton(x, 884)),
154 ...tabBar(0)
155]
156
157const discover: Shape[] = [
158 box(0, 0, 497, 720, 'secondary'),
159 box(0, 300, 497, 420, 'fade'),
160
161 ...iconButton(47, 40),
162 bar(196, 31, 106, 18),
163 box(354, 15, 120, 50, 'raised', 25),
164 dot(382, 40, 12, 'label'),
165 dot(446, 40, 12, 'label'),
166
167 ...cover(-15, 215, 47, 370, 'tertiary', 12),
168 ...cover(465, 215, 47, 370, 'tertiary', 12),
169 ...cover(50, 114, 397, 570, 'tertiary', 16),
170 box(61, 124, 55, 28, 'accent', 14),
171 dot(76, 138, 6, 'on-accent'),
172 bar(87, 133, 21, 10, 'on-accent'),
173 bar(99, 604, 300, 20),
174 bar(201, 633, 96, 14, 'muted'),
175
176 bar(18, 772, 158, 20),
177 dot(190, 782, 8, 'accent'),
178 bar(18, 811, 270, 12, 'muted'),
179
180 box(18, 838, 461, 180, 'secondary', 12),
181 box(29, 850, 103, 150, 'tertiary', 6),
182 bar(145, 853, 315, 18),
183 bar(145, 884, 88, 13, 'muted'),
184 bar(365, 884, 100, 13, 'muted'),
185 bar(145, 908, 88, 13, 'muted'),
186 bar(365, 908, 100, 13, 'muted'),
187
188 ...tabBar(1)
189]
190
191const settingRow = (y: number, width: number) => bar(45, y, width, 15)
192const stepper = (y: number) => [
193 box(347, y, 105, 36, 'tertiary', 18),
194 box(398, y + 8, 1, 20, 'separator'),
195 dot(372, y + 18, 6, 'muted'),
196 dot(425, y + 18, 6, 'label')
197]
198
199const search: Shape[] = [
200 ...iconButton(47, 40),
201 ...pill(376, 15, 98, 50, 'accent', 'on-accent'),
202
203 bar(23, 88, 150, 30),
204 ...searchField([dot(444, 159, 11, 'label')]),
205
206 bar(45, 210, 100, 12, 'muted'),
207 box(23, 236, 451, 117, 'secondary', 22),
208 settingRow(258, 56),
209 dot(441, 265, 8, 'muted'),
210 line(45, 294, 407),
211 settingRow(317, 36),
212 dot(441, 324, 10, 'accent'),
213
214 bar(34, 388, 34, 12, 'muted'),
215 ...[[23, 70], [101, 82], [191, 76], [275, 56]].flatMap(([x, w]) =>
216 pill(x, 422, w, 32)
217 ),
218
219 bar(34, 487, 44, 12, 'muted'),
220 ...[[23, 81], [113, 101], [222, 69], [299, 89]].flatMap(([x, w]) =>
221 pill(x, 521, w, 32)
222 ),
223
224 bar(45, 585, 80, 12, 'muted'),
225 box(23, 611, 451, 176, 'secondary', 22),
226 settingRow(633, 98),
227 bar(302, 635, 34, 12, 'muted'),
228 ...stepper(623),
229 line(45, 669, 407),
230 settingRow(692, 142),
231 bar(324, 694, 12, 12, 'muted'),
232 ...stepper(682),
233 line(45, 728, 407),
234 settingRow(751, 186),
235 box(381, 742, 71, 32, 'tertiary', 16),
236 box(383, 744, 44, 28, 'label', 14),
237
238 bar(45, 821, 34, 12, 'muted'),
239 box(23, 847, 451, 59, 'secondary', 22),
240 settingRow(869, 36),
241 box(324, 862, 128, 29, 'accent-soft', 14.5),
242 bar(352, 871, 72, 11, 'accent'),
243
244 ...tabBar(2)
245]
246
247const chevronDown = (x: number, y: number): Shape => ({
248 tag: 'path',
249 attrs: { d: `M${x} ${y}l9 9 9-9`, class: 'chevron' }
250})
251
252const chevronRight = (x: number, y: number): Shape => ({
253 tag: 'path',
254 attrs: { d: `M${x} ${y}l9 9-9 9`, class: 'chevron' }
255})
256
257function progressRing(cx: number, cy: number, progress: number): Shape[] {
258 const r = 10.5
259 const circumference = 2 * Math.PI * r
260 return [
261 { tag: 'circle', attrs: { cx, cy, r, class: 'progress-track' } },
262 {
263 tag: 'circle',
264 attrs: {
265 cx,
266 cy,
267 r,
268 class: 'progress',
269 transform: `rotate(-90 ${cx} ${cy})`,
270 'stroke-dasharray': `${circumference * progress} ${circumference}`
271 }
272 }
273 ]
274}
275
276function historyRow(y: number, divider: boolean, progress: number) {
277 return [
278 ...cover(36, y, 86, 118, 'tertiary', 10),
279 bar(140, y + 4, 150, 15),
280 bar(140, y + 27, 118, 11, 'muted'),
281 ...progressRing(443, y + 46, progress),
282 bar(366, y + 92, 88, 10, 'muted'),
283 ...(divider ? [line(140, y + 128, 336)] : [])
284 ]
285}
286
287function settingsRow(y: number, width: number) {
288 return [
289 box(40, y + 13, 26, 26, 'accent', 8),
290 bar(84, y + 19, width, 14),
291 chevronRight(446, y + 15)
292 ]
293}
294
295const history: Shape[] = [
296 bar(23, 88, 130, 30),
297 ...searchField(),
298
299 bar(23, 208, 70, 14),
300 chevronDown(444, 208),
301 box(20, 232, 457, 500, 'secondary', 22),
302 ...[0, 1, 2].flatMap(i =>
303 historyRow(248 + i * 154, i < 2, [0.72, 0.48, 0.86][i])
304 ),
305
306 bar(23, 772, 96, 15),
307 chevronRight(446, 771),
308 bar(23, 832, 168, 15),
309 chevronDown(444, 834),
310 box(20, 857, 457, 300, 'secondary', 22),
311 ...historyRow(873, false, 0.32),
312
313 ...tabBar(3),
314 bar(159, 1010, 176, 5)
315]
316
317const settings: Shape[] = [
318 bar(23, 88, 150, 30),
319
320 box(20, 135, 457, 126, 'support', 24),
321 dot(88, 198, 34, 'support-label'),
322 bar(140, 168, 110, 16, 'support-label'),
323 bar(140, 194, 250, 11, 'support-label-soft'),
324 bar(140, 213, 190, 11, 'support-label-soft'),
325
326 box(20, 277, 457, 106, 'secondary', 22),
327 box(40, 317, 26, 26, 'accent', 8),
328 bar(84, 300, 110, 15),
329 bar(84, 322, 220, 11, 'muted'),
330 bar(84, 339, 130, 11, 'muted'),
331 box(392, 308, 66, 30, 'separator', 15),
332 box(396, 311, 42, 24, 'label', 12),
333
334 box(20, 405, 457, 272, 'secondary', 22),
335 ...[[424, 70], [476, 58], [528, 66], [580, 60], [632, 108]].flatMap(
336 ([y, width]) => settingsRow(y, width)
337 ),
338 line(84, 475, 368),
339 line(84, 527, 368),
340 line(84, 579, 368),
341 line(84, 631, 368),
342
343 box(20, 700, 457, 176, 'secondary', 22),
344 ...settingsRow(712, 62),
345 ...settingsRow(764, 66),
346 ...settingsRow(816, 78),
347 line(84, 763, 368),
348 line(84, 815, 368),
349
350 ...tabBar(4),
351 bar(159, 1010, 176, 5)
352]
353
354export const screens: Screen[] = [
355 { id: 'library', title: 'Library', shapes: library },
356 { id: 'discover', title: 'Discover', shapes: discover },
357 { id: 'search', title: 'Search', shapes: search },
358 { id: 'history', title: 'History', shapes: history },
359 { id: 'settings', title: 'Settings', shapes: settings },
360 { id: 'content', title: 'Chapters', shapes: content }
361]