@alphacifer/slidev-addon-theme 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/components/core/Date.vue +6 -3
- package/components/core/QnA.vue +12 -6
- package/components/core/Quote.vue +2 -4
- package/components/core/ReflectedTitle.vue +8 -11
- package/components/core/Speaker.vue +4 -2
- package/components/shifting-heading/TransitionHeading.vue +15 -61
- package/components/thanks/ThanksContent.vue +43 -58
- package/components/thanks/ThanksOutlineSquare.vue +1 -1
- package/components/thanks/ThanksSquare.vue +1 -1
- package/layouts/core/arc-toc.vue +518 -0
- package/layouts/core/bg-center.vue +1 -1
- package/layouts/core/table-of-contents.vue +1 -1
- package/layouts/shifting-heading/shifting-intro.vue +44 -75
- package/layouts/thanks/thanks.vue +1 -1
- package/package.json +1 -1
- package/utils/shiftingHeading/collectShiftingIntroNodes.ts +74 -0
- package/utils/tableOfContents/calculateTocCenterAlignmentOffset.ts +11 -0
- package/utils/tableOfContents/calculateTocMarkerPositions.ts +118 -0
- package/utils/tableOfContents/calculateUniformTocArticleWidth.ts +10 -0
- package/utils/tableOfContents/createTocArcPath.ts +80 -0
- package/utils/tableOfContents/createTocConnectorPath.ts +43 -0
- package/utils/tableOfContents/index.ts +5 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useSlideContext } from '@slidev/client';
|
|
3
|
+
import type { CSSProperties } from 'vue';
|
|
4
|
+
import {
|
|
5
|
+
computed,
|
|
6
|
+
nextTick,
|
|
7
|
+
onBeforeUnmount,
|
|
8
|
+
onMounted,
|
|
9
|
+
ref,
|
|
10
|
+
watch,
|
|
11
|
+
} from 'vue';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
calculateFullTocArcPoints,
|
|
15
|
+
calculateTocArticleOffsetPx,
|
|
16
|
+
calculateTocCenterAlignmentOffsetPx,
|
|
17
|
+
calculateTocConnectorEndX,
|
|
18
|
+
calculateTocItemCount,
|
|
19
|
+
calculateTocListGapRem,
|
|
20
|
+
calculateTocMarkerPositions,
|
|
21
|
+
calculateTocMiddleMarkerOffsetPx,
|
|
22
|
+
calculateUniformTocArticleWidthPx,
|
|
23
|
+
createTocArcPath,
|
|
24
|
+
createTocConnectorPath,
|
|
25
|
+
} from '../../utils/tableOfContents';
|
|
26
|
+
import { useMergedUnoAttrs } from '../../utils/useMergedUnoAttrs';
|
|
27
|
+
|
|
28
|
+
defineOptions({
|
|
29
|
+
inheritAttrs: false,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const props = defineProps({
|
|
33
|
+
maxItems: {
|
|
34
|
+
type: [Number, String],
|
|
35
|
+
default: 7,
|
|
36
|
+
},
|
|
37
|
+
maxDepth: {
|
|
38
|
+
type: [Number, String],
|
|
39
|
+
default: 1,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const { className, forwardedAttrs } = useMergedUnoAttrs(
|
|
44
|
+
'alpha-arc-toc slidev-layout default arc-toc-layout',
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const markerColors = [
|
|
48
|
+
'#ffad21',
|
|
49
|
+
'#24b9aa',
|
|
50
|
+
'#3188e4',
|
|
51
|
+
'#59d875',
|
|
52
|
+
'#f53270',
|
|
53
|
+
'#8b5cf6',
|
|
54
|
+
'#ef4444',
|
|
55
|
+
] as const;
|
|
56
|
+
|
|
57
|
+
interface ITocConnector {
|
|
58
|
+
readonly color: string;
|
|
59
|
+
readonly path: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const { $slidev } = useSlideContext();
|
|
63
|
+
const rootElement = ref<HTMLElement>();
|
|
64
|
+
const arcPath = ref('');
|
|
65
|
+
const connectors = ref<readonly ITocConnector[]>([]);
|
|
66
|
+
const tocItemCount = computed(() => {
|
|
67
|
+
return calculateTocItemCount({
|
|
68
|
+
maximumCount: Number(props.maxItems),
|
|
69
|
+
availableCount: $slidev.nav.tocTree.length,
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
const markerPositions = computed(() => {
|
|
73
|
+
return calculateTocMarkerPositions(tocItemCount.value);
|
|
74
|
+
});
|
|
75
|
+
const tocContentStyle = computed(() => {
|
|
76
|
+
return {
|
|
77
|
+
'--toc-list-gap': `${calculateTocListGapRem(tocItemCount.value)}rem`,
|
|
78
|
+
left: `calc(40.4% + ${calculateTocMiddleMarkerOffsetPx(tocItemCount.value)}px)`,
|
|
79
|
+
} satisfies CSSProperties;
|
|
80
|
+
});
|
|
81
|
+
const markerStyles = computed(() => {
|
|
82
|
+
return markerPositions.value.map(
|
|
83
|
+
({ offsetFromMiddlePx, rightShiftPx, topPercent }, index) => {
|
|
84
|
+
return {
|
|
85
|
+
'--marker-color': markerColors[index],
|
|
86
|
+
left: `calc(40.4% - ${offsetFromMiddlePx}px + ${rightShiftPx}px)`,
|
|
87
|
+
top: `${topPercent}%`,
|
|
88
|
+
} satisfies CSSProperties;
|
|
89
|
+
},
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
let connectorAnimationFrame: number | undefined;
|
|
94
|
+
let connectorMutationObserver: MutationObserver | undefined;
|
|
95
|
+
let connectorResizeObserver: ResizeObserver | undefined;
|
|
96
|
+
|
|
97
|
+
function isMiddleItem(index: number, count: number): boolean {
|
|
98
|
+
const middleIndex = (count - 1) / 2;
|
|
99
|
+
return Math.abs(index - middleIndex) < 1;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function updateConnectors(): void {
|
|
103
|
+
const root = rootElement.value;
|
|
104
|
+
|
|
105
|
+
if (!root || root.clientWidth === 0 || root.clientHeight === 0) {
|
|
106
|
+
arcPath.value = '';
|
|
107
|
+
connectors.value = [];
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const markers = Array.from(root.querySelectorAll<HTMLElement>('.toc-marker'));
|
|
112
|
+
const articles = Array.from(
|
|
113
|
+
root.querySelectorAll<HTMLElement>(
|
|
114
|
+
'.toc-content .slidev-toc-list-level-1 > .slidev-toc-item > a',
|
|
115
|
+
),
|
|
116
|
+
).slice(0, tocItemCount.value);
|
|
117
|
+
const count = Math.min(markers.length, articles.length);
|
|
118
|
+
|
|
119
|
+
articles.forEach((article) => {
|
|
120
|
+
article.style.width = 'max-content';
|
|
121
|
+
});
|
|
122
|
+
const uniformArticleWidthPx = calculateUniformTocArticleWidthPx(
|
|
123
|
+
articles.map((article) => {
|
|
124
|
+
return article.scrollWidth;
|
|
125
|
+
}),
|
|
126
|
+
);
|
|
127
|
+
articles.forEach((article) => {
|
|
128
|
+
article.style.width = `${uniformArticleWidthPx}px`;
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
articles.forEach((article, index) => {
|
|
132
|
+
const position = markerPositions.value[index];
|
|
133
|
+
const item = article.closest<HTMLElement>('.slidev-toc-item');
|
|
134
|
+
|
|
135
|
+
if (item && position) {
|
|
136
|
+
item.style.transform = `translateX(${calculateTocArticleOffsetPx(position)}px)`;
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const rootRect = root.getBoundingClientRect();
|
|
141
|
+
const scaleX = rootRect.width / root.clientWidth;
|
|
142
|
+
const scaleY = rootRect.height / root.clientHeight;
|
|
143
|
+
const tocContent = root.querySelector<HTMLElement>('.toc-content');
|
|
144
|
+
|
|
145
|
+
arcPath.value = createTocArcPath(
|
|
146
|
+
calculateFullTocArcPoints({
|
|
147
|
+
width: root.clientWidth,
|
|
148
|
+
height: root.clientHeight,
|
|
149
|
+
}),
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
if (tocContent && count > 0) {
|
|
153
|
+
tocContent.style.transform = 'none';
|
|
154
|
+
|
|
155
|
+
const firstMiddleIndex = Math.floor((count - 1) / 2);
|
|
156
|
+
const lastMiddleIndex = Math.ceil((count - 1) / 2);
|
|
157
|
+
const middleIndices = [firstMiddleIndex, lastMiddleIndex];
|
|
158
|
+
const markerCenterY =
|
|
159
|
+
middleIndices.reduce((sum, index) => {
|
|
160
|
+
const rect = markers[index]?.getBoundingClientRect();
|
|
161
|
+
return sum + (rect ? rect.top + rect.height / 2 : 0);
|
|
162
|
+
}, 0) / middleIndices.length;
|
|
163
|
+
const articleCenterY =
|
|
164
|
+
middleIndices.reduce((sum, index) => {
|
|
165
|
+
const rect = articles[index]?.getBoundingClientRect();
|
|
166
|
+
return sum + (rect ? rect.top + rect.height / 2 : 0);
|
|
167
|
+
}, 0) / middleIndices.length;
|
|
168
|
+
const offsetPx = calculateTocCenterAlignmentOffsetPx(
|
|
169
|
+
markerCenterY,
|
|
170
|
+
articleCenterY,
|
|
171
|
+
scaleY,
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
tocContent.style.transform = `translateY(${offsetPx}px)`;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const nextConnectors: ITocConnector[] = [];
|
|
178
|
+
|
|
179
|
+
for (let index = 0; index < count; index += 1) {
|
|
180
|
+
const markerRect = markers[index]?.getBoundingClientRect();
|
|
181
|
+
const articleRect = articles[index]?.getBoundingClientRect();
|
|
182
|
+
|
|
183
|
+
if (!markerRect || !articleRect) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const start = {
|
|
188
|
+
x: (markerRect.left + markerRect.width / 2 - rootRect.left) / scaleX,
|
|
189
|
+
y: (markerRect.top + markerRect.height / 2 - rootRect.top) / scaleY,
|
|
190
|
+
};
|
|
191
|
+
const end = {
|
|
192
|
+
x: calculateTocConnectorEndX({
|
|
193
|
+
articleLeftX: (articleRect.left - rootRect.left) / scaleX,
|
|
194
|
+
}),
|
|
195
|
+
y: (articleRect.top + articleRect.height / 2 - rootRect.top) / scaleY,
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
nextConnectors.push({
|
|
199
|
+
color: markerColors[index % markerColors.length] ?? markerColors[0],
|
|
200
|
+
path: createTocConnectorPath(start, end, isMiddleItem(index, count)),
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
connectors.value = nextConnectors;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function scheduleConnectorUpdate(): void {
|
|
208
|
+
if (connectorAnimationFrame !== undefined) {
|
|
209
|
+
cancelAnimationFrame(connectorAnimationFrame);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
connectorAnimationFrame = requestAnimationFrame(() => {
|
|
213
|
+
connectorAnimationFrame = undefined;
|
|
214
|
+
updateConnectors();
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
onMounted(async () => {
|
|
219
|
+
await nextTick();
|
|
220
|
+
scheduleConnectorUpdate();
|
|
221
|
+
|
|
222
|
+
const root = rootElement.value;
|
|
223
|
+
if (!root) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
connectorResizeObserver = new ResizeObserver(scheduleConnectorUpdate);
|
|
228
|
+
connectorResizeObserver.observe(root);
|
|
229
|
+
const tocContent = root.querySelector('.toc-content');
|
|
230
|
+
if (tocContent) {
|
|
231
|
+
connectorMutationObserver = new MutationObserver(scheduleConnectorUpdate);
|
|
232
|
+
connectorMutationObserver.observe(tocContent, {
|
|
233
|
+
childList: true,
|
|
234
|
+
subtree: true,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
window.addEventListener('resize', scheduleConnectorUpdate);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
watch(tocItemCount, async () => {
|
|
241
|
+
await nextTick();
|
|
242
|
+
scheduleConnectorUpdate();
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
onBeforeUnmount(() => {
|
|
246
|
+
connectorMutationObserver?.disconnect();
|
|
247
|
+
connectorResizeObserver?.disconnect();
|
|
248
|
+
window.removeEventListener('resize', scheduleConnectorUpdate);
|
|
249
|
+
|
|
250
|
+
if (connectorAnimationFrame !== undefined) {
|
|
251
|
+
cancelAnimationFrame(connectorAnimationFrame);
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
</script>
|
|
255
|
+
|
|
256
|
+
<template>
|
|
257
|
+
<div
|
|
258
|
+
ref="rootElement"
|
|
259
|
+
v-bind="forwardedAttrs()"
|
|
260
|
+
:class="className()"
|
|
261
|
+
>
|
|
262
|
+
<header class="toc-heading">
|
|
263
|
+
<slot>
|
|
264
|
+
<h1>Table of Contents</h1>
|
|
265
|
+
</slot>
|
|
266
|
+
</header>
|
|
267
|
+
<svg
|
|
268
|
+
class="toc-curve"
|
|
269
|
+
:viewBox="`0 0 ${rootElement?.clientWidth ?? 0} ${rootElement?.clientHeight ?? 0}`"
|
|
270
|
+
preserveAspectRatio="none"
|
|
271
|
+
aria-hidden="true"
|
|
272
|
+
>
|
|
273
|
+
<path :d="arcPath" />
|
|
274
|
+
</svg>
|
|
275
|
+
<div class="toc-markers" aria-hidden="true">
|
|
276
|
+
<span
|
|
277
|
+
v-for="(markerStyle, index) in markerStyles"
|
|
278
|
+
:key="index"
|
|
279
|
+
class="toc-marker"
|
|
280
|
+
:style="markerStyle"
|
|
281
|
+
></span>
|
|
282
|
+
</div>
|
|
283
|
+
<svg
|
|
284
|
+
class="toc-connectors"
|
|
285
|
+
:viewBox="`0 0 ${rootElement?.clientWidth ?? 0} ${rootElement?.clientHeight ?? 0}`"
|
|
286
|
+
preserveAspectRatio="none"
|
|
287
|
+
aria-hidden="true"
|
|
288
|
+
>
|
|
289
|
+
<path
|
|
290
|
+
v-for="(connector, index) in connectors"
|
|
291
|
+
:key="index"
|
|
292
|
+
:d="connector.path"
|
|
293
|
+
:stroke="connector.color"
|
|
294
|
+
/>
|
|
295
|
+
</svg>
|
|
296
|
+
<Toc
|
|
297
|
+
class="toc-content"
|
|
298
|
+
:data-item-count="tocItemCount"
|
|
299
|
+
:max-depth="props.maxDepth"
|
|
300
|
+
:style="tocContentStyle"
|
|
301
|
+
/>
|
|
302
|
+
</div>
|
|
303
|
+
</template>
|
|
304
|
+
|
|
305
|
+
<style scoped>
|
|
306
|
+
.alpha-arc-toc {
|
|
307
|
+
--toc-orange: #ffad21;
|
|
308
|
+
--toc-teal: #24b9aa;
|
|
309
|
+
--toc-blue: #3188e4;
|
|
310
|
+
--toc-green: #59d875;
|
|
311
|
+
--toc-pink: #f53270;
|
|
312
|
+
--toc-purple: #8b5cf6;
|
|
313
|
+
--toc-red: #ef4444;
|
|
314
|
+
|
|
315
|
+
position: relative;
|
|
316
|
+
overflow: hidden;
|
|
317
|
+
padding: 0;
|
|
318
|
+
font-family: ui-sans-serif, system-ui, sans-serif;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.toc-heading {
|
|
322
|
+
position: absolute;
|
|
323
|
+
top: 50%;
|
|
324
|
+
left: 10%;
|
|
325
|
+
z-index: 2;
|
|
326
|
+
width: 25%;
|
|
327
|
+
transform: translateY(-50%);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.toc-heading :deep(h1) {
|
|
331
|
+
max-width: 8ch;
|
|
332
|
+
margin: 0;
|
|
333
|
+
font-family: inherit;
|
|
334
|
+
font-size: 2.65rem;
|
|
335
|
+
font-weight: 800;
|
|
336
|
+
line-height: 1.04;
|
|
337
|
+
letter-spacing: -0.045em;
|
|
338
|
+
text-transform: capitalize;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/* Slide markdown often contains explanatory copy after its heading. This
|
|
342
|
+
layout intentionally presents only the heading and the TOC labels. */
|
|
343
|
+
.toc-heading :deep(:not(h1)) {
|
|
344
|
+
display: none;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.toc-curve {
|
|
348
|
+
position: absolute;
|
|
349
|
+
inset: 0;
|
|
350
|
+
width: 100%;
|
|
351
|
+
height: 100%;
|
|
352
|
+
overflow: visible;
|
|
353
|
+
pointer-events: none;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.toc-curve path {
|
|
357
|
+
fill: none;
|
|
358
|
+
stroke: #d7d7d5;
|
|
359
|
+
stroke-width: 2;
|
|
360
|
+
vector-effect: non-scaling-stroke;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.toc-marker {
|
|
364
|
+
position: absolute;
|
|
365
|
+
z-index: 2;
|
|
366
|
+
width: 1rem;
|
|
367
|
+
height: 1rem;
|
|
368
|
+
border: 0.23rem solid #f8f8f7;
|
|
369
|
+
border-radius: 50%;
|
|
370
|
+
background: var(--marker-color);
|
|
371
|
+
box-shadow: 0 0 0 2px var(--marker-color);
|
|
372
|
+
transform: translate(-50%, -50%);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
.toc-connectors {
|
|
376
|
+
position: absolute;
|
|
377
|
+
inset: 0;
|
|
378
|
+
z-index: 1;
|
|
379
|
+
width: 100%;
|
|
380
|
+
height: 100%;
|
|
381
|
+
overflow: visible;
|
|
382
|
+
pointer-events: none;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
.toc-connectors path {
|
|
386
|
+
fill: none;
|
|
387
|
+
stroke-linecap: round;
|
|
388
|
+
stroke-linejoin: round;
|
|
389
|
+
stroke-width: 2.5;
|
|
390
|
+
vector-effect: non-scaling-stroke;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
.toc-content {
|
|
394
|
+
position: absolute;
|
|
395
|
+
top: 9%;
|
|
396
|
+
left: 41.2%;
|
|
397
|
+
z-index: 2;
|
|
398
|
+
width: 55%;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.toc-content :deep(.slidev-toc-list) {
|
|
402
|
+
display: flex;
|
|
403
|
+
flex-direction: column;
|
|
404
|
+
gap: var(--toc-list-gap);
|
|
405
|
+
margin: 0;
|
|
406
|
+
padding: 0;
|
|
407
|
+
list-style: none;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.toc-content :deep(.slidev-toc-list-level-1 > .slidev-toc-item:nth-child(n + 8)) {
|
|
411
|
+
display: none;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
.toc-content[data-item-count='1']
|
|
415
|
+
:deep(.slidev-toc-list-level-1 > .slidev-toc-item:nth-child(n + 2)),
|
|
416
|
+
.toc-content[data-item-count='2']
|
|
417
|
+
:deep(.slidev-toc-list-level-1 > .slidev-toc-item:nth-child(n + 3)),
|
|
418
|
+
.toc-content[data-item-count='3']
|
|
419
|
+
:deep(.slidev-toc-list-level-1 > .slidev-toc-item:nth-child(n + 4)),
|
|
420
|
+
.toc-content[data-item-count='4']
|
|
421
|
+
:deep(.slidev-toc-list-level-1 > .slidev-toc-item:nth-child(n + 5)),
|
|
422
|
+
.toc-content[data-item-count='5']
|
|
423
|
+
:deep(.slidev-toc-list-level-1 > .slidev-toc-item:nth-child(n + 6)),
|
|
424
|
+
.toc-content[data-item-count='6']
|
|
425
|
+
:deep(.slidev-toc-list-level-1 > .slidev-toc-item:nth-child(n + 7)) {
|
|
426
|
+
display: none;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.toc-content :deep(.slidev-toc-item) {
|
|
430
|
+
--toc-color: var(--toc-orange);
|
|
431
|
+
|
|
432
|
+
position: relative;
|
|
433
|
+
margin: 0;
|
|
434
|
+
padding: 0;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
.toc-content :deep(.slidev-toc-item:nth-child(7n + 2)) {
|
|
438
|
+
--toc-color: var(--toc-teal);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
.toc-content :deep(.slidev-toc-item:nth-child(7n + 3)) {
|
|
442
|
+
--toc-color: var(--toc-blue);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
.toc-content :deep(.slidev-toc-item:nth-child(7n + 4)) {
|
|
446
|
+
--toc-color: var(--toc-green);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.toc-content :deep(.slidev-toc-item:nth-child(7n + 5)) {
|
|
450
|
+
--toc-color: var(--toc-pink);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
.toc-content :deep(.slidev-toc-item:nth-child(7n + 6)) {
|
|
454
|
+
--toc-color: var(--toc-purple);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
.toc-content :deep(.slidev-toc-item:nth-child(7n + 7)) {
|
|
458
|
+
--toc-color: var(--toc-red);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
.toc-content :deep(.slidev-toc-item > a) {
|
|
462
|
+
position: relative;
|
|
463
|
+
display: flex;
|
|
464
|
+
min-width: 260px;
|
|
465
|
+
min-height: 2.3rem;
|
|
466
|
+
align-items: center;
|
|
467
|
+
justify-content: center;
|
|
468
|
+
width: 260px;
|
|
469
|
+
padding: 0.5rem 1.25rem;
|
|
470
|
+
border: 0 !important;
|
|
471
|
+
border-radius: 999px;
|
|
472
|
+
background: var(--toc-color);
|
|
473
|
+
box-shadow: 0.45rem 0.65rem 0.85rem rgb(15 23 42 / 18%);
|
|
474
|
+
color: white;
|
|
475
|
+
font-family: inherit;
|
|
476
|
+
font-size: 0.9rem;
|
|
477
|
+
font-weight: 700;
|
|
478
|
+
line-height: 1.15;
|
|
479
|
+
text-align: center;
|
|
480
|
+
text-decoration: none !important;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
.toc-content :deep(.slidev-toc-item > a::before) {
|
|
484
|
+
display: none;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
.toc-content :deep(.slidev-toc-item-active > a),
|
|
488
|
+
.toc-content :deep(.slidev-toc-item > a:hover) {
|
|
489
|
+
filter: brightness(1.06);
|
|
490
|
+
transform: translateX(0.35rem);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
.toc-content :deep(.slidev-toc-list-level-2) {
|
|
494
|
+
gap: 0.35rem;
|
|
495
|
+
padding: 0.55rem 0 0 2rem;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.toc-content :deep(.slidev-toc-list-level-2 .slidev-toc-item::before) {
|
|
499
|
+
display: none;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.toc-content :deep(.slidev-toc-list-level-2 .slidev-toc-item > a) {
|
|
503
|
+
min-height: auto;
|
|
504
|
+
justify-content: flex-start;
|
|
505
|
+
padding: 0.15rem 0;
|
|
506
|
+
background: transparent;
|
|
507
|
+
box-shadow: none;
|
|
508
|
+
color: #525252;
|
|
509
|
+
font-size: 0.85rem;
|
|
510
|
+
font-weight: 500;
|
|
511
|
+
text-align: left;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
.toc-content :deep(.slidev-toc-list-level-2 .slidev-toc-item > a::before) {
|
|
515
|
+
display: none;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
</style>
|
|
@@ -19,7 +19,7 @@ const style = computed(() => {
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const { className, forwardedAttrs } = useMergedUnoAttrs(
|
|
22
|
-
'slidev-layout bg-center h-full grid place-content-center',
|
|
22
|
+
'alpha-bg-center slidev-layout bg-center h-full grid place-content-center',
|
|
23
23
|
);
|
|
24
24
|
</script>
|
|
25
25
|
|
|
@@ -1,41 +1,37 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { useSlideContext } from '@slidev/client';
|
|
3
|
-
import {
|
|
3
|
+
import { ref, shallowRef, useSlots, watch, watchEffect } from 'vue';
|
|
4
4
|
|
|
5
|
+
import { collectShiftingIntroNodes } from '../../utils/shiftingHeading/collectShiftingIntroNodes';
|
|
5
6
|
import { useMergedUnoAttrs } from '../../utils/useMergedUnoAttrs';
|
|
6
7
|
|
|
7
8
|
defineOptions({
|
|
8
9
|
inheritAttrs: false,
|
|
9
10
|
});
|
|
10
11
|
|
|
12
|
+
const context = useSlideContext();
|
|
11
13
|
const slots = useSlots();
|
|
12
|
-
const { $clicks } =
|
|
14
|
+
const { $clicks } = context;
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
return nodes.flatMap((node) => {
|
|
16
|
-
if (node.type === Fragment && Array.isArray(node.children))
|
|
17
|
-
return flattenTopLevel(node.children.filter(isVNode));
|
|
16
|
+
const delayClass = ref('delay-600');
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
watch($clicks, (newVal, oldVal) => {
|
|
19
|
+
if (newVal > oldVal) {
|
|
20
|
+
delayClass.value = 'delay-600';
|
|
21
|
+
} else {
|
|
22
|
+
delayClass.value = 'delay-0';
|
|
23
|
+
}
|
|
24
|
+
});
|
|
22
25
|
|
|
23
|
-
const nodes =
|
|
24
|
-
const children = flattenTopLevel(slots.default?.() ?? []);
|
|
25
|
-
const titleIndex = children.findIndex((node) => node.type === 'h1');
|
|
26
|
+
const nodes = shallowRef(collectShiftingIntroNodes([]));
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
titleIndex >= 0
|
|
31
|
-
? children.filter((_, index) => index !== titleIndex)
|
|
32
|
-
: children,
|
|
33
|
-
};
|
|
28
|
+
watchEffect(() => {
|
|
29
|
+
const children = slots.default?.() || [];
|
|
30
|
+
nodes.value = collectShiftingIntroNodes(children);
|
|
34
31
|
});
|
|
35
32
|
|
|
36
|
-
const isRevealed = computed(() => !nodes.value.title || $clicks.value > 0);
|
|
37
33
|
const { className, forwardedAttrs } = useMergedUnoAttrs(
|
|
38
|
-
'slidev-layout shifting-intro-layout
|
|
34
|
+
'alpha-shifting-intro slidev-layout shifting-intro-layout',
|
|
39
35
|
);
|
|
40
36
|
</script>
|
|
41
37
|
|
|
@@ -44,68 +40,41 @@ const { className, forwardedAttrs } = useMergedUnoAttrs(
|
|
|
44
40
|
v-bind="forwardedAttrs()"
|
|
45
41
|
:class="className()"
|
|
46
42
|
>
|
|
43
|
+
<component
|
|
44
|
+
:is="nodes.title"
|
|
45
|
+
v-if="nodes.title"
|
|
46
|
+
aria-hidden="true"
|
|
47
|
+
class="op-0"
|
|
48
|
+
/>
|
|
47
49
|
<TransitionHeading
|
|
48
50
|
v-if="nodes.title"
|
|
49
|
-
:
|
|
50
|
-
:
|
|
51
|
+
:idle="$clicks !== 0"
|
|
52
|
+
:center="$clicks === 0"
|
|
51
53
|
>
|
|
52
54
|
<component :is="nodes.title" />
|
|
53
55
|
</TransitionHeading>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
:size="1"
|
|
56
|
+
<div
|
|
57
|
+
v-click
|
|
58
|
+
class="hidden"
|
|
58
59
|
/>
|
|
59
|
-
|
|
60
60
|
<div
|
|
61
|
-
class="
|
|
62
|
-
:class="
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
class="transition-all duration-1000"
|
|
62
|
+
:class="[
|
|
63
|
+
$clicks > 0 ? 'opacity-100' : 'opacity-0',
|
|
64
|
+
delayClass,
|
|
65
|
+
]"
|
|
65
66
|
>
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
<template v-for="(content) in nodes.contents" :key="content.key">
|
|
68
|
+
<component
|
|
69
|
+
v-if="nodes.clickRef.has(content.key)"
|
|
70
|
+
:is="content.node"
|
|
71
|
+
v-click="nodes.clickRef.get(content.key)"
|
|
72
|
+
/>
|
|
73
|
+
<component
|
|
74
|
+
v-else
|
|
75
|
+
:is="content.node"
|
|
76
|
+
/>
|
|
77
|
+
</template>
|
|
71
78
|
</div>
|
|
72
79
|
</div>
|
|
73
80
|
</template>
|
|
74
|
-
|
|
75
|
-
<style>
|
|
76
|
-
.shifting-intro-content {
|
|
77
|
-
box-sizing: border-box;
|
|
78
|
-
min-height: 100%;
|
|
79
|
-
padding-top: var(--shifting-heading-content-offset, 4.25rem);
|
|
80
|
-
visibility: hidden;
|
|
81
|
-
opacity: 0;
|
|
82
|
-
transition:
|
|
83
|
-
opacity var(--shifting-content-exit-duration, 250ms) ease-out,
|
|
84
|
-
visibility 0s linear var(--shifting-content-exit-duration, 250ms);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.shifting-intro-content.is-revealed {
|
|
88
|
-
visibility: visible;
|
|
89
|
-
opacity: 1;
|
|
90
|
-
transition:
|
|
91
|
-
opacity var(--shifting-content-duration, 700ms) ease-out
|
|
92
|
-
var(--shifting-content-delay, 450ms),
|
|
93
|
-
visibility 0s linear;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
@media (prefers-reduced-motion: reduce) {
|
|
97
|
-
.shifting-intro-content,
|
|
98
|
-
.shifting-intro-content.is-revealed {
|
|
99
|
-
transition-duration: 1ms;
|
|
100
|
-
transition-delay: 0ms;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
@media print {
|
|
105
|
-
.shifting-heading,
|
|
106
|
-
.shifting-intro-content,
|
|
107
|
-
.shifting-intro-content.is-revealed {
|
|
108
|
-
transition: none;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
</style>
|