Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
39 changes: 37 additions & 2 deletions src/tool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,21 @@ export function Reel({ scenes }: { scenes: ReelScene[] }) {

export type Benefit = { title: string; text: string };

/** "Why <tool> · 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 <tool> · 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 (
<section className="akt-why">
<h2>Why {toolName(tool)}<small>the short version</small></h2>
Expand All @@ -158,6 +171,7 @@ export function Why({ tool, benefits }: { tool: ToolId; benefits: [Benefit, Bene
<p>{benefit.text}</p>
</div>
))}
{works && <Works works={works} />}
<div className="akt-card">
<h3>Addis tools<small>they work together</small></h3>
<div className="akt-family">
Expand All @@ -174,6 +188,27 @@ export function Why({ tool, benefits }: { tool: ToolId; benefits: [Benefit, Bene
);
}

function Works({ works }: { works: WorksWith }) {
return (
<div className="akt-card akt-works">
<h3>{works.title}{works.note && <small>{works.note}</small>}</h3>
<div className="akt-family">
{works.items.map((item) => (
<div key={item.name} className="akt-work">
{item.logo && (item.logo.dark
? <span className="akt-mark akt-work-logo"><img className="akt-light" src={item.logo.light} alt="" /><img className="akt-dark" src={item.logo.dark} alt="" /></span>
: <span className="akt-work-logo"><img src={item.logo.light} alt="" /></span>)}
<div>
<strong>{item.name}</strong>
{item.note && <span>{item.note}</span>}
</div>
</div>
))}
</div>
</div>
);
}

export type DocsPage = { href: string; title: string };

/** The docs, after rixse.dev: the pages down the side, the page on the right. */
Expand Down
8 changes: 8 additions & 0 deletions src/tool/tool.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
30 changes: 30 additions & 0 deletions tests/tool.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Loading