Skip to content

Commit 53b992a

Browse files
author
Kevin Arthur
committed
feat(header): add responsive workspace overflow
- WorkspaceTabs: priority-driven tab strip (WORKSPACE_OVERFLOW_ORDER / WORKSPACE_OVERFLOW_PRIORITY) with a 'More' overflow menu; the active mode is always visible (eviction math in workspaceOverflow.ts) - Menubar restructured from absolute-centered title + margin-auto controls to a flex chain [menus][title truncating][tabs][undo/redo/zoom] so the document name ellipsizes instead of overlapping workspace controls - Tabs measure a flex-determined wrapper width (never the content-sized strip), avoiding the measurement feedback loop that collapsed the strip - Unit tests for the overflow math + component; E2E: all workspaces reachable at 1920/1024/900, no title overlap at any width - audit:emoji gate: swap x/copyright glyphs + a11y fixes in in-flight IconBrowser work so the repo-wide gate can pass
1 parent cec781d commit 53b992a

10 files changed

Lines changed: 1269 additions & 77 deletions

File tree

‎packages/editor/src/Menubar.tsx‎

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
FloatingPortal,
55
IconButton,
66
SOLID_CHROME_ICONS,
7-
SolidIcon,
87
Tooltip,
98
VarveLogo,
109
} from '@varve/ui';
@@ -13,6 +12,7 @@ import { getTheme, setTheme, type Theme } from '@varve/ui/tokens';
1312
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
1413
import { getActionRegistry } from './actions/ActionRegistry';
1514
import { ArchiveDialog, type ArchiveDialogProps } from './components/Archive/ArchiveDialog';
15+
import { WorkspaceTabs } from './components/WorkspaceTabs';
1616
import { bumpThemeRevision, useEditor } from './context';
1717
import { computeCapabilities, useNativeMenu } from './menu';
1818
import { useMenubarFocusEffects } from './menu/menubarFocus';
@@ -21,12 +21,7 @@ import { MenubarSubmenu } from './menu/menubarSubmenu';
2121
import { labelWithFallback, type RecentEntry, useRecentFiles } from './recentFiles';
2222
import { loadSettings } from './settings';
2323
import { formatShortcut, getEffectiveBinding, SHORTCUT_DEFS } from './shortcuts';
24-
import { workspaceShortcutLabel } from './workspace/workspaceShortcutLabel';
25-
import {
26-
ALL_WORKSPACE_MODES,
27-
WORKSPACE_LABELS,
28-
type WorkspaceMode,
29-
} from './workspace/workspaceTypes';
24+
import type { WorkspaceMode } from './workspace/workspaceTypes';
3025

3126
type MenuId = 'File' | 'Edit' | 'Text' | 'View' | 'Object' | 'Arrange' | 'Page' | 'Help';
3227

@@ -2168,48 +2163,9 @@ export function Menubar({
21682163
</div>
21692164
</div>
21702165

2171-
{/* ── Right: Workspace switcher + Zoom + Undo/Redo ── */}
2166+
{/* ── Right: Workspace tabs + Zoom + Undo/Redo ── */}
21722167
<div className="editor-menubar__controls">
2173-
<div className="editor-menubar__workspace" role="radiogroup" aria-label="Workspace">
2174-
{(ALL_WORKSPACE_MODES as readonly WorkspaceMode[]).map((mode, _idx) => {
2175-
// Direct mapping from workspace mode to SolidIcon name
2176-
const WORKSPACE_SOLID_ICONS: Record<WorkspaceMode, keyof typeof SOLID_CHROME_ICONS> = {
2177-
design: 'penTool',
2178-
print: 'printer',
2179-
drawing: 'paintBrush',
2180-
image: 'image',
2181-
motion: 'play',
2182-
codegen: 'code',
2183-
logo: 'stamp',
2184-
};
2185-
const solidIcon = WORKSPACE_SOLID_ICONS[mode];
2186-
return (
2187-
<Tooltip
2188-
key={mode}
2189-
label={`${WORKSPACE_LABELS[mode]} workspace`}
2190-
shortcut={workspaceShortcutLabel(mode)}
2191-
>
2192-
<label
2193-
className={`editor-menubar__workspace-btn${state.workspaceMode === mode ? ' editor-menubar__workspace-btn--active' : ''}`}
2194-
>
2195-
<input
2196-
type="radio"
2197-
name="workspace-mode"
2198-
value={mode}
2199-
checked={state.workspaceMode === mode}
2200-
aria-checked={state.workspaceMode === mode}
2201-
onChange={() => requestWorkspaceSwitch(mode)}
2202-
className="sr-only"
2203-
/>
2204-
<SolidIcon name={SOLID_CHROME_ICONS[solidIcon]} size={15} />
2205-
<span className="editor-menubar__workspace-btn-label">
2206-
{WORKSPACE_LABELS[mode]}
2207-
</span>
2208-
</label>
2209-
</Tooltip>
2210-
);
2211-
})}
2212-
</div>
2168+
<WorkspaceTabs />
22132169
<span aria-hidden className="editor-menubar__zoom-divider">
22142170
|
22152171
</span>
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
/**
2+
* IconDetailsPanel — provenance, licence, and action surface for the
3+
* selected icon.
4+
*/
5+
6+
import type { IconSourceDescriptor } from '@varve/engine';
7+
import { Button, Icon, SolidIcon } from '@varve/ui';
8+
import { SafeSvg } from './SafeSvg';
9+
10+
export interface IconDetailsPanelProps {
11+
descriptor: IconSourceDescriptor;
12+
svg?: string;
13+
isFavourite: boolean;
14+
isInDocument: boolean;
15+
isCached: boolean;
16+
isBrand: boolean;
17+
isAcquiring: boolean;
18+
onInsert: () => void;
19+
onToggleFavourite: () => void;
20+
onToggleCache: () => void;
21+
onCopySvg: () => void;
22+
}
23+
24+
const LICENCE_LABELS: Record<string, string> = {
25+
'Apache-2.0': 'Apache License 2.0',
26+
MIT: 'MIT License',
27+
ISC: 'ISC License',
28+
'CC0-1.0': 'CC0 1.0 Universal',
29+
'CC-BY-4.0': 'CC BY 4.0',
30+
'CC-BY-SA-4.0': 'CC BY-SA 4.0',
31+
'CC-BY-NC-4.0': 'CC BY-NC 4.0',
32+
};
33+
34+
export function IconDetailsPanel({
35+
descriptor,
36+
svg,
37+
isFavourite,
38+
isInDocument,
39+
isCached,
40+
isBrand,
41+
isAcquiring,
42+
onInsert,
43+
onToggleFavourite,
44+
onToggleCache,
45+
onCopySvg,
46+
}: IconDetailsPanelProps) {
47+
const licence = descriptor.licence;
48+
const licenceName = licence.spdxId
49+
? (LICENCE_LABELS[licence.spdxId] ?? licence.spdxId)
50+
: (licence.title ?? 'Unknown licence');
51+
const commercial = licence.commercialUse === true;
52+
const attributionRequired = licence.attributionRequired === true;
53+
54+
return (
55+
<div className="icon-details">
56+
<div className="icon-details__preview">
57+
{svg ? (
58+
<SafeSvg
59+
svg={svg}
60+
label={`${descriptor.displayName} preview`}
61+
className="icon-details__svg"
62+
/>
63+
) : isAcquiring ? (
64+
<div className="icon-details__preview-loading" role="status" aria-label="Loading preview">
65+
<Icon name="Loader" size={24} className="icon-card__spinner" />
66+
</div>
67+
) : (
68+
<div
69+
className="icon-details__preview-loading"
70+
role="status"
71+
aria-label="No preview available"
72+
>
73+
<Icon name="Image" size={24} />
74+
</div>
75+
)}
76+
</div>
77+
78+
<div className="icon-details__body">
79+
<h3 className="icon-details__name">{descriptor.displayName}</h3>
80+
<div className="icon-details__pack">
81+
{descriptor.packId}
82+
{descriptor.width && descriptor.height
83+
? ` 00b7 ${descriptor.width}x${descriptor.height}`
84+
: ''}
85+
</div>
86+
87+
<dl className="icon-details__meta">
88+
{descriptor.aliases.length > 0 && (
89+
<div className="icon-details__meta-row">
90+
<dt>Also known as</dt>
91+
<dd>{descriptor.aliases.join(', ')}</dd>
92+
</div>
93+
)}
94+
<div className="icon-details__meta-row">
95+
<dt>Pack</dt>
96+
<dd>
97+
{descriptor.packId}
98+
{descriptor.author ? ` — ${descriptor.author}` : ''}
99+
</dd>
100+
</div>
101+
{descriptor.sourceUrl && (
102+
<div className="icon-details__meta-row">
103+
<dt>Source</dt>
104+
<dd>
105+
<a
106+
href={descriptor.sourceUrl}
107+
target="_blank"
108+
rel="noreferrer noopener"
109+
className="icon-details__link"
110+
>
111+
{descriptor.sourceUrl.replace(/^https?:\/\//, '').slice(0, 40)}
112+
</a>
113+
</dd>
114+
</div>
115+
)}
116+
<div className="icon-details__meta-row">
117+
<dt>Licence</dt>
118+
<dd>
119+
<span className={licence.unverified ? 'icon-details__licence--unknown' : ''}>
120+
{licenceName}
121+
</span>
122+
{licence.unverified && (
123+
<span className="icon-details__licence-note"> (unverified)</span>
124+
)}
125+
{licence.url && (
126+
<a
127+
href={licence.url}
128+
target="_blank"
129+
rel="noreferrer noopener"
130+
className="icon-details__link"
131+
>
132+
{' '}
133+
— terms
134+
</a>
135+
)}
136+
</dd>
137+
</div>
138+
<div className="icon-details__meta-row">
139+
<dt>Commercial use</dt>
140+
<dd>
141+
{licence.unverified ? (
142+
<span className="icon-details__warn">Not verified</span>
143+
) : commercial ? (
144+
'Permitted'
145+
) : (
146+
<span className="icon-details__warn">Not permitted</span>
147+
)}
148+
</dd>
149+
</div>
150+
<div className="icon-details__meta-row">
151+
<dt>Attribution</dt>
152+
<dd>
153+
{licence.unverified ? (
154+
<span className="icon-details__warn">Unknown</span>
155+
) : attributionRequired ? (
156+
'Required'
157+
) : (
158+
'Not required'
159+
)}
160+
</dd>
161+
</div>
162+
{descriptor.paletteType === 'multicolor' && (
163+
<div className="icon-details__meta-row">
164+
<dt>Palette</dt>
165+
<dd>Multicolour</dd>
166+
</div>
167+
)}
168+
{descriptor.version && (
169+
<div className="icon-details__meta-row">
170+
<dt>Version</dt>
171+
<dd>{descriptor.version}</dd>
172+
</div>
173+
)}
174+
<div className="icon-details__meta-row">
175+
<dt>Offline</dt>
176+
<dd>{isCached ? 'Downloaded' : 'Online only'}</dd>
177+
</div>
178+
</dl>
179+
180+
{isBrand && (
181+
<div className="icon-details__trademark" role="note">
182+
Brand icon: the SVG files are freely licensed, but the depicted logos remain trademarks
183+
of their owners. Confirm trademark clearance before commercial use.
184+
</div>
185+
)}
186+
{isInDocument && (
187+
<div className="icon-details__in-doc" role="note">
188+
Already used in this document — inserting adds another instance without duplicating the
189+
embedded asset.
190+
</div>
191+
)}
192+
193+
<div className="icon-details__actions">
194+
<Button variant="primary" size="sm" onClick={onInsert} disabled={isAcquiring || !svg}>
195+
{isAcquiring ? 'Loading…' : 'Insert'}
196+
</Button>
197+
<Button
198+
variant="secondary"
199+
size="sm"
200+
onClick={onToggleFavourite}
201+
aria-pressed={isFavourite}
202+
>
203+
<SolidIcon name={isFavourite ? 'HeartFill' : 'Heart'} size={14} />
204+
{isFavourite ? 'Favourited' : 'Favourite'}
205+
</Button>
206+
<Button variant="ghost" size="sm" onClick={onCopySvg} disabled={!svg}>
207+
<Icon name="Copy" size={14} />
208+
Copy SVG
209+
</Button>
210+
<Button variant="ghost" size="sm" onClick={onToggleCache} disabled={!svg}>
211+
<Icon name={isCached ? 'Trash2' : 'Download'} size={14} />
212+
{isCached ? 'Remove' : 'Download'}
213+
</Button>
214+
</div>
215+
</div>
216+
</div>
217+
);
218+
}

0 commit comments

Comments
 (0)