@bloxwap/hig 0.9.0 → 0.9.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/README.md +1 -0
- package/chart/README.md +3 -4
- package/chart/dist/altimeter-burst.d.ts +2 -2
- package/chart/dist/altimeter-burst.js +8 -7
- package/chart/dist/altimeter-chart.d.ts +13 -3
- package/chart/dist/altimeter-chart.js +37 -12
- package/chart/dist/altimeter-core.d.ts +21 -0
- package/chart/dist/altimeter-core.js +13 -0
- package/chart/dist/altimeter-targets.d.ts +3 -2
- package/chart/dist/altimeter-targets.js +7 -7
- package/chart/dist/index.d.ts +2 -2
- package/chart/dist/outcome-chart.d.ts +4 -2
- package/chart/dist/outcome-chart.js +9 -6
- package/chart/dist/outcome-model.d.ts +14 -1
- package/chart/dist/outcome-model.js +12 -4
- package/contracts/README.md +1 -1
- package/feedback/README.md +1 -1
- package/native/README.md +1 -1
- package/native/dist/address-readout.d.ts +9 -0
- package/native/dist/address-readout.js +22 -0
- package/native/dist/blocks.d.ts +2 -1
- package/native/dist/blocks.js +2 -1
- package/native/dist/chart.d.ts +20 -0
- package/native/dist/chart.js +161 -0
- package/native/dist/claim-reward-block.d.ts +22 -0
- package/native/dist/claim-reward-block.js +16 -0
- package/native/dist/confirm-block.d.ts +1 -5
- package/native/dist/confirm-block.js +5 -16
- package/native/dist/deposit-block.js +5 -2
- package/native/dist/gesture-sheet.js +1 -1
- package/native/dist/language-block.js +1 -1
- package/native/dist/manage-position-block.d.ts +7 -0
- package/native/dist/manage-position-block.js +29 -28
- package/native/dist/modal-radius.d.ts +2 -0
- package/native/dist/modal-radius.js +2 -0
- package/native/dist/overlay.d.ts +6 -2
- package/native/dist/overlay.js +7 -5
- package/native/dist/positions-block.d.ts +28 -0
- package/native/dist/positions-block.js +15 -0
- package/native/dist/screen-header.d.ts +3 -1
- package/native/dist/screen-header.js +2 -2
- package/native/dist/status.js +3 -2
- package/native-fonts/README.md +1 -1
- package/og-fonts/README.md +1 -1
- package/package.json +32 -12
- package/react/README.md +1 -1
- package/react/dist/blocks/address-readout.d.ts +9 -0
- package/react/dist/blocks/address-readout.js +16 -0
- package/react/dist/blocks/claim-reward-block.d.ts +22 -0
- package/react/dist/blocks/claim-reward-block.js +10 -0
- package/react/dist/blocks/confirm-block.d.ts +1 -5
- package/react/dist/blocks/confirm-block.js +3 -13
- package/react/dist/blocks/deposit-block.js +5 -2
- package/react/dist/blocks/login-block.d.ts +15 -3
- package/react/dist/blocks/login-block.js +22 -7
- package/react/dist/blocks/manage-position-block.d.ts +7 -0
- package/react/dist/blocks/manage-position-block.js +9 -4
- package/react/dist/blocks/positions-block.d.ts +28 -0
- package/react/dist/blocks/positions-block.js +14 -0
- package/react/dist/blocks.d.ts +2 -1
- package/react/dist/blocks.js +2 -1
- package/react/dist/gesture-sheet.js +6 -2
- package/react/dist/styles.css +170 -37
- package/tokens/README.md +1 -1
- package/native/dist/explainer-block.d.ts +0 -91
- package/native/dist/explainer-block.js +0 -34
- package/react/dist/blocks/explainer-block.d.ts +0 -80
- package/react/dist/blocks/explainer-block.js +0 -20
package/README.md
CHANGED
|
@@ -24,6 +24,7 @@ import {Button} from '@bloxwap/hig/react/button';
|
|
|
24
24
|
| `@bloxwap/hig/react/*` | Web components, blocks, `./react/css` and `./react/css/base` ([README](react/README.md)) |
|
|
25
25
|
| `@bloxwap/hig/native/*` | React Native components ([README](native/README.md)) |
|
|
26
26
|
| `@bloxwap/hig/chart` | `AltimeterChart` live price chart and `OutcomeChart`; `PriceChart` and `chartTheme` for `@bloxwap/chart` ([README](chart/README.md)) |
|
|
27
|
+
| `@bloxwap/hig/native/chart` | React Native SVG altimeter with live prices, open positions and target crossings |
|
|
27
28
|
| `@bloxwap/hig/feedback/*` | Opt-in web and native sound/haptic adapters ([README](feedback/README.md)) |
|
|
28
29
|
| `@bloxwap/hig/native-fonts` | Static TTFs for React Native and Expo ([README](native-fonts/README.md)) |
|
|
29
30
|
| `@bloxwap/hig/og-fonts` | Satori / `next/og` faces and the Node loader ([README](og-fonts/README.md)) |
|
package/chart/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/chart
|
|
2
2
|
|
|
3
|
-
Version 0.9.
|
|
3
|
+
Version 0.9.1, an entry of `@bloxwap/hig`. `AltimeterChart` is the Bloxwap live chart on its
|
|
4
4
|
own: a plus grid and price trail that flow left at 50px per second, a price ladder centered on the current price,
|
|
5
5
|
and the current price at the trail's tip. Pass `price` or a `feed`; with neither it shows live Bitcoin through
|
|
6
6
|
`bitcoinPrice`. Optional `targets` (`AltimeterTarget`: `{id, price, label?, color?}`) add full-width horizontal dotted lines
|
|
@@ -8,13 +8,12 @@ and colored text labels at the chart's trailing edge that glide to the side of e
|
|
|
8
8
|
Labels pass behind the current-price pill where they overlap. Streaming price updates retarget from the current position and forward velocity without overshoot; the canvas reuses its font and measured ladder widths between frames.
|
|
9
9
|
Each label shows its title on the left and formatted target price on the right, such as `Take Profit $100.02`.
|
|
10
10
|
Offscreen labels pin and stack at the top or bottom in price order while their lines stay hidden. Labels follow their lines on the same frame and move aside only for other labels or the chart edges. Only the above/below offset animates (260ms), reversing from its current offset; collision constraints apply afterward so labels stay separated throughout.
|
|
11
|
-
Set `
|
|
11
|
+
Set `degen` to shake the price pill and send glowing particles mostly in the direction of travel when its price crosses a target;
|
|
12
12
|
it defaults to off and respects reduced motion. `OutcomeChart` shows a question with two to ten
|
|
13
13
|
outcomes live, as one flowing trail each on a 0 to 100% ladder, ending in a stroked capsule with the label and chance; with no `outcomes` or `feed` it shows the
|
|
14
14
|
UEFA Champions League winner market through `championsLeagueWinner`. The entry is also the HIG adapter for [`@bloxwap/chart`](https://github.com/bloxwap/chart): `PriceChart` (a
|
|
15
15
|
`<figure>` with a required text `summary`, lazy-loading `@bloxwap/chart/react` inside `Suspense`) and
|
|
16
|
-
`chartTheme` (HIG token colors in sRGB for the canvas).
|
|
17
|
-
from `@bloxwap/hig/native/data`.
|
|
16
|
+
`chartTheme` (HIG token colors in sRGB for the canvas). React Native exposes the SVG altimeter at `@bloxwap/hig/native/chart`. Outcome and candle charts use labeled readouts and lists from `@bloxwap/hig/native/data` on native.
|
|
18
17
|
|
|
19
18
|
```sh
|
|
20
19
|
npm install @bloxwap/hig @bloxwap/chart@^0.5.0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/** Coalesce noisy crossings into at most one burst per cooldown, with no queued effects. */
|
|
2
|
-
export
|
|
2
|
+
export { ALTIMETER_BURST_COOLDOWN_MS } from './altimeter-core.js';
|
|
3
3
|
/** A bounded, compositor-driven burst radiating from the price pill. No frame loop or motion dependency. */
|
|
4
|
-
export declare function burstAtPill(pill: HTMLElement, layer: HTMLElement, color: string): () => void;
|
|
4
|
+
export declare function burstAtPill(pill: HTMLElement, layer: HTMLElement, color: string, direction: 'up' | 'down'): () => void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { tokens } from '@bloxwap/hig/tokens';
|
|
2
2
|
/** Coalesce noisy crossings into at most one burst per cooldown, with no queued effects. */
|
|
3
|
-
export
|
|
3
|
+
export { ALTIMETER_BURST_COOLDOWN_MS } from './altimeter-core.js';
|
|
4
|
+
import { sparkGeometry } from './altimeter-core.js';
|
|
4
5
|
const easing = `cubic-bezier(${tokens.easing.standard.join(',')})`;
|
|
5
6
|
/** A bounded, compositor-driven burst radiating from the price pill. No frame loop or motion dependency. */
|
|
6
|
-
export function burstAtPill(pill, layer, color) {
|
|
7
|
+
export function burstAtPill(pill, layer, color, direction) {
|
|
7
8
|
if (typeof pill.animate !== 'function')
|
|
8
9
|
return () => { };
|
|
9
10
|
// Measure once, before the shake, so the origin follows the pill's actual size and position.
|
|
@@ -20,15 +21,15 @@ export function burstAtPill(pill, layer, color) {
|
|
|
20
21
|
{ transform: 'translate(1px, -1px)', offset: .78 }, { transform: 'translate(0, 0)' },
|
|
21
22
|
], { duration: tokens.motion.base, easing: 'linear' }));
|
|
22
23
|
const ring = document.createElement('span');
|
|
23
|
-
Object.assign(ring.style, { position: 'absolute', left: `${-width / 2}px`, top: `${-height / 2}px`, width: `${width}px`, height: `${height}px`, border: '2px solid currentColor', borderRadius: `${tokens.radius.pill}px`, boxSizing: 'border-box' });
|
|
24
|
+
Object.assign(ring.style, { position: 'absolute', left: `${-width / 2}px`, top: `${-height / 2}px`, width: `${width}px`, height: `${height}px`, border: '2px solid currentColor', boxShadow: '0 0 8px currentColor', borderRadius: `${tokens.radius.pill}px`, boxSizing: 'border-box' });
|
|
24
25
|
burst.append(ring);
|
|
25
|
-
animations.push(ring.animate([{ transform: 'scale(.95)', opacity: .
|
|
26
|
+
animations.push(ring.animate([{ transform: 'scale(.95)', opacity: .95 }, { transform: 'scale(1.6)', opacity: 0 }], { duration: tokens.motion.base, easing, fill: 'forwards' }));
|
|
26
27
|
for (let i = 0; i < 24; i++) {
|
|
27
|
-
const
|
|
28
|
-
const
|
|
28
|
+
const { dx, dy, distance, size } = sparkGeometry(i, direction);
|
|
29
|
+
const spark = document.createElement('span');
|
|
29
30
|
// Begin just inside the capsule, then travel outward from its perimeter.
|
|
30
31
|
const startX = dx * Math.max(0, width / 2 - 3), startY = dy * Math.max(0, height / 2 - 3);
|
|
31
|
-
Object.assign(spark.style, { position: 'absolute', left: `${-size / 2}px`, top: `${-size / 2}px`, width: `${size}px`, height: `${size}px`, background: 'currentColor', borderRadius: '50%' });
|
|
32
|
+
Object.assign(spark.style, { position: 'absolute', left: `${-size / 2}px`, top: `${-size / 2}px`, width: `${size}px`, height: `${size}px`, background: 'currentColor', borderRadius: '50%', boxShadow: 'inset 0 0 2px #fff, 0 0 6px currentColor' });
|
|
32
33
|
burst.append(spark);
|
|
33
34
|
animations.push(spark.animate([
|
|
34
35
|
{ transform: `translate(${startX}px, ${startY}px)`, opacity: 1 },
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type AltimeterTick } from './altimeter-model.js';
|
|
3
3
|
import { type AltimeterFeed } from './bitcoin-price.js';
|
|
4
|
+
import type { TargetLabelInsets } from './outcome-model.js';
|
|
4
5
|
import { type AltimeterTarget } from './altimeter-targets.js';
|
|
6
|
+
import type { AltimeterPosition } from './altimeter-core.js';
|
|
7
|
+
export type { AltimeterPosition } from './altimeter-core.js';
|
|
5
8
|
export interface AltimeterChartProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
6
9
|
/** Text alternative shown as the figure's caption, for example what the chart tracks and where the price comes from. */
|
|
7
10
|
summary: string;
|
|
@@ -9,13 +12,19 @@ export interface AltimeterChartProps extends Omit<React.HTMLAttributes<HTMLEleme
|
|
|
9
12
|
price?: number | null;
|
|
10
13
|
/** Live price source, used only while `price` is omitted. Defaults to `bitcoinPrice`. Keep its identity stable. */
|
|
11
14
|
feed?: AltimeterFeed;
|
|
15
|
+
/** Shade the trail to break-even and color the capsule by actual P&L. */
|
|
16
|
+
position?: AltimeterPosition;
|
|
12
17
|
/** Chart height in pixels. Default 320. */
|
|
13
18
|
height?: number;
|
|
14
19
|
/** Format of the current price and the ladder. Defaults to US dollars with the digits the ladder needs. */
|
|
15
20
|
priceOptions?: Intl.NumberFormatOptions;
|
|
16
21
|
/** Horizontal dotted levels with optional right-aligned labels and CSS colors. Offscreen labels pin and stack at the edges. Use stable, unique IDs. */
|
|
17
22
|
targets?: readonly AltimeterTarget[];
|
|
18
|
-
/**
|
|
23
|
+
/** Top and bottom clearance for target text only. Defaults to 8 per edge. */
|
|
24
|
+
targetLabelInsets?: TargetLabelInsets;
|
|
25
|
+
/** DEGEN: shake the live pill and burst particles on target crossings. Off by default; suppressed by reduced motion. */
|
|
26
|
+
degen?: boolean;
|
|
27
|
+
/** @deprecated Use degen. */
|
|
19
28
|
dgen?: boolean;
|
|
20
29
|
}
|
|
21
30
|
export interface AltimeterFrame {
|
|
@@ -29,6 +38,7 @@ export interface AltimeterFrame {
|
|
|
29
38
|
display: number;
|
|
30
39
|
anchor: number;
|
|
31
40
|
spacing: number;
|
|
41
|
+
breakEvenPrice?: number;
|
|
32
42
|
colors: {
|
|
33
43
|
grid: string;
|
|
34
44
|
ladder: string;
|
|
@@ -47,6 +57,6 @@ export declare function drawAltimeter(ctx: CanvasRenderingContext2D, frame: Alti
|
|
|
47
57
|
/**
|
|
48
58
|
* The Bloxwap live chart on its own: a grid of plus marks and a price trail that flow left at 50px per second, a
|
|
49
59
|
* price ladder that keeps the current price at the vertical center, and the current price at the trail's tip. It
|
|
50
|
-
* accepts optional target lines and opt-in
|
|
60
|
+
* accepts optional target lines and opt-in DEGEN crossing feedback. Web only.
|
|
51
61
|
*/
|
|
52
|
-
export declare function AltimeterChart({ summary, price, feed, height, priceOptions, targets, dgen, style, ...props }: AltimeterChartProps): React.JSX.Element;
|
|
62
|
+
export declare function AltimeterChart({ summary, price, feed, height, priceOptions, position, targets, targetLabelInsets, dgen, degen, style, ...props }: AltimeterChartProps): React.JSX.Element;
|
|
@@ -17,6 +17,7 @@ const EDGE = 8;
|
|
|
17
17
|
const NO_TARGETS = [];
|
|
18
18
|
const transparent = (color) => /^#[0-9a-f]{6}$/i.test(color) ? `${color}00` : 'transparent';
|
|
19
19
|
const usable = (price) => price != null && Number.isFinite(price) && price > 0;
|
|
20
|
+
const positionColor = (value, colors) => !Number.isFinite(value) || value === 0 ? colors.muted : value > 0 ? colors.positive : colors.negative;
|
|
20
21
|
const formatter = (locale, options, decimals) => new Intl.NumberFormat(locale, { style: 'currency', currency: 'USD', minimumFractionDigits: decimals, maximumFractionDigits: decimals, ...options });
|
|
21
22
|
/** Paints one frame (grid, ladder, trail) and returns the x where the trail ends and the price pill begins. */
|
|
22
23
|
export function drawAltimeter(ctx, frame) {
|
|
@@ -70,14 +71,30 @@ export function drawAltimeter(ctx, frame) {
|
|
|
70
71
|
else
|
|
71
72
|
ctx.lineTo(trailEnd, center);
|
|
72
73
|
ctx.stroke();
|
|
74
|
+
if (usable(frame.breakEvenPrice)) {
|
|
75
|
+
const baseline = yFor(frame.breakEvenPrice);
|
|
76
|
+
if (baseline !== center) {
|
|
77
|
+
const bottom = Math.max(0, Math.min(height, baseline));
|
|
78
|
+
const shade = ctx.createLinearGradient(0, center, 0, bottom);
|
|
79
|
+
shade.addColorStop(0, frame.colors.line);
|
|
80
|
+
shade.addColorStop(1, transparent(frame.colors.line));
|
|
81
|
+
ctx.lineTo(trailEnd, baseline);
|
|
82
|
+
ctx.lineTo(points[0][0], baseline);
|
|
83
|
+
ctx.closePath();
|
|
84
|
+
ctx.fillStyle = shade;
|
|
85
|
+
ctx.globalAlpha = .5;
|
|
86
|
+
ctx.fill();
|
|
87
|
+
ctx.globalAlpha = 1;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
73
90
|
return trailEnd;
|
|
74
91
|
}
|
|
75
92
|
/**
|
|
76
93
|
* The Bloxwap live chart on its own: a grid of plus marks and a price trail that flow left at 50px per second, a
|
|
77
94
|
* price ladder that keeps the current price at the vertical center, and the current price at the trail's tip. It
|
|
78
|
-
* accepts optional target lines and opt-in
|
|
95
|
+
* accepts optional target lines and opt-in DEGEN crossing feedback. Web only.
|
|
79
96
|
*/
|
|
80
|
-
export function AltimeterChart({ summary, price, feed = bitcoinPrice, height = 320, priceOptions, targets = NO_TARGETS, dgen = false, style, ...props }) {
|
|
97
|
+
export function AltimeterChart({ summary, price, feed = bitcoinPrice, height = 320, priceOptions, position, targets = NO_TARGETS, targetLabelInsets, dgen, degen = dgen ?? false, style, ...props }) {
|
|
81
98
|
const { locale, messages, reducedMotion } = useHIG();
|
|
82
99
|
const colors = useColors();
|
|
83
100
|
const box = useRef(null), canvas = useRef(null), pill = useRef(null);
|
|
@@ -90,15 +107,21 @@ export function AltimeterChart({ summary, price, feed = bitcoinPrice, height = 3
|
|
|
90
107
|
const [reading, setReading] = useState(() => usable(price) ? price : null);
|
|
91
108
|
const digits = reading == null ? 2 : labelDecimalsFor(tickSpacingFor(reading), reading);
|
|
92
109
|
const readingOptions = useMemo(() => ({ style: 'currency', currency: 'USD', minimumFractionDigits: digits, maximumFractionDigits: digits, ...priceOptions }), [digits, JSON.stringify(priceOptions ?? {})]);
|
|
110
|
+
const capsuleColor = position ? positionColor(position.pnl, colors) : colors.action;
|
|
111
|
+
const capsule = position?.capsule;
|
|
112
|
+
const pillValue = typeof capsule === 'object' ? capsule.returnRatio : capsule === 'pnl' ? position?.pnl : reading;
|
|
113
|
+
const pillOptions = typeof capsule === 'object'
|
|
114
|
+
? { style: 'percent', minimumFractionDigits: 2, maximumFractionDigits: 2, signDisplay: 'exceptZero' }
|
|
115
|
+
: capsule === 'pnl' ? { style: 'currency', currency: priceOptions?.currency ?? 'USD', signDisplay: 'exceptZero' } : readingOptions;
|
|
93
116
|
const targetFormat = useMemo(() => new Intl.NumberFormat(locale, readingOptions), [locale, readingOptions]);
|
|
94
117
|
// The frame loop reads the newest props without restarting, so a re-render never clears the trail.
|
|
95
|
-
const settings = useRef({ colors, locale, priceOptions, optionsKey: '', reducedMotion, levels,
|
|
96
|
-
useEffect(() => { settings.current = { colors, locale, priceOptions, optionsKey: JSON.stringify(priceOptions ?? {}), reducedMotion, levels,
|
|
118
|
+
const settings = useRef({ colors, locale, priceOptions, optionsKey: '', reducedMotion, levels, degen, position, targetLabelInsets });
|
|
119
|
+
useEffect(() => { settings.current = { colors, locale, priceOptions, optionsKey: JSON.stringify(priceOptions ?? {}), reducedMotion, levels, degen, position, targetLabelInsets }; if (controlled)
|
|
97
120
|
latest.current = usable(price) ? price : null; });
|
|
98
|
-
useEffect(() => { if (!
|
|
121
|
+
useEffect(() => { if (!degen || reducedMotion) {
|
|
99
122
|
cancelBurst.current?.();
|
|
100
123
|
cancelBurst.current = undefined;
|
|
101
|
-
} }, [
|
|
124
|
+
} }, [degen, reducedMotion]);
|
|
102
125
|
useEffect(() => {
|
|
103
126
|
if (controlled) {
|
|
104
127
|
setStale(false);
|
|
@@ -153,7 +176,8 @@ export function AltimeterChart({ summary, price, feed = bitcoinPrice, height = 3
|
|
|
153
176
|
} };
|
|
154
177
|
const step = (now) => {
|
|
155
178
|
raf = requestAnimationFrame(step);
|
|
156
|
-
const { colors, locale, priceOptions, optionsKey, reducedMotion, levels,
|
|
179
|
+
const { colors, locale, priceOptions, optionsKey, reducedMotion, levels, degen, position, targetLabelInsets } = settings.current, target = latest.current;
|
|
180
|
+
const previousDisplay = display;
|
|
157
181
|
const resumed = now - lastFrame > 2000;
|
|
158
182
|
lastFrame = now;
|
|
159
183
|
if (resumed) {
|
|
@@ -197,7 +221,7 @@ export function AltimeterChart({ summary, price, feed = bitcoinPrice, height = 3
|
|
|
197
221
|
show(target);
|
|
198
222
|
}
|
|
199
223
|
}
|
|
200
|
-
const positions = layout.update(levels, display, spacing, height, now, reducedMotion || resumed);
|
|
224
|
+
const positions = layout.update(levels, display, spacing, height, now, reducedMotion || resumed, targetLabelInsets);
|
|
201
225
|
for (const level of levels) {
|
|
202
226
|
const row = targetRows.current.get(level.id);
|
|
203
227
|
if (!row)
|
|
@@ -240,7 +264,8 @@ export function AltimeterChart({ summary, price, feed = bitcoinPrice, height = 3
|
|
|
240
264
|
for (const { labelTop } of positions.values())
|
|
241
265
|
if (labelTop !== undefined)
|
|
242
266
|
targetLabelBounds.push([labelTop, labelTop + 18]);
|
|
243
|
-
|
|
267
|
+
const spread = position && usable(position.breakEvenPrice) && target != null ? (target - position.breakEvenPrice) * (position.side === 'short' ? -1 : 1) : 0;
|
|
268
|
+
trailEnd = drawAltimeter(context, { width, height, now, phase: reducedMotion ? 0 : gridPhase(now), ticks, display, anchor, spacing, font, targetLabelBounds, breakEvenPrice: position?.breakEvenPrice, colors: { grid: colors.nested, ladder: colors.muted, line: position ? positionColor(spread, colors) : colors.action }, label: value => { let text = labels.get(value); if (text === undefined) {
|
|
244
269
|
text = format.format(value);
|
|
245
270
|
labels.set(value, text);
|
|
246
271
|
} return text; }, labelWidth: text => { let size = widths.get(text); if (size === undefined) {
|
|
@@ -253,10 +278,10 @@ export function AltimeterChart({ summary, price, feed = bitcoinPrice, height = 3
|
|
|
253
278
|
if (pill.current.style.left !== left)
|
|
254
279
|
pill.current.style.left = left;
|
|
255
280
|
const hit = crossed.at(-1);
|
|
256
|
-
if (hit &&
|
|
281
|
+
if (hit && degen && !reducedMotion && now - lastBurst >= ALTIMETER_BURST_COOLDOWN_MS && effects.current) {
|
|
257
282
|
lastBurst = now;
|
|
258
283
|
cancelBurst.current?.();
|
|
259
|
-
cancelBurst.current = burstAtPill(pill.current, effects.current, hit.color ?? colors.action);
|
|
284
|
+
cancelBurst.current = burstAtPill(pill.current, effects.current, hit.color ?? colors.action, display > previousDisplay ? 'up' : 'down');
|
|
260
285
|
}
|
|
261
286
|
}
|
|
262
287
|
};
|
|
@@ -271,5 +296,5 @@ export function AltimeterChart({ summary, price, feed = bitcoinPrice, height = 3
|
|
|
271
296
|
else
|
|
272
297
|
targetLabels.current.delete(level.id); }, "data-hig-altimeter-target-label": level.id, dir: 'ltr', title: `${level.label} ${targetFormat.format(level.price)}`, style: { position: 'absolute', right: EDGE, top: 0, visibility: 'hidden', transform: 'translateY(0px)', maxWidth: `calc(100% - ${EDGE * 2}px)`, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', textAlign: 'right', color: level.color ?? colors.action, fontSize: 12, fontWeight: 600, lineHeight: '18px', fontVariantNumeric: 'tabular-nums' }, children: [_jsx("bdi", { style: { textTransform: 'capitalize' }, children: level.label }), ' ', _jsx("bdi", { children: targetFormat.format(level.price) })] })] }, level.id)) }), reading == null
|
|
273
298
|
? _jsx("p", { role: 'status', style: { position: 'absolute', inset: 0, margin: 0, display: 'grid', placeItems: 'center', color: colors.muted, fontFamily: 'var(--hig-font-sans, inherit)' }, children: stale ? (messages.stale ?? en.stale) : (messages.loadingChart ?? en.loadingChart) })
|
|
274
|
-
: _jsx("span", { ref: pill, "data-hig-altimeter-price": true, style: { position: 'absolute', right: EDGE, top: height / 2 - 18, height: 36, minWidth: 110, boxSizing: 'border-box', display: 'flex', alignItems: 'center', justifyContent: 'center', paddingInline: 10, border: `1px solid ${
|
|
299
|
+
: _jsx("span", { ref: pill, "data-hig-altimeter-price": true, style: { position: 'absolute', right: EDGE, top: height / 2 - 18, height: 36, minWidth: 110, boxSizing: 'border-box', display: 'flex', alignItems: 'center', justifyContent: 'center', paddingInline: 10, border: `1px solid ${capsuleColor}`, borderRadius: tokens.radius.pill, background: colors.background, color: capsuleColor, fontSize: 16, fontWeight: 600, lineHeight: 1, fontVariantNumeric: 'tabular-nums', whiteSpace: 'nowrap' }, children: pillValue != null && Number.isFinite(pillValue) ? _jsx(AnimatedNumberReadout, { value: pillValue, options: pillOptions }) : '—' }), _jsx("div", { ref: effects, "aria-hidden": true, style: { position: 'absolute', inset: 0, pointerEvents: 'none' } })] }), levels.length > 0 && _jsx("ul", { className: 'hig-sr-only', children: levels.map(level => _jsxs("li", { children: [level.label ? `${level.label}: ` : '', targetFormat.format(level.price)] }, level.id)) })] });
|
|
275
300
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './altimeter-model.js';
|
|
2
|
+
export * from './altimeter-targets.js';
|
|
3
|
+
export type { TargetLabelInsets } from './outcome-model.js';
|
|
4
|
+
export { bitcoinPrice, type AltimeterFeed } from './bitcoin-price.js';
|
|
5
|
+
export interface AltimeterPosition {
|
|
6
|
+
side: 'long' | 'short';
|
|
7
|
+
breakEvenPrice: number;
|
|
8
|
+
/** Host-reported net P&L, including fees where applicable. */
|
|
9
|
+
pnl: number;
|
|
10
|
+
/** Default is price. For a percentage, supply the return as a ratio (0.025 means +2.50%). */
|
|
11
|
+
capsule?: 'price' | 'pnl' | {
|
|
12
|
+
returnRatio: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare const ALTIMETER_BURST_COOLDOWN_MS = 600;
|
|
16
|
+
export declare function sparkGeometry(index: number, direction: 'up' | 'down'): {
|
|
17
|
+
dx: number;
|
|
18
|
+
dy: number;
|
|
19
|
+
distance: number;
|
|
20
|
+
size: number;
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Platform-independent chart geometry and feed. This entry loads neither renderer.
|
|
2
|
+
export * from './altimeter-model.js';
|
|
3
|
+
export * from './altimeter-targets.js';
|
|
4
|
+
export { bitcoinPrice } from './bitcoin-price.js';
|
|
5
|
+
export const ALTIMETER_BURST_COOLDOWN_MS = 600;
|
|
6
|
+
export function sparkGeometry(index, direction) {
|
|
7
|
+
// Eighteen sparks fan into the crossing; six shorter sparks scatter back.
|
|
8
|
+
const forward = index < 18, count = forward ? 18 : 6, slot = forward ? index : index - 18;
|
|
9
|
+
const angle = Math.PI * (slot + .5) / count;
|
|
10
|
+
const dx = Math.cos(angle), dy = Math.sin(angle) * (direction === 'up' ? -1 : 1) * (forward ? 1 : -1);
|
|
11
|
+
const distance = forward ? 50 + (index % 5) * 12 : 28 + (index % 3) * 10, size = 4 + index % 4;
|
|
12
|
+
return { dx, dy, distance, size };
|
|
13
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TargetLabelInsets } from './outcome-model.js';
|
|
1
2
|
/** A host-owned price level. Plain labels align right; colors accept any CSS color, including variables. */
|
|
2
3
|
export interface AltimeterTarget {
|
|
3
4
|
/** Stable, unique identity. Changing the price re-arms this target without firing an effect. */
|
|
@@ -20,11 +21,11 @@ export interface AltimeterTargetPosition {
|
|
|
20
21
|
pinned: 'top' | 'bottom' | null;
|
|
21
22
|
}
|
|
22
23
|
/** Labels stay inside the chart and share the chart capsule layout's collision avoidance. */
|
|
23
|
-
export declare function placeTargets(targets: readonly AltimeterTarget[], display: number, spacing: number, height: number, sideOffsets?: ReadonlyMap<string, number
|
|
24
|
+
export declare function placeTargets(targets: readonly AltimeterTarget[], display: number, spacing: number, height: number, sideOffsets?: ReadonlyMap<string, number>, insets?: TargetLabelInsets): Map<string, AltimeterTargetPosition>;
|
|
24
25
|
/** Follow the line exactly; animate only its above/below offset, then resolve collisions and edge pinning. */
|
|
25
26
|
export declare function targetLayout(): {
|
|
26
27
|
reset(): void;
|
|
27
|
-
update(targets: readonly AltimeterTarget[], display: number, spacing: number, height: number, now: number, snap?: boolean): Map<string, AltimeterTargetPosition>;
|
|
28
|
+
update(targets: readonly AltimeterTarget[], display: number, spacing: number, height: number, now: number, snap?: boolean, insets?: TargetLabelInsets): Map<string, AltimeterTargetPosition>;
|
|
28
29
|
};
|
|
29
30
|
/** Tracks displayed prices, so the effect coincides with the line reaching the live pill. */
|
|
30
31
|
export declare function targetCrossings(): {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { tokens } from '@bloxwap/hig/tokens';
|
|
2
2
|
import { ALTIMETER_TICK_PX, easeInOut } from './altimeter-model.js';
|
|
3
|
-
import { capsuleCenters } from './outcome-model.js';
|
|
3
|
+
import { capsuleCenters, labelBounds } from './outcome-model.js';
|
|
4
4
|
/** Keep the first valid target for each ID. Invalid prices must never enter chart geometry. */
|
|
5
5
|
export function validTargets(targets) {
|
|
6
6
|
const ids = new Set();
|
|
@@ -14,7 +14,7 @@ export function validTargets(targets) {
|
|
|
14
14
|
const LABEL_HEIGHT = 18, LABEL_GAP = 6, EDGE_INSET = 8;
|
|
15
15
|
const sideOffset = (price, display) => price > display ? LABEL_GAP + 2 : -LABEL_HEIGHT - LABEL_GAP + 2;
|
|
16
16
|
/** Labels stay inside the chart and share the chart capsule layout's collision avoidance. */
|
|
17
|
-
export function placeTargets(targets, display, spacing, height, sideOffsets) {
|
|
17
|
+
export function placeTargets(targets, display, spacing, height, sideOffsets, insets) {
|
|
18
18
|
const positions = new Map();
|
|
19
19
|
if (!Number.isFinite(display) || display <= 0 || !Number.isFinite(spacing) || spacing <= 0 || !Number.isFinite(height) || height <= 0)
|
|
20
20
|
return positions;
|
|
@@ -27,11 +27,11 @@ export function placeTargets(targets, display, spacing, height, sideOffsets) {
|
|
|
27
27
|
const wanted = labelled.map(target => {
|
|
28
28
|
const { y } = positions.get(target.id);
|
|
29
29
|
const top = y + (sideOffsets?.get(target.id) ?? sideOffset(target.price, display));
|
|
30
|
-
return top + LABEL_HEIGHT / 2
|
|
30
|
+
return top + LABEL_HEIGHT / 2;
|
|
31
31
|
});
|
|
32
|
-
const centers = capsuleCenters(wanted,
|
|
32
|
+
const centers = capsuleCenters(wanted, height, LABEL_HEIGHT, LABEL_GAP, true, labelBounds(height, LABEL_HEIGHT, insets, EDGE_INSET));
|
|
33
33
|
for (const [index, target] of labelled.entries())
|
|
34
|
-
positions.get(target.id).labelTop = centers[index] - LABEL_HEIGHT / 2
|
|
34
|
+
positions.get(target.id).labelTop = centers[index] - LABEL_HEIGHT / 2;
|
|
35
35
|
return positions;
|
|
36
36
|
}
|
|
37
37
|
/** Follow the line exactly; animate only its above/below offset, then resolve collisions and edge pinning. */
|
|
@@ -39,7 +39,7 @@ export function targetLayout() {
|
|
|
39
39
|
const sides = new Map();
|
|
40
40
|
return {
|
|
41
41
|
reset() { sides.clear(); },
|
|
42
|
-
update(targets, display, spacing, height, now, snap = false) {
|
|
42
|
+
update(targets, display, spacing, height, now, snap = false, insets) {
|
|
43
43
|
const offsets = new Map();
|
|
44
44
|
for (const target of targets) {
|
|
45
45
|
if (!target.label)
|
|
@@ -61,7 +61,7 @@ export function targetLayout() {
|
|
|
61
61
|
for (const id of sides.keys())
|
|
62
62
|
if (!offsets.has(id))
|
|
63
63
|
sides.delete(id);
|
|
64
|
-
const positions = placeTargets(targets, display, spacing, height, offsets);
|
|
64
|
+
const positions = placeTargets(targets, display, spacing, height, offsets, insets);
|
|
65
65
|
if (!positions.size)
|
|
66
66
|
sides.clear();
|
|
67
67
|
return positions;
|
package/chart/dist/index.d.ts
CHANGED
|
@@ -6,9 +6,9 @@ export declare const chartTheme: DeepPartial<ChartConfig>;
|
|
|
6
6
|
export declare function PriceChart({ summary, ...props }: ChartProps & {
|
|
7
7
|
summary: string;
|
|
8
8
|
}): React.JSX.Element;
|
|
9
|
-
export { AltimeterChart, type AltimeterChartProps } from './altimeter-chart.js';
|
|
9
|
+
export { AltimeterChart, type AltimeterChartProps, type AltimeterPosition } from './altimeter-chart.js';
|
|
10
10
|
export type { AltimeterTarget } from './altimeter-targets.js';
|
|
11
11
|
export { bitcoinPrice, type AltimeterFeed } from './bitcoin-price.js';
|
|
12
12
|
export { OutcomeChart, type OutcomeChartProps } from './outcome-chart.js';
|
|
13
|
-
export { outcomeColors, type Outcome, type OutcomeFeed } from './outcome-model.js';
|
|
13
|
+
export { outcomeColors, type Outcome, type OutcomeFeed, type TargetLabelInsets } from './outcome-model.js';
|
|
14
14
|
export { championsLeagueWinner } from './champions-league.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type AltimeterTick } from './altimeter-model.js';
|
|
3
|
-
import { type Outcome, type OutcomeFeed, type OutcomeScale } from './outcome-model.js';
|
|
3
|
+
import { type TargetLabelInsets, type Outcome, type OutcomeFeed, type OutcomeScale } from './outcome-model.js';
|
|
4
4
|
export interface OutcomeChartProps extends Omit<React.HTMLAttributes<HTMLElement>, 'children'> {
|
|
5
5
|
/** Text alternative shown as the figure's caption, for example the question and where its prices come from. */
|
|
6
6
|
summary: string;
|
|
@@ -10,6 +10,8 @@ export interface OutcomeChartProps extends Omit<React.HTMLAttributes<HTMLElement
|
|
|
10
10
|
feed?: OutcomeFeed;
|
|
11
11
|
/** Chart height in pixels. Default 360. */
|
|
12
12
|
height?: number;
|
|
13
|
+
/** Clearance for outcome capsules in pixels. Defaults to zero on both edges. */
|
|
14
|
+
targetLabelInsets?: TargetLabelInsets;
|
|
13
15
|
}
|
|
14
16
|
export interface OutcomeTrail {
|
|
15
17
|
color: string;
|
|
@@ -34,4 +36,4 @@ export declare function drawOutcomes(ctx: CanvasRenderingContext2D, frame: {
|
|
|
34
36
|
* second, on a ladder zoomed to the range the chances occupy. Each outcome's trail ends in a stroked capsule
|
|
35
37
|
* with its label and its chance. It draws no positions or controls. Web canvas only.
|
|
36
38
|
*/
|
|
37
|
-
export declare function OutcomeChart({ summary, outcomes, feed, height, style, ...props }: OutcomeChartProps): React.JSX.Element;
|
|
39
|
+
export declare function OutcomeChart({ summary, outcomes, feed, height, targetLabelInsets, style, ...props }: OutcomeChartProps): React.JSX.Element;
|
|
@@ -6,7 +6,7 @@ import * as en from '@bloxwap/hig/contracts/messages';
|
|
|
6
6
|
import { useHIG, useColors } from '@bloxwap/hig/react/provider';
|
|
7
7
|
import { AnimatedNumberReadout } from '@bloxwap/hig/react/animated-number';
|
|
8
8
|
import { ALTIMETER_EASE_MS, ALTIMETER_FLOW_PX, ALTIMETER_SAMPLE_MS, easeInOut, gridPhase, smoothTrail, trailPoints } from './altimeter-model.js';
|
|
9
|
-
import { OUTCOME_LIMIT, capsuleCenters, outcomeChance, outcomeColors, outcomeScale, outcomeTicks, outcomeY } from './outcome-model.js';
|
|
9
|
+
import { OUTCOME_LIMIT, capsuleCenters, labelBounds, outcomeChance, outcomeColors, outcomeScale, outcomeTicks, outcomeY } from './outcome-model.js';
|
|
10
10
|
import { championsLeagueWinner } from './champions-league.js';
|
|
11
11
|
import { drawPlusGrid, monoFont } from './plus-grid.js';
|
|
12
12
|
/** How long a capsule takes to glide from the waiting stack to its place once its first price arrives. */
|
|
@@ -61,7 +61,7 @@ export function drawOutcomes(ctx, frame) {
|
|
|
61
61
|
* second, on a ladder zoomed to the range the chances occupy. Each outcome's trail ends in a stroked capsule
|
|
62
62
|
* with its label and its chance. It draws no positions or controls. Web canvas only.
|
|
63
63
|
*/
|
|
64
|
-
export function OutcomeChart({ summary, outcomes, feed = championsLeagueWinner, height = 360, style, ...props }) {
|
|
64
|
+
export function OutcomeChart({ summary, outcomes, feed = championsLeagueWinner, height = 360, targetLabelInsets, style, ...props }) {
|
|
65
65
|
const { locale, messages, reducedMotion } = useHIG();
|
|
66
66
|
const colors = useColors();
|
|
67
67
|
const box = useRef(null), canvas = useRef(null), list = useRef(null);
|
|
@@ -96,7 +96,8 @@ export function OutcomeChart({ summary, outcomes, feed = championsLeagueWinner,
|
|
|
96
96
|
// Only a ladder fitted to real chances is worth holding; the whole ladder shown while waiting is not.
|
|
97
97
|
held.current = chances.some(chance => chance != null) ? scale : null;
|
|
98
98
|
const ticks = outcomeTicks(scale);
|
|
99
|
-
const
|
|
99
|
+
const bounds = labelBounds(height, CAPSULE, targetLabelInsets);
|
|
100
|
+
const rest = capsuleCenters(shown.map(outcome => outcomeY(outcomeChance(outcome.price) ?? scale.low, height, INSET, scale)), height, CAPSULE, 6, false, bounds);
|
|
100
101
|
// The frame loop reads the newest props without restarting, so a re-render never clears the trails.
|
|
101
102
|
const settings = useRef({ shown, rest, scale, colors, reducedMotion });
|
|
102
103
|
const eased = useRef(new Map());
|
|
@@ -109,7 +110,7 @@ export function OutcomeChart({ summary, outcomes, feed = championsLeagueWinner,
|
|
|
109
110
|
if (frameTime !== undefined)
|
|
110
111
|
state.clock = frameTime;
|
|
111
112
|
const now = state.clock, tips = shown.map(outcome => { const value = eased.current.get(outcome.id)?.value; return outcomeY(value != null && Number.isFinite(value) ? value : outcomeChance(outcome.price) ?? scale.low, height, INSET, scale); });
|
|
112
|
-
const centers = capsuleCenters(tips, height, CAPSULE), items = list.current?.children;
|
|
113
|
+
const centers = capsuleCenters(tips, height, CAPSULE, 6, false, bounds), items = list.current?.children;
|
|
113
114
|
for (const id of state.priced.keys())
|
|
114
115
|
if (!shown.some(outcome => outcome.id === id)) {
|
|
115
116
|
state.priced.delete(id);
|
|
@@ -126,8 +127,10 @@ export function OutcomeChart({ summary, outcomes, feed = championsLeagueWinner,
|
|
|
126
127
|
const progress = (now - move.start) / ARRIVE_MS;
|
|
127
128
|
if (progress >= 1 || reducedMotion)
|
|
128
129
|
state.moving.delete(outcome.id);
|
|
129
|
-
else
|
|
130
|
-
|
|
130
|
+
else {
|
|
131
|
+
const start = Math.max(bounds.top + CAPSULE / 2, Math.min(bounds.bottom - CAPSULE / 2, move.from));
|
|
132
|
+
centers[index] = start + (centers[index] - start) * easeInOut(progress);
|
|
133
|
+
}
|
|
131
134
|
}
|
|
132
135
|
state.at.set(outcome.id, centers[index]);
|
|
133
136
|
const item = items?.[index];
|
|
@@ -35,9 +35,22 @@ export declare function outcomeScale(chances: readonly (number | null)[], previo
|
|
|
35
35
|
export declare function outcomeTicks(scale?: OutcomeScale): number[];
|
|
36
36
|
/** Vertical position of a chance: the top of the scale sits `inset` below the top and its bottom `inset` above the bottom. Chances outside the scale stay on its edge. */
|
|
37
37
|
export declare function outcomeY(chance: number, height: number, inset: number, scale?: OutcomeScale): number;
|
|
38
|
+
/** Clearance between the plot edges and the outer edges of target labels, in layout units. */
|
|
39
|
+
export interface TargetLabelInsets {
|
|
40
|
+
top?: number;
|
|
41
|
+
bottom?: number;
|
|
42
|
+
}
|
|
43
|
+
/** Reduce excessive clearance proportionally so at least one label can fit. */
|
|
44
|
+
export declare function labelBounds(height: number, size: number, insets?: TargetLabelInsets, defaultInset?: number): {
|
|
45
|
+
top: number;
|
|
46
|
+
bottom: number;
|
|
47
|
+
};
|
|
38
48
|
/**
|
|
39
49
|
* Centers for capsules of `size` that want to sit at `wanted` but may not overlap: neighbors keep `gap` between
|
|
40
50
|
* them and all stay inside `height`; when they cannot all fit with the gap, the gap shrinks. Returned in the order given.
|
|
41
51
|
* `preserveOrder` keeps the input sequence instead of sorting by desired position, for stable target-label stacks.
|
|
42
52
|
*/
|
|
43
|
-
export declare function capsuleCenters(wanted: readonly number[], height: number, size?: number, gap?: number, preserveOrder?: boolean
|
|
53
|
+
export declare function capsuleCenters(wanted: readonly number[], height: number, size?: number, gap?: number, preserveOrder?: boolean, bounds?: {
|
|
54
|
+
top: number;
|
|
55
|
+
bottom: number;
|
|
56
|
+
}): number[];
|
|
@@ -49,21 +49,29 @@ export function outcomeY(chance, height, inset, scale = fullScale) {
|
|
|
49
49
|
const share = Math.min(1, Math.max(0, (scale.high - chance) / (scale.high - scale.low)));
|
|
50
50
|
return inset + share * (height - 2 * inset);
|
|
51
51
|
}
|
|
52
|
+
/** Reduce excessive clearance proportionally so at least one label can fit. */
|
|
53
|
+
export function labelBounds(height, size, insets, defaultInset = 0) {
|
|
54
|
+
const available = Math.max(0, height - size);
|
|
55
|
+
const edge = (value) => Math.min(available, value !== undefined && Number.isFinite(value) ? Math.max(0, value) : defaultInset);
|
|
56
|
+
const top = edge(insets?.top), bottom = edge(insets?.bottom);
|
|
57
|
+
const factor = top + bottom > available ? available / (top + bottom) : 1;
|
|
58
|
+
return { top: top * factor, bottom: Math.max(size, height) - bottom * factor };
|
|
59
|
+
}
|
|
52
60
|
/**
|
|
53
61
|
* Centers for capsules of `size` that want to sit at `wanted` but may not overlap: neighbors keep `gap` between
|
|
54
62
|
* them and all stay inside `height`; when they cannot all fit with the gap, the gap shrinks. Returned in the order given.
|
|
55
63
|
* `preserveOrder` keeps the input sequence instead of sorting by desired position, for stable target-label stacks.
|
|
56
64
|
*/
|
|
57
|
-
export function capsuleCenters(wanted, height, size = 36, gap = 6, preserveOrder = false) {
|
|
65
|
+
export function capsuleCenters(wanted, height, size = 36, gap = 6, preserveOrder = false, bounds = { top: 0, bottom: height }) {
|
|
58
66
|
const order = wanted.map((_, index) => index), placed = [];
|
|
59
67
|
if (!preserveOrder)
|
|
60
68
|
order.sort((a, b) => wanted[a] - wanted[b]);
|
|
61
69
|
// A crowded chart gives up the gap before any capsule leaves it.
|
|
62
|
-
const step = order.length > 1 ? Math.min(size + gap, (
|
|
70
|
+
const step = order.length > 1 ? Math.min(size + gap, (bounds.bottom - bounds.top - size) / (order.length - 1)) : size + gap;
|
|
63
71
|
for (const [rank, index] of order.entries())
|
|
64
|
-
placed[rank] = Math.max(wanted[index], rank ? placed[rank - 1] + step : size / 2);
|
|
72
|
+
placed[rank] = Math.max(wanted[index], rank ? placed[rank - 1] + step : bounds.top + size / 2);
|
|
65
73
|
for (let rank = order.length - 1; rank >= 0; rank--)
|
|
66
|
-
placed[rank] = Math.min(placed[rank], rank === order.length - 1 ?
|
|
74
|
+
placed[rank] = Math.min(placed[rank], rank === order.length - 1 ? bounds.bottom - size / 2 : placed[rank + 1] - step);
|
|
67
75
|
const centers = [];
|
|
68
76
|
for (const [rank, index] of order.entries())
|
|
69
77
|
centers[index] = placed[rank];
|
package/contracts/README.md
CHANGED
package/feedback/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/feedback
|
|
2
2
|
|
|
3
|
-
Version 0.9.
|
|
3
|
+
Version 0.9.1, an entry of `@bloxwap/hig`. Root contract imports no React, DOM, RN, audio or device API. Use independent web/native entries and opt in to each channel. Successful API invocation never certifies physical output. See docs/feedback for timing, storage, capability and device verification.
|
|
4
4
|
|
|
5
5
|
`createWebSoundAdapter` passes a per-adapter abort signal to SFX. The signal-aware engine cancels that root's active voices while other roots and host-owned playback continue. The shared default engine remains reference-counted.
|
|
6
6
|
|
package/native/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @bloxwap/hig/native
|
|
2
2
|
|
|
3
|
-
Version 0.9.
|
|
3
|
+
Version 0.9.1, an entry of `@bloxwap/hig`. Import individual entries; see docs/components for platform and accessibility contracts.
|
|
4
4
|
|
|
5
5
|
UI symbols come from `@bloxwap/icons` (install `@bloxwap/icons@^0.1.0`). Native symbols also require the `expo-image` version for your Expo SDK.
|
|
6
6
|
Use `npx expo install expo-image`, then rebuild a development client so the native
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** The address as the two rows the block draws: split at the middle, with `anchor` on the characters people compare, the first 4 (6 when it starts with `0x`) and the last 4. An address too short to have a middle is all anchor. */
|
|
3
|
+
export declare function confirmAddressRows(address: string): {
|
|
4
|
+
text: string;
|
|
5
|
+
anchor: boolean;
|
|
6
|
+
}[][];
|
|
7
|
+
export declare function AddressReadout({ address }: {
|
|
8
|
+
address: string;
|
|
9
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import { useColors, useHIG } from './provider.js';
|
|
5
|
+
import { Text } from './surface.js';
|
|
6
|
+
/** The address as the two rows the block draws: split at the middle, with `anchor` on the characters people compare, the first 4 (6 when it starts with `0x`) and the last 4. An address too short to have a middle is all anchor. */
|
|
7
|
+
export function confirmAddressRows(address) {
|
|
8
|
+
const characters = Array.from(address), head = address.startsWith('0x') ? 6 : 4, tail = characters.length - 4, split = Math.ceil(characters.length / 2);
|
|
9
|
+
return [characters.slice(0, split), characters.slice(split)].map((row, rowIndex) => {
|
|
10
|
+
const parts = [];
|
|
11
|
+
row.forEach((character, index) => { const position = rowIndex * split + index, anchor = position < head || position >= tail, last = parts[parts.length - 1]; if (last && last.anchor === anchor)
|
|
12
|
+
last.text += character;
|
|
13
|
+
else
|
|
14
|
+
parts.push({ text: character, anchor }); });
|
|
15
|
+
return parts;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function AddressReadout({ address }) {
|
|
19
|
+
const colors = useColors(), { monoFontFamily } = useHIG();
|
|
20
|
+
const type = { fontFamily: monoFontFamily ?? Platform.select({ ios: 'Menlo', default: 'monospace' }), fontSize: 15, lineHeight: 22 };
|
|
21
|
+
return _jsx(Text, { accessible: false, maxFontSizeMultiplier: 1.2, style: { ...type, writingDirection: 'ltr', textAlign: 'left' }, children: confirmAddressRows(address).map((row, index) => _jsxs(React.Fragment, { children: [index > 0 ? '\n' : null, row.map((part, offset) => _jsx(Text, { maxFontSizeMultiplier: 1.2, style: { ...type, color: part.anchor ? colors.text : colors.muted, fontWeight: part.anchor ? '700' : '500' }, children: part.text }, offset))] }, index)) });
|
|
22
|
+
}
|
package/native/dist/blocks.d.ts
CHANGED
|
@@ -42,4 +42,5 @@ export { SwapAmountCard, SwapPill, type SwapAmountCardProps, type SwapPillProps
|
|
|
42
42
|
export { SwapBlock, SwapPanelBlock, SwapPanel, swapAction, type SwapBlockProps, type SwapPanelBlockProps, type SwapPanelProps, type SwapToken, type SwapArtwork, type SwapChain, type SwapAction, type SwapDenomination, type SwapWallet, type SwapFee, type SwapFigure, type SwapReceive, type SwapDestination, type SwapDetail, type SwapView } from './swap-block.js';
|
|
43
43
|
export { ConfirmBlock, type ConfirmBlockProps, type ConfirmDetail, type ConfirmTertiaryAction } from './confirm-block.js';
|
|
44
44
|
export { PresetPickerBlock, type PresetPickerBlockProps, type PresetPickerCustom, type PresetPickerAdjustable } from './preset-picker-block.js';
|
|
45
|
-
export {
|
|
45
|
+
export { PositionsBlock, type PositionsBlockProps, type OpenPosition } from './positions-block.js';
|
|
46
|
+
export { ClaimRewardBlock, type ClaimRewardBlockProps } from './claim-reward-block.js';
|
package/native/dist/blocks.js
CHANGED
|
@@ -46,4 +46,5 @@ export { SwapAmountCard, SwapPill } from './swap-amount-card.js';
|
|
|
46
46
|
export { SwapBlock, SwapPanelBlock, SwapPanel, swapAction } from './swap-block.js';
|
|
47
47
|
export { ConfirmBlock } from './confirm-block.js';
|
|
48
48
|
export { PresetPickerBlock } from './preset-picker-block.js';
|
|
49
|
-
export {
|
|
49
|
+
export { PositionsBlock } from './positions-block.js';
|
|
50
|
+
export { ClaimRewardBlock } from './claim-reward-block.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type ViewProps } from 'react-native';
|
|
3
|
+
import { bitcoinPrice, type AltimeterFeed, type AltimeterPosition, type AltimeterTarget, type TargetLabelInsets } from '@bloxwap/hig/chart/altimeter-core';
|
|
4
|
+
export { bitcoinPrice, type AltimeterFeed, type AltimeterPosition, type AltimeterTarget, type TargetLabelInsets };
|
|
5
|
+
export interface AltimeterChartProps extends Omit<ViewProps, 'children'> {
|
|
6
|
+
summary: string;
|
|
7
|
+
price?: number | null;
|
|
8
|
+
feed?: AltimeterFeed;
|
|
9
|
+
height?: number;
|
|
10
|
+
priceOptions?: Intl.NumberFormatOptions;
|
|
11
|
+
position?: AltimeterPosition;
|
|
12
|
+
targets?: readonly AltimeterTarget[];
|
|
13
|
+
/** Top and bottom clearance for target text only. Defaults to 8 per edge. */
|
|
14
|
+
targetLabelInsets?: TargetLabelInsets;
|
|
15
|
+
degen?: boolean;
|
|
16
|
+
/** @deprecated Use degen. */
|
|
17
|
+
dgen?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Native SVG price ladder, scrolling trail and position readout. Stops drawing and unsubscribes in the background. */
|
|
20
|
+
export declare function AltimeterChart({ summary, price, feed, height, priceOptions, position, targets, targetLabelInsets, dgen, degen, ...view }: AltimeterChartProps): React.JSX.Element;
|