@slidev-react/client 0.2.5 → 0.2.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slidev-react/client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Browser-side React app and presentation UI for slidev-react",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"shiki": "4.0.1",
|
|
15
15
|
"shiki-magic-move": "1.2.1",
|
|
16
16
|
"zod": "4.3.6",
|
|
17
|
-
"@slidev-react/core": "0.2.
|
|
17
|
+
"@slidev-react/core": "0.2.6"
|
|
18
18
|
},
|
|
19
19
|
"peerDependencies": {
|
|
20
20
|
"@antv/g-svg": ">=2.0.0",
|
|
@@ -68,39 +68,39 @@ export function buildSlidevTheme(): G2Theme {
|
|
|
68
68
|
category10: categoryPalette,
|
|
69
69
|
category20: categoryPalette,
|
|
70
70
|
axis: {
|
|
71
|
-
labelFontSize:
|
|
72
|
-
labelFill:
|
|
71
|
+
labelFontSize: 12,
|
|
72
|
+
labelFill: '#8b95a2',
|
|
73
73
|
labelFontFamily: font,
|
|
74
|
-
titleFontSize:
|
|
75
|
-
titleFill:
|
|
74
|
+
titleFontSize: 13,
|
|
75
|
+
titleFill: '#718096',
|
|
76
76
|
titleFontFamily: font,
|
|
77
|
-
titleFontWeight: '
|
|
78
|
-
gridStroke: '#
|
|
79
|
-
gridStrokeOpacity:
|
|
80
|
-
lineStroke: '#
|
|
77
|
+
titleFontWeight: 'normal',
|
|
78
|
+
gridStroke: '#e8ecf1',
|
|
79
|
+
gridStrokeOpacity: 0.6,
|
|
80
|
+
lineStroke: '#dfe4ea',
|
|
81
81
|
lineLineWidth: 1,
|
|
82
|
-
tickStroke: '#
|
|
82
|
+
tickStroke: '#dfe4ea',
|
|
83
83
|
},
|
|
84
84
|
legendCategory: {
|
|
85
|
-
itemLabelFontSize:
|
|
85
|
+
itemLabelFontSize: 13,
|
|
86
86
|
itemLabelFill: mutedColor,
|
|
87
87
|
itemLabelFontFamily: font,
|
|
88
|
-
titleFontSize:
|
|
88
|
+
titleFontSize: 14,
|
|
89
89
|
titleFill: textColor,
|
|
90
90
|
titleFontFamily: font,
|
|
91
91
|
titleFontWeight: 'bold',
|
|
92
92
|
},
|
|
93
93
|
title: {
|
|
94
|
-
titleFontSize:
|
|
94
|
+
titleFontSize: 18,
|
|
95
95
|
titleFill: textColor,
|
|
96
96
|
titleFontFamily: font,
|
|
97
97
|
titleFontWeight: 'bold',
|
|
98
|
-
subtitleFontSize:
|
|
98
|
+
subtitleFontSize: 14,
|
|
99
99
|
subtitleFill: mutedColor,
|
|
100
100
|
subtitleFontFamily: font,
|
|
101
101
|
},
|
|
102
102
|
label: {
|
|
103
|
-
fontSize:
|
|
103
|
+
fontSize: 12,
|
|
104
104
|
fontFamily: font,
|
|
105
105
|
fill: mutedColor,
|
|
106
106
|
},
|
|
@@ -35,7 +35,7 @@ function cloneWithRevealClass(
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export function
|
|
38
|
+
export function Step({
|
|
39
39
|
step,
|
|
40
40
|
preset = "fade-up",
|
|
41
41
|
asChild = false,
|
|
@@ -71,7 +71,7 @@ export function Reveal({
|
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
export function
|
|
74
|
+
export function Steps({
|
|
75
75
|
start = 1,
|
|
76
76
|
increment = 1,
|
|
77
77
|
preset = "fade-up",
|
|
@@ -96,7 +96,7 @@ export function RevealGroup({
|
|
|
96
96
|
|
|
97
97
|
if (isValidElement(child)) {
|
|
98
98
|
return (
|
|
99
|
-
<
|
|
99
|
+
<Step
|
|
100
100
|
key={child.key ?? step}
|
|
101
101
|
step={step}
|
|
102
102
|
preset={preset}
|
|
@@ -104,14 +104,14 @@ export function RevealGroup({
|
|
|
104
104
|
asChild
|
|
105
105
|
>
|
|
106
106
|
{child}
|
|
107
|
-
</
|
|
107
|
+
</Step>
|
|
108
108
|
);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
return (
|
|
112
|
-
<
|
|
112
|
+
<Step key={step} step={step} preset={preset} reserveSpace={reserveSpace}>
|
|
113
113
|
{child}
|
|
114
|
-
</
|
|
114
|
+
</Step>
|
|
115
115
|
);
|
|
116
116
|
})}
|
|
117
117
|
</>
|
|
@@ -3,7 +3,7 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
3
3
|
import { createHighlighter } from "shiki";
|
|
4
4
|
import { ShikiMagicMove } from "shiki-magic-move/react";
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const DEFAULT_STEPS = [
|
|
7
7
|
`const message = 'Hello'
|
|
8
8
|
const target = 'world'
|
|
9
9
|
|
|
@@ -32,7 +32,8 @@ function getHighlighter() {
|
|
|
32
32
|
return highlighterPromise;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export function
|
|
35
|
+
export function CodeMagicMove({ steps }: { steps?: string[] }) {
|
|
36
|
+
const resolvedSteps = steps && steps.length > 0 ? steps : DEFAULT_STEPS;
|
|
36
37
|
const [stepIndex, setStepIndex] = useState(0);
|
|
37
38
|
const [highlighter, setHighlighter] = useState<HighlighterCore>();
|
|
38
39
|
|
|
@@ -51,7 +52,7 @@ export function MagicMoveDemo() {
|
|
|
51
52
|
};
|
|
52
53
|
}, []);
|
|
53
54
|
|
|
54
|
-
const code = useMemo(() =>
|
|
55
|
+
const code = useMemo(() => resolvedSteps[stepIndex], [resolvedSteps, stepIndex]);
|
|
55
56
|
|
|
56
57
|
if (!highlighter) {
|
|
57
58
|
return (
|
|
@@ -79,31 +80,33 @@ export function MagicMoveDemo() {
|
|
|
79
80
|
lineNumbers: false,
|
|
80
81
|
splitTokens: false,
|
|
81
82
|
enhanceMatching: true,
|
|
82
|
-
animateContainer:
|
|
83
|
-
containerStyle: false,
|
|
83
|
+
animateContainer: true,
|
|
84
84
|
}}
|
|
85
85
|
/>
|
|
86
86
|
</div>
|
|
87
|
-
<div className="flex flex-wrap gap-2">
|
|
87
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
88
88
|
<button
|
|
89
89
|
type="button"
|
|
90
|
-
className="rounded-lg bg-
|
|
90
|
+
className="rounded-lg bg-emerald-600 px-3.5 py-1.5 text-sm font-medium text-white shadow-sm transition hover:bg-emerald-500 active:bg-emerald-700 disabled:opacity-40 disabled:hover:bg-emerald-600"
|
|
91
91
|
onClick={() => setStepIndex((index) => Math.max(index - 1, 0))}
|
|
92
92
|
disabled={stepIndex === 0}
|
|
93
93
|
>
|
|
94
|
-
Prev
|
|
94
|
+
← Prev
|
|
95
95
|
</button>
|
|
96
96
|
<button
|
|
97
97
|
type="button"
|
|
98
|
-
className="rounded-lg bg-
|
|
99
|
-
onClick={() => setStepIndex((index) => Math.min(index + 1,
|
|
100
|
-
disabled={stepIndex >=
|
|
98
|
+
className="rounded-lg bg-emerald-600 px-3.5 py-1.5 text-sm font-medium text-white shadow-sm transition hover:bg-emerald-500 active:bg-emerald-700 disabled:opacity-40 disabled:hover:bg-emerald-600"
|
|
99
|
+
onClick={() => setStepIndex((index) => Math.min(index + 1, resolvedSteps.length - 1))}
|
|
100
|
+
disabled={stepIndex >= resolvedSteps.length - 1}
|
|
101
101
|
>
|
|
102
|
-
Next
|
|
102
|
+
Next →
|
|
103
103
|
</button>
|
|
104
|
+
<span className="text-xs text-slate-400">
|
|
105
|
+
{stepIndex + 1} / {resolvedSteps.length}
|
|
106
|
+
</span>
|
|
104
107
|
<button
|
|
105
108
|
type="button"
|
|
106
|
-
className="rounded-lg
|
|
109
|
+
className="ml-auto rounded-lg border border-slate-200 bg-white/80 px-3 py-1.5 text-sm font-medium text-slate-600 shadow-sm transition hover:bg-slate-50 active:bg-slate-100"
|
|
107
110
|
onClick={() => setStepIndex(0)}
|
|
108
111
|
>
|
|
109
112
|
Reset
|
package/src/ui/mdx/index.ts
CHANGED
|
@@ -2,19 +2,19 @@ import { PlantUmlDiagram } from "../diagrams/PlantUmlDiagram"
|
|
|
2
2
|
import { Annotate } from "../primitives/Annotate"
|
|
3
3
|
import { Badge } from "../primitives/Badge"
|
|
4
4
|
import { Callout } from "../primitives/Callout"
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { CodeMagicMove } from "./CodeMagicMove"
|
|
6
|
+
import { Step, Steps } from "../../features/presentation/reveal/Reveal"
|
|
7
7
|
import { CourseCover } from "../../../../../components/CourseCover"
|
|
8
8
|
import { MinimaxReactVisualizer } from "../../../../../components/MinimaxReactVisualizer"
|
|
9
9
|
|
|
10
10
|
export const mdxComponents = {
|
|
11
11
|
Badge,
|
|
12
12
|
Callout,
|
|
13
|
-
|
|
13
|
+
CodeMagicMove,
|
|
14
14
|
Annotate,
|
|
15
15
|
PlantUmlDiagram,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
Step,
|
|
17
|
+
Steps,
|
|
18
18
|
CourseCover,
|
|
19
19
|
MinimaxReactVisualizer,
|
|
20
20
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
|
|
3
3
|
export function Badge({ children }: { children: ReactNode }) {
|
|
4
|
-
return
|
|
4
|
+
return (
|
|
5
|
+
<span className="inline-block rounded-full border border-emerald-500/16 bg-green-100 px-2 py-0.5 text-sm font-semibold leading-snug text-green-800">
|
|
6
|
+
{children}
|
|
7
|
+
</span>
|
|
8
|
+
);
|
|
5
9
|
}
|