@silvery/examples 0.17.4 → 0.17.5
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/dist/_banner-A70_y2Vi.mjs +43 -0
- package/dist/{ansi-CCE2pVS0.mjs → ansi-0VXlUmNn.mjs} +7 -7
- package/dist/apng-B0gRaDVT.mjs +3 -0
- package/dist/{apng-HhhBjRGt.mjs → apng-BTRDTfDW.mjs} +2 -2
- package/dist/apps/aichat/index.mjs +69 -70
- package/dist/apps/app-todo.mjs +19 -20
- package/dist/apps/async-data.mjs +40 -41
- package/dist/apps/cli-wizard.mjs +51 -52
- package/dist/apps/clipboard.mjs +26 -27
- package/dist/apps/components.mjs +189 -190
- package/dist/apps/data-explorer.mjs +52 -53
- package/dist/apps/dev-tools.mjs +39 -40
- package/dist/apps/explorer.mjs +73 -74
- package/dist/apps/gallery.mjs +61 -62
- package/dist/apps/inline-bench.mjs +1 -1
- package/dist/apps/kanban.mjs +22 -23
- package/dist/apps/layout-ref.mjs +27 -28
- package/dist/apps/outline.mjs +35 -36
- package/dist/apps/paste-demo.mjs +33 -34
- package/dist/apps/scroll.mjs +11 -12
- package/dist/apps/search-filter.mjs +23 -24
- package/dist/apps/selection.mjs +30 -31
- package/dist/apps/spatial-focus-demo.mjs +32 -33
- package/dist/apps/task-list.mjs +25 -26
- package/dist/apps/terminal-caps-demo.mjs +30 -31
- package/dist/apps/terminal.mjs +157 -158
- package/dist/apps/text-selection-demo.mjs +62 -63
- package/dist/apps/textarea.mjs +21 -22
- package/dist/apps/theme.mjs +142 -143
- package/dist/apps/transform.mjs +25 -26
- package/dist/apps/virtual-10k.mjs +52 -53
- package/dist/{backends-Bahh9mKN.mjs → backends-Dj-11kZF.mjs} +1 -1
- package/dist/backends-U3QwStfO.mjs +3 -0
- package/dist/components/counter.mjs +6 -7
- package/dist/components/hello.mjs +5 -6
- package/dist/components/progress-bar.mjs +10 -11
- package/dist/components/select-list.mjs +8 -9
- package/dist/components/spinner.mjs +10 -11
- package/dist/components/text-input.mjs +8 -9
- package/dist/components/virtual-list.mjs +7 -8
- package/dist/{flexily-zero-adapter-UB-ra8fR.mjs → flexily-zero-adapter-ByVzLTFP.mjs} +1 -1
- package/dist/gif-B6NGH5gs.mjs +3 -0
- package/dist/{gif-BtnXuxLF.mjs → gif-CfkOF-iG.mjs} +2 -2
- package/dist/layout/dashboard.mjs +197 -198
- package/dist/layout/live-resize.mjs +44 -45
- package/dist/layout/overflow.mjs +16 -17
- package/dist/layout/text-layout.mjs +67 -68
- package/dist/{plugins-D1KtkT4a.mjs → plugins-CT0DdV_E.mjs} +12 -13
- package/dist/{src-BTEVGpd9.mjs → src-jO3Zuzjj.mjs} +3 -3
- package/dist/{yoga-adapter-BVtQ5OJR.mjs → yoga-adapter-BSQHuMV9.mjs} +1 -1
- package/package.json +4 -2
- package/dist/_banner-DLPxCqVy.mjs +0 -44
- package/dist/apng-mwUQbTTF.mjs +0 -3
- package/dist/backends-CCtCDQ94.mjs +0 -3
- package/dist/gif-BZaqPPVX.mjs +0 -3
- package/dist/jsx-runtime-dMs_8fNu.mjs +0 -241
- /package/dist/{UPNG-Cy7ViL8f.mjs → UPNG-ShUlaTDh.mjs} +0 -0
- /package/dist/{__vite-browser-external-2447137e-BML7CYau.mjs → __vite-browser-external-2447137e-Bopa5BFR.mjs} +0 -0
- /package/dist/{gifenc-CLRW41dk.mjs → gifenc-BI4ihP_T.mjs} +0 -0
- /package/dist/{node-NuJ94BWl.mjs → node-nsrAOjH4.mjs} +0 -0
- /package/dist/{resvg-js-C_8Wps1F.mjs → resvg-js-Cnk2o49d.mjs} +0 -0
- /package/dist/{src-CzfRafCQ.mjs → src-9ZhfQyzD.mjs} +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as ExampleBanner } from "../_banner-DLPxCqVy.mjs";
|
|
1
|
+
import { t as ExampleBanner } from "../_banner-A70_y2Vi.mjs";
|
|
3
2
|
import { useCallback } from "react";
|
|
4
3
|
import { Box, H1, H3, Kbd, Muted, Small, Text, useBoxRect } from "silvery";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { run, useInput as useInput$1 } from "silvery/runtime";
|
|
6
6
|
//#region layout/live-resize.tsx
|
|
7
|
-
var import_jsx_runtime = require_jsx_runtime();
|
|
8
7
|
const meta = {
|
|
9
8
|
name: "Live Resize",
|
|
10
9
|
description: "Responsive multi-column grid that reflows based on terminal width",
|
|
@@ -65,44 +64,44 @@ const CARDS = [
|
|
|
65
64
|
}
|
|
66
65
|
];
|
|
67
66
|
function MetricCard({ card, compact }) {
|
|
68
|
-
if (compact) return /* @__PURE__ */
|
|
67
|
+
if (compact) return /* @__PURE__ */ jsxs(Box, {
|
|
69
68
|
borderStyle: "round",
|
|
70
69
|
borderColor: card.color,
|
|
71
70
|
paddingX: 1,
|
|
72
71
|
flexDirection: "row",
|
|
73
72
|
justifyContent: "space-between",
|
|
74
|
-
children: [/* @__PURE__ */
|
|
73
|
+
children: [/* @__PURE__ */ jsx(H1, {
|
|
75
74
|
color: card.color,
|
|
76
75
|
children: card.title
|
|
77
|
-
}), /* @__PURE__ */
|
|
76
|
+
}), /* @__PURE__ */ jsx(H3, { children: card.value })]
|
|
78
77
|
});
|
|
79
|
-
return /* @__PURE__ */
|
|
78
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
80
79
|
borderStyle: "round",
|
|
81
80
|
borderColor: card.color,
|
|
82
81
|
paddingX: 1,
|
|
83
82
|
flexDirection: "column",
|
|
84
83
|
flexGrow: 1,
|
|
85
84
|
children: [
|
|
86
|
-
/* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
87
86
|
justifyContent: "space-between",
|
|
88
|
-
children: [/* @__PURE__ */
|
|
87
|
+
children: [/* @__PURE__ */ jsx(H1, {
|
|
89
88
|
color: card.color,
|
|
90
89
|
children: card.title
|
|
91
|
-
}), /* @__PURE__ */
|
|
90
|
+
}), /* @__PURE__ */ jsx(H1, {
|
|
92
91
|
color: card.color,
|
|
93
92
|
children: card.value
|
|
94
93
|
})]
|
|
95
94
|
}),
|
|
96
|
-
/* @__PURE__ */
|
|
95
|
+
/* @__PURE__ */ jsx(Text, {
|
|
97
96
|
color: card.color,
|
|
98
97
|
children: card.sparkline
|
|
99
98
|
}),
|
|
100
|
-
/* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ jsx(Small, { children: card.detail })
|
|
101
100
|
]
|
|
102
101
|
});
|
|
103
102
|
}
|
|
104
103
|
function BreakpointIndicator({ width, columns }) {
|
|
105
|
-
return /* @__PURE__ */
|
|
104
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
106
105
|
gap: 2,
|
|
107
106
|
paddingX: 1,
|
|
108
107
|
children: [
|
|
@@ -123,13 +122,13 @@ function BreakpointIndicator({ width, columns }) {
|
|
|
123
122
|
}
|
|
124
123
|
].map((bp) => {
|
|
125
124
|
const isActive = bp.cols === columns;
|
|
126
|
-
return /* @__PURE__ */
|
|
125
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
127
126
|
gap: 1,
|
|
128
|
-
children: [/* @__PURE__ */
|
|
127
|
+
children: [/* @__PURE__ */ jsx(Text, {
|
|
129
128
|
color: isActive ? "green" : "gray",
|
|
130
129
|
bold: isActive,
|
|
131
130
|
children: isActive ? "●" : "○"
|
|
132
|
-
}), /* @__PURE__ */
|
|
131
|
+
}), /* @__PURE__ */ jsxs(Text, {
|
|
133
132
|
color: isActive ? "white" : "gray",
|
|
134
133
|
bold: isActive,
|
|
135
134
|
children: [
|
|
@@ -146,32 +145,32 @@ function BreakpointIndicator({ width, columns }) {
|
|
|
146
145
|
});
|
|
147
146
|
}
|
|
148
147
|
function GridLayout({ cards, columns, compact }) {
|
|
149
|
-
if (columns === 1) return /* @__PURE__ */
|
|
148
|
+
if (columns === 1) return /* @__PURE__ */ jsx(Box, {
|
|
150
149
|
flexDirection: "column",
|
|
151
150
|
gap: compact ? 0 : 1,
|
|
152
151
|
flexGrow: 1,
|
|
153
|
-
children: cards.map((card) => /* @__PURE__ */
|
|
152
|
+
children: cards.map((card) => /* @__PURE__ */ jsx(MetricCard, {
|
|
154
153
|
card,
|
|
155
154
|
compact
|
|
156
155
|
}, card.title))
|
|
157
156
|
});
|
|
158
157
|
const rows = [];
|
|
159
158
|
for (let i = 0; i < cards.length; i += columns) rows.push(cards.slice(i, i + columns));
|
|
160
|
-
return /* @__PURE__ */
|
|
159
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
161
160
|
flexDirection: "column",
|
|
162
161
|
gap: 1,
|
|
163
162
|
flexGrow: 1,
|
|
164
|
-
children: rows.map((row, rowIndex) => /* @__PURE__ */
|
|
163
|
+
children: rows.map((row, rowIndex) => /* @__PURE__ */ jsxs(Box, {
|
|
165
164
|
flexDirection: "row",
|
|
166
165
|
gap: 1,
|
|
167
|
-
children: [row.map((card) => /* @__PURE__ */
|
|
166
|
+
children: [row.map((card) => /* @__PURE__ */ jsx(Box, {
|
|
168
167
|
flexGrow: 1,
|
|
169
168
|
flexBasis: 0,
|
|
170
|
-
children: /* @__PURE__ */
|
|
169
|
+
children: /* @__PURE__ */ jsx(MetricCard, {
|
|
171
170
|
card,
|
|
172
171
|
compact: false
|
|
173
172
|
})
|
|
174
|
-
}, card.title)), row.length < columns && Array.from({ length: columns - row.length }, (_, i) => /* @__PURE__ */
|
|
173
|
+
}, card.title)), row.length < columns && Array.from({ length: columns - row.length }, (_, i) => /* @__PURE__ */ jsx(Box, {
|
|
175
174
|
flexGrow: 1,
|
|
176
175
|
flexBasis: 0
|
|
177
176
|
}, `spacer-${i}`))]
|
|
@@ -179,29 +178,29 @@ function GridLayout({ cards, columns, compact }) {
|
|
|
179
178
|
});
|
|
180
179
|
}
|
|
181
180
|
function CodeSnippet({ width }) {
|
|
182
|
-
if (!(width >= 60)) return /* @__PURE__ */
|
|
181
|
+
if (!(width >= 60)) return /* @__PURE__ */ jsx(Box, {
|
|
183
182
|
paddingX: 1,
|
|
184
|
-
children: /* @__PURE__ */
|
|
183
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
185
184
|
dim: true,
|
|
186
185
|
italic: true,
|
|
187
186
|
children: "(Widen terminal to see the code that powers this)"
|
|
188
187
|
})
|
|
189
188
|
});
|
|
190
|
-
return /* @__PURE__ */
|
|
189
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
191
190
|
flexDirection: "column",
|
|
192
191
|
borderStyle: "single",
|
|
193
192
|
borderColor: "$border",
|
|
194
193
|
paddingX: 1,
|
|
195
194
|
children: [
|
|
196
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ jsx(H1, {
|
|
197
196
|
color: "yellow",
|
|
198
197
|
children: "How it works:"
|
|
199
198
|
}),
|
|
200
|
-
/* @__PURE__ */
|
|
199
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
201
200
|
color: "gray",
|
|
202
201
|
children: [
|
|
203
202
|
" ",
|
|
204
|
-
/* @__PURE__ */
|
|
203
|
+
/* @__PURE__ */ jsx(Text, {
|
|
205
204
|
color: "magenta",
|
|
206
205
|
children: "const"
|
|
207
206
|
}),
|
|
@@ -210,25 +209,25 @@ function CodeSnippet({ width }) {
|
|
|
210
209
|
" width ",
|
|
211
210
|
"}",
|
|
212
211
|
" = ",
|
|
213
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ jsx(Text, {
|
|
214
213
|
color: "cyan",
|
|
215
214
|
children: "useBoxRect"
|
|
216
215
|
}),
|
|
217
216
|
"()"
|
|
218
217
|
]
|
|
219
218
|
}),
|
|
220
|
-
/* @__PURE__ */
|
|
219
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
221
220
|
color: "gray",
|
|
222
221
|
children: [
|
|
223
222
|
" ",
|
|
224
|
-
/* @__PURE__ */
|
|
223
|
+
/* @__PURE__ */ jsx(Text, {
|
|
225
224
|
color: "magenta",
|
|
226
225
|
children: "const"
|
|
227
226
|
}),
|
|
228
227
|
" columns = width ",
|
|
229
228
|
">",
|
|
230
229
|
" 100 ? ",
|
|
231
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ jsx(Text, {
|
|
232
231
|
color: "green",
|
|
233
232
|
children: "3"
|
|
234
233
|
}),
|
|
@@ -236,18 +235,18 @@ function CodeSnippet({ width }) {
|
|
|
236
235
|
">",
|
|
237
236
|
" 60 ?",
|
|
238
237
|
" ",
|
|
239
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ jsx(Text, {
|
|
240
239
|
color: "green",
|
|
241
240
|
children: "2"
|
|
242
241
|
}),
|
|
243
242
|
" : ",
|
|
244
|
-
/* @__PURE__ */
|
|
243
|
+
/* @__PURE__ */ jsx(Text, {
|
|
245
244
|
color: "green",
|
|
246
245
|
children: "1"
|
|
247
246
|
})
|
|
248
247
|
]
|
|
249
248
|
}),
|
|
250
|
-
/* @__PURE__ */
|
|
249
|
+
/* @__PURE__ */ jsxs(Text, {
|
|
251
250
|
dim: true,
|
|
252
251
|
italic: true,
|
|
253
252
|
children: [" ", "// No useEffect, no layout thrashing. Synchronous."]
|
|
@@ -262,40 +261,40 @@ function LiveResize() {
|
|
|
262
261
|
useInput$1(useCallback((input, key) => {
|
|
263
262
|
if (input === "q" || key.escape || key.ctrl && input === "c") return "exit";
|
|
264
263
|
}, []));
|
|
265
|
-
return /* @__PURE__ */
|
|
264
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
266
265
|
flexDirection: "column",
|
|
267
266
|
width: "100%",
|
|
268
267
|
height: "100%",
|
|
269
268
|
padding: 1,
|
|
270
269
|
children: [
|
|
271
|
-
/* @__PURE__ */
|
|
270
|
+
/* @__PURE__ */ jsx(BreakpointIndicator, {
|
|
272
271
|
width,
|
|
273
272
|
columns
|
|
274
273
|
}),
|
|
275
|
-
/* @__PURE__ */
|
|
274
|
+
/* @__PURE__ */ jsx(Box, {
|
|
276
275
|
flexGrow: 1,
|
|
277
276
|
flexDirection: "column",
|
|
278
277
|
marginTop: 1,
|
|
279
|
-
children: /* @__PURE__ */
|
|
278
|
+
children: /* @__PURE__ */ jsx(GridLayout, {
|
|
280
279
|
cards: CARDS,
|
|
281
280
|
columns,
|
|
282
281
|
compact
|
|
283
282
|
})
|
|
284
283
|
}),
|
|
285
|
-
!compact && /* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
284
|
+
!compact && /* @__PURE__ */ jsx(CodeSnippet, { width }),
|
|
285
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
287
286
|
justifyContent: "space-between",
|
|
288
287
|
paddingX: 1,
|
|
289
|
-
children: [/* @__PURE__ */
|
|
288
|
+
children: [/* @__PURE__ */ jsx(Muted, { children: "Resize your terminal to see the layout reflow" }), /* @__PURE__ */ jsxs(Muted, { children: [/* @__PURE__ */ jsx(Kbd, { children: "Esc/q" }), " quit"] })]
|
|
290
289
|
})
|
|
291
290
|
]
|
|
292
291
|
});
|
|
293
292
|
}
|
|
294
293
|
async function main() {
|
|
295
|
-
await (await run(/* @__PURE__ */
|
|
294
|
+
await (await run(/* @__PURE__ */ jsx(ExampleBanner, {
|
|
296
295
|
meta,
|
|
297
296
|
controls: "Resize terminal to see reflow Esc/q quit",
|
|
298
|
-
children: /* @__PURE__ */
|
|
297
|
+
children: /* @__PURE__ */ jsx(LiveResize, {})
|
|
299
298
|
}))).waitUntilExit();
|
|
300
299
|
}
|
|
301
300
|
if (import.meta.main) await main();
|
package/dist/layout/overflow.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { t as _usingCtx } from "../usingCtx-CsEf0xO3.mjs";
|
|
2
|
-
import { t as
|
|
3
|
-
import { t as ExampleBanner } from "../_banner-DLPxCqVy.mjs";
|
|
2
|
+
import { t as ExampleBanner } from "../_banner-A70_y2Vi.mjs";
|
|
4
3
|
import "react";
|
|
5
4
|
import { Box, Text, createTerm, render, useApp, useInput } from "silvery";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
//#region layout/overflow.tsx
|
|
7
|
-
var import_jsx_runtime = require_jsx_runtime();
|
|
8
7
|
const meta = {
|
|
9
8
|
name: "Overflow",
|
|
10
9
|
description: "overflow=\"hidden\" content clipping demonstration",
|
|
@@ -15,34 +14,34 @@ function OverflowApp() {
|
|
|
15
14
|
useInput((input, key) => {
|
|
16
15
|
if (input === "q" || key.escape) exit();
|
|
17
16
|
});
|
|
18
|
-
return /* @__PURE__ */
|
|
17
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
19
18
|
flexDirection: "column",
|
|
20
19
|
padding: 1,
|
|
21
20
|
children: [
|
|
22
|
-
/* @__PURE__ */
|
|
21
|
+
/* @__PURE__ */ jsx(Text, {
|
|
23
22
|
color: "yellow",
|
|
24
23
|
children: "Title"
|
|
25
24
|
}),
|
|
26
|
-
/* @__PURE__ */
|
|
25
|
+
/* @__PURE__ */ jsx(Box, {
|
|
27
26
|
borderStyle: "single",
|
|
28
27
|
borderColor: "$primary",
|
|
29
28
|
height: 5,
|
|
30
29
|
overflow: "hidden",
|
|
31
|
-
children: /* @__PURE__ */
|
|
30
|
+
children: /* @__PURE__ */ jsxs(Box, {
|
|
32
31
|
flexDirection: "column",
|
|
33
32
|
flexGrow: 1,
|
|
34
33
|
children: [
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
/* @__PURE__ */
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
/* @__PURE__ */
|
|
34
|
+
/* @__PURE__ */ jsx(Text, { children: "Line 1" }),
|
|
35
|
+
/* @__PURE__ */ jsx(Text, { children: "Line 2" }),
|
|
36
|
+
/* @__PURE__ */ jsx(Text, { children: "Line 3" }),
|
|
37
|
+
/* @__PURE__ */ jsx(Text, { children: "Line 4" }),
|
|
38
|
+
/* @__PURE__ */ jsx(Text, { children: "Line 5" }),
|
|
39
|
+
/* @__PURE__ */ jsx(Text, { children: "Line 6 - should NOT appear" }),
|
|
40
|
+
/* @__PURE__ */ jsx(Text, { children: "Line 7 - should NOT appear" })
|
|
42
41
|
]
|
|
43
42
|
})
|
|
44
43
|
}),
|
|
45
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ jsx(Text, {
|
|
46
45
|
color: "$success",
|
|
47
46
|
children: "This should NOT be corrupted"
|
|
48
47
|
})
|
|
@@ -53,10 +52,10 @@ async function main() {
|
|
|
53
52
|
try {
|
|
54
53
|
var _usingCtx$1 = _usingCtx();
|
|
55
54
|
const term = _usingCtx$1.u(createTerm());
|
|
56
|
-
const { waitUntilExit } = await render(/* @__PURE__ */
|
|
55
|
+
const { waitUntilExit } = await render(/* @__PURE__ */ jsx(ExampleBanner, {
|
|
57
56
|
meta,
|
|
58
57
|
controls: "Esc/q quit",
|
|
59
|
-
children: /* @__PURE__ */
|
|
58
|
+
children: /* @__PURE__ */ jsx(OverflowApp, {})
|
|
60
59
|
}), term);
|
|
61
60
|
await waitUntilExit();
|
|
62
61
|
} catch (_) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { t as ExampleBanner } from "../_banner-DLPxCqVy.mjs";
|
|
1
|
+
import { t as ExampleBanner } from "../_banner-A70_y2Vi.mjs";
|
|
3
2
|
import { useCallback, useState } from "react";
|
|
4
3
|
import { Box, Divider, H2, Kbd, Muted, Small, Text } from "silvery";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { run, useInput as useInput$1 } from "silvery/runtime";
|
|
6
6
|
//#region layout/text-layout.tsx
|
|
7
7
|
/**
|
|
@@ -19,7 +19,6 @@ import { run, useInput as useInput$1 } from "silvery/runtime";
|
|
|
19
19
|
* j/k - Cycle demo sections
|
|
20
20
|
* Esc/q - Quit
|
|
21
21
|
*/
|
|
22
|
-
var import_jsx_runtime = require_jsx_runtime();
|
|
23
22
|
const meta = {
|
|
24
23
|
name: "text layout",
|
|
25
24
|
description: "Snug-content bubbles + even wrapping — inspired by chenglou/pretext",
|
|
@@ -56,16 +55,16 @@ const CHAT_MESSAGES = [
|
|
|
56
55
|
const PARAGRAPH = "The quick brown fox jumps over the lazy dog. Typography in terminal applications has always been limited by the character grid, but modern algorithms can distribute text across lines for minimum raggedness, producing results that rival print-quality typesetting. Silvery brings these techniques to the terminal.";
|
|
57
56
|
/** A single chat bubble with configurable width and wrap mode. */
|
|
58
57
|
function Bubble({ sender, text, width, wrap, align }) {
|
|
59
|
-
return /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
60
59
|
flexDirection: "column",
|
|
61
60
|
alignItems: align ?? "flex-start",
|
|
62
|
-
children: [/* @__PURE__ */
|
|
61
|
+
children: [/* @__PURE__ */ jsxs(Small, { children: [" ", sender] }), /* @__PURE__ */ jsx(Box, {
|
|
63
62
|
width,
|
|
64
63
|
borderStyle: "round",
|
|
65
64
|
borderColor: "$border",
|
|
66
65
|
paddingX: 1,
|
|
67
66
|
maxWidth: 48,
|
|
68
|
-
children: /* @__PURE__ */
|
|
67
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
69
68
|
wrap: wrap ?? "wrap",
|
|
70
69
|
children: text
|
|
71
70
|
})
|
|
@@ -74,22 +73,22 @@ function Bubble({ sender, text, width, wrap, align }) {
|
|
|
74
73
|
}
|
|
75
74
|
/** Column of chat bubbles with a label. */
|
|
76
75
|
function BubbleColumn({ label, sublabel, width, wrap }) {
|
|
77
|
-
return /* @__PURE__ */
|
|
76
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
78
77
|
flexDirection: "column",
|
|
79
78
|
flexGrow: 1,
|
|
80
79
|
flexBasis: 0,
|
|
81
80
|
children: [
|
|
82
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ jsx(Text, {
|
|
83
82
|
bold: true,
|
|
84
83
|
color: "$accent",
|
|
85
84
|
children: label
|
|
86
85
|
}),
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
89
|
-
/* @__PURE__ */
|
|
86
|
+
/* @__PURE__ */ jsx(Muted, { children: sublabel }),
|
|
87
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
88
|
+
/* @__PURE__ */ jsx(Box, {
|
|
90
89
|
flexDirection: "column",
|
|
91
90
|
gap: 1,
|
|
92
|
-
children: CHAT_MESSAGES.map((msg, i) => /* @__PURE__ */
|
|
91
|
+
children: CHAT_MESSAGES.map((msg, i) => /* @__PURE__ */ jsx(Bubble, {
|
|
93
92
|
sender: msg.sender,
|
|
94
93
|
text: msg.text,
|
|
95
94
|
width,
|
|
@@ -102,24 +101,24 @@ function BubbleColumn({ label, sublabel, width, wrap }) {
|
|
|
102
101
|
}
|
|
103
102
|
/** Side-by-side paragraph comparison. */
|
|
104
103
|
function ParagraphComparison({ label, sublabel, wrap }) {
|
|
105
|
-
return /* @__PURE__ */
|
|
104
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
106
105
|
flexDirection: "column",
|
|
107
106
|
flexGrow: 1,
|
|
108
107
|
flexBasis: 0,
|
|
109
108
|
children: [
|
|
110
|
-
/* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ jsx(Text, {
|
|
111
110
|
bold: true,
|
|
112
111
|
color: "$accent",
|
|
113
112
|
children: label
|
|
114
113
|
}),
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
114
|
+
/* @__PURE__ */ jsx(Muted, { children: sublabel }),
|
|
115
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
116
|
+
/* @__PURE__ */ jsx(Box, {
|
|
118
117
|
width: 52,
|
|
119
118
|
borderStyle: "single",
|
|
120
119
|
borderColor: "$border",
|
|
121
120
|
paddingX: 1,
|
|
122
|
-
children: /* @__PURE__ */
|
|
121
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
123
122
|
wrap,
|
|
124
123
|
children: PARAGRAPH
|
|
125
124
|
})
|
|
@@ -128,22 +127,22 @@ function ParagraphComparison({ label, sublabel, wrap }) {
|
|
|
128
127
|
});
|
|
129
128
|
}
|
|
130
129
|
function Demo1Bubbles() {
|
|
131
|
-
return /* @__PURE__ */
|
|
130
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
132
131
|
flexDirection: "column",
|
|
133
132
|
children: [
|
|
134
|
-
/* @__PURE__ */
|
|
135
|
-
/* @__PURE__ */
|
|
136
|
-
/* @__PURE__ */
|
|
137
|
-
/* @__PURE__ */
|
|
138
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ jsx(H2, { children: "Chat Bubbles: fit-content vs snug-content" }),
|
|
134
|
+
/* @__PURE__ */ jsxs(Muted, { children: [" ", "fit-content sizes to the widest wrapped line (dead space on short lines)."] }),
|
|
135
|
+
/* @__PURE__ */ jsxs(Muted, { children: [" ", "snug-content binary-searches for the tightest width with the same line count."] }),
|
|
136
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
137
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
139
138
|
flexDirection: "row",
|
|
140
139
|
gap: 3,
|
|
141
140
|
paddingX: 1,
|
|
142
|
-
children: [/* @__PURE__ */
|
|
141
|
+
children: [/* @__PURE__ */ jsx(BubbleColumn, {
|
|
143
142
|
label: "width=\"fit-content\"",
|
|
144
143
|
sublabel: "CSS default — dead space",
|
|
145
144
|
width: "fit-content"
|
|
146
|
-
}), /* @__PURE__ */
|
|
145
|
+
}), /* @__PURE__ */ jsx(BubbleColumn, {
|
|
147
146
|
label: "width=\"snug-content\"",
|
|
148
147
|
sublabel: "Pretext shrinkwrap — tight",
|
|
149
148
|
width: "snug-content"
|
|
@@ -153,22 +152,22 @@ function Demo1Bubbles() {
|
|
|
153
152
|
});
|
|
154
153
|
}
|
|
155
154
|
function Demo2EvenWrap() {
|
|
156
|
-
return /* @__PURE__ */
|
|
155
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
157
156
|
flexDirection: "column",
|
|
158
157
|
children: [
|
|
159
|
-
/* @__PURE__ */
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
/* @__PURE__ */
|
|
163
|
-
/* @__PURE__ */
|
|
158
|
+
/* @__PURE__ */ jsx(H2, { children: "Paragraph Layout: greedy vs even wrapping" }),
|
|
159
|
+
/* @__PURE__ */ jsxs(Muted, { children: [" ", "Greedy fills each line left-to-right, leaving a ragged right edge."] }),
|
|
160
|
+
/* @__PURE__ */ jsxs(Muted, { children: [" ", "Even uses minimum-raggedness DP to distribute words across all lines."] }),
|
|
161
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
162
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
164
163
|
flexDirection: "row",
|
|
165
164
|
gap: 3,
|
|
166
165
|
paddingX: 1,
|
|
167
|
-
children: [/* @__PURE__ */
|
|
166
|
+
children: [/* @__PURE__ */ jsx(ParagraphComparison, {
|
|
168
167
|
label: "wrap=\"wrap\"",
|
|
169
168
|
sublabel: "Greedy — ragged right edge",
|
|
170
169
|
wrap: "wrap"
|
|
171
|
-
}), /* @__PURE__ */
|
|
170
|
+
}), /* @__PURE__ */ jsx(ParagraphComparison, {
|
|
172
171
|
label: "wrap=\"even\"",
|
|
173
172
|
sublabel: "Min-raggedness — balanced lines",
|
|
174
173
|
wrap: "even"
|
|
@@ -178,86 +177,86 @@ function Demo2EvenWrap() {
|
|
|
178
177
|
});
|
|
179
178
|
}
|
|
180
179
|
function Demo3Combined() {
|
|
181
|
-
return /* @__PURE__ */
|
|
180
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
182
181
|
flexDirection: "column",
|
|
183
182
|
children: [
|
|
184
|
-
/* @__PURE__ */
|
|
185
|
-
/* @__PURE__ */
|
|
186
|
-
/* @__PURE__ */
|
|
187
|
-
/* @__PURE__ */
|
|
183
|
+
/* @__PURE__ */ jsx(H2, { children: "Combined: snug-content + even wrapping" }),
|
|
184
|
+
/* @__PURE__ */ jsxs(Muted, { children: [" ", "The tightest, most beautiful text layout — both features together."] }),
|
|
185
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
186
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
188
187
|
flexDirection: "row",
|
|
189
188
|
gap: 3,
|
|
190
189
|
paddingX: 1,
|
|
191
|
-
children: [/* @__PURE__ */
|
|
190
|
+
children: [/* @__PURE__ */ jsxs(Box, {
|
|
192
191
|
flexDirection: "column",
|
|
193
192
|
flexGrow: 1,
|
|
194
193
|
flexBasis: 0,
|
|
195
194
|
children: [
|
|
196
|
-
/* @__PURE__ */
|
|
195
|
+
/* @__PURE__ */ jsx(Text, {
|
|
197
196
|
bold: true,
|
|
198
197
|
color: "$accent",
|
|
199
198
|
children: "Default (fit-content + greedy)"
|
|
200
199
|
}),
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
/* @__PURE__ */
|
|
203
|
-
/* @__PURE__ */
|
|
200
|
+
/* @__PURE__ */ jsx(Muted, { children: "Widest line sets width, lines fill greedily" }),
|
|
201
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
202
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
204
203
|
flexDirection: "column",
|
|
205
204
|
gap: 1,
|
|
206
|
-
children: [/* @__PURE__ */
|
|
205
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
207
206
|
width: "fit-content",
|
|
208
207
|
borderStyle: "round",
|
|
209
208
|
borderColor: "$border",
|
|
210
209
|
paddingX: 1,
|
|
211
210
|
maxWidth: 48,
|
|
212
|
-
children: /* @__PURE__ */
|
|
211
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
213
212
|
wrap: "wrap",
|
|
214
213
|
children: "Typography in terminal applications has always been limited by the character grid, but modern algorithms change that."
|
|
215
214
|
})
|
|
216
|
-
}), /* @__PURE__ */
|
|
215
|
+
}), /* @__PURE__ */ jsx(Box, {
|
|
217
216
|
width: "fit-content",
|
|
218
217
|
borderStyle: "round",
|
|
219
218
|
borderColor: "$border",
|
|
220
219
|
paddingX: 1,
|
|
221
220
|
maxWidth: 48,
|
|
222
|
-
children: /* @__PURE__ */
|
|
221
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
223
222
|
wrap: "wrap",
|
|
224
223
|
children: "Silvery brings Pretext-inspired layout to the terminal with two simple props."
|
|
225
224
|
})
|
|
226
225
|
})]
|
|
227
226
|
})
|
|
228
227
|
]
|
|
229
|
-
}), /* @__PURE__ */
|
|
228
|
+
}), /* @__PURE__ */ jsxs(Box, {
|
|
230
229
|
flexDirection: "column",
|
|
231
230
|
flexGrow: 1,
|
|
232
231
|
flexBasis: 0,
|
|
233
232
|
children: [
|
|
234
|
-
/* @__PURE__ */
|
|
233
|
+
/* @__PURE__ */ jsx(Text, {
|
|
235
234
|
bold: true,
|
|
236
235
|
color: "$accent",
|
|
237
236
|
children: "Pretext (snug-content + even)"
|
|
238
237
|
}),
|
|
239
|
-
/* @__PURE__ */
|
|
240
|
-
/* @__PURE__ */
|
|
241
|
-
/* @__PURE__ */
|
|
238
|
+
/* @__PURE__ */ jsx(Muted, { children: "Tightest width, balanced line lengths" }),
|
|
239
|
+
/* @__PURE__ */ jsx(Text, { children: " " }),
|
|
240
|
+
/* @__PURE__ */ jsxs(Box, {
|
|
242
241
|
flexDirection: "column",
|
|
243
242
|
gap: 1,
|
|
244
|
-
children: [/* @__PURE__ */
|
|
243
|
+
children: [/* @__PURE__ */ jsx(Box, {
|
|
245
244
|
width: "snug-content",
|
|
246
245
|
borderStyle: "round",
|
|
247
246
|
borderColor: "$primary",
|
|
248
247
|
paddingX: 1,
|
|
249
248
|
maxWidth: 48,
|
|
250
|
-
children: /* @__PURE__ */
|
|
249
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
251
250
|
wrap: "even",
|
|
252
251
|
children: "Typography in terminal applications has always been limited by the character grid, but modern algorithms change that."
|
|
253
252
|
})
|
|
254
|
-
}), /* @__PURE__ */
|
|
253
|
+
}), /* @__PURE__ */ jsx(Box, {
|
|
255
254
|
width: "snug-content",
|
|
256
255
|
borderStyle: "round",
|
|
257
256
|
borderColor: "$primary",
|
|
258
257
|
paddingX: 1,
|
|
259
258
|
maxWidth: 48,
|
|
260
|
-
children: /* @__PURE__ */
|
|
259
|
+
children: /* @__PURE__ */ jsx(Text, {
|
|
261
260
|
wrap: "even",
|
|
262
261
|
children: "Silvery brings Pretext-inspired layout to the terminal with two simple props."
|
|
263
262
|
})
|
|
@@ -290,14 +289,14 @@ function PretextDemo() {
|
|
|
290
289
|
if (input === "3") setDemoIndex(2);
|
|
291
290
|
}, []));
|
|
292
291
|
const Demo = DEMOS[demoIndex];
|
|
293
|
-
return /* @__PURE__ */
|
|
292
|
+
return /* @__PURE__ */ jsxs(Box, {
|
|
294
293
|
flexDirection: "column",
|
|
295
294
|
padding: 1,
|
|
296
295
|
gap: 1,
|
|
297
296
|
children: [
|
|
298
|
-
/* @__PURE__ */
|
|
297
|
+
/* @__PURE__ */ jsx(Box, {
|
|
299
298
|
gap: 2,
|
|
300
|
-
children: DEMO_LABELS.map((label, i) => /* @__PURE__ */
|
|
299
|
+
children: DEMO_LABELS.map((label, i) => /* @__PURE__ */ jsxs(Text, {
|
|
301
300
|
bold: i === demoIndex,
|
|
302
301
|
color: i === demoIndex ? "$primary" : "$muted",
|
|
303
302
|
children: [
|
|
@@ -308,26 +307,26 @@ function PretextDemo() {
|
|
|
308
307
|
]
|
|
309
308
|
}, i))
|
|
310
309
|
}),
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
-
/* @__PURE__ */
|
|
310
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
311
|
+
/* @__PURE__ */ jsx(Demo, {}),
|
|
312
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Muted, { children: [
|
|
314
313
|
" ",
|
|
315
|
-
/* @__PURE__ */
|
|
314
|
+
/* @__PURE__ */ jsx(Kbd, { children: "j/k" }),
|
|
316
315
|
" or ",
|
|
317
|
-
/* @__PURE__ */
|
|
316
|
+
/* @__PURE__ */ jsx(Kbd, { children: "1-3" }),
|
|
318
317
|
" switch demo",
|
|
319
318
|
" ",
|
|
320
|
-
/* @__PURE__ */
|
|
319
|
+
/* @__PURE__ */ jsx(Kbd, { children: "Esc/q" }),
|
|
321
320
|
" quit"
|
|
322
321
|
] }) })
|
|
323
322
|
]
|
|
324
323
|
});
|
|
325
324
|
}
|
|
326
325
|
async function main() {
|
|
327
|
-
await (await run(/* @__PURE__ */
|
|
326
|
+
await (await run(/* @__PURE__ */ jsx(ExampleBanner, {
|
|
328
327
|
meta,
|
|
329
328
|
controls: "j/k switch demo 1-3 jump Esc/q quit",
|
|
330
|
-
children: /* @__PURE__ */
|
|
329
|
+
children: /* @__PURE__ */ jsx(PretextDemo, {})
|
|
331
330
|
}))).waitUntilExit();
|
|
332
331
|
}
|
|
333
332
|
if (import.meta.main) await main();
|