From 8c4f744afc523d7135e8e28d05460aae3171da3d Mon Sep 17 00:00:00 2001 From: th Date: Sun, 26 Apr 2026 10:27:19 +0200 Subject: [PATCH] 1.2.6: dedicated FontPicker component with in-line type previews MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the bare diff --git a/src/devtools/tests.ts b/src/devtools/tests.ts index f06e088..a6a6139 100644 --- a/src/devtools/tests.ts +++ b/src/devtools/tests.ts @@ -15032,7 +15032,7 @@ export function registerAllTests(): void { expect(fontCssFamily('does-not-exist')).toBe(SYSTEM_SANS.family) }) - test('PropertiesPanel renders a font dropdown for text assets and writes back', async () => { + test('PropertiesPanel renders the font picker for text assets and writes back', async () => { const s = makeFreshStore() const a = s.addAsset({ kind: 'text', name: 'T', text: 'hello', fontSize: 32, fill: '#000', @@ -15043,30 +15043,40 @@ export function registerAllTests(): void { const handle = mountComponent(PropertiesPanel, {}) try { await nextTick() - const select = handle.host.querySelector('select') as HTMLSelectElement | null - expect(select).toBeTruthy() - const options = Array.from(select!.options).map(o => o.value) - expect(options).toContain('system-sans') - expect(options).toContain('inter') - expect(options).toContain('marker') - // Default selection: system-sans (asset.fontFamily is undefined). - expect(select!.value).toBe('system-sans') - // Pick Inter — the asset should mutate. - select!.value = 'inter' - select!.dispatchEvent(new Event('change')) + const trigger = handle.host.querySelector('.font-picker .trigger') as HTMLButtonElement | null + expect(!!trigger).toBe(true) + // Closed state: the label shows the default — System Sans. + expect((trigger!.textContent ?? '').includes('System Sans')).toBe(true) + trigger!.click() + await nextTick() + // Popover lives in document.body via Teleport. + const opts = Array.from(document.querySelectorAll('.font-popover .font-option')) as HTMLButtonElement[] + expect(opts.length).toBeGreaterThan(5) + const labels = opts.map(o => o.textContent?.trim() ?? '') + expect(labels.some(l => l.includes('System Sans'))).toBe(true) + expect(labels.some(l => l.includes('Inter'))).toBe(true) + expect(labels.some(l => l.includes('Permanent Marker'))).toBe(true) + // Click Inter. + const interOpt = opts.find(o => (o.textContent ?? '').trim() === 'Inter')! + interOpt.click() await nextTick() const textAsset = s.scene.assets.find(x => x.id === a.id)! if (textAsset.kind !== 'text') throw new Error('unexpected kind') expect(textAsset.fontFamily).toBe('inter') - // Picking system-sans clears the field (undefined, not the literal id). - select!.value = 'system-sans' - select!.dispatchEvent(new Event('change')) + // Re-open + click System Sans → clears (undefined). + trigger!.click() + await nextTick() + const opts2 = Array.from(document.querySelectorAll('.font-popover .font-option')) as HTMLButtonElement[] + const sysOpt = opts2.find(o => (o.textContent ?? '').trim() === 'System Sans')! + sysOpt.click() await nextTick() const textAsset2 = s.scene.assets.find(x => x.id === a.id)! if (textAsset2.kind !== 'text') throw new Error('unexpected kind') expect(textAsset2.fontFamily === undefined).toBe(true) } finally { handle.unmount() + // Make sure the teleported popover doesn't leak into other tests. + document.querySelectorAll('.font-popover').forEach(el => el.remove()) } }) diff --git a/src/version.ts b/src/version.ts index a6846ca..580b2d8 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,2 +1,2 @@ -export const APP_VERSION = '1.2.5' +export const APP_VERSION = '1.2.6' export const APP_NAME = 'RUWIO'