mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 18:52:18 +00:00
fix(ui): right rail tabs: review fixes, launcher in the strip, strip never scrolls on common windows
Review fixes P1.1-P2.7: a panel hidden at mount gets its tab when revealed; any live opening of a rail panel makes it the owner, restores do not; a short lane scrolls the strip with a thin scrollbar and brings a newly opened tab into view once; the join and the panel cover stay inside the lane and the fillet shrinks to the room left; a share link carries an owner-collapsed peer as collapsed so the recipient opens the sender's panel; border-box on phones; the strip's column folds into the panel width at 721-760px; the focus ring draws inside the tab. The compact Radio launcher moves from Context's header into a tool slot under the tabs on desktop (back into the header for the phone sheet) and always toggles the compact player, also while Context is open; the player's Details button leads to the Radio section. The jump-to-section role, its two labels and the #804 closings of the player on Context expansion and rail layout passes are gone with it. The rail panels' own collapse arrows are hidden on desktop: the tab opens and closes a panel, Escape inside closes it and returns focus to the tab. The tabs are denser and the rail climbs toward the HUD corner above its left-rail baseline when the strip's column is taller than the lane, so the strip no longer scrolls on windows down to about 680px tall; the measuring pass keeps the strip's scroll offset. scripts/qa-radio.mjs expectations follow the launcher's new role. Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
1 parent
ff017c99ca
commit
bff1d0eb29
24 files changed
+804
-379
No files matched your search
+148
-55
@@ -10,10 +10,16 @@
|
||||
* their joined silhouette as an SVG path (railJoinPath) and keeps a join
|
||||
* element under the panels whose layers blur, tint, outline and shadow that
|
||||
* shape (styles/right-rail-tabs.css).
|
||||
*
|
||||
* The strip sits in a column with a tool slot under it. The compact Radio
|
||||
* launcher lives in the slot on desktop (radioPanelPlacement.js), where the
|
||||
* collapsed Context that carries it otherwise is hidden.
|
||||
*/
|
||||
import { msg, t } from '../i18n/index.js';
|
||||
|
||||
export const RIGHT_RAIL_TABS_ID = 'right-rail-tabs';
|
||||
export const RIGHT_RAIL_COLUMN_ID = 'right-rail-column';
|
||||
export const RIGHT_RAIL_TOOLS_ID = 'right-rail-tools';
|
||||
|
||||
/**
|
||||
* Marks the rail while its strip is mounted; styles/right-rail-tabs.css keys
|
||||
@@ -69,8 +75,9 @@ export function railTabPanels(rail) {
|
||||
*
|
||||
* @param {object} g
|
||||
* @param {{x0: number, y0: number, x1: number, y1: number}} g.panel
|
||||
* @param {{top: number, bottom: number, right: number}} g.tab The tab's
|
||||
* extent; its left edge is the panel's right edge.
|
||||
* @param {{top: number, bottom: number, right: number}|null} g.tab The tab's
|
||||
* extent; its left edge is the panel's right edge. Null draws the panel
|
||||
* alone.
|
||||
* @param {number} [g.corner] Panel corner radius, or the chamfer size.
|
||||
* @param {number} [g.tabRadius] The tab's outer corner radius.
|
||||
* @param {number} [g.fillet] Concave fillet radius at the junction.
|
||||
@@ -93,12 +100,24 @@ export function railJoinPath({
|
||||
const y0 = panel.y0 + inset;
|
||||
const x1 = panel.x1 - inset;
|
||||
const y1 = panel.y1 - inset;
|
||||
const ty0 = tab.top + inset;
|
||||
const ty1 = tab.bottom - inset;
|
||||
const tx1 = tab.right - inset;
|
||||
// No tab (it is scrolled out of the strip): the panel alone.
|
||||
const ty0 = tab ? tab.top + inset : NaN;
|
||||
const ty1 = tab ? tab.bottom - inset : NaN;
|
||||
const tx1 = tab ? tab.right - inset : NaN;
|
||||
if (style === 'chamfer') {
|
||||
const c = corner;
|
||||
const cx = (panel.x0 + panel.x1) / 2;
|
||||
// The tab's edges along the panel stay between the chamfers.
|
||||
const tyA = Math.max(ty0, y0 + c);
|
||||
const tyB = Math.max(tyA, Math.min(ty1, y1 - c));
|
||||
const edge = tab
|
||||
? [
|
||||
`L ${P(x1, tyA)}`,
|
||||
`L ${P(tx1, tyA)}`,
|
||||
`L ${P(tx1, tyB)}`,
|
||||
`L ${P(x1, tyB)}`,
|
||||
]
|
||||
: [];
|
||||
return [
|
||||
`M ${P(x0, y0 + c)}`,
|
||||
`L ${P(x0 + c, y0)}`,
|
||||
@@ -108,10 +127,7 @@ export function railJoinPath({
|
||||
`L ${P(cx + 25, y0)}`,
|
||||
`L ${P(x1 - c, y0)}`,
|
||||
`L ${P(x1, y0 + c)}`,
|
||||
`L ${P(x1, ty0)}`,
|
||||
`L ${P(tx1, ty0)}`,
|
||||
`L ${P(tx1, ty1)}`,
|
||||
`L ${P(x1, ty1)}`,
|
||||
...edge,
|
||||
`L ${P(x1, y1 - c)}`,
|
||||
`L ${P(x1 - c, y1)}`,
|
||||
`L ${P(x0 + c, y1)}`,
|
||||
@@ -122,36 +138,68 @@ export function railJoinPath({
|
||||
const R = Math.max(0, corner - inset);
|
||||
const r = Math.max(0, tabRadius - inset);
|
||||
const f = fillet + inset;
|
||||
// sweep 1 turns clockwise (convex), 0 counter-clockwise (concave).
|
||||
const arc = (radius, sweep, x, y) =>
|
||||
`A ${n(radius)} ${n(radius)} 0 0 ${sweep} ${P(x, y)}`;
|
||||
const first = tab.top - panel.y0 < 0.5;
|
||||
const d = [`M ${P(x0 + R, y0)}`];
|
||||
if (first) {
|
||||
d.push(`L ${P(tx1 - r, y0)}`, arc(r, 1, tx1, y0 + r));
|
||||
const d = [];
|
||||
let at = null;
|
||||
const same = (x, y) => at && at[0] === n(x) && at[1] === n(y);
|
||||
const move = (x, y) => {
|
||||
d.push(`M ${P(x, y)}`);
|
||||
at = [n(x), n(y)];
|
||||
};
|
||||
const line = (x, y) => {
|
||||
if (same(x, y)) return;
|
||||
d.push(`L ${P(x, y)}`);
|
||||
at = [n(x), n(y)];
|
||||
};
|
||||
// sweep 1 turns clockwise (convex), 0 counter-clockwise (concave); a zero
|
||||
// radius is a plain corner.
|
||||
const arc = (radius, sweep, x, y) => {
|
||||
if (!(radius > 0)) return line(x, y);
|
||||
d.push(`A ${n(radius)} ${n(radius)} 0 0 ${sweep} ${P(x, y)}`);
|
||||
at = [n(x), n(y)];
|
||||
};
|
||||
// The run of panel edge above or below the tab may be shorter than a fillet
|
||||
// plus a corner: shrink them to what fits, down to a straight edge shared
|
||||
// with the panel's top or bottom.
|
||||
const fit = (room) => {
|
||||
const fillet = Math.min(f, Math.max(0, room - R));
|
||||
return { fillet, corner: Math.min(R, Math.max(0, room - fillet)) };
|
||||
};
|
||||
move(x0 + R, y0);
|
||||
if (!tab) {
|
||||
line(x1 - R, y0);
|
||||
arc(R, 1, x1, y0 + R);
|
||||
line(x1, y1 - R);
|
||||
arc(R, 1, x1 - R, y1);
|
||||
} else {
|
||||
d.push(
|
||||
`L ${P(x1 - R, y0)}`,
|
||||
arc(R, 1, x1, y0 + R),
|
||||
`L ${P(x1, ty0 - f)}`,
|
||||
arc(f, 0, x1 + f, ty0),
|
||||
`L ${P(tx1 - r, ty0)}`,
|
||||
arc(r, 1, tx1, ty0 + r),
|
||||
);
|
||||
const first = tab.top - panel.y0 < 0.5;
|
||||
const last = panel.y1 - tab.bottom < 0.5;
|
||||
const above = fit(ty0 - y0);
|
||||
const below = fit(y1 - ty1);
|
||||
if (first) {
|
||||
line(tx1 - r, y0);
|
||||
arc(r, 1, tx1, y0 + r);
|
||||
} else {
|
||||
line(x1 - above.corner, y0);
|
||||
arc(above.corner, 1, x1, y0 + above.corner);
|
||||
line(x1, ty0 - above.fillet);
|
||||
arc(above.fillet, 0, x1 + above.fillet, ty0);
|
||||
line(tx1 - r, ty0);
|
||||
arc(r, 1, tx1, ty0 + r);
|
||||
}
|
||||
line(tx1, ty1 - r);
|
||||
arc(r, 1, tx1 - r, ty1);
|
||||
if (!last) {
|
||||
line(x1 + below.fillet, ty1);
|
||||
arc(below.fillet, 0, x1, ty1 + below.fillet);
|
||||
line(x1, y1 - below.corner);
|
||||
arc(below.corner, 1, x1 - below.corner, y1);
|
||||
}
|
||||
}
|
||||
d.push(
|
||||
`L ${P(tx1, ty1 - r)}`,
|
||||
arc(r, 1, tx1 - r, ty1),
|
||||
`L ${P(x1 + f, ty1)}`,
|
||||
arc(f, 0, x1, ty1 + f),
|
||||
`L ${P(x1, y1 - R)}`,
|
||||
arc(R, 1, x1 - R, y1),
|
||||
`L ${P(x0 + R, y1)}`,
|
||||
arc(R, 1, x0, y1 - R),
|
||||
`L ${P(x0, y0 + R)}`,
|
||||
arc(R, 1, x0 + R, y0),
|
||||
'Z',
|
||||
);
|
||||
line(x0 + R, y1);
|
||||
arc(R, 1, x0, y1 - R);
|
||||
line(x0, y0 + R);
|
||||
arc(R, 1, x0 + R, y0);
|
||||
d.push('Z');
|
||||
return d.join(' ');
|
||||
}
|
||||
|
||||
@@ -171,7 +219,8 @@ function panelTitle(panel) {
|
||||
* @param {(panelId: string, collapsed: boolean, options: object) => void} input.setPanelCollapsed
|
||||
* Owner callback; the strip never touches panel classes itself.
|
||||
* @param {Document} [input.documentRef]
|
||||
* @returns {{ element: HTMLElement, sync: () => void, destroy: () => void }}
|
||||
* @returns {{ element: HTMLElement, column: HTMLElement, tools: HTMLElement,
|
||||
* join: HTMLElement, sync: () => void, destroy: () => void }}
|
||||
*/
|
||||
export function createRightRailTabs({
|
||||
rail,
|
||||
@@ -183,11 +232,20 @@ export function createRightRailTabs({
|
||||
'Right rail tabs require a rail, a document and setPanelCollapsed',
|
||||
);
|
||||
}
|
||||
const column = documentRef.createElement('div');
|
||||
column.id = RIGHT_RAIL_COLUMN_ID;
|
||||
const strip = documentRef.createElement('div');
|
||||
strip.id = RIGHT_RAIL_TABS_ID;
|
||||
strip.setAttribute('role', 'tablist');
|
||||
strip.setAttribute('aria-orientation', 'vertical');
|
||||
strip.setAttribute('aria-label', t('Panels'));
|
||||
// The rail's measuring pass (rightPanelRail.js) lifts the column's lane
|
||||
// clamp, which would reset a scrolled strip; the marker has it put the
|
||||
// offset back.
|
||||
strip.setAttribute('data-rail-scroller', '');
|
||||
const tools = documentRef.createElement('div');
|
||||
tools.id = RIGHT_RAIL_TOOLS_ID;
|
||||
column.append(strip, tools);
|
||||
rail.setAttribute(RIGHT_RAIL_TABS_ATTRIBUTE, 'vertical');
|
||||
|
||||
// The join: shadow under, glass, outline over; all shaped by one path.
|
||||
@@ -264,25 +322,51 @@ export function createRightRailTabs({
|
||||
* rail pixels; the stylesheet sets the panel's minimum height from it) and
|
||||
* the joined silhouette on the join's layers. The rail can be taller than
|
||||
* its panel in the focus layout, so the join is sized from the panel,
|
||||
* extended down to cover the tab if that is shorter.
|
||||
* extended down to cover the tab if that is shorter, but never past the
|
||||
* rail's lane (--right-stack-max-height).
|
||||
*/
|
||||
let shownTab = null;
|
||||
function placeJoin(tab, panel) {
|
||||
if (!tab) {
|
||||
rail.style.removeProperty('--rail-tab-bottom');
|
||||
join.hidden = true;
|
||||
shownTab = null;
|
||||
return;
|
||||
}
|
||||
// A short lane makes the strip scroll. A newly opened tab is brought into
|
||||
// view once; after that the strip scrolls as the user wishes and the join
|
||||
// follows the visible part of the tab, or the panel alone.
|
||||
const viewHeight = strip.clientHeight;
|
||||
const scrolls = Number.isFinite(viewHeight) && viewHeight > 0;
|
||||
if (scrolls && tab !== shownTab) {
|
||||
const above = tab.offsetTop - strip.scrollTop;
|
||||
const below =
|
||||
tab.offsetTop + tab.offsetHeight - (strip.scrollTop + viewHeight);
|
||||
if (above < 0) strip.scrollTop += above;
|
||||
else if (below > 0) strip.scrollTop += below;
|
||||
}
|
||||
shownTab = tab;
|
||||
const top = tab.offsetTop - (strip.scrollTop || 0);
|
||||
rail.style.setProperty('--rail-tab-bottom', `${top + tab.offsetHeight}px`);
|
||||
const computed = documentRef.defaultView?.getComputedStyle?.(rail);
|
||||
const corner = token(computed, '--right-rail-corner', 16);
|
||||
const tabRadius = token(computed, '--right-rail-tab-radius', 10);
|
||||
const fillet = token(computed, '--right-rail-fillet', 8);
|
||||
const lane = token(computed, '--right-stack-max-height', Infinity);
|
||||
const chamfer =
|
||||
computed?.getPropertyValue?.('--right-rail-join-style').trim() ===
|
||||
'chamfer';
|
||||
const tabTop = (strip.offsetTop || 0) + top;
|
||||
const tabBottom = tabTop + tab.offsetHeight;
|
||||
// Tab offsets are relative to the strip, the strip's to the column, the
|
||||
// column's to the rail.
|
||||
const stripTop = (column.offsetTop || 0) + (strip.offsetTop || 0);
|
||||
const stripLeft = (column.offsetLeft || 0) + (strip.offsetLeft || 0);
|
||||
let tabTop = stripTop + top;
|
||||
let tabBottom = tabTop + tab.offsetHeight;
|
||||
if (scrolls) {
|
||||
tabTop = Math.max(tabTop, stripTop);
|
||||
tabBottom = Math.min(tabBottom, stripTop + viewHeight);
|
||||
}
|
||||
const visible = tabBottom - tabTop >= 1;
|
||||
const geometry = {
|
||||
panel: {
|
||||
x0: panel.offsetLeft,
|
||||
@@ -290,16 +374,20 @@ export function createRightRailTabs({
|
||||
x1: panel.offsetLeft + panel.offsetWidth,
|
||||
y1: Math.max(
|
||||
panel.offsetTop + panel.offsetHeight,
|
||||
tabBottom + fillet + 4 + corner,
|
||||
visible ? Math.min(lane, tabBottom + fillet + 4 + corner) : 0,
|
||||
),
|
||||
},
|
||||
tab: {
|
||||
top: tabTop,
|
||||
bottom: tabBottom,
|
||||
right: (strip.offsetLeft || 0) + tab.offsetLeft + tab.offsetWidth,
|
||||
},
|
||||
tab: visible
|
||||
? {
|
||||
top: tabTop,
|
||||
bottom: tabBottom,
|
||||
right: stripLeft + tab.offsetLeft + tab.offsetWidth,
|
||||
}
|
||||
: null,
|
||||
corner,
|
||||
tabRadius,
|
||||
tabRadius: visible
|
||||
? Math.min(tabRadius, (tabBottom - tabTop) / 2)
|
||||
: tabRadius,
|
||||
fillet,
|
||||
style: chamfer ? 'chamfer' : 'round',
|
||||
};
|
||||
@@ -318,11 +406,15 @@ export function createRightRailTabs({
|
||||
/** Reconcile tabs with the rail: order, visibility, selection, labels. */
|
||||
function sync() {
|
||||
if (destroyed) return;
|
||||
// The tablist precedes its panels in the tab order, so Tab from the open
|
||||
// tab lands inside the open panel. The rail owner moves panels in at
|
||||
// start-up; keep the strip first afterwards too.
|
||||
if (rail.firstElementChild !== strip) rail.prepend(strip);
|
||||
// The column precedes its panels in the tab order, so Tab from the open
|
||||
// tab reaches the tool slot and then the open panel. The rail owner moves
|
||||
// panels in at start-up; keep the column first afterwards too.
|
||||
if (rail.firstElementChild !== column) rail.prepend(column);
|
||||
if (join.parentElement !== rail) rail.append(join);
|
||||
// Hidden panels too: Weather and Recent Imagery arrive hidden and their
|
||||
// owners reveal them by attribute, which must create their tabs.
|
||||
for (const panel of rail.children)
|
||||
if (panel.matches?.('[data-panel-id]')) observe(panel);
|
||||
const panels = railTabPanels(rail);
|
||||
const focusOwner =
|
||||
panels.find((panel) => !panel.classList.contains('collapsed')) ||
|
||||
@@ -344,7 +436,6 @@ export function createRightRailTabs({
|
||||
tab.title = t(collapsed ? msg('Expand {name}') : msg('Collapse {name}'), {
|
||||
name,
|
||||
});
|
||||
observe(panel);
|
||||
}
|
||||
const live = new Set(panels.map((panel) => panel.id));
|
||||
for (const [id, entry] of entries) {
|
||||
@@ -379,12 +470,14 @@ export function createRightRailTabs({
|
||||
strip.addEventListener('keydown', onKeydown);
|
||||
strip.addEventListener('scroll', onScroll, { passive: true });
|
||||
observer?.observe(rail, { childList: true });
|
||||
rail.prepend(strip);
|
||||
rail.prepend(column);
|
||||
rail.append(join);
|
||||
sync();
|
||||
|
||||
return {
|
||||
element: strip,
|
||||
column,
|
||||
tools,
|
||||
join,
|
||||
sync,
|
||||
destroy() {
|
||||
@@ -395,7 +488,7 @@ export function createRightRailTabs({
|
||||
strip.removeEventListener('click', onClick);
|
||||
strip.removeEventListener('keydown', onKeydown);
|
||||
strip.removeEventListener('scroll', onScroll);
|
||||
strip.remove();
|
||||
column.remove();
|
||||
join.remove();
|
||||
rail.removeAttribute(RIGHT_RAIL_TABS_ATTRIBUTE);
|
||||
placeJoin(null, null);
|
||||
|
||||
Reference in new issue
Block a user