markgraphy 0.1.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.txt +21 -0
- package/README.md +154 -0
- package/dist/animated/GraphAgni.svelte +430 -0
- package/dist/animated/GraphAgni.svelte.d.ts +22 -0
- package/dist/animated/GraphAum.svelte +294 -0
- package/dist/animated/GraphAum.svelte.d.ts +20 -0
- package/dist/animated/GraphBoot.svelte +325 -0
- package/dist/animated/GraphBoot.svelte.d.ts +28 -0
- package/dist/animated/GraphCron.svelte +476 -0
- package/dist/animated/GraphCron.svelte.d.ts +42 -0
- package/dist/animated/GraphDamru.svelte +341 -0
- package/dist/animated/GraphDamru.svelte.d.ts +18 -0
- package/dist/animated/GraphDeps.svelte +245 -0
- package/dist/animated/GraphDeps.svelte.d.ts +29 -0
- package/dist/animated/GraphDiya.svelte +330 -0
- package/dist/animated/GraphDiya.svelte.d.ts +22 -0
- package/dist/animated/GraphFire.svelte +246 -0
- package/dist/animated/GraphFire.svelte.d.ts +22 -0
- package/dist/animated/GraphFlame.svelte +258 -0
- package/dist/animated/GraphFlame.svelte.d.ts +14 -0
- package/dist/animated/GraphFlowPlayer.svelte +346 -0
- package/dist/animated/GraphFlowPlayer.svelte.d.ts +27 -0
- package/dist/animated/GraphGanga.svelte +305 -0
- package/dist/animated/GraphGanga.svelte.d.ts +20 -0
- package/dist/animated/GraphHash.svelte +251 -0
- package/dist/animated/GraphHash.svelte.d.ts +20 -0
- package/dist/animated/GraphJapa.svelte +253 -0
- package/dist/animated/GraphJapa.svelte.d.ts +20 -0
- package/dist/animated/GraphLife.svelte +312 -0
- package/dist/animated/GraphLife.svelte.d.ts +27 -0
- package/dist/animated/GraphMandala.svelte +262 -0
- package/dist/animated/GraphMandala.svelte.d.ts +24 -0
- package/dist/animated/GraphMandel.svelte +290 -0
- package/dist/animated/GraphMandel.svelte.d.ts +27 -0
- package/dist/animated/GraphPulse.svelte +248 -0
- package/dist/animated/GraphPulse.svelte.d.ts +24 -0
- package/dist/animated/GraphRain.svelte +280 -0
- package/dist/animated/GraphRain.svelte.d.ts +22 -0
- package/dist/animated/GraphScatter.svelte +395 -0
- package/dist/animated/GraphScatter.svelte.d.ts +31 -0
- package/dist/animated/GraphScope.svelte +197 -0
- package/dist/animated/GraphScope.svelte.d.ts +22 -0
- package/dist/animated/GraphSequence.svelte +247 -0
- package/dist/animated/GraphSequence.svelte.d.ts +18 -0
- package/dist/animated/GraphSpinners.svelte +109 -0
- package/dist/animated/GraphSpinners.svelte.d.ts +22 -0
- package/dist/animated/GraphState.svelte +270 -0
- package/dist/animated/GraphState.svelte.d.ts +14 -0
- package/dist/animated/GraphStream.svelte +223 -0
- package/dist/animated/GraphStream.svelte.d.ts +24 -0
- package/dist/animated/GraphSurya.svelte +268 -0
- package/dist/animated/GraphSurya.svelte.d.ts +22 -0
- package/dist/animated/GraphTerminal.svelte +238 -0
- package/dist/animated/GraphTerminal.svelte.d.ts +28 -0
- package/dist/animated/GraphTicker.svelte +163 -0
- package/dist/animated/GraphTicker.svelte.d.ts +21 -0
- package/dist/animated/GraphTypewriter.svelte +130 -0
- package/dist/animated/GraphTypewriter.svelte.d.ts +22 -0
- package/dist/animated/GraphWorkflow.svelte +570 -0
- package/dist/animated/GraphWorkflow.svelte.d.ts +29 -0
- package/dist/assets/favicon.svg +21 -0
- package/dist/diagram/AmplifierDiagram.svelte +206 -0
- package/dist/diagram/AmplifierDiagram.svelte.d.ts +12 -0
- package/dist/diagram/AsciiDiagram.svelte +212 -0
- package/dist/diagram/AsciiDiagram.svelte.d.ts +24 -0
- package/dist/diagram/DiagramEditor.svelte +414 -0
- package/dist/diagram/DiagramEditor.svelte.d.ts +3 -0
- package/dist/diagram/MetricsTableDiagram.svelte +125 -0
- package/dist/diagram/MetricsTableDiagram.svelte.d.ts +18 -0
- package/dist/diagram/NestedRadiiDiagram.svelte +218 -0
- package/dist/diagram/NestedRadiiDiagram.svelte.d.ts +12 -0
- package/dist/diagram/PromptLoopDiagram.svelte +331 -0
- package/dist/diagram/PromptLoopDiagram.svelte.d.ts +12 -0
- package/dist/diagram/ascii.d.ts +35 -0
- package/dist/diagram/ascii.js +83 -0
- package/dist/diagram/parser.d.ts +16 -0
- package/dist/diagram/parser.js +71 -0
- package/dist/frame/Graph.svelte +141 -0
- package/dist/frame/Graph.svelte.d.ts +14 -0
- package/dist/frame/GraphArrow.svelte +49 -0
- package/dist/frame/GraphArrow.svelte.d.ts +9 -0
- package/dist/frame/GraphBody.svelte +39 -0
- package/dist/frame/GraphBody.svelte.d.ts +10 -0
- package/dist/frame/GraphRule.svelte +21 -0
- package/dist/frame/GraphRule.svelte.d.ts +6 -0
- package/dist/frame/GraphTick.svelte +23 -0
- package/dist/frame/GraphTick.svelte.d.ts +9 -0
- package/dist/frame/GraphTrack.svelte +29 -0
- package/dist/frame/GraphTrack.svelte.d.ts +14 -0
- package/dist/frame/clock.d.ts +10 -0
- package/dist/frame/clock.js +62 -0
- package/dist/frame/glyphs.d.ts +22 -0
- package/dist/frame/glyphs.js +53 -0
- package/dist/frame/motion.css +27 -0
- package/dist/frame/motion.d.ts +24 -0
- package/dist/frame/motion.js +47 -0
- package/dist/frame/tone.d.ts +11 -0
- package/dist/frame/tone.js +64 -0
- package/dist/graphs/GraphActivity.svelte +387 -0
- package/dist/graphs/GraphActivity.svelte.d.ts +22 -0
- package/dist/graphs/GraphBars.svelte +194 -0
- package/dist/graphs/GraphBars.svelte.d.ts +20 -0
- package/dist/graphs/GraphBullet.svelte +208 -0
- package/dist/graphs/GraphBullet.svelte.d.ts +22 -0
- package/dist/graphs/GraphCalendar.svelte +203 -0
- package/dist/graphs/GraphCalendar.svelte.d.ts +20 -0
- package/dist/graphs/GraphCells.svelte +181 -0
- package/dist/graphs/GraphCells.svelte.d.ts +18 -0
- package/dist/graphs/GraphCompare.svelte +192 -0
- package/dist/graphs/GraphCompare.svelte.d.ts +18 -0
- package/dist/graphs/GraphCountdown.svelte +96 -0
- package/dist/graphs/GraphCountdown.svelte.d.ts +14 -0
- package/dist/graphs/GraphDiff.svelte +181 -0
- package/dist/graphs/GraphDiff.svelte.d.ts +18 -0
- package/dist/graphs/GraphFlow.svelte +137 -0
- package/dist/graphs/GraphFlow.svelte.d.ts +21 -0
- package/dist/graphs/GraphFunnel.svelte +190 -0
- package/dist/graphs/GraphFunnel.svelte.d.ts +21 -0
- package/dist/graphs/GraphGantt.svelte +258 -0
- package/dist/graphs/GraphGantt.svelte.d.ts +25 -0
- package/dist/graphs/GraphHeatmap.svelte +287 -0
- package/dist/graphs/GraphHeatmap.svelte.d.ts +22 -0
- package/dist/graphs/GraphInvoice.svelte +294 -0
- package/dist/graphs/GraphInvoice.svelte.d.ts +34 -0
- package/dist/graphs/GraphKpi.svelte +166 -0
- package/dist/graphs/GraphKpi.svelte.d.ts +17 -0
- package/dist/graphs/GraphLatency.svelte +340 -0
- package/dist/graphs/GraphLatency.svelte.d.ts +28 -0
- package/dist/graphs/GraphMeter.svelte +121 -0
- package/dist/graphs/GraphMeter.svelte.d.ts +16 -0
- package/dist/graphs/GraphPlot.svelte +226 -0
- package/dist/graphs/GraphPlot.svelte.d.ts +18 -0
- package/dist/graphs/GraphQuota.svelte +303 -0
- package/dist/graphs/GraphQuota.svelte.d.ts +27 -0
- package/dist/graphs/GraphRank.svelte +141 -0
- package/dist/graphs/GraphRank.svelte.d.ts +21 -0
- package/dist/graphs/GraphSlo.svelte +325 -0
- package/dist/graphs/GraphSlo.svelte.d.ts +31 -0
- package/dist/graphs/GraphSlope.svelte +197 -0
- package/dist/graphs/GraphSlope.svelte.d.ts +19 -0
- package/dist/graphs/GraphSpark.svelte +125 -0
- package/dist/graphs/GraphSpark.svelte.d.ts +15 -0
- package/dist/graphs/GraphSpec.svelte +69 -0
- package/dist/graphs/GraphSpec.svelte.d.ts +14 -0
- package/dist/graphs/GraphStack.svelte +266 -0
- package/dist/graphs/GraphStack.svelte.d.ts +25 -0
- package/dist/graphs/GraphStat.svelte +103 -0
- package/dist/graphs/GraphStat.svelte.d.ts +16 -0
- package/dist/graphs/GraphTable.svelte +133 -0
- package/dist/graphs/GraphTable.svelte.d.ts +15 -0
- package/dist/graphs/GraphTimeline.svelte +164 -0
- package/dist/graphs/GraphTimeline.svelte.d.ts +18 -0
- package/dist/graphs/GraphTimer.svelte +117 -0
- package/dist/graphs/GraphTimer.svelte.d.ts +15 -0
- package/dist/graphs/GraphTree.svelte +147 -0
- package/dist/graphs/GraphTree.svelte.d.ts +16 -0
- package/dist/graphs/GraphUptime.svelte +210 -0
- package/dist/graphs/GraphUptime.svelte.d.ts +18 -0
- package/dist/graphs/GraphWaffle.svelte +131 -0
- package/dist/graphs/GraphWaffle.svelte.d.ts +17 -0
- package/dist/graphs/GraphWaterfall.svelte +258 -0
- package/dist/graphs/GraphWaterfall.svelte.d.ts +22 -0
- package/dist/index.d.ts +147 -0
- package/dist/index.js +87 -0
- package/dist/themes.css +54 -0
- package/package.json +67 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export interface AmplifierDiagramProps {
|
|
3
|
+
/** Starting gain multiplier. Default 3.5. */
|
|
4
|
+
gain?: number;
|
|
5
|
+
/** Show the gain slider and dB readout. Default true. */
|
|
6
|
+
interactive?: boolean;
|
|
7
|
+
/** Animate the waves. Default true. Reduced motion freezes them. */
|
|
8
|
+
animated?: boolean;
|
|
9
|
+
class?: string;
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
import { dashEdge, padRow, splitLabeledEdge, type ArtSeg } from './ascii';
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
gain = 3.5,
|
|
18
|
+
interactive = true,
|
|
19
|
+
animated = true,
|
|
20
|
+
class: className = ''
|
|
21
|
+
}: AmplifierDiagramProps = $props();
|
|
22
|
+
|
|
23
|
+
const BARS = [' ', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
|
|
24
|
+
const WIDTH = 66;
|
|
25
|
+
|
|
26
|
+
const uid = $props.id();
|
|
27
|
+
|
|
28
|
+
// svelte-ignore state_referenced_locally
|
|
29
|
+
let multiplier = $state(gain);
|
|
30
|
+
let frame = $state(0);
|
|
31
|
+
|
|
32
|
+
const moving = $derived(
|
|
33
|
+
animated &&
|
|
34
|
+
(typeof window === 'undefined' ||
|
|
35
|
+
!window.matchMedia('(prefers-reduced-motion: reduce)').matches)
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
$effect(() => {
|
|
39
|
+
if (!moving) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const timer = window.setInterval(() => {
|
|
44
|
+
frame = (frame + 1) % 12;
|
|
45
|
+
}, 150);
|
|
46
|
+
|
|
47
|
+
return () => window.clearInterval(timer);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Your taste: a small, calm wave. Five columns, always.
|
|
51
|
+
const tasteWave = $derived.by(() => {
|
|
52
|
+
const base = [1, 3, 5, 3, 1];
|
|
53
|
+
return base
|
|
54
|
+
.map((h, i) => BARS[Math.min(7, Math.max(0, h + Math.round(Math.sin((frame + i) * 0.8) * 0.8)))])
|
|
55
|
+
.join('');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Amplified: large, scaled by the gain slider. Nine columns, always.
|
|
59
|
+
const ampWave = $derived.by(() => {
|
|
60
|
+
const base = [2, 4, 6, 7, 7, 7, 6, 4, 2];
|
|
61
|
+
return base
|
|
62
|
+
.map((h, i) => {
|
|
63
|
+
const scaled = Math.round((h * multiplier) / 3 + Math.sin((frame + i * 2) * 0.6) * 1.2);
|
|
64
|
+
return BARS[Math.min(7, Math.max(1, scaled))];
|
|
65
|
+
})
|
|
66
|
+
.join('');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const arrows = '- - - - ▶';
|
|
70
|
+
|
|
71
|
+
const art = $derived.by((): ArtSeg[][] => {
|
|
72
|
+
const [edgeBefore, edgeLabel, edgeAfter] = splitLabeledEdge(WIDTH, 'AI IS AN AMPLIFIER');
|
|
73
|
+
|
|
74
|
+
return [
|
|
75
|
+
[
|
|
76
|
+
{ text: edgeBefore },
|
|
77
|
+
{ text: edgeLabel, cls: 'title' },
|
|
78
|
+
{ text: edgeAfter }
|
|
79
|
+
],
|
|
80
|
+
[{ text: padRow(WIDTH) }],
|
|
81
|
+
[
|
|
82
|
+
{ text: '| ' },
|
|
83
|
+
{ text: tasteWave, cls: 'taste' },
|
|
84
|
+
{ text: ` ${arrows} ` },
|
|
85
|
+
{ text: 'AI', cls: 'chip' },
|
|
86
|
+
{ text: ` ${arrows} ` },
|
|
87
|
+
{ text: ampWave, cls: 'wave' },
|
|
88
|
+
{ text: ' |' }
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
{ text: '| ', cls: '' },
|
|
92
|
+
{ text: 'your taste', cls: 'muted' },
|
|
93
|
+
{ text: ' ' },
|
|
94
|
+
{ text: 'amplified', cls: 'muted' },
|
|
95
|
+
{ text: ' |' }
|
|
96
|
+
],
|
|
97
|
+
[{ text: padRow(WIDTH) }],
|
|
98
|
+
[{ text: dashEdge(WIDTH) }]
|
|
99
|
+
];
|
|
100
|
+
});
|
|
101
|
+
</script>
|
|
102
|
+
|
|
103
|
+
<div class="amp {className}">
|
|
104
|
+
<div class="viewport">
|
|
105
|
+
<pre class="art"><code>{#each art as line, i (i)}{#each line as seg, j (j)}{#if seg.cls}<span class={seg.cls}>{seg.text}</span>{:else}{seg.text}{/if}{/each}{#if i < art.length - 1}{'\n'}{/if}{/each}</code></pre>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
{#if interactive}
|
|
109
|
+
<div class="controls">
|
|
110
|
+
<label class="gain" for="{uid}-gain">
|
|
111
|
+
Amplification <span class="badge">{multiplier.toFixed(1)}x</span>
|
|
112
|
+
<input id="{uid}-gain" type="range" min="1" max="5" step="0.1" bind:value={multiplier} />
|
|
113
|
+
</label>
|
|
114
|
+
<p class="hint">Signal power: <code>+{(multiplier * 6).toFixed(1)} dB</code></p>
|
|
115
|
+
</div>
|
|
116
|
+
{/if}
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
<style>
|
|
120
|
+
.amp {
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
gap: 1rem;
|
|
124
|
+
min-width: 0;
|
|
125
|
+
font-size: 0.875rem;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.viewport {
|
|
129
|
+
overflow-x: auto;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.art {
|
|
133
|
+
margin: 0;
|
|
134
|
+
font-size: 0.85rem;
|
|
135
|
+
line-height: 1.4;
|
|
136
|
+
color: var(--graph-frame, oklch(0.6 0 0 / 0.5));
|
|
137
|
+
white-space: pre;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.title {
|
|
141
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
142
|
+
font-weight: 600;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.taste {
|
|
146
|
+
color: var(--graph-foreground, oklch(0.93 0 0));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.chip {
|
|
150
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
151
|
+
font-weight: 600;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.wave {
|
|
155
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
156
|
+
font-weight: 600;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.muted {
|
|
160
|
+
color: var(--graph-muted, oklch(0.62 0 0));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.controls {
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: center;
|
|
166
|
+
justify-content: space-between;
|
|
167
|
+
gap: 1rem;
|
|
168
|
+
padding-top: 0.875rem;
|
|
169
|
+
border-top: 1px dashed var(--graph-frame, oklch(0.6 0 0 / 0.5));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.gain {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex: 1;
|
|
175
|
+
max-width: 20rem;
|
|
176
|
+
align-items: center;
|
|
177
|
+
gap: 0.75rem;
|
|
178
|
+
color: var(--graph-muted, oklch(0.62 0 0));
|
|
179
|
+
white-space: nowrap;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.gain input {
|
|
183
|
+
flex: 1;
|
|
184
|
+
min-width: 0;
|
|
185
|
+
height: 4px;
|
|
186
|
+
accent-color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
187
|
+
cursor: pointer;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.badge {
|
|
191
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
192
|
+
border: 1px dashed var(--graph-accent, oklch(0.78 0.17 155));
|
|
193
|
+
padding: 0.1rem 0.4rem;
|
|
194
|
+
font-size: 0.75rem;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.hint {
|
|
198
|
+
margin: 0;
|
|
199
|
+
font-size: 0.8rem;
|
|
200
|
+
color: var(--graph-muted, oklch(0.62 0 0));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.hint code {
|
|
204
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
205
|
+
}
|
|
206
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface AmplifierDiagramProps {
|
|
2
|
+
/** Starting gain multiplier. Default 3.5. */
|
|
3
|
+
gain?: number;
|
|
4
|
+
/** Show the gain slider and dB readout. Default true. */
|
|
5
|
+
interactive?: boolean;
|
|
6
|
+
/** Animate the waves. Default true. Reduced motion freezes them. */
|
|
7
|
+
animated?: boolean;
|
|
8
|
+
class?: string;
|
|
9
|
+
}
|
|
10
|
+
declare const AmplifierDiagram: import("svelte").Component<AmplifierDiagramProps, {}, "">;
|
|
11
|
+
type AmplifierDiagram = ReturnType<typeof AmplifierDiagram>;
|
|
12
|
+
export default AmplifierDiagram;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export interface AsciiDiagramProps {
|
|
3
|
+
/** Raw ASCII or Unicode diagram text. */
|
|
4
|
+
content?: string;
|
|
5
|
+
/** Optional label above the diagram. Uppercase, 1-2 words. */
|
|
6
|
+
title?: string;
|
|
7
|
+
/** Show a copy-to-clipboard button. Default true. */
|
|
8
|
+
showCopy?: boolean;
|
|
9
|
+
/** Dashed border around the diagram. Default true. */
|
|
10
|
+
bordered?: boolean;
|
|
11
|
+
/** Phosphor glow on accent tokens. Default false. */
|
|
12
|
+
glow?: boolean;
|
|
13
|
+
/** Font size of the diagram text. */
|
|
14
|
+
fontSize?: string;
|
|
15
|
+
/** Line height of the diagram text. */
|
|
16
|
+
lineHeight?: string;
|
|
17
|
+
align?: 'left' | 'center';
|
|
18
|
+
class?: string;
|
|
19
|
+
/** Custom content instead of text. */
|
|
20
|
+
children?: Snippet;
|
|
21
|
+
}
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
import type { Snippet } from 'svelte';
|
|
26
|
+
import { formatDiagramHtml } from './parser';
|
|
27
|
+
|
|
28
|
+
let {
|
|
29
|
+
content = '',
|
|
30
|
+
title = '',
|
|
31
|
+
showCopy = true,
|
|
32
|
+
bordered = true,
|
|
33
|
+
glow = false,
|
|
34
|
+
fontSize = '0.85rem',
|
|
35
|
+
lineHeight = '1.35',
|
|
36
|
+
align = 'left',
|
|
37
|
+
class: className = '',
|
|
38
|
+
children
|
|
39
|
+
}: AsciiDiagramProps = $props();
|
|
40
|
+
|
|
41
|
+
let copied = $state(false);
|
|
42
|
+
|
|
43
|
+
const formattedHtml = $derived(content ? formatDiagramHtml(content) : '');
|
|
44
|
+
|
|
45
|
+
async function handleCopy() {
|
|
46
|
+
if (!content) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
await navigator.clipboard.writeText(content);
|
|
52
|
+
copied = true;
|
|
53
|
+
window.setTimeout(() => {
|
|
54
|
+
copied = false;
|
|
55
|
+
}, 2000);
|
|
56
|
+
} catch {
|
|
57
|
+
// Clipboard unavailable (permissions or non-secure context).
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<div
|
|
63
|
+
class="diagram {className}"
|
|
64
|
+
class:bordered
|
|
65
|
+
class:glow
|
|
66
|
+
style:--diag-font-size={fontSize}
|
|
67
|
+
style:--diag-line-height={lineHeight}
|
|
68
|
+
style:text-align={align}
|
|
69
|
+
>
|
|
70
|
+
{#if title || (showCopy && content)}
|
|
71
|
+
<div class="header">
|
|
72
|
+
{#if title}
|
|
73
|
+
<span class="label">{title}</span>
|
|
74
|
+
{/if}
|
|
75
|
+
{#if showCopy && content}
|
|
76
|
+
<button class="copy" type="button" onclick={handleCopy}>
|
|
77
|
+
{copied ? '✓ copied' : 'copy'}
|
|
78
|
+
</button>
|
|
79
|
+
{/if}
|
|
80
|
+
</div>
|
|
81
|
+
{/if}
|
|
82
|
+
|
|
83
|
+
<div class="viewport">
|
|
84
|
+
{#if content}
|
|
85
|
+
<pre class="art"><code>{@html formattedHtml}</code></pre>
|
|
86
|
+
{:else if children}
|
|
87
|
+
<div class="custom">
|
|
88
|
+
{@render children()}
|
|
89
|
+
</div>
|
|
90
|
+
{/if}
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<style>
|
|
95
|
+
.diagram {
|
|
96
|
+
position: relative;
|
|
97
|
+
min-width: 0;
|
|
98
|
+
font-size: 0.875rem;
|
|
99
|
+
user-select: text;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.bordered {
|
|
103
|
+
border: 1px dashed var(--graph-frame, oklch(0.6 0 0 / 0.5));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.bordered .header + .viewport,
|
|
107
|
+
.bordered .viewport {
|
|
108
|
+
padding: 1.25rem 1.5rem;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.header {
|
|
112
|
+
display: flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: space-between;
|
|
115
|
+
gap: 1rem;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.bordered .header {
|
|
119
|
+
padding: 0.5rem 1.5rem;
|
|
120
|
+
border-bottom: 1px dashed var(--graph-frame, oklch(0.6 0 0 / 0.5));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.label {
|
|
124
|
+
font-size: 0.75rem;
|
|
125
|
+
letter-spacing: 0.08em;
|
|
126
|
+
text-transform: uppercase;
|
|
127
|
+
color: var(--graph-muted, oklch(0.62 0 0));
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.copy {
|
|
131
|
+
padding: 0.15rem 0.5rem;
|
|
132
|
+
font-size: 0.75rem;
|
|
133
|
+
color: var(--graph-muted, oklch(0.62 0 0));
|
|
134
|
+
background: none;
|
|
135
|
+
border: 1px dashed var(--graph-frame, oklch(0.6 0 0 / 0.5));
|
|
136
|
+
border-radius: 0;
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.copy:hover {
|
|
141
|
+
color: var(--graph-foreground, oklch(0.93 0 0));
|
|
142
|
+
border-color: var(--graph-muted, oklch(0.62 0 0));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.viewport {
|
|
146
|
+
overflow-x: auto;
|
|
147
|
+
min-width: 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.viewport:not(:first-child) {
|
|
151
|
+
margin-top: 0.75rem;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.bordered .viewport:not(:first-child) {
|
|
155
|
+
margin-top: 0;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.art {
|
|
159
|
+
margin: 0;
|
|
160
|
+
font-size: var(--diag-font-size, 0.85rem);
|
|
161
|
+
line-height: var(--diag-line-height, 1.35);
|
|
162
|
+
color: var(--graph-muted, oklch(0.62 0 0));
|
|
163
|
+
tab-size: 2;
|
|
164
|
+
white-space: pre;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.custom {
|
|
168
|
+
font-size: var(--diag-font-size, 0.85rem);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Token classes come from formatDiagramHtml's {@html} output, so they are
|
|
172
|
+
global descendants of the scoped wrapper. */
|
|
173
|
+
.diagram :global(.diag-title) {
|
|
174
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
175
|
+
font-weight: 600;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.diagram :global(.diag-arrow) {
|
|
179
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
180
|
+
font-weight: 600;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.diagram :global(.diag-corner) {
|
|
184
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
185
|
+
font-weight: 500;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.diagram :global(.diag-box) {
|
|
189
|
+
color: var(--graph-frame, oklch(0.6 0 0 / 0.5));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.diagram :global(.diag-glyph) {
|
|
193
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.diagram :global(.diag-accent) {
|
|
197
|
+
color: var(--graph-accent, oklch(0.78 0.17 155));
|
|
198
|
+
font-weight: 500;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.glow :global(.diag-title) {
|
|
202
|
+
text-shadow: 0 0 12px color-mix(in oklab, var(--graph-accent, oklch(0.78 0.17 155)) 40%, transparent);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.glow :global(.diag-arrow) {
|
|
206
|
+
text-shadow: 0 0 8px color-mix(in oklab, var(--graph-accent, oklch(0.78 0.17 155)) 40%, transparent);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.glow :global(.diag-glyph) {
|
|
210
|
+
text-shadow: 0 0 8px color-mix(in oklab, var(--graph-accent, oklch(0.78 0.17 155)) 40%, transparent);
|
|
211
|
+
}
|
|
212
|
+
</style>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface AsciiDiagramProps {
|
|
2
|
+
/** Raw ASCII or Unicode diagram text. */
|
|
3
|
+
content?: string;
|
|
4
|
+
/** Optional label above the diagram. Uppercase, 1-2 words. */
|
|
5
|
+
title?: string;
|
|
6
|
+
/** Show a copy-to-clipboard button. Default true. */
|
|
7
|
+
showCopy?: boolean;
|
|
8
|
+
/** Dashed border around the diagram. Default true. */
|
|
9
|
+
bordered?: boolean;
|
|
10
|
+
/** Phosphor glow on accent tokens. Default false. */
|
|
11
|
+
glow?: boolean;
|
|
12
|
+
/** Font size of the diagram text. */
|
|
13
|
+
fontSize?: string;
|
|
14
|
+
/** Line height of the diagram text. */
|
|
15
|
+
lineHeight?: string;
|
|
16
|
+
align?: 'left' | 'center';
|
|
17
|
+
class?: string;
|
|
18
|
+
/** Custom content instead of text. */
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
}
|
|
21
|
+
import type { Snippet } from 'svelte';
|
|
22
|
+
declare const AsciiDiagram: import("svelte").Component<AsciiDiagramProps, {}, "">;
|
|
23
|
+
type AsciiDiagram = ReturnType<typeof AsciiDiagram>;
|
|
24
|
+
export default AsciiDiagram;
|