From e28a828a8e88878a9b17069b0f01dc9d8e11744f Mon Sep 17 00:00:00 2001 From: Sami Fouad Date: Fri, 6 Nov 2026 03:26:03 -0600 Subject: [PATCH] Why can put a "Works with" card in the third benefit's place: logos where the owner allows them, names, notes (0.2.5) --- package-lock.json | 4 ++-- package.json | 2 +- src/tool/index.tsx | 39 +++++++++++++++++++++++++++++++++++++-- src/tool/tool.css | 8 ++++++++ tests/tool.test.mjs | 30 ++++++++++++++++++++++++++++++ 5 files changed, 78 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 54b8957..027c199 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@addiscorp/kit", - "version": "0.2.4", + "version": "0.2.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@addiscorp/kit", - "version": "0.2.4", + "version": "0.2.5", "license": "Apache-2.0", "devDependencies": { "@types/react": "19.2.7", diff --git a/package.json b/package.json index 15d3d11..8ffcc28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@addiscorp/kit", - "version": "0.2.4", + "version": "0.2.5", "description": "The header, footer, theme and tool-site layout every Addis site shares, in each project's own brand colours.", "license": "Apache-2.0", "type": "module", diff --git a/src/tool/index.tsx b/src/tool/index.tsx index c096ca0..24d1e24 100644 --- a/src/tool/index.tsx +++ b/src/tool/index.tsx @@ -145,8 +145,21 @@ export function Reel({ scenes }: { scenes: ReelScene[] }) { export type Benefit = { title: string; text: string }; -/** "Why · the short version": three benefits, and the other Addis tools. */ -export function Why({ tool, benefits }: { tool: ToolId; benefits: [Benefit, Benefit, Benefit] }) { +/** + * Something the tool works with: a name, and its logo when the owner allows reference use + * (an image the site serves itself; `dark` when it needs another one on a dark ground). + */ +export type WorksItem = { name: string; logo?: { light: string; dark?: string }; note?: string }; +export type WorksWith = { title: string; note?: string; items: WorksItem[] }; + +/** + * "Why · the short version": three benefits, and the other Addis tools. A tool can put a + * "Works with" card in the third benefit's place instead. + */ +export function Why({ tool, benefits, works }: { tool: ToolId } & ( + | { benefits: [Benefit, Benefit, Benefit]; works?: never } + | { benefits: [Benefit, Benefit]; works: WorksWith } +)) { return (

Why {toolName(tool)}the short version

@@ -158,6 +171,7 @@ export function Why({ tool, benefits }: { tool: ToolId; benefits: [Benefit, Bene

{benefit.text}

))} + {works && }

Addis toolsthey work together

@@ -174,6 +188,27 @@ export function Why({ tool, benefits }: { tool: ToolId; benefits: [Benefit, Bene ); } +function Works({ works }: { works: WorksWith }) { + return ( +
+

{works.title}{works.note && {works.note}}

+
+ {works.items.map((item) => ( +
+ {item.logo && (item.logo.dark + ? + : )} +
+ {item.name} + {item.note && {item.note}} +
+
+ ))} +
+
+ ); +} + export type DocsPage = { href: string; title: string }; /** The docs, after rixse.dev: the pages down the side, the page on the right. */ diff --git a/src/tool/tool.css b/src/tool/tool.css index ca49221..6cc241b 100644 --- a/src/tool/tool.css +++ b/src/tool/tool.css @@ -98,6 +98,14 @@ .akt-row strong { display: flex; align-items: center; gap: 8px; font: var(--akt-wm-weight) 16px/1 var(--akt-display); letter-spacing: var(--akt-wm-spacing); } .akt-row span { color: var(--akt-soft); } .akt-row:hover span { color: var(--akt-ink); } +/* "Works with": a logo (or nothing, where the owner allows the name only), the name, a note under it. */ +.akt-work { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--akt-faint); } +.akt-work:last-child { border-bottom: 0; } +.akt-work > div { grid-column: 2; display: flex; flex-direction: column; gap: 3px; } +.akt-work strong { font: var(--akt-wm-weight) 16px/1.2 var(--akt-display); letter-spacing: var(--akt-wm-spacing); } +.akt-work span:not(.akt-work-logo) { font: 12px/1.5 var(--akt-mono); color: var(--akt-soft); } +.akt-work-logo { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; } +.akt-work-logo img { width: 28px; height: 28px; object-fit: contain; } /* Docs, after rixse.dev: the pages down the side, the page on the right. */ .akt-docs { background-image: none; } diff --git a/tests/tool.test.mjs b/tests/tool.test.mjs index 8ae58ef..37988f8 100644 --- a/tests/tool.test.mjs +++ b/tests/tool.test.mjs @@ -124,3 +124,33 @@ test('a site’s footnote is a line in its footer, on the site and in its docs; assert.equal(docs.querySelector('.ak-foot .ak-foot-note').textContent, note); assert.equal(page(h(kit.ToolSite, { tool: 'harar' }, h('p', null, 'hi'))).querySelector('.ak-foot-note'), null); }); + +test('a "works with" card takes the third benefit’s place: logos where given, names always, notes under them', () => { + const works = { + title: 'Works with', + items: [ + { name: 'WordPress', logo: { light: '/logos/w.png', dark: '/logos/w-white.png' }, note: 'core stays on your PHP' }, + { name: 'WooCommerce', note: 'runs trusted, outside the sandbox' }, + { name: 'Some Plugin', logo: { light: '/icons/some.png' } }, + ], + }; + const doc = page(h(kit.Why, { tool: 'securecore', benefits: [{ title: 'a', text: '1' }, { title: 'b', text: '2' }], works })); + const cards = [...doc.querySelectorAll('.akt-cards > .akt-card')]; + assert.deepEqual(cards.map((c) => c.querySelector('h3').firstChild.textContent), ['a', 'b', 'Works with', 'Addis tools']); + const rows = [...cards[2].querySelectorAll('.akt-work')]; + assert.deepEqual(rows.map((r) => r.querySelector('strong').textContent), ['WordPress', 'WooCommerce', 'Some Plugin']); + // Light and dark logos, switched by the theme like the marks; one logo when it reads on both grounds. + assert.deepEqual([...rows[0].querySelectorAll('.akt-mark img')].map((i) => [i.className, i.getAttribute('src')]), + [['akt-light', '/logos/w.png'], ['akt-dark', '/logos/w-white.png']]); + const note = (row) => row.querySelector(':scope > div > span'); + assert.equal(note(rows[0]).textContent, 'core stays on your PHP'); + // A name the owner allows only as plain text has no image at all. + assert.equal(rows[1].querySelector('img'), null); + assert.equal(note(rows[1]).textContent, 'runs trusted, outside the sandbox'); + assert.deepEqual([...rows[2].querySelectorAll('img')].map((i) => i.getAttribute('src')), ['/icons/some.png']); + assert.equal(note(rows[2]), null); + // Three benefits and no card: as before. + const three = page(h(kit.Why, { tool: 'woreda', benefits: [{ title: 'a', text: '1' }, { title: 'b', text: '2' }, { title: 'c', text: '3' }] })); + assert.equal(three.querySelector('.akt-works'), null); + assert.equal(three.querySelectorAll('.akt-cards > .akt-card').length, 4); +});