A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(gates): an icon-only button is an IconButton, or says why not
esengine5c1fbed2b59c
diff --git a/desktop b/desktopindex fb736f713..6e6958867 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit fb736f71347666a2fa8b53857aea798fe7a87a9e+Subproject commit 6e695886735fde72077cf960bc9c39c94ac6ab6ddiff --git a/tools/baselines/theme-drift.json b/tools/baselines/theme-drift.jsonindex 9e6059eae..6582eb3cb 100644--- a/tools/baselines/theme-drift.json+++ b/tools/baselines/theme-drift.json@@ -56,15 +56,15 @@},"handRolled": {"components/AgentCheckpoint.tsx": 2,- "components/AgentDrawer.tsx": 39,+ "components/AgentDrawer.tsx": 31,"components/AudioWavePreview.tsx": 1,- "components/BuildDialog.tsx": 5,+ "components/BuildDialog.tsx": 4,"components/BuildSizePanel.tsx": 1,"components/ColorControl.tsx": 1,"components/ErrorBoundary.tsx": 1,"components/FindingLocations.tsx": 2,"components/FindUsagesDialog.tsx": 1,- "components/MarkdownView.tsx": 2,+ "components/MarkdownView.tsx": 1,"components/OverlayMenu.tsx": 1,"components/QuickOpen.tsx": 1,"components/SaveButton.tsx": 1,@@ -88,7 +88,7 @@"panels/HealthPanel.tsx": 1,"panels/HistoryPanel.tsx": 5,"panels/inspector/componentDecorators.tsx": 9,- "panels/inspector/controls.tsx": 15,+ "panels/inspector/controls.tsx": 13,"panels/LightingPanel.tsx": 2,"panels/Outliner.tsx": 1,"panels/OutputLog.tsx": 1,@@ -99,7 +99,7 @@"panels/SpineDiagnosticsSection.tsx": 1,"panels/SpinePreviewPane.tsx": 1,"panels/TilemapPainter.tsx": 10,- "panels/TilesetEditor.tsx": 20,+ "panels/TilesetEditor.tsx": 19,"panels/UIWidgetsPanel.tsx": 1,"panels/Viewport.tsx": 6,"panels/WorldPanel.tsx": 3diff --git a/tools/check-theme.mjs b/tools/check-theme.mjsindex 3886fa9de..50e07902c 100644--- a/tools/check-theme.mjs+++ b/tools/check-theme.mjs@@ -519,6 +519,84 @@ const droppedAttributes = () => {return out;};for (const finding of droppedAttributes()) problems.push(finding);++/**+ * Icon-only buttons the editor keeps hand-rolled, by class, each with the reason+ * it is not an IconButton. Everything else icon-only is one: the square ghost or+ * outlined glyph button is a component, and a third copy of it is drift.+ */+const ICON_BUTTONS_KEPT = {+ 'play-side': 'a segment of the Play split button: accent fill, joined to its neighbours',+ 'winctl__btn': "the window's own minimise / maximise / close, drawn to the platform's convention",+ 'tab-popout': "dock tab chrome, styled with the dock's tabs",+ 'tab-x': "dock tab chrome, styled with the dock's tabs",+ 'dv-collapse': "dock group chrome, styled with the dock's tabs",+ 'ag-send': "the composer's send: the drawer's accent-filled primary action",+ 'awp-play': "an audio preview's play: the accent-outlined primary control",+ 'transport__play': "the transport's play: the accent-outlined primary control",+ 'ts-zone': 'a cell of the tile being edited; the cell is the content, not an icon',+ 'ts-oneway-dir': 'a direction cell of a one-way platform picker; the cell is the content',+ 'ts-wquad': "a corner of a Wang tile; its fill is the corner's colour",+ 'frame-pick__cell': 'a frame of the sheet being picked; the frame is the content',+ 'ts-wswatch': 'a colour swatch; its fill is the colour it offers',+ 'fx-on': "an effect's on / off box: a checkbox in a list row",+ 'mini-toggle': 'one half of a two-state toggle pair that reads as one control',+ 'seq-row__btn': "a track's mute / lock: on is the warning colour, not IconButton's accent fill",+ 'seq-btn': "the sequencer toolbar's toggles: on is accent text, not IconButton's accent fill",+ 'prop-gear': 'binds a property to a controller; recording shows in --rec',+ 'prop-reset': 'resets a changed property, in the modified colour, only when there is a change',+ 'tp-layer-vis': "a layer's visibility toggle in the layer row",+ 'tp-layer-lock': "a layer's lock toggle in the layer row",+ 'ts-terrain': 'a terrain in the picker, bordered when it is the active one',+ 'tp-tsx': "the close segment of a tileset tab",+ 'ctrl-chip-x': "a chip's remove, in the chip's own colour, shown on hover",+ 'proj-card__remove': 'a remove badge placed over a project card',+ 'proj-row__remove': 'a remove badge placed over a project row',+ 'ag-att-x': 'a remove badge placed over an attachment thumbnail',+ 'lc-field__browse': "the browse end of a path field, part of the field's well",+ 'build__scene-start': 'marks the start scene; its state is its fill',+ 'ovbtn': "a viewport overlay menu trigger; the rest of its family carry text",+};++/** The first class a tag names, however the className is written. */+const firstClass = (tag) => {+ const m = /\bclassName=(?:"([^"]*)"|\{\s*[`'"]([^`'"$]*))/.exec(tag);+ return (m?.[1] ?? m?.[2] ?? '').trim().split(/\s+/)[0] || null;+};++/** Nothing but icons (and a choice between icons) between the tags, or nothing at all. */+const iconOnly = (inner) => {+ let rest = inner;+ for (let i = rest.search(/<[A-Z]/); i >= 0; i = rest.search(/<[A-Z]/)) {+ const tag = openingTag(rest, i);+ if (!tag.endsWith('/>')) return false;+ rest = rest.slice(0, i) + rest.slice(i + tag.length);+ }+ rest = rest.replace(/\{[^{}]*(?:\?\s*:\s*|&&\s*)\}/g, '').trim();+ return !/[{<]/.test(rest) && !/[\p{L}\p{N}]/u.test(rest);+};++const seenKept = new Set();+for (const file of everyFile(SRC_DIR)) {+ if (!file.endsWith('.tsx')) continue;+ const rel = path.relative(SRC_DIR, file).replaceAll(path.sep, '/');+ if (PRIMITIVES.has(rel)) continue;+ const text = readFileSync(file, 'utf8');+ for (const m of text.matchAll(/<button\b/g)) {+ const tag = openingTag(text, m.index);+ if (ITEM_ROLE.test(tag)) continue;+ const inner = tag.endsWith('/>') ? '' : text.slice(m.index + tag.length, text.indexOf('</button>', m.index));+ if (!iconOnly(inner)) continue;+ const cls = firstClass(tag);+ if (cls && cls in ICON_BUTTONS_KEPT) { seenKept.add(cls); continue; }+ const line = text.slice(0, m.index).split('\n').length;+ problems.push(`desktop/src/${rel}:${line}: an icon-only <button${cls ? ` class="${cls}"` : ''}> — `+ + 'use <IconButton>, or name the class in ICON_BUTTONS_KEPT with why it is not one');+ }+}+for (const cls of Object.keys(ICON_BUTTONS_KEPT)) {+ if (!seenKept.has(cls)) problems.push(`tools/check-theme.mjs: ICON_BUTTONS_KEPT names "${cls}", which no icon-only button carries any more`);+}for (const site of nativeTitles()) {problems.push(`${site}: title= is the operating system's tooltip — use data-tip, `+ 'and aria-label where it was the control\'s only name');