@unfold-mdx/react 0.0.1
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/LICENSE +21 -0
- package/README.md +275 -0
- package/dist/chunk-OX5XKYQT.js +218 -0
- package/dist/codeDiff-BVwZfdt9.d.cts +19 -0
- package/dist/codeDiff-BVwZfdt9.d.ts +19 -0
- package/dist/diff/index.cjs +248 -0
- package/dist/diff/index.d.cts +37 -0
- package/dist/diff/index.d.ts +37 -0
- package/dist/diff/index.js +14 -0
- package/dist/index.cjs +626 -0
- package/dist/index.d.cts +65 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +378 -0
- package/dist/shiki/index.cjs +125 -0
- package/dist/shiki/index.d.cts +14 -0
- package/dist/shiki/index.d.ts +14 -0
- package/dist/shiki/index.js +100 -0
- package/package.json +88 -0
- package/theme.css +212 -0
package/package.json
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@unfold-mdx/react",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Progressive-depth prose & code explanations for React + MDX. Sentence-level diffing, inline code highlights, and Shiki syntax coloring — all headless.",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./diff": {
|
|
16
|
+
"types": "./dist/diff/index.d.ts",
|
|
17
|
+
"import": "./dist/diff/index.js",
|
|
18
|
+
"require": "./dist/diff/index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./shiki": {
|
|
21
|
+
"types": "./dist/shiki/index.d.ts",
|
|
22
|
+
"import": "./dist/shiki/index.js",
|
|
23
|
+
"require": "./dist/shiki/index.cjs"
|
|
24
|
+
},
|
|
25
|
+
"./theme.css": "./theme.css"
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"theme.css",
|
|
30
|
+
"README.md",
|
|
31
|
+
"LICENSE"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"theme.css"
|
|
35
|
+
],
|
|
36
|
+
"keywords": [
|
|
37
|
+
"react",
|
|
38
|
+
"mdx",
|
|
39
|
+
"progressive-disclosure",
|
|
40
|
+
"code-diff",
|
|
41
|
+
"sentence-diff",
|
|
42
|
+
"shiki",
|
|
43
|
+
"syntax-highlighting",
|
|
44
|
+
"headless",
|
|
45
|
+
"documentation",
|
|
46
|
+
"tutorial"
|
|
47
|
+
],
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "https://github.com/Shakya47/unfold-mdx.git"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/Shakya47/unfold-mdx#readme",
|
|
53
|
+
"bugs": {
|
|
54
|
+
"url": "https://github.com/Shakya47/unfold-mdx/issues"
|
|
55
|
+
},
|
|
56
|
+
"author": "Shakya47",
|
|
57
|
+
"license": "MIT",
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"diff-match-patch": "^1.0.5"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"react": ">=18.0.0",
|
|
63
|
+
"react-dom": ">=18.0.0",
|
|
64
|
+
"shiki": "^1.0.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"shiki": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"devDependencies": {
|
|
72
|
+
"@testing-library/jest-dom": "^6.0.0",
|
|
73
|
+
"@testing-library/react": "^14.0.0",
|
|
74
|
+
"@testing-library/user-event": "^14.0.0",
|
|
75
|
+
"@types/diff-match-patch": "^1.0.36",
|
|
76
|
+
"@types/react": "^18.2.0",
|
|
77
|
+
"@types/react-dom": "^18.2.0",
|
|
78
|
+
"jsdom": "^22.0.0",
|
|
79
|
+
"shiki": "^1.0.0",
|
|
80
|
+
"tsup": "^8.0.0",
|
|
81
|
+
"typescript": "^5.0.0",
|
|
82
|
+
"vitest": "^1.0.0"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "tsup src/index.ts src/diff/index.ts src/shiki/index.ts --format cjs,esm --dts --clean",
|
|
86
|
+
"test": "vitest run"
|
|
87
|
+
}
|
|
88
|
+
}
|
package/theme.css
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/* ──────────────────────────────────────────────────────────────
|
|
2
|
+
unfold-mdx · Opinionated Default Theme
|
|
3
|
+
Import: import 'unfold-mdx/theme.css'
|
|
4
|
+
|
|
5
|
+
Override points (CSS custom properties):
|
|
6
|
+
--unfold-ratio Prose/code split (0–1, default 0.5)
|
|
7
|
+
--unfold-prose-color Prose text color
|
|
8
|
+
--unfold-prose-muted Equal-sentence dimmed color
|
|
9
|
+
--unfold-code-bg Code pane background
|
|
10
|
+
--unfold-code-border Code pane border
|
|
11
|
+
--unfold-code-text Code fallback text color
|
|
12
|
+
--unfold-highlight Thin-border highlight color
|
|
13
|
+
--unfold-highlight-bg Subtle background tint on added items
|
|
14
|
+
--unfold-btn-bg Button background
|
|
15
|
+
--unfold-btn-border Button border
|
|
16
|
+
--unfold-btn-text Button text color
|
|
17
|
+
--unfold-btn-hover-bg Button hover background
|
|
18
|
+
--unfold-dot-bg Inactive dot color
|
|
19
|
+
--unfold-dot-active Active dot color
|
|
20
|
+
────────────────────────────────────────────────────────────── */
|
|
21
|
+
|
|
22
|
+
/* ── Root ── */
|
|
23
|
+
[data-unfold-root] {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
gap: 16px;
|
|
27
|
+
font-family: inherit;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* ── Pane Container ── */
|
|
31
|
+
[data-unfold-panes] {
|
|
32
|
+
display: flex;
|
|
33
|
+
gap: 24px;
|
|
34
|
+
align-items: stretch;
|
|
35
|
+
min-height: 200px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
[data-unfold-root][data-orientation="vertical"] [data-unfold-panes] {
|
|
39
|
+
flex-direction: column;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
[data-unfold-root][data-show="both"][data-orientation="horizontal"] [data-unfold-pane="prose"] {
|
|
43
|
+
flex: var(--unfold-ratio, 0.5);
|
|
44
|
+
min-width: 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
[data-unfold-root][data-show="both"][data-orientation="horizontal"] [data-unfold-pane="code"] {
|
|
48
|
+
flex: calc(1 - var(--unfold-ratio, 0.5));
|
|
49
|
+
min-width: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/* ── Single Pane Layouts (Full Width) ── */
|
|
53
|
+
[data-unfold-root][data-show="prose"] [data-unfold-pane="prose"] {
|
|
54
|
+
flex: 1;
|
|
55
|
+
width: 100%;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
[data-unfold-root][data-show="code"] [data-unfold-pane="code"] {
|
|
59
|
+
flex: 1;
|
|
60
|
+
width: 100%;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* ── Prose Pane ── */
|
|
64
|
+
[data-unfold-pane="prose"] {
|
|
65
|
+
line-height: 1.75;
|
|
66
|
+
font-size: 1.05rem;
|
|
67
|
+
color: var(--unfold-prose-color, #e2e8f0);
|
|
68
|
+
padding: 4px 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* ── Code Pane ── */
|
|
72
|
+
[data-unfold-pane="code"] {
|
|
73
|
+
background: var(--unfold-code-bg, #0d1117);
|
|
74
|
+
border: 1px solid var(--unfold-code-border, rgba(56, 189, 248, 0.15));
|
|
75
|
+
border-radius: 10px;
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
[data-unfold-pane="code"] pre {
|
|
80
|
+
margin: 0;
|
|
81
|
+
padding: 16px 20px;
|
|
82
|
+
overflow-x: auto;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
[data-unfold-pane="code"] code {
|
|
86
|
+
font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
|
|
87
|
+
font-size: 0.875rem;
|
|
88
|
+
line-height: 1.6;
|
|
89
|
+
color: var(--unfold-code-text, #c9d1d9);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* ── Prose Sentence Highlighting ──
|
|
93
|
+
Spec: thin border, NOT a background fill.
|
|
94
|
+
Equal sentences look normal; added sentences get a subtle marker. */
|
|
95
|
+
|
|
96
|
+
[data-sentence="equal"] {
|
|
97
|
+
transition: border-color 0.6s ease, background-color 0.6s ease;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
[data-sentence="added"] {
|
|
101
|
+
border: 1px solid var(--unfold-highlight, rgba(56, 189, 248, 0.5));
|
|
102
|
+
border-radius: 3px;
|
|
103
|
+
padding: 0 3px;
|
|
104
|
+
background: var(--unfold-highlight-bg, rgba(56, 189, 248, 0.06));
|
|
105
|
+
transition: border-color 0.3s ease, background-color 0.3s ease;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* ── Code Token Highlighting ── */
|
|
109
|
+
[data-code-token="added"] {
|
|
110
|
+
/* Inherits line highlight. */
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* ── Code Line Highlighting ──
|
|
114
|
+
Added or changed lines get a thin border and subtle background tint, matching prose.
|
|
115
|
+
Equal lines get transparent borders to prevent text shifting during transitions. */
|
|
116
|
+
[data-code-line="added"],
|
|
117
|
+
[data-code-line="changed"] {
|
|
118
|
+
display: block;
|
|
119
|
+
border: 1px solid var(--unfold-highlight, rgba(56, 189, 248, 0.5));
|
|
120
|
+
border-radius: 4px;
|
|
121
|
+
padding: 0 6px;
|
|
122
|
+
margin: 2px 0;
|
|
123
|
+
background: var(--unfold-highlight-bg, rgba(56, 189, 248, 0.06));
|
|
124
|
+
transition: border-color 0.3s ease, background-color 0.3s ease;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
[data-code-line="equal"] {
|
|
128
|
+
display: block;
|
|
129
|
+
border: 1px solid transparent;
|
|
130
|
+
border-radius: 4px;
|
|
131
|
+
padding: 0 6px;
|
|
132
|
+
margin: 2px 0;
|
|
133
|
+
transition: border-color 0.6s ease, background-color 0.6s ease;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* ── Controls ── */
|
|
137
|
+
[data-unfold-controls] {
|
|
138
|
+
display: flex;
|
|
139
|
+
gap: 12px;
|
|
140
|
+
align-items: center;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
[data-unfold-controls] > button {
|
|
144
|
+
background: var(--unfold-btn-bg, rgba(255, 255, 255, 0.06));
|
|
145
|
+
border: 1px solid var(--unfold-btn-border, rgba(255, 255, 255, 0.12));
|
|
146
|
+
color: var(--unfold-btn-text, #e2e8f0);
|
|
147
|
+
padding: 7px 18px;
|
|
148
|
+
border-radius: 6px;
|
|
149
|
+
cursor: pointer;
|
|
150
|
+
font-size: 0.875rem;
|
|
151
|
+
font-weight: 500;
|
|
152
|
+
transition: background 0.15s ease, border-color 0.15s ease;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
[data-unfold-controls] > button:hover:not([aria-disabled="true"]) {
|
|
156
|
+
background: var(--unfold-btn-hover-bg, rgba(255, 255, 255, 0.12));
|
|
157
|
+
border-color: rgba(255, 255, 255, 0.2);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
[data-unfold-controls] > button[aria-disabled="true"] {
|
|
161
|
+
opacity: 0.3;
|
|
162
|
+
cursor: not-allowed;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* ── Indicators (carousel dots) ── */
|
|
166
|
+
[data-unfold-indicators] {
|
|
167
|
+
display: flex;
|
|
168
|
+
gap: 6px;
|
|
169
|
+
align-items: center;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
[data-unfold-dot] {
|
|
173
|
+
width: 8px;
|
|
174
|
+
height: 8px;
|
|
175
|
+
border-radius: 50%;
|
|
176
|
+
background: var(--unfold-dot-bg, rgba(255, 255, 255, 0.15));
|
|
177
|
+
border: none;
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
padding: 0;
|
|
180
|
+
transition: background 0.2s ease, transform 0.2s ease;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
[data-unfold-dot]:hover {
|
|
184
|
+
background: rgba(255, 255, 255, 0.3);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
[data-unfold-dot][data-active="true"] {
|
|
188
|
+
background: var(--unfold-dot-active, #38bdf8);
|
|
189
|
+
transform: scale(1.25);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/* ── Animation: data-enter flash ── */
|
|
193
|
+
[data-enter="true"] {
|
|
194
|
+
animation: unfold-enter 0.4s ease-out;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@keyframes unfold-enter {
|
|
198
|
+
0% { background-color: rgba(56, 189, 248, 0.15); }
|
|
199
|
+
100% { background-color: transparent; }
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@media (prefers-reduced-motion: reduce) {
|
|
203
|
+
[data-enter="true"] {
|
|
204
|
+
animation: none;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/* ── SSR / no-JS fallback ── */
|
|
209
|
+
[data-unfold-root] > [data-depth-level]:not([data-unfold-active]),
|
|
210
|
+
[data-unfold-root] > pre[data-lang]:not([data-unfold-active]) {
|
|
211
|
+
display: none;
|
|
212
|
+
}
|