aboutsummaryrefslogtreecommitdiffstats
path: root/ui-web/src
diff options
context:
space:
mode:
Diffstat (limited to 'ui-web/src')
-rw-r--r--ui-web/src/App.tsx502
-rw-r--r--ui-web/src/Chart.tsx94
-rw-r--r--ui-web/src/Events.tsx370
-rw-r--r--ui-web/src/Users.tsx298
-rw-r--r--ui-web/src/api.ts176
-rw-r--r--ui-web/src/graphics.tsx51
-rw-r--r--ui-web/src/main.tsx10
-rw-r--r--ui-web/src/styles.css1068
8 files changed, 2569 insertions, 0 deletions
diff --git a/ui-web/src/App.tsx b/ui-web/src/App.tsx
new file mode 100644
index 0000000..204beae
--- /dev/null
+++ b/ui-web/src/App.tsx
@@ -0,0 +1,502 @@
1import { FormEvent, ReactNode, useCallback, useEffect, useRef, useState } from 'react';
2import {
3 api,
4 ApiError,
5 ChatMessage,
6 CHEVRON,
7 EventDetail,
8 eventPath,
9 GLYPH,
10 Ledger,
11 MarketData,
12 money,
13 num,
14 optionTitle,
15 same,
16 Sync,
17} from './api';
18import { Events } from './Events';
19import { MarketChart, Pinwheel } from './graphics';
20import { Users } from './Users';
21
22export type Act = (work: () => Promise<unknown>, done: string) => Promise<void>;
23
24const SKINS = [
25 ['rose-pine-dawn', 'Rosé Pine Dawn'],
26 ['catppuccin', 'Catppuccin'],
27 ['gruvbox', 'Gruvbox'],
28];
29
30function useSetting(key: string, initial: string): [string, (value: string) => void] {
31 const [value, setValue] = useState(() => {
32 try {
33 return localStorage.getItem(key) ?? initial;
34 } catch {
35 return initial;
36 }
37 });
38 const set = (next: string) => {
39 setValue(next);
40 try {
41 localStorage.setItem(key, next);
42 } catch {
43 }
44 };
45 return [value, set];
46}
47
48export function App() {
49 const [user, setUser] = useState<string | null | undefined>(undefined);
50 const [notice, setNotice] = useState<string | null>(null);
51 const [skin, setSkin] = useSetting('gm-skin', SKINS[0][0]);
52 const [animations, setAnimations] = useSetting('gm-animations', 'on');
53
54 useEffect(() => {
55 document.documentElement.dataset.skin = skin;
56 document.documentElement.classList.toggle('anim', animations === 'on');
57 }, [skin, animations]);
58
59 useEffect(() => {
60 api<Ledger>('/user/account')
61 .then((account) => setUser(account.owner))
62 .catch(() => setUser(null));
63 }, []);
64
65 const leave = useCallback((why?: string) => {
66 setNotice(why ?? null);
67 setUser(null);
68 }, []);
69
70 const controls = (
71 <>
72 <button
73 className={animations === 'on' ? 'btn icon on' : 'btn icon'}
74 title="Toggle animations"
75 aria-label="Toggle animations"
76 aria-pressed={animations === 'on'}
77 onClick={() => setAnimations(animations === 'on' ? 'off' : 'on')}
78 >
79 <Pinwheel />
80 </button>
81 <select className="select" aria-label="Skin" value={skin} onChange={(e) => setSkin(e.target.value)}>
82 {SKINS.map(([id, name]) => (
83 <option key={id} value={id}>
84 {name}
85 </option>
86 ))}
87 </select>
88 </>
89 );
90
91 if (user === undefined) return null;
92 if (user === null) return <Login notice={notice} onLoggedIn={setUser} />;
93 return <Market user={user} onLoggedOut={leave} controls={controls} />;
94}
95
96function Login({ notice, onLoggedIn }: { notice: string | null; onLoggedIn: (user: string) => void }) {
97 const [name, setName] = useState('');
98 const [error, setError] = useState(notice);
99 const [busy, setBusy] = useState(false);
100
101 async function submit(e: FormEvent) {
102 e.preventDefault();
103 setBusy(true);
104 setError(null);
105 try {
106 const res = await api<{ username: string }>('/login', { username: name });
107 onLoggedIn(res.username);
108 } catch (err) {
109 setError((err as Error).message);
110 setBusy(false);
111 }
112 }
113
114 return (
115 <main className="login">
116 <form className="card" onSubmit={submit}>
117 <h1 className="xl bold">Guess Market</h1>
118 <p className="base ink2">Sign in to a market server</p>
119 <label className="base ink2" htmlFor="username" style={{ marginTop: 8 }}>
120 User name
121 </label>
122 <input id="username" className="field" autoFocus value={name} onChange={(e) => setName(e.target.value)} />
123 {error && <p className="base bold no">{error}</p>}
124 <button className="btn primary" style={{ marginTop: 8 }} disabled={busy || name.trim() === ''}>
125 Log in
126 </button>
127 </form>
128 </main>
129 );
130}
131
132function Market(props: { user: string; onLoggedOut: (why?: string) => void; controls: ReactNode }) {
133 const { user, onLoggedOut } = props;
134 const [data, setData] = useState<MarketData | null>(null);
135 const [tab, setTab] = useState<'events' | 'users'>('events');
136 const [selectedKey, setSelectedKey] = useState<string | null>(null);
137 const [dialog, setDialog] = useState<'deposit' | 'resolve' | null>(null);
138 const [offline, setOffline] = useState(false);
139 const [toast, setToast] = useState<string | null>(null);
140 const refresh = useRef<() => Promise<void>>(async () => {});
141
142 useEffect(() => {
143 let stopped = false;
144 let version = -1;
145 let timer: number | undefined;
146
147 async function pull() {
148 const sync = await api<Sync>(`/sync?since=${version}`);
149 if (!sync.changed) return;
150 const details = await Promise.all(sync.events.map((e) => api<EventDetail>(eventPath(e.name))));
151 if (stopped || sync.version < version) return;
152 version = sync.version;
153 setData({
154 events: sync.events,
155 details: Object.fromEntries(details.map((d) => [d.summary.key, d])),
156 users: sync.users,
157 account: sync.account,
158 });
159 }
160
161 async function tick() {
162 try {
163 await pull();
164 setOffline(false);
165 } catch (err) {
166 if (err instanceof ApiError && err.status === 401) {
167 stopped = true;
168 onLoggedOut('Your session ended. Please log in again.');
169 } else {
170 setOffline(true);
171 }
172 }
173 }
174
175 async function loop() {
176 await tick();
177 if (!stopped) timer = window.setTimeout(loop, 1000);
178 }
179
180 refresh.current = tick;
181 loop();
182 return () => {
183 stopped = true;
184 window.clearTimeout(timer);
185 };
186 }, [onLoggedOut]);
187
188 useEffect(() => {
189 if (!toast) return;
190 const timer = window.setTimeout(() => setToast(null), 2500);
191 return () => window.clearTimeout(timer);
192 }, [toast]);
193
194 const act: Act = useCallback(async (work, done) => {
195 try {
196 await work();
197 setToast(done);
198 } catch (err) {
199 setToast((err as Error).message);
200 }
201 await refresh.current();
202 }, []);
203
204 async function logout() {
205 try {
206 await api('/logout', {});
207 } catch {
208 }
209 onLoggedOut();
210 }
211
212 const selected = data?.events.find((e) => e.key === selectedKey) ?? data?.events[0];
213 const detail = selected && data?.details[selected.key];
214
215 return (
216 <div className="app">
217 <div className="windowbar">Guess Market</div>
218
219 <div className="toolbar">
220 <button className="btn primary" onClick={logout}>
221 Log out
222 </button>
223 <div className="path card2 grow">
224 <span className="ink2">{CHEVRON}</span>
225 <span className="ellipsis">{window.location.host}/guess-market</span>
226 </div>
227 {props.controls}
228 </div>
229
230 {offline && <div className="banner">Cannot reach the server. Retrying every second…</div>}
231
232 {data === null || data.events.length === 0 ? (
233 <div className="empty">
234 <MarketChart />
235 <p className="xl bold">{data === null ? 'Loading the market…' : 'No events yet'}</p>
236 {data !== null && (
237 <p className="ink2" style={{ maxWidth: 420 }}>
238 Events are uploaded from the desktop client. They appear here by themselves.
239 </p>
240 )}
241 </div>
242 ) : (
243 <>
244 <div className="tabs">
245 <button className={tab === 'events' ? 'tab on' : 'tab'} onClick={() => setTab('events')}>
246 Events
247 </button>
248 <button className={tab === 'users' ? 'tab on' : 'tab'} onClick={() => setTab('users')}>
249 Users
250 </button>
251 <span className="grow" />
252 <span className="tabinfo">
253 <span style={{ paddingRight: 12 }}>acting as {user}</span>
254 ACCOUNT BALANCE
255 <span className={num(data.account.balance) < 0 ? 'lg bold no' : 'lg bold accent'}>
256 {money(data.account.balance)}
257 </span>
258 </span>
259 </div>
260
261 {/* key: a new element per tab, so the fade-in runs on every switch */}
262 <div className="content fade" key={tab}>
263 {tab === 'events' ? (
264 <Events
265 data={data}
266 user={user}
267 selected={selected}
268 onSelect={setSelectedKey}
269 act={act}
270 onTrade={() => setTab('users')}
271 onResolve={() => setDialog('resolve')}
272 />
273 ) : (
274 <Users
275 data={data}
276 user={user}
277 selected={selected}
278 onSelect={setSelectedKey}
279 act={act}
280 onDeposit={() => setDialog('deposit')}
281 />
282 )}
283 </div>
284 </>
285 )}
286
287 <div className="statusbar">
288 <span className="grow">
289 {data === null
290 ? ` IDLE ${CHEVRON}`
291 : ` ${GLYPH.file} ${user} ${CHEVRON} ${GLYPH.bolt} ${data.events.length} events ${CHEVRON} ${GLYPH.users} ${data.users.length} users`}
292 </span>
293 <Chat user={user} onError={setToast} />
294 </div>
295
296 {dialog === 'deposit' && (
297 <DepositDialog
298 onCancel={() => setDialog(null)}
299 onConfirm={(amount) => {
300 setDialog(null);
301 act(() => api('/user/deposit', { amount }), `Deposited ${money(amount)}`);
302 }}
303 />
304 )}
305 {dialog === 'resolve' && detail && (
306 <ResolveDialog
307 detail={detail}
308 onCancel={() => setDialog(null)}
309 onConfirm={(i) => {
310 setDialog(null);
311 act(
312 () => api(eventPath(detail.summary.name) + '/resolve', { option: detail.state.markets[i].key }),
313 `Event resolved as ${detail.summary.optionNames[i]}`,
314 );
315 }}
316 />
317 )}
318
319 {toast && (
320 <div className="toast" role="status">
321 {toast}
322 </div>
323 )}
324 </div>
325 );
326}
327
328function Chat({ user, onError }: { user: string; onError: (message: string) => void }) {
329 const [messages, setMessages] = useState<ChatMessage[]>([]);
330 const [open, setOpen] = useState(false);
331 const [unread, setUnread] = useState(0);
332 const [text, setText] = useState('');
333 const openRef = useRef(open);
334 openRef.current = open;
335 const list = useRef<HTMLDivElement>(null);
336
337 useEffect(() => {
338 let stopped = false;
339 let last = 0;
340 let timer: number | undefined;
341 async function loop() {
342 try {
343 const said = await api<ChatMessage[]>(`/chat?since=${last}`);
344 if (!stopped && said.length > 0) {
345 last = said[said.length - 1].id;
346 setMessages((m) => [...m, ...said]);
347 if (!openRef.current) setUnread((n) => n + said.length);
348 }
349 } catch {
350 }
351 if (!stopped) timer = window.setTimeout(loop, 1000);
352 }
353 loop();
354 return () => {
355 stopped = true;
356 window.clearTimeout(timer);
357 };
358 }, []);
359
360 useEffect(() => {
361 if (list.current) list.current.scrollTop = list.current.scrollHeight;
362 }, [messages, open]);
363
364 async function send(e: FormEvent) {
365 e.preventDefault();
366 const line = text.trim();
367 if (line === '') return;
368 setText('');
369 try {
370 await api('/chat', { text: line.slice(0, 500) });
371 } catch (err) {
372 onError((err as Error).message);
373 }
374 }
375
376 return (
377 <>
378 <button
379 className={open ? 'chatbtn on' : 'chatbtn'}
380 title="Chat"
381 aria-label="Chat"
382 aria-expanded={open}
383 onClick={() => {
384 setOpen(!open);
385 setUnread(0);
386 }}
387 >
388 {GLYPH.chat}
389 {unread > 0 && ` ${unread}`}
390 </button>
391 {open && (
392 <div className="card chat">
393 <p className="base bold">Chat</p>
394 <div className="chatlist" ref={list}>
395 {messages.map((m) => (
396 <div key={m.id}>
397 <div className={same(m.sender, user) ? 'xs bold accent' : 'xs bold ink2'}>
398 {m.sender} {m.at}
399 </div>
400 <div className="base">{m.text}</div>
401 </div>
402 ))}
403 </div>
404 <form className="row" onSubmit={send}>
405 <input
406 className="field grow"
407 placeholder="Message everyone"
408 autoFocus
409 value={text}
410 onChange={(e) => setText(e.target.value)}
411 />
412 <button className="btn primary" disabled={text.trim() === ''}>
413 Send
414 </button>
415 </form>
416 </div>
417 )}
418 </>
419 );
420}
421
422function DepositDialog(props: { onCancel: () => void; onConfirm: (amount: string) => void }) {
423 const [amount, setAmount] = useState('');
424 const valid = num(amount) > 0;
425 return (
426 <div className="scrim">
427 <form
428 className="card dialog"
429 onSubmit={(e) => {
430 e.preventDefault();
431 if (valid) props.onConfirm(amount.trim());
432 }}
433 >
434 <header>Deposit funds</header>
435 <div>
436 <label className="base ink2" htmlFor="amount">
437 Amount to add to your account
438 </label>
439 <input
440 id="amount"
441 className={amount !== '' && !valid ? 'field bad' : 'field'}
442 style={{ width: '100%' }}
443 autoFocus
444 placeholder="100.00"
445 inputMode="decimal"
446 value={amount}
447 onChange={(e) => setAmount(e.target.value)}
448 />
449 </div>
450 <footer>
451 <button type="button" className="btn" onClick={props.onCancel}>
452 Cancel
453 </button>
454 <button className="btn primary" disabled={!valid}>
455 Deposit
456 </button>
457 </footer>
458 </form>
459 </div>
460 );
461}
462
463function ResolveDialog(props: { detail: EventDetail; onCancel: () => void; onConfirm: (option: number) => void }) {
464 const [option, setOption] = useState<number | null>(null);
465 const e = props.detail.summary;
466 return (
467 <div className="scrim">
468 <div className="card dialog" style={{ width: 470 }}>
469 <header>Close &amp; resolve event</header>
470 <div>
471 <p className="base ink2">
472 Pick the option the event ended with. The contract account is emptied to holders of the winning option; a
473 close-time fee is moved to the market maker. This cannot be undone.
474 </p>
475 <div className="row">
476 {[0, 1].map((i) => (
477 <button
478 key={i}
479 className={`resolveopt ${i === 0 ? 'yes' : 'no'}${option === i ? ' on' : ''}`}
480 onClick={() => setOption(i)}
481 >
482 {optionTitle(e, i)}
483 </button>
484 ))}
485 </div>
486 </div>
487 <footer>
488 <button className="btn" onClick={props.onCancel}>
489 Cancel
490 </button>
491 <button
492 className="btn destructive"
493 disabled={option === null}
494 onClick={() => option !== null && props.onConfirm(option)}
495 >
496 Resolve as {option === null ? '…' : option === 0 ? 'YES' : 'NO'}
497 </button>
498 </footer>
499 </div>
500 </div>
501 );
502}
diff --git a/ui-web/src/Chart.tsx b/ui-web/src/Chart.tsx
new file mode 100644
index 0000000..4caf3a5
--- /dev/null
+++ b/ui-web/src/Chart.tsx
@@ -0,0 +1,94 @@
1import { EventDetail, Ledger, num } from './api';
2
3export type Point = [number, number];
4
5const seconds = (at: string) => {
6 const t = Date.parse(at.replace(' ', 'T'));
7 return Number.isNaN(t) ? 0 : t / 1000;
8};
9const now = () => Date.now() / 1000;
10const clock = (t: number) => new Date(t * 1000).toTimeString().slice(0, 8);
11
12export function priceSeries(detail: EventDetail): Point[] {
13 const first = detail.summary.optionNames[0];
14 const current = num(detail.state.markets[0]?.price) || 0.5;
15 const trades = [...detail.history].reverse();
16 if (trades.length === 0) {
17 return [
18 [now() - 60, current],
19 [now(), current],
20 ];
21 }
22 const start = seconds(trades[0].at) || now();
23 const points: Point[] = [[start - 60, 0.5]];
24 for (const t of trades) {
25 const quantity = num(t.quantity);
26 const unit = quantity > 0 ? num(t.pricePaid) / quantity : current;
27 const price = t.optionName === first ? unit : 1 - unit;
28 points.push([seconds(t.at) || start, Math.max(0, Math.min(1, price))]);
29 }
30 return points;
31}
32
33export function balanceSeries(ledger: Ledger): Point[] {
34 const rows = ledger.entries;
35 const balance = num(ledger.balance);
36 if (rows.length === 0) {
37 return [
38 [now() - 60, balance],
39 [now(), balance],
40 ];
41 }
42 const start = seconds(rows[0].at) || now();
43 const points: Point[] = [[start - 60, Math.max(0, num(rows[0].balanceAfter) - num(rows[0].amount))]];
44 for (const row of rows) {
45 points.push([seconds(row.at) || start, num(row.balanceAfter)]);
46 }
47 return points;
48}
49
50const TICKS = [0, 1, 2, 3, 4];
51
52export function LineChart(props: {
53 series: { points: Point[]; tone: 'accent' | 'yes' | 'no' }[];
54 range?: [number, number];
55 height?: number;
56}) {
57 const all = props.series.flatMap((s) => s.points);
58 const t0 = Math.min(...all.map((p) => p[0]));
59 const t1 = Math.max(...all.map((p) => p[0]), t0 + 60);
60 let [lo, hi] = props.range ?? [Math.min(...all.map((p) => p[1]), 0), Math.max(...all.map((p) => p[1]))];
61 if (hi <= lo) hi = lo + 1;
62 if (!props.range) hi = lo + Math.ceil(((hi - lo) * 1.1) / 4) * 4; // headroom, in four whole steps
63
64 const x = (t: number) => ((t - t0) / (t1 - t0)) * 100;
65 const y = (v: number) => 100 - ((v - lo) / (hi - lo)) * 100;
66 const label = (v: number) => (hi - lo <= 1 ? v.toFixed(2).replace(/\.?0+$/, '') || '0' : Math.round(v).toLocaleString());
67
68 return (
69 <div className="chart card2">
70 <div className="yaxis">
71 {TICKS.map((i) => (
72 <span key={i}>{label(hi - ((hi - lo) * i) / 4)}</span>
73 ))}
74 </div>
75 <svg viewBox="0 0 100 100" preserveAspectRatio="none" style={{ height: props.height ?? 150 }}>
76 {TICKS.map((i) => (
77 <line key={i} className="grid" x1="0" x2="100" y1={i * 25} y2={i * 25} />
78 ))}
79 {props.series.map((s, i) => (
80 <path
81 key={i}
82 className={'stroke-' + s.tone}
83 d={s.points.map((p, j) => `${j ? 'L' : 'M'}${x(p[0]).toFixed(2)} ${y(p[1]).toFixed(2)}`).join(' ')}
84 />
85 ))}
86 </svg>
87 <div className="xaxis">
88 {TICKS.map((i) => (
89 <span key={i}>{clock(t0 + ((t1 - t0) * i) / 4)}</span>
90 ))}
91 </div>
92 </div>
93 );
94}
diff --git a/ui-web/src/Events.tsx b/ui-web/src/Events.tsx
new file mode 100644
index 0000000..e33b4e2
--- /dev/null
+++ b/ui-web/src/Events.tsx
@@ -0,0 +1,370 @@
1import { useState } from 'react';
2import {
3 api,
4 EventDetail,
5 eventPath,
6 EventSummary,
7 feeLabel,
8 FeeTiming,
9 MarketData,
10 Mechanism,
11 mechanismLabel,
12 money,
13 num,
14 OrderBook,
15 same,
16 SEP,
17 Status,
18} from './api';
19import type { Act } from './App';
20import { LineChart, priceSeries } from './Chart';
21import { Equalizer } from './graphics';
22
23const STATUS_PILL: Record<Status, [string, string]> = {
24 DRAFT: ['', 'IDLE'],
25 ACTIVE: ['active', 'ACTIVE'],
26 SETTLED: ['closed', 'CLOSED'],
27};
28
29function Filter<T extends string>(props: {
30 label: string;
31 value: T | null;
32 options: [T, string][];
33 onChange: (value: T | null) => void;
34}) {
35 return (
36 <div className="filter">
37 <span>{props.label}</span>
38 <button className={props.value === null ? 'toggle on' : 'toggle'} onClick={() => props.onChange(null)}>
39 All
40 </button>
41 {props.options.map(([value, text]) => (
42 <button
43 key={value}
44 className={props.value === value ? 'toggle on' : 'toggle'}
45 onClick={() => props.onChange(value)}
46 >
47 {text}
48 </button>
49 ))}
50 </div>
51 );
52}
53
54export function Events(props: {
55 data: MarketData;
56 user: string;
57 selected: EventSummary | undefined;
58 onSelect: (key: string) => void;
59 act: Act;
60 onTrade: () => void;
61 onResolve: () => void;
62}) {
63 const { data, selected } = props;
64 const [method, setMethod] = useState<Mechanism | null>(null);
65 const [status, setStatus] = useState<Status | null>(null);
66 const [fee, setFee] = useState<FeeTiming | null>(null);
67
68 const shown = data.events.filter(
69 (e) =>
70 (method === null || e.mechanism === method) &&
71 (status === null || e.status === status) &&
72 (fee === null || e.commissionTiming === fee),
73 );
74 const detail = selected && data.details[selected.key];
75
76 return (
77 <>
78 <section className="card side events">
79 <Filter
80 label="Method"
81 value={method}
82 onChange={setMethod}
83 options={[
84 ['LMSR', 'LMSR'],
85 ['ORDER_BOOK', 'Order Book'],
86 ]}
87 />
88 <Filter
89 label="Status"
90 value={status}
91 onChange={setStatus}
92 options={[
93 ['DRAFT', 'Not started'],
94 ['ACTIVE', 'Active'],
95 ['SETTLED', 'Closed'],
96 ]}
97 />
98 <Filter
99 label="Fee"
100 value={fee}
101 onChange={setFee}
102 options={[
103 ['ON_PURCHASE', 'On purchase'],
104 ['ON_CLOSE', 'On close'],
105 ]}
106 />
107 <div className="list">
108 {shown.map((e) => (
109 <button
110 key={e.key}
111 className={e.key === selected?.key ? 'listrow on' : 'listrow'}
112 style={{ flexDirection: 'column', alignItems: 'stretch', gap: 6 }}
113 onClick={() => props.onSelect(e.key)}
114 >
115 <span className="row">
116 <span className="sm ink2">#{e.displayId}</span>
117 <span className="bold ellipsis">{e.name}</span>
118 </span>
119 <span className="row sm ink2">
120 <span>{mechanismLabel(e.mechanism)}</span>
121 <span className={'pill ' + STATUS_PILL[e.status][0]}>{STATUS_PILL[e.status][1]}</span>
122 <span>{feeLabel(e)}</span>
123 <span className="grow" />
124 <span>{money(e.accountBalance)}</span>
125 </span>
126 </button>
127 ))}
128 </div>
129 <span className="sm ink2">
130 {shown.length} of {data.events.length} events shown
131 </span>
132 </section>
133
134 {detail ? (
135 <EventView detail={detail} user={props.user} act={props.act} onTrade={props.onTrade} onResolve={props.onResolve} />
136 ) : (
137 <section className="card main" />
138 )}
139 </>
140 );
141}
142
143function EventView(props: { detail: EventDetail; user: string; act: Act; onTrade: () => void; onResolve: () => void }) {
144 const { detail, user, act } = props;
145 const e = detail.summary;
146 const markets = detail.state.markets;
147 const isMm = same(e.marketMaker, user);
148 const live = e.status === 'ACTIVE' ? 'LIVE' : e.status === 'SETTLED' ? 'ENDED' : 'IDLE';
149 const yes = priceSeries(detail);
150
151 return (
152 <section className="card main">
153 <div className="head" style={{ flexDirection: 'column', gap: 9 }}>
154 <div className="row" style={{ alignItems: 'flex-start', gap: 14, width: '100%' }}>
155 <div className="grow">
156 <h2 className="xl bold">
157 {e.displayId}. {e.name}
158 </h2>
159 <p className="base ink2 ellipsis" title={e.description}>
160 {e.description}
161 </p>
162 </div>
163 {/* Open = go trade on an active event, or the Market Maker starting their own */}
164 {e.status === 'ACTIVE' && (
165 <button className="btn primary" onClick={props.onTrade}>
166 Trade
167 </button>
168 )}
169 {e.status === 'DRAFT' && isMm && (
170 <button
171 className="btn primary"
172 onClick={() => act(() => api(eventPath(e.name) + '/open', {}), `Event started`)}
173 >
174 Start Event
175 </button>
176 )}
177 {e.status === 'ACTIVE' && isMm && (
178 <button className="btn" onClick={props.onResolve}>
179 Close &amp; Resolve…
180 </button>
181 )}
182 </div>
183 <div className="meta">
184 <span className={'pill ' + STATUS_PILL[e.status][0]}>
185 <Equalizer />
186 {live}
187 </span>
188 <span>
189 <span className="ink2">Method</span> <b>{mechanismLabel(e.mechanism)}</b>
190 </span>
191 <span>
192 <span className="ink2">Status</span> <b>{e.status}</b>
193 </span>
194 <span>
195 <span className="ink2">Market Maker</span> <b>{e.marketMaker}</b>
196 </span>
197 <span>
198 <span className="ink2">Fee</span> <b>{feeLabel(e)}</b>
199 </span>
200 <span>
201 <span className="ink2">Contract</span> <b>{money(e.accountBalance)}</b>
202 </span>
203 </div>
204 </div>
205
206 <div className="body">
207 {e.status === 'SETTLED' && (
208 <div className="notice">
209 <span className="pill resolved">RESOLVED</span>
210 <span>
211 Winning option: <b>{detail.settledMarket}</b> {SEP} contract emptied to its holders
212 </span>
213 </div>
214 )}
215
216 {e.mechanism === 'LMSR' ? (
217 <>
218 <div className="pair">
219 {markets.map((m, i) => (
220 <div key={m.key} className={i === 0 ? 'optcard yes' : 'optcard no'}>
221 <div className="row">
222 <span className="bold grow ellipsis">
223 {i === 0 ? 'YES' : 'NO'} <span className="sm">{m.name}</span>
224 </span>
225 <span className="bold" style={{ fontSize: 22 }}>
226 {money(m.price)}
227 </span>
228 </div>
229 <div className="bar">
230 <i style={{ width: `${num(m.price) * 100}%` }} />
231 </div>
232 <span className="sm ink2">
233 {m.volume} shares {SEP} p = {num(m.price).toFixed(2)}
234 </span>
235 </div>
236 ))}
237 </div>
238 <div className="section">
239 <div className="section-title">
240 Share price over time <span className="grow" />
241 <span className="sm ink2" style={{ fontWeight: 400 }}>
242 YES / NO {SEP} LMSR
243 </span>
244 </div>
245 <LineChart
246 range={[0, 1]}
247 series={[
248 { points: yes, tone: 'yes' },
249 { points: yes.map(([t, v]) => [t, 1 - v]), tone: 'no' },
250 ]}
251 />
252 </div>
253 </>
254 ) : (
255 <>
256 <div className="pair">
257 {detail.orderBooks.map((book, i) => (
258 <Book key={book.optionKey} book={book} last={markets[i]?.price} side={i === 0 ? 'YES' : 'NO'} />
259 ))}
260 </div>
261 <div className="section">
262 <div className="section-title">
263 Last trade price over time <span className="grow" />
264 <span className="sm ink2" style={{ fontWeight: 400 }}>
265 last trade YES
266 </span>
267 </div>
268 <LineChart range={[0, 1]} series={[{ points: yes, tone: 'accent' }]} />
269 </div>
270 </>
271 )}
272
273 <div className="section">
274 <div className="section-title">
275 Trade history <span className="sm ink2">newest first</span>
276 </div>
277 <div className="table">
278 <div className="thead">
279 <span className="w66">#</span>
280 <span className="grow">User</span>
281 <span className="w150">Option</span>
282 <span className="w92 num">Shares</span>
283 <span className="w92 num">Paid</span>
284 </div>
285 {detail.history.map((t, i) => (
286 <div className="trow" key={i}>
287 <span className="w66 ink2 bold">#{detail.history.length - i}</span>
288 <span className="grow ellipsis">{t.userName}</span>
289 <span className={`w150 bold ellipsis ${t.optionName === e.optionNames[0] ? 'yes' : 'no'}`}>
290 {t.optionName}
291 </span>
292 <span className="w92 num">{t.quantity} shares</span>
293 <span className="w92 num bold accent">{money(t.pricePaid)}</span>
294 </div>
295 ))}
296 {detail.history.length === 0 && <div className="trow ink2">No trades yet</div>}
297 </div>
298 </div>
299
300 <div className="section">
301 <div className="section-title">Participants</div>
302 <div className="table">
303 <div className="thead">
304 <span className="grow">User</span>
305 <span className="w78 num">YES</span>
306 <span className="w78 num">NO</span>
307 <span className="w92 num">Value</span>
308 <span className="w92 num">Fees paid</span>
309 </div>
310 {detail.participants.map((p) => (
311 <div className="trow" key={p.user}>
312 <span className="grow ellipsis bold">
313 {p.user}
314 {p.tag && ` (${p.tag})`}
315 </span>
316 <span className="w78 num">{p.yes}</span>
317 <span className="w78 num">{p.no}</span>
318 <span className="w92 num">{p.value}</span>
319 <span className="w92 num">{p.fees}</span>
320 </div>
321 ))}
322 {detail.participants.length === 0 && <div className="trow ink2">Nobody yet</div>}
323 </div>
324 </div>
325 </div>
326 </section>
327 );
328}
329
330function Book({ book, last, side }: { book: OrderBook; last: string | undefined; side: string }) {
331 const mid = book.bestBid && book.bestAsk ? money((num(book.bestBid) + num(book.bestAsk)) / 2) : '—';
332 return (
333 <div className="table">
334 <div className="row" style={{ padding: '10px 11px 0' }}>
335 <span className={side === 'YES' ? 'bold yes' : 'bold no'}>{side} Order Book</span>
336 <span className="sm ink2 ellipsis grow">{book.optionName}</span>
337 <span className="sm ink2">{book.orders.length} orders</span>
338 </div>
339 <div className="stats">
340 {[
341 ['Last', money(last)],
342 ['Best bid', book.bestBid ?? '—'],
343 ['Best ask', book.bestAsk ?? '—'],
344 ['Mid', mid],
345 ['Spread', book.spread ?? '—'],
346 ].map(([label, value]) => (
347 <span key={label}>
348 <span className="xs ink2">{label}</span>
349 <b>{value}</b>
350 </span>
351 ))}
352 </div>
353 <div className="thead">
354 <span className="w54 num">Price</span>
355 <span className="w54 num">Side</span>
356 <span className="w54 num">Qty</span>
357 <span className="grow">User</span>
358 </div>
359 {book.orders.map((o, i) => (
360 <div className={o.isBid ? 'trow bid' : 'trow ask'} key={i}>
361 <span className="w54 num bold">{o.price}</span>
362 <span className={o.isBid ? 'w54 num yes' : 'w54 num no'}>{o.side}</span>
363 <span className="w54 num">{o.quantity}</span>
364 <span className="grow ellipsis">{o.user}</span>
365 </div>
366 ))}
367 {book.orders.length === 0 && <div className="trow ink2">No resting orders</div>}
368 </div>
369 );
370}
diff --git a/ui-web/src/Users.tsx b/ui-web/src/Users.tsx
new file mode 100644
index 0000000..b2593d9
--- /dev/null
+++ b/ui-web/src/Users.tsx
@@ -0,0 +1,298 @@
1import { useState } from 'react';
2import { api, EventSummary, feeLabel, MarketData, mechanismLabel, money, num, same, SEP } from './api';
3import type { Act } from './App';
4import { balanceSeries, LineChart } from './Chart';
5import { Sparkline } from './graphics';
6
7export function Users(props: {
8 data: MarketData;
9 user: string;
10 selected: EventSummary | undefined;
11 onSelect: (key: string) => void;
12 act: Act;
13 onDeposit: () => void;
14}) {
15 const { data, user, selected } = props;
16 const account = data.account;
17 const balance = num(account.balance);
18
19 const myEvents = data.events.flatMap((e) => {
20 const me = data.details[e.key]?.participants.find((p) => same(p.user, user));
21 const owner = same(e.marketMaker, user);
22 return owner || (me && (me.yes > 0 || me.no > 0)) ? [{ e, me, owner }] : [];
23 });
24 const isMm = myEvents.some((row) => row.owner);
25
26 return (
27 <>
28 <section className="card side users">
29 <div className="row xs bold ink2">
30 <span className="grow">User</span>
31 <span>Balance</span>
32 </div>
33 {/* A directory of everyone on the server; you can only ever act as yourself */}
34 <div className="list">
35 {data.users.map((u) => {
36 const me = same(u.username, user);
37 return (
38 <div key={u.username} className={me ? 'listrow plain on' : 'listrow plain'}>
39 <span className="grow">
40 <span className="bold ellipsis" style={{ display: 'block' }}>
41 {u.username}
42 </span>
43 <span className="xs ink2">
44 {u.marketMaker ? 'Market Maker' : 'Trader'}
45 {me ? ' (you)' : u.online ? '' : ' · offline'}
46 </span>
47 </span>
48 <span className={num(u.balance) < 0 ? 'balcell neg' : 'balcell'}>{money(u.balance)}</span>
49 </div>
50 );
51 })}
52 </div>
53 <button className="btn primary" onClick={props.onDeposit}>
54 Deposit Funds
55 </button>
56 </section>
57
58 <section className="card main">
59 <div className="head" style={{ alignItems: 'center' }}>
60 <div className="grow">
61 <div className="row" style={{ gap: 9 }}>
62 <h2 className="xl bold">{user}</h2>
63 <span className={account.blocked ? 'pill blocked' : isMm ? 'pill mm' : 'pill'}>
64 {account.blocked ? 'BLOCKED' : isMm ? 'MARKET MAKER' : 'TRADER'}
65 </span>
66 </div>
67 <p className="base ink2">Active in {myEvents.length} events</p>
68 </div>
69 <Sparkline negative={balance < 0} />
70 <div style={{ textAlign: 'right' }}>
71 <div className="base ink2">Balance</div>
72 <div className={balance < 0 ? 'balance neg' : 'balance'}>{money(account.balance)}</div>
73 </div>
74 </div>
75
76 <div className="body">
77 {account.blocked && (
78 <div className="notice blocked">
79 <span className="pill blocked">BLOCKED</span>
80 <span>
81 This account reached a negative balance. All trading actions are disabled until you deposit enough
82 funds to bring it back above zero.
83 </span>
84 </div>
85 )}
86
87 <div className="section">
88 <div className="section-title">
89 Account balance over time <span className="grow" />
90 <span className="sm ink2" style={{ fontWeight: 400 }}>
91 every trade, fee and payout
92 </span>
93 </div>
94 <LineChart series={[{ points: balanceSeries(account), tone: balance < 0 ? 'no' : 'accent' }]} />
95 </div>
96
97 <div className="section">
98 <div className="section-title">Events participation / owner</div>
99 <div className="table">
100 <div className="thead">
101 <span className="grow">Event</span>
102 <span className="w92">Role</span>
103 <span className="w78">Type</span>
104 <span className="w78 num">YES</span>
105 <span className="w78 num">NO</span>
106 <span className="w92 num">P/L</span>
107 </div>
108 {myEvents.map(({ e, me, owner }) => {
109 const pnl = e.status === 'SETTLED' ? (me?.pnl ?? '$0.00') : '—';
110 return (
111 <div
112 key={e.key}
113 className={e.key === selected?.key ? 'trow click on' : 'trow click'}
114 onClick={() => props.onSelect(e.key)}
115 >
116 <span className="grow ellipsis">{e.name}</span>
117 <span className="w92 ink2">{owner ? 'Market Maker' : 'Trader'}</span>
118 <span className="w78 ink2">{mechanismLabel(e.mechanism)}</span>
119 <span className="w78 num">{me?.yes ?? 0}</span>
120 <span className="w78 num">{me?.no ?? 0}</span>
121 <span className={num(pnl) < 0 ? 'w92 num pnl neg' : 'w92 num pnl'}>{pnl}</span>
122 </div>
123 );
124 })}
125 {myEvents.length === 0 && <div className="trow ink2">You are not part of any event yet</div>}
126 </div>
127 </div>
128
129 {/* key: a different event starts with a fresh form */}
130 {selected ? (
131 <TradePanel key={selected.key} {...props} event={selected} />
132 ) : (
133 <div className="card2 base ink2" style={{ padding: '13px 14px' }}>
134 Select an event to trade.
135 </div>
136 )}
137
138 <div className="section">
139 <div className="section-title">
140 Account activity <span className="grow" />
141 <span className="sm ink2" style={{ fontWeight: 400 }}>
142 newest first
143 </span>
144 </div>
145 <div className="table">
146 <div className="thead">
147 <span className="w150">Time</span>
148 <span className="w92">Type</span>
149 <span className="grow">Details</span>
150 <span className="w92 num">Amount</span>
151 <span className="w92 num">Balance</span>
152 </div>
153 {/* seq is not unique across entries, so the position is the key */}
154 {[...account.entries].reverse().map((row, i) => (
155 <div className="trow" key={account.entries.length - i}>
156 <span className="w150 ink2">{row.at}</span>
157 <span className="w92 ink2">{row.type}</span>
158 <span className="grow ellipsis">{row.note}</span>
159 <span className="w92 num">{row.amount}</span>
160 <span className="w92 num">{row.balanceAfter}</span>
161 </div>
162 ))}
163 {account.entries.length === 0 && (
164 <div className="trow ink2">Nothing yet. Deposit funds to start trading.</div>
165 )}
166 </div>
167 </div>
168 </div>
169 </section>
170 </>
171 );
172}
173
174function TradePanel(props: { data: MarketData; user: string; act: Act; event: EventSummary }) {
175 const { data, user, event: e } = props;
176 const detail = data.details[e.key];
177 const markets = detail?.state.markets ?? [];
178 const me = detail?.participants.find((p) => same(p.user, user));
179 const held = [me?.yes ?? 0, me?.no ?? 0];
180 const isBook = e.mechanism === 'ORDER_BOOK';
181
182 const [option, setOption] = useState(0);
183 const [side, setSide] = useState<'BUY' | 'SELL'>('BUY');
184 const [quantity, setQuantity] = useState('50');
185 const [price, setPrice] = useState('0.62');
186
187 const qty = Number(quantity);
188 const qtyOk = Number.isInteger(qty) && qty > 0;
189 const unit = isBook ? Number(price) : num(markets[option]?.price);
190 const priceOk = unit > 0;
191 const cost = qty * unit;
192
193 let hint: string;
194 let allowed = false;
195 if (!qtyOk) hint = 'Shares must be a positive whole number.';
196 else if (!priceOk) hint = 'Price per share must be positive.';
197 else if (data.account.blocked) hint = 'Trading is disabled because this account is blocked.';
198 else if (e.status !== 'ACTIVE') hint = 'Trading is only available for ACTIVE events.';
199 else if (side === 'SELL' && !same(e.marketMaker, user) && qty > held[option])
200 hint = `Cannot sell ${qty} shares; you only hold ${held[option]}.`;
201 else if (side === 'BUY' && num(data.account.balance) < cost)
202 hint = `Insufficient balance. Required: ${money(cost)}, available: ${money(data.account.balance)}`;
203 else {
204 allowed = true;
205 hint =
206 side === 'SELL'
207 ? 'Sell order will match existing bids or rest as an ask.'
208 : isBook
209 ? 'Buy order will match existing asks or rest as a bid.'
210 : 'Orders execute immediately against the market maker.';
211 }
212
213 const submit = () =>
214 props.act(
215 () =>
216 api('/orders', {
217 event: e.name,
218 option: markets[option].key,
219 side,
220 price: isBook ? price.trim() : markets[option].price,
221 quantity: String(qty),
222 }),
223 `Order placed ${SEP} ${side === 'BUY' ? 'Bought' : 'Sold'} ${qty} ${e.optionNames[option]}`,
224 );
225
226 return (
227 <div className="card2 section" style={{ padding: '13px 14px', gap: 9 }}>
228 <div className="row" style={{ alignItems: 'baseline' }}>
229 <span className="lg bold grow ellipsis">
230 {e.displayId}. {e.name}
231 </span>
232 <span className="sm ink2">
233 {mechanismLabel(e.mechanism)} {SEP} Status: {e.status} {SEP} Fee: {feeLabel(e)}
234 </span>
235 </div>
236 <div className="pair">
237 {markets.map((m, i) => (
238 <button
239 key={m.key}
240 className={`optcard pick ${i === 0 ? 'yes' : 'no'}${option === i ? ' on' : ''}`}
241 onClick={() => setOption(i)}
242 >
243 <span className="row">
244 <span className={i === 0 ? 'bold yes grow ellipsis' : 'bold no grow ellipsis'}>
245 {i === 0 ? 'YES' : 'NO'} <span className="sm">{m.name}</span>
246 </span>
247 <span className={i === 0 ? 'xl bold yes' : 'xl bold no'}>{money(m.price)}</span>
248 </span>
249 <span className="sm ink2">You hold {held[i]} shares</span>
250 </button>
251 ))}
252 </div>
253 <div className="tradeform">
254 <label>
255 Action
256 <span>
257 <button className={side === 'BUY' ? 'seg on' : 'seg'} onClick={() => setSide('BUY')}>
258 Buy
259 </button>
260 <button className={side === 'SELL' ? 'seg on' : 'seg'} onClick={() => setSide('SELL')}>
261 Sell
262 </button>
263 </span>
264 </label>
265 <label>
266 Shares
267 <input
268 className={qtyOk ? 'field' : 'field bad'}
269 inputMode="numeric"
270 value={quantity}
271 onChange={(ev) => setQuantity(ev.target.value)}
272 />
273 </label>
274 {isBook && (
275 <label>
276 Price / share
277 <input
278 className={priceOk ? 'field' : 'field bad'}
279 inputMode="decimal"
280 value={price}
281 onChange={(ev) => setPrice(ev.target.value)}
282 />
283 </label>
284 )}
285 <label>
286 Estimated cost
287 <span className="lg bold" style={{ color: 'var(--ink)', padding: '7px 0' }}>
288 {qtyOk && priceOk ? money(cost) : '—'}
289 </span>
290 </label>
291 <button className="btn primary" disabled={!allowed} onClick={submit}>
292 Place {side === 'BUY' ? 'Buy' : 'Sell'} Order
293 </button>
294 </div>
295 <span className="sm ink2">{hint}</span>
296 </div>
297 );
298}
diff --git a/ui-web/src/api.ts b/ui-web/src/api.ts
new file mode 100644
index 0000000..2ce1a8d
--- /dev/null
+++ b/ui-web/src/api.ts
@@ -0,0 +1,176 @@
1
2export type Mechanism = 'LMSR' | 'ORDER_BOOK';
3export type Status = 'DRAFT' | 'ACTIVE' | 'SETTLED';
4export type FeeTiming = 'ON_PURCHASE' | 'ON_CLOSE';
5
6export interface EventSummary {
7 key: string;
8 displayId: number;
9 name: string;
10 description: string;
11 commissionPercent: number;
12 commissionTiming: FeeTiming;
13 mechanism: Mechanism;
14 status: Status;
15 optionNames: string[];
16 accountBalance: string;
17 marketMaker: string;
18}
19
20export interface Market {
21 key: string;
22 name: string;
23 price: string;
24 volume: string;
25}
26
27export interface BookOrder {
28 side: string;
29 user: string;
30 quantity: number;
31 price: string;
32 isBid: boolean;
33}
34
35export interface OrderBook {
36 optionKey: string;
37 optionName: string;
38 bestBid: string | null;
39 bestAsk: string | null;
40 spread: string | null;
41 orders: BookOrder[];
42}
43
44export interface TradeRow {
45 at: string;
46 userName: string;
47 optionName: string;
48 quantity: string;
49 pricePaid: string;
50}
51
52export interface Participant {
53 user: string;
54 tag: string;
55 yes: number;
56 no: number;
57 value: string;
58 fees: string;
59 pnl: string;
60}
61
62export interface EventDetail {
63 summary: EventSummary;
64 state: { markets: Market[]; accountBalance: string; commissionCollected: string };
65 history: TradeRow[];
66 settledMarket: string;
67 orderBooks: OrderBook[];
68 participants: Participant[];
69}
70
71export interface LedgerEntry {
72 seq: number;
73 at: string;
74 type: string;
75 amount: string;
76 balanceAfter: string;
77 note: string;
78}
79
80export interface Ledger {
81 owner: string;
82 balance: string;
83 blocked: boolean;
84 entries: LedgerEntry[];
85}
86
87export interface UserSummary {
88 username: string;
89 balance: string;
90 marketMaker: boolean;
91 online: boolean;
92}
93
94export interface Sync {
95 changed: boolean;
96 version: number;
97 events: EventSummary[];
98 users: UserSummary[];
99 account: Ledger;
100}
101
102export interface ChatMessage {
103 id: number;
104 at: string;
105 sender: string;
106 text: string;
107}
108
109export interface MarketData {
110 events: EventSummary[];
111 details: Record<string, EventDetail>;
112 users: UserSummary[];
113 account: Ledger;
114}
115
116export class ApiError extends Error {
117 constructor(
118 public status: number,
119 message: string,
120 ) {
121 super(message);
122 }
123}
124
125const BASE = '/guess-market/api';
126const UNREACHABLE = 'Cannot reach the server. Is Tomcat running on port 8080?';
127
128export async function api<T>(path: string, form?: Record<string, string>): Promise<T> {
129 let res: Response;
130 try {
131 res = await fetch(
132 BASE + path,
133 form ? { method: 'POST', body: new URLSearchParams(form) } : undefined,
134 );
135 } catch {
136 throw new ApiError(0, UNREACHABLE);
137 }
138 const text = await res.text();
139 let body: any = null;
140 try {
141 body = text ? JSON.parse(text) : null;
142 } catch {
143 }
144 if (!res.ok) {
145 throw new ApiError(res.status, body?.message ?? (res.status >= 500 ? UNREACHABLE : `The server answered ${res.status}.`));
146 }
147 return body as T;
148}
149
150export const eventPath = (name: string) => '/events/' + encodeURIComponent(name);
151
152export function num(value: string | number | null | undefined): number {
153 const n = typeof value === 'number' ? value : Number(String(value ?? '').replace(/[$,]/g, ''));
154 return Number.isNaN(n) ? 0 : n;
155}
156
157export const same = (a: string, b: string) => a.toLowerCase() === b.toLowerCase();
158
159export function money(value: string | number | null | undefined): string {
160 if (value === null || value === undefined || value === '') return '—';
161 const n = typeof value === 'number' ? value : Number(String(value).replace(/[$,]/g, ''));
162 if (Number.isNaN(n)) return String(value);
163 return (n < 0 ? '-$' : '$') + Math.abs(n).toFixed(2);
164}
165
166export const mechanismLabel = (m: Mechanism) => (m === 'LMSR' ? 'LMSR' : 'Order Book');
167
168export const CHEVRON = '\ue0b1';
169export const SEP = '\ueb04';
170
171export const optionTitle = (e: EventSummary, i: number) => `${i === 0 ? 'YES' : 'NO'} ${SEP} ${e.optionNames[i]}`;
172
173export const feeLabel = (e: EventSummary) =>
174 `${e.commissionPercent}% ${e.commissionTiming === 'ON_PURCHASE' ? 'on purchase' : 'on close'}`;
175
176export const GLYPH = { file: '\uf15b', bolt: '\uf0e7', users: '\uf0c0', chat: '\u{f0b79}' };
diff --git a/ui-web/src/graphics.tsx b/ui-web/src/graphics.tsx
new file mode 100644
index 0000000..2d452df
--- /dev/null
+++ b/ui-web/src/graphics.tsx
@@ -0,0 +1,51 @@
1
2export function Equalizer() {
3 return (
4 <svg className="eq" width="16" height="12" viewBox="0 0 16 12" aria-hidden="true">
5 <rect className="b0" x="0" width="4" height="12" rx="1" />
6 <rect className="b1" x="6" width="4" height="12" rx="1" />
7 <rect className="b2" x="12" width="4" height="12" rx="1" />
8 </svg>
9 );
10}
11
12export function Sparkline({ negative }: { negative: boolean }) {
13 return (
14 <svg className={negative ? 'spark neg' : 'spark'} width="64" height="28" viewBox="0 0 64 28" aria-hidden="true">
15 <polyline className="draw" pathLength="100" points="2,20 14,16 26,22 38,11 50,14 62,5" />
16 <circle className="rider" r="2.8" />
17 </svg>
18 );
19}
20
21export function MarketChart() {
22 return (
23 <svg className="mchart" width="300" height="162" viewBox="0 0 240 130" aria-hidden="true">
24 <line className="rule" x1="18" y1="20" x2="228" y2="20" />
25 <line className="rule" x1="18" y1="65" x2="228" y2="65" strokeDasharray="3 4" />
26 <line className="rule" x1="18" y1="110" x2="228" y2="110" />
27 <line className="rule" x1="18" y1="14" x2="18" y2="116" />
28 <text x="0" y="24">
29 1.0
30 </text>
31 <text className="lo" x="0" y="114">
32 0.0
33 </text>
34 <path className="draw y" pathLength="100" d="M22 66 C96 64 150 22 224 22" />
35 <path className="draw n" pathLength="100" d="M22 66 C96 68 150 110 224 110" />
36 <circle className="rider y" r="4" />
37 <circle className="rider n" r="4" />
38 </svg>
39 );
40}
41
42export function Pinwheel() {
43 return (
44 <svg className="pinwheel" width="20" height="20" viewBox="0 0 20 20" aria-hidden="true">
45 <g>
46 <path d="M 10 10 L 10 2 A 8 8 0 0 1 15.65 4.35 Q 12 8 10 10 Z M 10 10 L 18 10 A 8 8 0 0 1 15.65 15.65 Q 12 12 10 10 Z M 10 10 L 10 18 A 8 8 0 0 1 4.35 15.65 Q 8 12 10 10 Z M 10 10 L 2 10 A 8 8 0 0 1 4.35 4.35 Q 8 8 10 10 Z" />
47 <circle cx="10" cy="10" r="2.2" />
48 </g>
49 </svg>
50 );
51}
diff --git a/ui-web/src/main.tsx b/ui-web/src/main.tsx
new file mode 100644
index 0000000..ed3b67f
--- /dev/null
+++ b/ui-web/src/main.tsx
@@ -0,0 +1,10 @@
1import { StrictMode } from 'react';
2import { createRoot } from 'react-dom/client';
3import { App } from './App';
4import './styles.css';
5
6createRoot(document.getElementById('root')!).render(
7 <StrictMode>
8 <App />
9 </StrictMode>,
10);
diff --git a/ui-web/src/styles.css b/ui-web/src/styles.css
new file mode 100644
index 0000000..028e2d2
--- /dev/null
+++ b/ui-web/src/styles.css
@@ -0,0 +1,1068 @@
1
2@font-face {
3 font-family: 'CaskaydiaCove NF';
4 src: url('/fonts/CaskaydiaCoveNerdFont-Regular.ttf');
5}
6@font-face {
7 font-family: 'CaskaydiaCove NF';
8 font-weight: bold;
9 src: url('/fonts/CaskaydiaCoveNerdFont-Bold.ttf');
10}
11@font-face {
12 font-family: 'JetBrainsMono NF';
13 src: url('/fonts/JetBrainsMonoNerdFont-Regular.ttf');
14}
15@font-face {
16 font-family: 'JetBrainsMono NF';
17 font-weight: bold;
18 src: url('/fonts/JetBrainsMonoNerdFont-Bold.ttf');
19}
20@font-face {
21 font-family: 'FiraCode Nerd Font';
22 src: url('/fonts/FiraCodeNerdFont-Regular.ttf');
23}
24@font-face {
25 font-family: 'FiraCode Nerd Font';
26 font-weight: bold;
27 src: url('/fonts/FiraCodeNerdFont-Bold.ttf');
28}
29
30:root,
31:root[data-skin='rose-pine-dawn'] {
32 --font: 'CaskaydiaCove NF', Consolas, monospace;
33 --size: 13px;
34 --bg: #faf4ed;
35 --panel: #fffaf3;
36 --panel2: #f2e9e1;
37 --panel3: #dfdad9;
38 --line: #cecacd;
39 --ink: #575279;
40 --ink2: #797593;
41 --accent: #907aa9;
42 --accent-fg: #fffaf3;
43 --btn: #f2e9e1;
44 --btn-line: #cecacd;
45 --yes: #286983;
46 --no: #b4637a;
47 --yes-soft: #e3edf0;
48 --no-soft: #f5e6ea;
49}
50
51:root[data-skin='catppuccin'] {
52 --font: 'JetBrainsMono NF', Consolas, monospace;
53 --bg: #181825;
54 --panel: #1e1e2e;
55 --panel2: #313244;
56 --panel3: #45475a;
57 --line: #585b70;
58 --ink: #cdd6f4;
59 --ink2: #a6adc8;
60 --accent: #cba6f7;
61 --accent-fg: #1e1e2e;
62 --btn: #313244;
63 --btn-line: #585b70;
64 --yes: #a6e3a1;
65 --no: #f38ba8;
66 --yes-soft: #23312a;
67 --no-soft: #34232c;
68}
69
70:root[data-skin='gruvbox'] {
71 --font: 'FiraCode Nerd Font', Consolas, monospace;
72 --size: 13.5px;
73 --bg: #1d2021;
74 --panel: #282828;
75 --panel2: #3c3836;
76 --panel3: #504945;
77 --line: #665c54;
78 --ink: #ebdbb2;
79 --ink2: #a89984;
80 --accent: #fe8019;
81 --accent-fg: #1d2021;
82 --btn: #3c3836;
83 --btn-line: #665c54;
84 --yes: #b8bb26;
85 --no: #fb4934;
86 --yes-soft: #2b3021;
87 --no-soft: #3b2320;
88}
89
90 box-sizing: border-box;
91}
92html,
93body,
94 height: 100%;
95}
96body {
97 margin: 0;
98 background: var(--bg);
99 color: var(--ink);
100 font: var(--size) / 1.35 var(--font);
101}
102h1,
103h2,
104h3,
105p {
106 margin: 0;
107 font-weight: inherit;
108}
109
110.ink2 {
111 color: var(--ink2);
112}
113.accent {
114 color: var(--accent);
115}
116.yes {
117 color: var(--yes);
118}
119.no {
120 color: var(--no);
121}
122.bold {
123 font-weight: 700;
124}
125.xs {
126 font-size: 10.5px;
127}
128.sm {
129 font-size: 11.5px;
130}
131.base {
132 font-size: 12.5px;
133}
134.lg {
135 font-size: 14px;
136}
137.xl {
138 font-size: 17px;
139}
140.grow {
141 flex: 1;
142 min-width: 0;
143}
144.ellipsis {
145 overflow: hidden;
146 text-overflow: ellipsis;
147 white-space: nowrap;
148}
149.row {
150 display: flex;
151 align-items: center;
152 gap: 8px;
153}
154.num {
155 text-align: right;
156 white-space: nowrap;
157}
158
159button,
160input,
161select {
162 font: inherit;
163 color: inherit;
164}
165button {
166 cursor: pointer;
167}
168button:disabled {
169 opacity: 0.45;
170 cursor: default;
171}
172:focus-visible {
173 outline: 2px solid var(--accent);
174 outline-offset: 1px;
175}
176.btn {
177 border: 1px solid var(--btn-line);
178 border-radius: 5px;
179 background: var(--btn);
180 font-size: 13px;
181 font-weight: 700;
182 padding: 8px 15px;
183 white-space: nowrap;
184}
185.btn:hover:not(:disabled) {
186 opacity: 0.92;
187}
188.btn.primary {
189 background: var(--accent);
190 border-color: var(--accent);
191 color: var(--accent-fg);
192}
193.btn.destructive {
194 background: var(--no);
195 border-color: var(--no);
196 color: var(--accent-fg);
197}
198.btn.icon {
199 padding: 4px 8px;
200 min-width: 34px;
201 height: 30px;
202 display: grid;
203 place-items: center;
204}
205.btn.icon.on {
206 background: var(--panel3);
207 border-color: var(--accent);
208}
209.toggle {
210 border: 1px solid var(--btn-line);
211 border-radius: 4px;
212 background: var(--btn);
213 color: var(--ink2);
214 font-size: 12px;
215 padding: 5px 11px;
216}
217.toggle.on {
218 background: var(--accent);
219 border-color: var(--accent);
220 color: var(--accent-fg);
221}
222.seg {
223 border: 1px solid var(--btn-line);
224 background: var(--btn);
225 font-size: 12px;
226 font-weight: 700;
227 padding: 8px 15px;
228}
229.seg:first-child {
230 border-radius: 5px 0 0 5px;
231}
232.seg:last-child {
233 border-radius: 0 5px 5px 0;
234 border-left: 0;
235}
236.seg.on {
237 background: var(--accent);
238 color: var(--accent-fg);
239}
240.field {
241 background: var(--panel2);
242 border: 1px solid var(--btn-line);
243 border-radius: 5px;
244 padding: 8px 10px;
245 font-size: 13px;
246 color: var(--ink);
247 width: 96px;
248}
249.field.bad {
250 border-color: var(--no);
251 border-width: 1.5px;
252}
253.select {
254 background: var(--btn);
255 border: 1px solid var(--btn-line);
256 border-radius: 5px;
257 padding: 6px 8px;
258 font-size: 12.5px;
259}
260
261.pill {
262 display: inline-flex;
263 align-items: center;
264 gap: 7px;
265 border-radius: 3px;
266 padding: 3px 6px;
267 font-size: 10px;
268 font-weight: 700;
269 background: var(--panel3);
270 color: var(--ink2);
271 white-space: nowrap;
272}
273.pill.active {
274 background: var(--yes-soft);
275 color: var(--yes);
276}
277.pill.closed {
278 background: var(--no-soft);
279 color: var(--no);
280}
281.pill.mm {
282 background: var(--accent);
283 color: var(--accent-fg);
284}
285.pill.blocked {
286 background: var(--no);
287 color: var(--accent-fg);
288}
289.pill.resolved {
290 background: var(--yes);
291 color: var(--accent-fg);
292}
293
294.card {
295 background: var(--panel);
296 border: 1px solid var(--line);
297 border-radius: 7px;
298}
299.card2 {
300 background: var(--panel2);
301 border: 1px solid var(--line);
302 border-radius: 6px;
303}
304.table {
305 background: var(--panel);
306 border: 1px solid var(--line);
307 border-radius: 6px;
308 overflow: hidden;
309}
310.thead,
311.trow {
312 display: flex;
313 align-items: center;
314 gap: 8px;
315 padding: 8px 11px;
316}
317.thead {
318 background: var(--panel3);
319 color: var(--ink2);
320 font-size: 10.5px;
321 font-weight: 700;
322}
323.trow {
324 border-top: 1px solid var(--line);
325 font-size: 11.5px;
326}
327.trow.click {
328 cursor: pointer;
329}
330.trow.click:hover {
331 background: var(--panel2);
332}
333.trow.on {
334 background: var(--panel3);
335}
336.trow.bid {
337 background: var(--yes-soft);
338}
339.trow.ask {
340 background: var(--no-soft);
341}
342.w54 {
343 width: 54px;
344}
345.w66 {
346 width: 66px;
347}
348.w78 {
349 width: 78px;
350}
351.w92 {
352 width: 92px;
353}
354.w150 {
355 width: 150px;
356}
357
358.app {
359 display: flex;
360 flex-direction: column;
361 height: 100%;
362 min-width: 1040px;
363}
364.windowbar {
365 display: flex;
366 align-items: center;
367 gap: 10px;
368 height: 32px;
369 padding: 0 14px;
370 background: var(--panel2);
371 border-bottom: 1px solid var(--line);
372 font-size: 12.5px;
373 font-weight: 700;
374 color: var(--ink2);
375}
376.toolbar {
377 display: flex;
378 align-items: center;
379 gap: 12px;
380 padding: 12px 16px;
381 background: var(--panel);
382 border-bottom: 1px solid var(--line);
383}
384.path {
385 display: flex;
386 align-items: center;
387 gap: 10px;
388 padding: 8px 12px;
389 font-size: 12.5px;
390}
391.tabs {
392 display: flex;
393 align-items: flex-end;
394 gap: 2px;
395 padding: 6px 16px 0;
396 background: var(--panel);
397 border-bottom: 1px solid var(--line);
398}
399.tab {
400 border: 1px solid var(--line);
401 border-bottom: 0;
402 border-radius: 6px 6px 0 0;
403 background: var(--panel2);
404 color: var(--ink2);
405 font-size: 13px;
406 font-weight: 700;
407 padding: 9px 20px;
408 margin-bottom: -1px;
409}
410.tab.on {
411 background: var(--bg);
412 color: var(--ink);
413}
414.tabinfo {
415 display: flex;
416 align-items: center;
417 gap: 8px;
418 padding: 0 4px 8px;
419 font-size: 12.5px;
420 color: var(--ink2);
421}
422.content {
423 flex: 1;
424 min-height: 0;
425 display: flex;
426 gap: 12px;
427 padding: 12px 16px;
428}
429.statusbar {
430 display: flex;
431 align-items: center;
432 height: 30px;
433 padding: 0 14px;
434 background: var(--panel2);
435 border-top: 1px solid var(--line);
436 font-size: 11.5px;
437 color: var(--ink2);
438 white-space: pre;
439}
440.chatbtn {
441 border: 0;
442 background: none;
443 padding: 0 2px;
444 color: var(--ink2);
445 font-size: 14.5px;
446 cursor: pointer;
447}
448.chatbtn.on {
449 color: var(--accent);
450}
451.chat {
452 position: fixed;
453 right: 14px;
454 bottom: 31px;
455 width: 320px;
456 height: 380px;
457 display: flex;
458 flex-direction: column;
459 gap: 8px;
460 padding: 12px;
461 white-space: normal;
462 color: var(--ink);
463 box-shadow: 0 4px 18px rgb(0 0 0 / 0.3);
464 z-index: 2;
465}
466.chatlist {
467 flex: 1;
468 min-height: 0;
469 overflow-y: auto;
470 display: flex;
471 flex-direction: column;
472 gap: 9px;
473 overflow-wrap: anywhere;
474}
475.banner {
476 padding: 8px 16px;
477 font-weight: 700;
478 background: var(--no-soft);
479 color: var(--no);
480 border-bottom: 1px solid var(--no);
481}
482.toast {
483 position: fixed;
484 left: 50%;
485 bottom: 44px;
486 transform: translateX(-50%);
487 max-width: 90vw;
488 background: var(--ink);
489 color: var(--bg);
490 border-radius: 6px;
491 padding: 10px 16px;
492 font-size: 12.5px;
493 font-weight: 700;
494 z-index: 3;
495}
496.empty {
497 flex: 1;
498 display: flex;
499 flex-direction: column;
500 align-items: center;
501 justify-content: center;
502 gap: 14px;
503 text-align: center;
504}
505
506.side {
507 display: flex;
508 flex-direction: column;
509 gap: 6px;
510 padding: 12px;
511}
512.side.events {
513 width: 498px;
514}
515.side.users {
516 width: 274px;
517}
518.main {
519 flex: 1;
520 min-width: 0;
521 display: flex;
522 flex-direction: column;
523}
524.head {
525 display: flex;
526 align-items: flex-start;
527 gap: 14px;
528 padding: 14px 16px;
529 border-bottom: 1px solid var(--line);
530}
531.body {
532 flex: 1;
533 min-height: 0;
534 overflow-y: auto;
535 display: flex;
536 flex-direction: column;
537 gap: 14px;
538 padding: 14px 16px;
539}
540.body > * {
541 flex-shrink: 0;
542}
543.section {
544 display: flex;
545 flex-direction: column;
546 gap: 7px;
547}
548.section-title {
549 display: flex;
550 align-items: baseline;
551 gap: 8px;
552 font-size: 12.5px;
553 font-weight: 700;
554}
555.filter {
556 display: flex;
557 align-items: center;
558 gap: 8px;
559 margin-bottom: 4px;
560}
561.filter > span {
562 width: 74px;
563 font-size: 12.5px;
564 color: var(--ink2);
565}
566.list {
567 flex: 1;
568 min-height: 0;
569 overflow-y: auto;
570 display: flex;
571 flex-direction: column;
572 gap: 2px;
573}
574.listrow {
575 display: flex;
576 align-items: center;
577 gap: 8px;
578 width: 100%;
579 text-align: left;
580 background: transparent;
581 border: 0;
582 border-left: 3px solid transparent;
583 border-radius: 5px;
584 padding: 9px 11px;
585}
586.listrow:hover {
587 background: var(--panel2);
588}
589.listrow.on {
590 background: var(--panel3);
591 border-left-color: var(--accent);
592}
593.listrow.plain {
594 cursor: default;
595}
596.meta {
597 display: flex;
598 align-items: center;
599 flex-wrap: wrap;
600 gap: 4px 16px;
601 font-size: 12.5px;
602}
603.meta b {
604 font-weight: 700;
605}
606.pair {
607 display: grid;
608 grid-template-columns: 1fr 1fr;
609 gap: 10px;
610}
611.optcard {
612 border: 1px solid var(--line);
613 border-radius: 6px;
614 padding: 12px 14px;
615 display: flex;
616 flex-direction: column;
617 gap: 8px;
618}
619.optcard.yes {
620 background: var(--yes-soft);
621}
622.optcard.no {
623 background: var(--no-soft);
624}
625.optcard.pick {
626 background: var(--panel);
627 cursor: pointer;
628 text-align: left;
629 color: var(--ink);
630 padding: 10px 12px;
631 gap: 6px;
632}
633.optcard.pick.yes.on {
634 background: var(--yes-soft);
635 border: 1.5px solid var(--yes);
636}
637.optcard.pick.no.on {
638 background: var(--no-soft);
639 border: 1.5px solid var(--no);
640}
641.bar {
642 height: 6px;
643 border-radius: 3px;
644 background: var(--panel3);
645 overflow: hidden;
646}
647.bar i {
648 display: block;
649 height: 100%;
650 border-radius: 3px;
651 background: currentColor;
652 transition: width 0.3s;
653}
654.stats {
655 display: flex;
656 gap: 16px;
657 padding: 8px 11px;
658 font-size: 11.5px;
659}
660.stats span {
661 display: flex;
662 flex-direction: column;
663 gap: 2px;
664}
665.tradeform {
666 display: flex;
667 flex-wrap: wrap;
668 align-items: flex-end;
669 gap: 10px;
670}
671.tradeform label {
672 display: flex;
673 flex-direction: column;
674 gap: 5px;
675 font-size: 12.5px;
676 color: var(--ink2);
677}
678.balance {
679 font-size: 22px;
680 font-weight: 700;
681 color: var(--accent);
682}
683.balance.neg,
684.neg {
685 color: var(--no);
686}
687.balcell {
688 font-weight: 700;
689 color: var(--accent);
690}
691.pnl {
692 font-size: 12px;
693 font-weight: 700;
694 color: var(--yes);
695}
696.notice {
697 display: flex;
698 align-items: center;
699 gap: 11px;
700 padding: 11px 13px;
701 border-radius: 6px;
702 border: 1px solid var(--line);
703 background: var(--yes-soft);
704 font-size: 12.5px;
705}
706.notice.blocked {
707 background: var(--no-soft);
708 border-color: var(--no);
709}
710
711.chart {
712 display: grid;
713 grid-template-columns: auto 1fr;
714 gap: 4px 6px;
715 padding: 10px;
716 font-size: 10px;
717 color: var(--ink2);
718}
719.chart .yaxis {
720 display: flex;
721 flex-direction: column;
722 justify-content: space-between;
723 text-align: right;
724 border-right: 1px solid var(--line);
725 padding-right: 6px;
726 line-height: 1;
727}
728.chart .xaxis {
729 grid-column: 2;
730 display: flex;
731 justify-content: space-between;
732 border-top: 1px solid var(--line);
733 padding-top: 4px;
734}
735.chart svg {
736 width: 100%;
737 display: block;
738}
739.chart .grid {
740 stroke: var(--line);
741 stroke-width: 1;
742 opacity: 0.6;
743}
744.chart path {
745 fill: none;
746 stroke-width: 2.5;
747 stroke-linejoin: round;
748 vector-effect: non-scaling-stroke;
749}
750.chart line {
751 vector-effect: non-scaling-stroke;
752}
753.stroke-accent {
754 stroke: var(--accent);
755}
756.stroke-yes {
757 stroke: var(--yes);
758}
759.stroke-no {
760 stroke: var(--no);
761}
762
763.scrim {
764 position: fixed;
765 inset: 0;
766 display: grid;
767 place-items: center;
768 background: rgba(10, 10, 10, 0.42);
769 z-index: 2;
770}
771.dialog {
772 width: 430px;
773 max-width: calc(100vw - 32px);
774}
775.dialog > header {
776 padding: 16px 20px;
777 border-bottom: 1px solid var(--line);
778 font-size: 14px;
779 font-weight: 700;
780}
781.dialog > div {
782 display: flex;
783 flex-direction: column;
784 gap: 10px;
785 padding: 18px 20px;
786}
787.dialog > footer {
788 display: flex;
789 justify-content: flex-end;
790 gap: 9px;
791 padding: 14px 20px;
792 border-top: 1px solid var(--line);
793}
794.resolveopt {
795 flex: 1;
796 border: 1px solid var(--line);
797 border-radius: 6px;
798 background: var(--panel2);
799 font-size: 14px;
800 font-weight: 700;
801 padding: 14px 6px;
802}
803.resolveopt.yes.on {
804 background: var(--yes-soft);
805 border: 1.5px solid var(--yes);
806}
807.resolveopt.no.on {
808 background: var(--no-soft);
809 border: 1.5px solid var(--no);
810}
811
812.login {
813 height: 100%;
814 display: grid;
815 place-items: center;
816 padding: 24px;
817}
818.login form {
819 width: 380px;
820 max-width: 100%;
821 display: flex;
822 flex-direction: column;
823 gap: 8px;
824 padding: 20px 22px;
825}
826.login .field {
827 width: 100%;
828}
829
830.eq rect {
831 fill: var(--ink2);
832 transform-box: fill-box;
833 transform-origin: bottom;
834}
835.pill.active .eq rect {
836 fill: var(--yes);
837}
838.pill.closed .eq rect {
839 fill: var(--no);
840}
841.eq .b0 {
842 transform: scaleY(0.35);
843}
844.eq .b1 {
845 transform: scaleY(0.8);
846}
847.eq .b2 {
848 transform: scaleY(0.55);
849}
850.anim .eq .b0 {
851 animation: eq0 3.6s linear infinite;
852}
853.anim .eq .b1 {
854 animation: eq1 3.6s linear infinite;
855}
856.anim .eq .b2 {
857 animation: eq2 3.6s linear infinite;
858}
859@keyframes eq0 {
860 0%,
861 100% {
862 transform: scaleY(0.35);
863 }
864 30% {
865 transform: scaleY(1);
866 }
867 60% {
868 transform: scaleY(0.6);
869 }
870}
871@keyframes eq1 {
872 0%,
873 100% {
874 transform: scaleY(0.8);
875 }
876 25% {
877 transform: scaleY(0.3);
878 }
879 70% {
880 transform: scaleY(1);
881 }
882}
883@keyframes eq2 {
884 0%,
885 100% {
886 transform: scaleY(0.55);
887 }
888 45% {
889 transform: scaleY(1);
890 }
891 80% {
892 transform: scaleY(0.4);
893 }
894}
895
896.draw {
897 fill: none;
898 stroke-linecap: round;
899 stroke-linejoin: round;
900 stroke-dasharray: 100;
901 stroke-dashoffset: 0;
902}
903.rider {
904 offset-rotate: 0deg;
905 offset-distance: 100%;
906}
907.spark .draw {
908 stroke: var(--accent);
909 stroke-width: 2;
910}
911.spark .rider {
912 fill: var(--accent);
913 offset-path: path('M2 20 L14 16 L26 22 L38 11 L50 14 L62 5');
914}
915.spark.neg .draw {
916 stroke: var(--no);
917}
918.spark.neg .rider {
919 fill: var(--no);
920}
921.anim .spark .draw {
922 animation: draw70 3.6s infinite;
923}
924.anim .spark .rider {
925 animation:
926 ride70 3.6s infinite,
927 appear 3.6s linear infinite;
928}
929@keyframes draw70 {
930 0% {
931 stroke-dashoffset: 100;
932 animation-timing-function: ease-in-out;
933 }
934 70%,
935 100% {
936 stroke-dashoffset: 0;
937 }
938}
939@keyframes ride70 {
940 0% {
941 offset-distance: 0%;
942 animation-timing-function: ease-in-out;
943 }
944 70%,
945 100% {
946 offset-distance: 100%;
947 }
948}
949@keyframes appear {
950 0% {
951 opacity: 0;
952 }
953 8%,
954 100% {
955 opacity: 1;
956 }
957}
958
959.mchart .rule {
960 stroke: var(--line);
961}
962.mchart text {
963 fill: var(--ink2);
964 font-size: 9px;
965 opacity: 0.7;
966}
967.mchart .draw {
968 stroke-width: 2.5;
969}
970.mchart .y {
971 stroke: var(--yes);
972}
973.mchart .n {
974 stroke: var(--no);
975}
976.mchart .rider.y {
977 fill: var(--yes);
978 stroke: none;
979 offset-path: path('M22 66 C96 64 150 22 224 22');
980}
981.mchart .rider.n {
982 fill: var(--no);
983 stroke: none;
984 offset-path: path('M22 66 C96 68 150 110 224 110');
985}
986.anim .mchart .draw {
987 animation: draw55 3.6s infinite;
988}
989.anim .mchart .rider {
990 animation:
991 ride55 3.6s infinite,
992 appear 3.6s linear infinite;
993}
994.anim .mchart text {
995 animation: breathe 3.6s linear infinite;
996}
997.anim .mchart text.lo {
998 animation-delay: -3.2s;
999}
1000@keyframes draw55 {
1001 0% {
1002 stroke-dashoffset: 100;
1003 animation-timing-function: ease-in-out;
1004 }
1005 55%,
1006 100% {
1007 stroke-dashoffset: 0;
1008 }
1009}
1010@keyframes ride55 {
1011 0% {
1012 offset-distance: 0%;
1013 animation-timing-function: ease-in-out;
1014 }
1015 55%,
1016 100% {
1017 offset-distance: 100%;
1018 }
1019}
1020@keyframes breathe {
1021 0%,
1022 100% {
1023 opacity: 0.25;
1024 }
1025 50% {
1026 opacity: 0.7;
1027 }
1028}
1029
1030.pinwheel path {
1031 fill: var(--ink2);
1032}
1033.pinwheel circle {
1034 fill: var(--panel);
1035 stroke: var(--ink2);
1036}
1037.btn.icon.on .pinwheel path {
1038 fill: var(--accent);
1039}
1040.btn.icon.on .pinwheel circle {
1041 stroke: var(--accent);
1042}
1043.pinwheel g {
1044 transform-origin: 10px 10px;
1045}
1046.anim .pinwheel g {
1047 animation: spin 2.4s linear infinite;
1048}
1049@keyframes spin {
1050 to {
1051 transform: rotate(360deg);
1052 }
1053}
1054
1055.anim .fade {
1056 animation: fade 0.5s;
1057}
1058@keyframes fade {
1059 from {
1060 opacity: 0;
1061 }
1062}
1063
1064@media (prefers-reduced-motion: reduce) {
1065 .anim * {
1066 animation: none !important;
1067 }
1068}