dev-api-ui 0.1.7

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.
Files changed (34) hide show
  1. package/README.md +36 -0
  2. package/package.json +40 -0
  3. package/ui/ThemeProvider.tsx +16 -0
  4. package/ui/components/ArticlePage.tsx +673 -0
  5. package/ui/components/AuthPage.tsx +109 -0
  6. package/ui/components/Callout.tsx +79 -0
  7. package/ui/components/Chart.tsx +100 -0
  8. package/ui/components/CodeTabs.tsx +145 -0
  9. package/ui/components/ComparePage.tsx +364 -0
  10. package/ui/components/DashboardPage.tsx +773 -0
  11. package/ui/components/DocsNav.tsx +80 -0
  12. package/ui/components/Footer.tsx +136 -0
  13. package/ui/components/HubPage.tsx +529 -0
  14. package/ui/components/Modal.tsx +412 -0
  15. package/ui/components/Nav.tsx +162 -0
  16. package/ui/components/OnThisPage.tsx +56 -0
  17. package/ui/components/ParamsTable.tsx +86 -0
  18. package/ui/components/RangeBar.tsx +68 -0
  19. package/ui/components/SeriesChart.tsx +218 -0
  20. package/ui/components/SeriesPage.tsx +461 -0
  21. package/ui/components/StatusMark.tsx +48 -0
  22. package/ui/components/publictrades/ExternalLink.tsx +37 -0
  23. package/ui/components/publictrades/FactsCard.tsx +40 -0
  24. package/ui/components/publictrades/LedgerFooter.tsx +22 -0
  25. package/ui/components/publictrades/LedgerNav.tsx +78 -0
  26. package/ui/components/publictrades/Mark.tsx +40 -0
  27. package/ui/components/publictrades/SourceBlock.tsx +91 -0
  28. package/ui/components/publictrades/Tape.tsx +164 -0
  29. package/ui/components/publictrades/ThreeStamps.tsx +47 -0
  30. package/ui/components/publictrades/types.ts +19 -0
  31. package/ui/data/series.ts +851 -0
  32. package/ui/index.ts +50 -0
  33. package/ui/publictrades.ts +16 -0
  34. package/ui/themes.css +81 -0
@@ -0,0 +1,86 @@
1
+ interface Param {
2
+ name: string;
3
+ type: string;
4
+ description: string;
5
+ }
6
+
7
+ interface ParamsTableProps {
8
+ params: Param[];
9
+ }
10
+
11
+ export default function ParamsTable({ params }: ParamsTableProps) {
12
+ return (
13
+ <div
14
+ style={{
15
+ background: 'var(--surface)',
16
+ border: '0.5px solid var(--hairline-2)',
17
+ borderRadius: 8,
18
+ overflow: 'hidden',
19
+ marginTop: 18,
20
+ }}
21
+ >
22
+ {/* Tinted header */}
23
+ <div
24
+ style={{
25
+ display: 'grid',
26
+ gridTemplateColumns: '180px 110px 1fr',
27
+ gap: 16,
28
+ padding: '9px 18px',
29
+ borderBottom: '0.5px solid var(--hairline-2)',
30
+ background: '#F4F4F1',
31
+ }}
32
+ >
33
+ {['Name', 'Type', 'Description'].map((h) => (
34
+ <span
35
+ key={h}
36
+ style={{
37
+ fontSize: 10,
38
+ fontWeight: 600,
39
+ textTransform: 'uppercase',
40
+ letterSpacing: '.07em',
41
+ color: 'var(--tertiary)',
42
+ }}
43
+ >
44
+ {h}
45
+ </span>
46
+ ))}
47
+ </div>
48
+
49
+ {/* Rows — horizontal hairlines only */}
50
+ {params.map((p, i) => (
51
+ <div
52
+ key={p.name}
53
+ style={{
54
+ display: 'grid',
55
+ gridTemplateColumns: '180px 110px 1fr',
56
+ gap: 16,
57
+ padding: '12px 18px',
58
+ borderBottom: i < params.length - 1 ? '0.5px solid var(--hairline)' : undefined,
59
+ fontSize: 13,
60
+ alignItems: 'start',
61
+ }}
62
+ >
63
+ <span
64
+ style={{
65
+ fontFamily: 'var(--mono)',
66
+ color: 'var(--ink)',
67
+ wordBreak: 'break-all',
68
+ }}
69
+ >
70
+ {p.name}
71
+ </span>
72
+ <span
73
+ style={{
74
+ fontFamily: 'var(--mono)',
75
+ color: 'var(--tertiary)',
76
+ fontSize: 12,
77
+ }}
78
+ >
79
+ {p.type}
80
+ </span>
81
+ <span style={{ color: 'var(--secondary)', lineHeight: 1.5 }}>{p.description}</span>
82
+ </div>
83
+ ))}
84
+ </div>
85
+ );
86
+ }
@@ -0,0 +1,68 @@
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import type { RangeEntry } from '../data/series';
5
+
6
+ interface RangeBarProps {
7
+ ranges: RangeEntry[];
8
+ defaultIndex?: number;
9
+ }
10
+
11
+ const UP_COLOR = '#1F8A5B';
12
+ const DOWN_COLOR = '#C2453B';
13
+
14
+ export default function RangeBar({ ranges, defaultIndex = 2 }: RangeBarProps) {
15
+ const [active, setActive] = useState(defaultIndex);
16
+
17
+ return (
18
+ <div
19
+ style={{
20
+ display: 'grid',
21
+ gridTemplateColumns: 'repeat(7, 1fr)',
22
+ gap: 8,
23
+ marginTop: 12,
24
+ }}
25
+ >
26
+ {ranges.map((r, i) => {
27
+ const isActive = i === active;
28
+ return (
29
+ <button
30
+ key={r.label}
31
+ onClick={() => setActive(i)}
32
+ style={{
33
+ display: 'flex',
34
+ flexDirection: 'column',
35
+ alignItems: 'center',
36
+ justifyContent: 'center',
37
+ gap: 3,
38
+ padding: '10px 8px',
39
+ borderRadius: 6,
40
+ border: `0.5px solid ${isActive ? 'var(--ink)' : 'var(--hairline-2)'}`,
41
+ background: isActive ? 'var(--ink)' : 'var(--surface)',
42
+ cursor: 'pointer',
43
+ textAlign: 'center',
44
+ }}
45
+ >
46
+ <span
47
+ style={{
48
+ fontSize: 13,
49
+ fontWeight: 600,
50
+ color: isActive ? '#fff' : 'var(--secondary)',
51
+ }}
52
+ >
53
+ {r.label}
54
+ </span>
55
+ <span
56
+ style={{
57
+ fontSize: 12,
58
+ color: isActive ? '#A9AFB8' : r.up ? UP_COLOR : DOWN_COLOR,
59
+ }}
60
+ >
61
+ {r.delta}
62
+ </span>
63
+ </button>
64
+ );
65
+ })}
66
+ </div>
67
+ );
68
+ }
@@ -0,0 +1,218 @@
1
+ 'use client';
2
+
3
+ import { useEffect, useRef } from 'react';
4
+ import { createChart, AreaSeries, ColorType, LineStyle, CrosshairMode } from 'lightweight-charts';
5
+ import type { UTCTimestamp } from 'lightweight-charts';
6
+
7
+ interface SeriesChartProps {
8
+ points?: { time: string; value: number }[];
9
+ line: string;
10
+ axisStart: string;
11
+ axisMid: string;
12
+ axisEnd: string;
13
+ }
14
+
15
+ /** Convert a hex string like "#1F8A5B" or "#1AB" to "rgba(31,138,91,0.10)".
16
+ * Falls back to the default accent rgba if the input is not a valid hex color. */
17
+ function hexToRgba(hex: string, alpha: number): string {
18
+ let h = hex.replace('#', '');
19
+ if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2];
20
+ const r = parseInt(h.slice(0, 2), 16);
21
+ const g = parseInt(h.slice(2, 4), 16);
22
+ const b = parseInt(h.slice(4, 6), 16);
23
+ if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
24
+ return `rgba(31,138,91,${alpha})`;
25
+ }
26
+ return `rgba(${r},${g},${b},${alpha})`;
27
+ }
28
+
29
+ /** Parse the SVG `line` points string into lightweight-charts data.
30
+ * Points are "x,y x,y …" where y is top-down (smaller y = higher value).
31
+ * We invert: value = maxY - y, and assign sequential daily UTCTimestamps. */
32
+ function parseLineData(line: string): { time: UTCTimestamp; value: number }[] {
33
+ if (!line.trim()) return [];
34
+ const pairs = line.trim().split(/\s+/);
35
+ const ys = pairs.map((p) => parseFloat(p.split(',')[1])).filter((y) => !Number.isNaN(y));
36
+ if (ys.length === 0) return [];
37
+ const maxY = Math.max(...ys);
38
+ const base = 1_600_000_000 as UTCTimestamp; // arbitrary epoch start
39
+ return ys.map((y, i) => ({
40
+ time: (base + i * 86400) as UTCTimestamp,
41
+ value: maxY - y,
42
+ }));
43
+ }
44
+
45
+ /** Convert 'YYYY-MM-DD' string points to lightweight-charts format. */
46
+ function parsePointsData(
47
+ points: { time: string; value: number }[],
48
+ ): { time: string; value: number }[] {
49
+ return [...points].sort((a, b) => (a.time < b.time ? -1 : 1));
50
+ }
51
+
52
+ export default function SeriesChart({ points, line, axisStart, axisMid, axisEnd }: SeriesChartProps) {
53
+ const containerRef = useRef<HTMLDivElement>(null);
54
+ const tooltipRef = useRef<HTMLDivElement>(null);
55
+
56
+ useEffect(() => {
57
+ const el = containerRef.current;
58
+ const tooltip = tooltipRef.current;
59
+ if (!el) return;
60
+
61
+ // Resolve CSS tokens from the nearest themed ancestor
62
+ const style = getComputedStyle(el);
63
+ const accent = style.getPropertyValue('--accent').trim() || '#1F8A5B';
64
+ const hairline = style.getPropertyValue('--hairline').trim() || '#E6E6E2';
65
+ const textColor = style.getPropertyValue('--secondary').trim() || '#6B7280';
66
+
67
+ const chart = createChart(el, {
68
+ width: el.clientWidth,
69
+ height: 240,
70
+ layout: {
71
+ background: { type: ColorType.Solid, color: 'transparent' },
72
+ textColor,
73
+ fontSize: 11,
74
+ attributionLogo: false, // logo removed; attribution in footer per ADR E4
75
+ },
76
+ grid: {
77
+ vertLines: { visible: false },
78
+ horzLines: { color: hairline, style: LineStyle.Solid },
79
+ },
80
+ rightPriceScale: { borderVisible: false, ticksVisible: false, visible: false },
81
+ timeScale: { borderVisible: false, ticksVisible: false, visible: false },
82
+ crosshair: {
83
+ mode: CrosshairMode.Magnet,
84
+ vertLine: {
85
+ color: accent,
86
+ width: 1,
87
+ style: LineStyle.Dashed,
88
+ labelVisible: false,
89
+ },
90
+ horzLine: { visible: false, labelVisible: false },
91
+ },
92
+ handleScroll: false,
93
+ handleScale: false,
94
+ });
95
+
96
+ const series = chart.addSeries(AreaSeries, {
97
+ lineColor: accent,
98
+ lineWidth: 2,
99
+ topColor: hexToRgba(accent, 0.10),
100
+ bottomColor: hexToRgba(accent, 0),
101
+ priceLineVisible: false,
102
+ lastValueVisible: false,
103
+ crosshairMarkerVisible: true,
104
+ crosshairMarkerRadius: 4,
105
+ crosshairMarkerBorderColor: accent,
106
+ crosshairMarkerBackgroundColor: accent,
107
+ });
108
+
109
+ // Prefer real `points` data; fall back to SVG-derived data
110
+ const hasPoints = points && points.length > 0;
111
+ if (hasPoints) {
112
+ series.setData(parsePointsData(points));
113
+ } else if (line.trim()) {
114
+ series.setData(parseLineData(line));
115
+ }
116
+
117
+ chart.timeScale().fitContent();
118
+
119
+ // Hover tooltip
120
+ chart.subscribeCrosshairMove((param) => {
121
+ if (!tooltip) return;
122
+
123
+ if (!param.time || !param.point || param.point.x < 0 || param.point.y < 0) {
124
+ tooltip.style.display = 'none';
125
+ return;
126
+ }
127
+
128
+ const d = param.seriesData.get(series) as { value?: number } | undefined;
129
+ if (!d || d.value === undefined) {
130
+ tooltip.style.display = 'none';
131
+ return;
132
+ }
133
+
134
+ // Format time: UTCTimestamp (number) or YYYY-MM-DD string
135
+ let dateStr = '';
136
+ if (typeof param.time === 'string') {
137
+ dateStr = param.time; // already YYYY-MM-DD
138
+ } else {
139
+ const date = new Date((param.time as number) * 1000);
140
+ dateStr = date.toISOString().slice(0, 10);
141
+ }
142
+
143
+ tooltip.innerHTML =
144
+ `<div style="font-size:11px;color:var(--tertiary)">${dateStr}</div>` +
145
+ `<div style="font-size:13px;font-weight:600;color:var(--ink);margin-top:2px">${d.value.toLocaleString(undefined, { maximumFractionDigits: 5 })}</div>`;
146
+
147
+ // Position tooltip near cursor, clamped inside container
148
+ const elRect = el.getBoundingClientRect();
149
+ const tooltipWidth = 112;
150
+ const tooltipHeight = 46;
151
+ let left = param.point.x + 12;
152
+ let top = param.point.y - tooltipHeight / 2;
153
+
154
+ if (left + tooltipWidth > elRect.width) left = param.point.x - tooltipWidth - 12;
155
+ if (top < 0) top = 0;
156
+ if (top + tooltipHeight > elRect.height) top = elRect.height - tooltipHeight;
157
+
158
+ tooltip.style.left = `${left}px`;
159
+ tooltip.style.top = `${top}px`;
160
+ tooltip.style.display = 'block';
161
+ });
162
+
163
+ const ro = new ResizeObserver(() => {
164
+ chart.applyOptions({ width: el.clientWidth });
165
+ });
166
+ ro.observe(el);
167
+
168
+ return () => {
169
+ ro.disconnect();
170
+ chart.remove();
171
+ if (tooltip) tooltip.style.display = 'none';
172
+ };
173
+ }, [points, line]);
174
+
175
+ return (
176
+ <div
177
+ style={{
178
+ background: 'var(--surface)',
179
+ border: '0.5px solid var(--hairline-2)',
180
+ borderRadius: 8,
181
+ padding: '18px 18px 10px',
182
+ }}
183
+ >
184
+ <div style={{ position: 'relative' }}>
185
+ <div ref={containerRef} />
186
+ {/* Floating hover tooltip */}
187
+ <div
188
+ ref={tooltipRef}
189
+ style={{
190
+ display: 'none',
191
+ position: 'absolute',
192
+ pointerEvents: 'none',
193
+ background: 'var(--surface)',
194
+ border: '0.5px solid var(--hairline-2)',
195
+ borderRadius: 4,
196
+ padding: '6px 10px',
197
+ boxShadow: '0 2px 8px rgba(0,0,0,0.08)',
198
+ whiteSpace: 'nowrap',
199
+ zIndex: 10,
200
+ }}
201
+ />
202
+ </div>
203
+ <div
204
+ style={{
205
+ display: 'flex',
206
+ justifyContent: 'space-between',
207
+ fontSize: 11,
208
+ color: 'var(--tertiary)',
209
+ padding: '8px 2px 2px',
210
+ }}
211
+ >
212
+ <span>{axisStart}</span>
213
+ <span>{axisMid}</span>
214
+ <span>{axisEnd}</span>
215
+ </div>
216
+ </div>
217
+ );
218
+ }