Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/viewer/app/i18n/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,9 @@ export const RU: Record<string, string> = {
// ⚙️ the navbar switches once more (ui/LookSettings.tsx)
'User preferences': 'Настройки пользователя',
'The language of the app': 'Язык приложения',
'Scrollbars of the tables, in the margins around the card; none: scroll with the wheel or a finger': 'Полосы прокрутки таблиц, в отступах вокруг карточки; без них таблица листается колесом или пальцем',
'Scrollbars of the page and the tables, in the margins around the cards, and the seconds they stay after a scroll; no side: scroll with the wheel or a finger': 'Полосы прокрутки страницы и таблиц, в отступах вокруг карточек, и сколько секунд они видны после прокрутки; без сторон листайте колесом или пальцем',
'Seconds the scrollbars stay after a scroll': 'Сколько секунд полосы видны после прокрутки',
'{n} s': '{n} с',
'Scrollbars': 'Полосы прокрутки',
'Right': 'Справа',
'Below': 'Снизу',
Expand Down
25 changes: 25 additions & 0 deletions src/viewer/app/scroll-shown.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// <reference types="bun" />
/// <reference lib="esnext" />
import { expect, test } from 'bun:test';
import { parseShown, saveShown, scrollShown, shownMs } from './scroll-shown';

test('3 s by default, only the offered choices are read back', () => {
expect(parseShown(null)).toBe(3);
expect(parseShown(undefined)).toBe(3);
expect(parseShown('')).toBe(3);
expect(parseShown('10')).toBe(10);
expect(parseShown('1')).toBe(1);
expect(parseShown('7')).toBe(3);
expect(parseShown('abc')).toBe(3);
});

test('a choice holds at once and is kept as the number of seconds', () => {
const kept: Record<string, string> = {};
saveShown(5, { setItem: (k, v) => { kept[k] = v; } });
expect(scrollShown.get()).toBe(5);
expect(shownMs()).toBe(5000);
expect(kept['accounts.scrollbarSeconds']).toBe('5');
saveShown(4, { setItem: (k, v) => { kept[k] = v; } });
expect(scrollShown.get()).toBe(3);
saveShown(3, undefined);
});
30 changes: 30 additions & 0 deletions src/viewer/app/scroll-shown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference lib="esnext" />
import { createStore } from '../../shared/store';

/**
* How long the scrollbars stay after a scroll stops, chosen in ⚙️ Settings on the line of the gutters (owner 2026-12-03:
* "add in settings time configuration how many seconds it will be visible after moving", "right after a [the sides] in
* the same line"): a few fixed choices, 3 s by default (owner 2026-12-02: "3 seconds after stopped"). It holds for every
* scrollbar of the app: the page's, the tables' in the gutters (ui/GutterScrollbars.tsx) and every other box
* (ui/scrollbars.ts). Kept in this browser as the number of seconds
*/
export const SHOWN_SECONDS: readonly number[] = [1, 2, 3, 5, 10];
export const DEFAULT_SHOWN = 3;
export const SHOWN_KEY = 'accounts.scrollbarSeconds';

/** the stored text back to seconds: nothing stored or a value not offered = the default */
export function parseShown(raw: string | null | undefined): number {
const n = Number(raw);
return raw && SHOWN_SECONDS.indexOf(n) >= 0 ? n : DEFAULT_SHOWN;
}

const storage = (): Storage | undefined => { try { return globalThis.localStorage; } catch { return undefined; } };
const read = (): number => { try { return parseShown(storage()?.getItem(SHOWN_KEY)); } catch { return DEFAULT_SHOWN; } };
export const scrollShown = createStore<number>(read());
/** the time in milliseconds, read at each scroll, so a new choice holds at once */
export const shownMs = (): number => scrollShown.get() * 1000;
export function saveShown(seconds: number, to: Pick<Storage, 'setItem'> | undefined = storage()): void {
const s = parseShown(String(seconds));
scrollShown.set(s);
try { to?.setItem(SHOWN_KEY, String(s)); } catch { /* private window */ }
}
14 changes: 0 additions & 14 deletions src/viewer/app/scrollbar-room.test.ts

This file was deleted.

9 changes: 0 additions & 9 deletions src/viewer/app/scrollbar-room.ts

This file was deleted.

16 changes: 9 additions & 7 deletions src/viewer/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import { Positions } from './Positions';
import { EdgeScrollRow } from './EdgeScrollRow';
import { SettingsPanel, SettingsTools } from './SettingsPanel';
import { SlidePanel } from './SlidePanel';
import { useScrollbarRoom } from './useScrollbarRoom';
import { TabLine } from './TabLine';
import { Summary } from './Summary';
import { animate } from './animate';
import { readTime } from './format';
import { GutterScrollbars } from './GutterScrollbars';
import { useStore } from './useStore';
import { useTheme } from './useTheme';
import { PHONE_QUERY, useMedia } from './useMedia';
Expand Down Expand Up @@ -138,7 +138,6 @@ export function App() {
const flow = phone && openTab !== 'positions' && !!ds;
const page = useRef<HTMLDivElement>(null);
const scrollBox = useRef<HTMLDivElement>(null);
useScrollbarRoom(scrollBox, !flow);
const tabsBox = useRef<HTMLDivElement>(null);
const [past, setPast] = useState(false);
useEffect(() => {
Expand Down Expand Up @@ -249,11 +248,12 @@ export function App() {
<SettingsPanel userscript={userscript} done={done} fresh={!setupStarted(setupState(userscript))} expand={expandSetup} theme={theme} />
</div>
</SlidePanel>
{/* the right gutter less the room of its own scrollbar, kept even when nothing scrolls (stable), so the cards end on the
navbar's line with or without a scrollbar (owner 2026-12-03, app/scrollbar-room.ts); what is left of the gutter is
split in two, half a margin outside the bar and half a padding inside, so the bar runs in the middle of the
gutter (owner 2026-12-03: "can we have scroll be in a middle of our gap?"), like the bars of the tables */}
<div ref={scrollBox} className={flow ? 'flex-none px-4' : 'min-h-0 flex-1 overflow-y-auto px-4 pr-[max(0px,calc((1rem-var(--bar,0px))/2))] mr-[max(0px,calc((1rem-var(--bar,0px))/2))] [scrollbar-gutter:stable] lg:px-6 lg:pr-[max(0px,calc((1.5rem-var(--bar,0px))/2))] lg:mr-[max(0px,calc((1.5rem-var(--bar,0px))/2))]'} data-scroll>
{/* the page scrolls in this box; its own scrollbar is hidden and ours runs in the middle of the gutter right of the
cards (and left of them if chosen), like the bars of the tables, for the seconds chosen in ⚙️ Settings (owner
2026-12-03: "vertical scroll is hiding too fast and its not in a mid of here", "our configuration should be
applied to the whole site and all its pages"); the browser's own bar stood at the window's edge and a Mac hid it
after a second. The cards end on the navbar's line, the frame of the bars is the tabs panel */}
<div ref={scrollBox} className={flow ? 'flex-none px-4' : 'scrollbar-hidden min-h-0 flex-1 overflow-y-auto px-4 lg:px-6'} data-scroll>
{/* the page tabs get a panel of their own under the navbar, in its look (owner 2026-11-24: "lets add same panel as
our navbar, but it will contains only tabs"): the tabs on the left, our read time on the right ("As of": Fidelity's
own keeps the page load time after Refresh Positions); the gap above is the gutter, like between the cards, and it is
Expand Down Expand Up @@ -315,6 +315,8 @@ export function App() {
<footer className={`flex min-h-4 shrink-0 items-center justify-center px-4 text-center text-[0.625rem] leading-tight text-slate-600 dark:text-slate-400 lg:min-h-6 lg:px-6 ${flow ? 'sticky bottom-0 z-10 bg-slate-100 dark:bg-slate-950' : ''}`}>
<a href="https://github.com/daggerok/accounts" target="_blank" rel="noreferrer" className="underline decoration-dotted hover:text-slate-900 dark:hover:text-slate-200">daggerok &copy; {year}</a>
</footer>
{/* the page's own scrollbar in the gutters (see the scrolling box above); on a phone the whole page scrolls instead */}
{!flow && <GutterScrollbars box={scrollBox} frame={tabsBox} />}
</div>
);
}
18 changes: 10 additions & 8 deletions src/viewer/ui/GutterScrollbars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import { useEffect, useRef, useState } from 'react';
import { createPortal } from 'react-dom';
import { gutterBars, movedAxes, scrollFor, type Bar } from '../app/gutter-bars';
import { gutterSides, type GutterSide } from '../app/gutter-sides';
import { SCROLL_SHOWN_MS } from './scrollbars';
import { shownMs } from '../app/scroll-shown';
import { useStore } from './useStore';

// The scrollbars of a table box drawn in the page's gutters, outside the card (app/gutter-bars.ts says where): the box
// carries `scrollbar-hidden`, so its own bars take no room and cover no value. Like the bars of the rest of the page they
// show while the box scrolls and 3 s after (only the bars of the way it moved: a scroll down shows no sideways bar), and while the pointer is over them; the thumb drags, a press on the track
// moves the thumb there. `frame`: the card around the box (default: the closest .card)
// The scrollbars of a table box, and of the page itself (ui/App.tsx), drawn in the page's gutters, outside the card
// (app/gutter-bars.ts says where): the box carries `scrollbar-hidden`, so its own bars take no room and cover no value.
// They show while the box scrolls and the seconds chosen in ⚙️ Settings after (app/scroll-shown.ts; only the bars of the
// way it moved: a scroll down shows no sideways bar), and while the pointer is over them; the thumb drags, a press on the
// track moves the thumb there. `frame`: the card around the box (default: the closest .card)
type Dir = 'v' | 'l' | 'h' | 't'; // the right and left gutters scroll down, the bottom and top ones sideways
const across = (d: Dir): boolean => d === 'h' || d === 't';
// the side chosen in ⚙️ Settings for each bar (app/gutter-sides.ts)
Expand All @@ -29,8 +30,9 @@ export function GutterScrollbars({ box, frame }: { box: React.RefObject<HTMLElem
useEffect(() => {
const el = box.current;
if (!el) return undefined;
// inside a ⤢ window the bars go into the window, above its dimmed page
setHost(el.closest<HTMLElement>('[role="dialog"]') ?? document.body);
// inside a ⤢ window the bars go into the window, above its dimmed page; inside a sliding panel (⚙️ Settings) into
// its layer, above the page and its halo
setHost(el.closest<HTMLElement>('[role="dialog"]') ?? el.closest<HTMLElement>('[data-overlay]') ?? document.body);
let frameId = 0;
const measure = (): void => {
frameId = 0;
Expand All @@ -45,7 +47,7 @@ export function GutterScrollbars({ box, frame }: { box: React.RefObject<HTMLElem
const show = (way: 'down' | 'across'): void => {
setShown((s) => (s[way] ? s : { ...s, [way]: true }));
if (hide[way] !== undefined) clearTimeout(hide[way]);
hide[way] = setTimeout(() => setShown((s) => ({ ...s, [way]: false })), SCROLL_SHOWN_MS);
hide[way] = setTimeout(() => setShown((s) => ({ ...s, [way]: false })), shownMs());
};
const onScroll = (): void => {
soon();
Expand Down
28 changes: 21 additions & 7 deletions src/viewer/ui/LookSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { ThemeMode } from '../../shared/theme';
import { GUTTER_SIDES, gutterSides, saveSides, toggleSide, type GutterSide } from '../app/gutter-sides';
import { t } from '../app/i18n';
import { SHOWN_SECONDS, saveShown, scrollShown } from '../app/scroll-shown';
import { LangButton, ThemeButton, WatchButton } from './IconButtons';
import { PILL_GAP, pillClass, pillStyle } from './Pills';
import { SettingRow } from './SettingRow';
Expand All @@ -28,18 +29,31 @@ export function WatchSetting({ userscript }: { userscript: string | null }) {
);
}

/** the gutters that carry the tables' scrollbars (app/gutter-sides.ts): a chip a side, any number on, none = no bars */
/**
* The gutters that carry the scrollbars of the page and the tables (app/gutter-sides.ts): a chip a side, any number on,
* none = no bars; right after them on the same line the seconds they stay after a scroll, one chosen
* (app/scroll-shown.ts; owner 2026-12-03: "right after a [the sides] in the same line")
*/
export function ScrollbarsSetting() {
const sides = useStore(gutterSides);
const seconds = useStore(scrollShown);
const name: Record<GutterSide, string> = { right: t('Right'), bottom: t('Below'), left: t('Left'), top: t('Above') };
return (
<SettingRow control={
<div role="group" aria-label={t('Scrollbars')} className={`flex flex-none items-center ${PILL_GAP}`} data-scrollbar-sides={sides.join(',')}>
{GUTTER_SIDES.map((s) => {
const on = sides.indexOf(s) >= 0;
return <button key={s} type="button" aria-pressed={on} className={pillClass(on)} style={pillStyle(on)} onClick={() => saveSides(toggleSide(sides, s))}>{name[s]}</button>;
})}
<div className="flex min-w-0 max-w-full flex-wrap items-center gap-x-3 gap-y-1">
<div role="group" aria-label={t('Scrollbars')} className={`flex flex-none items-center ${PILL_GAP}`} data-scrollbar-sides={sides.join(',')}>
{GUTTER_SIDES.map((s) => {
const on = sides.indexOf(s) >= 0;
return <button key={s} type="button" aria-pressed={on} className={pillClass(on)} style={pillStyle(on)} onClick={() => saveSides(toggleSide(sides, s))}>{name[s]}</button>;
})}
</div>
<div role="radiogroup" aria-label={t('Seconds the scrollbars stay after a scroll')} className={`flex flex-none items-center ${PILL_GAP}`} data-scrollbar-seconds={seconds}>
{SHOWN_SECONDS.map((n) => {
const on = n === seconds;
return <button key={n} type="button" role="radio" aria-checked={on} className={pillClass(on)} style={pillStyle(on)} onClick={() => saveShown(n)}>{t('{n} s', { n })}</button>;
})}
</div>
</div>
}>{t('Scrollbars of the tables, in the margins around the card; none: scroll with the wheel or a finger')}</SettingRow>
}>{t('Scrollbars of the page and the tables, in the margins around the cards, and the seconds they stay after a scroll; no side: scroll with the wheel or a finger')}</SettingRow>
);
}
7 changes: 6 additions & 1 deletion src/viewer/ui/SlidePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { useEffect, useRef, useState } from 'react';
import { t } from '../app/i18n';
import { panelRoom, pressCloses } from '../app/overlay';
import { GutterScrollbars } from './GutterScrollbars';

// A panel that slides down under the toolbar and back up (pattern slide-down-panels, its overlay form): it lies OVER the
// page (owner 2026-12-03: "do not move whole page content when we open settings ... slide down like now, but on top of
Expand All @@ -11,6 +12,7 @@ import { panelRoom, pressCloses } from '../app/overlay';
// (the Settings resets, owner 2026-11-24). Above the gutter scrollbars (z 40), under the ⤢ windows and the 🔔 popups (z 50)
export function SlidePanel({ open, title, onClose, id, children, tools }: { open: boolean; title: string; onClose: () => void; id: string; children: React.ReactNode; tools?: React.ReactNode }) {
const box = useRef<HTMLElement>(null);
const body = useRef<HTMLDivElement>(null);
const [room, setRoom] = useState<number | undefined>(undefined);
const close = useRef(onClose);
close.current = onClose;
Expand Down Expand Up @@ -76,7 +78,10 @@ export function SlidePanel({ open, title, onClose, id, children, tools }: { open
</div>
<button type="button" className="tb self-start" title={t('Close')} aria-label={t('Close')} onClick={onClose}>✕</button>
</div>
<div className="min-h-0 overflow-y-auto px-6 py-4" data-panel-body>{children}</div>
{/* its scrollbar runs in the gutter right of the panel, like the page's and the tables' (owner 2026-12-03: "our
configuration should be applied to the whole site"), drawn in this layer so the halo does not cover it */}
<div ref={body} className="scrollbar-hidden min-h-0 overflow-y-auto px-6 py-4" data-panel-body>{children}</div>
{open && <GutterScrollbars box={body} frame={box} />}
</section>
</div>
</div>
Expand Down
15 changes: 15 additions & 0 deletions src/viewer/ui/scrollbars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@ test('the real timers work when called through the default (a method call of set
expect(box.classList.contains('is-scrolling')).toBe(false);
stop();
});

test('the time is read at each scroll, so a new choice in ⚙️ Settings holds at once', () => {
const asked: number[] = [];
const set = ((_fn: () => void, ms: number) => { asked.push(ms); return asked.length; }) as unknown as typeof setTimeout;
const clear = (() => undefined) as unknown as typeof clearTimeout;
let seconds = 3;
const box = document.createElement('div');
document.body.appendChild(box);
const stop = revealScrollbars(document, () => seconds * 1000, { set, clear });
box.dispatchEvent(new Event('scroll'));
seconds = 10;
box.dispatchEvent(new Event('scroll'));
expect(asked).toEqual([3000, 10000]);
stop();
});
Loading