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.6",
"version": "0.2.7",
"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
56 changes: 50 additions & 6 deletions src/tool/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,21 @@ export type ReelScene = { title: string; caption: string; lines: ReelLine[] };

const SCENE_SECONDS = 5;

/** The hero: headline, buttons, install commands under them, and the demo reel on the right. */
export function Hero({ headline, sub, status, docs = '/docs/', github, installs, reel, Link = PlainLink }: {
/**
* A screenshot of the app, in each theme: images the site serves itself
* (`dark` when the app looks different on a dark ground). Width and height
* are the image's own, so the page keeps its place while it loads.
*/
export type Shot = { light: string; dark?: string; alt: string; width: number; height: number };
/** A screen of the app and what it shows, for the tour. */
export type Feature = { title: string; text: string; shot: Shot };

/**
* The hero: headline, buttons, install commands under them, and the demo
* beside them: the reel for a tool you run in a terminal, or, for an app, a
* screenshot of it, under the words and as wide as the page.
*/
export function Hero({ headline, sub, status, docs = '/docs/', github, installs, reel, shot, Link = PlainLink }: {
headline: Headline;
sub: string;
/** Where the tool stands, when a visitor should know before installing: "Early: not yet audited." */
Expand All @@ -78,11 +91,10 @@ export function Hero({ headline, sub, status, docs = '/docs/', github, installs,
github?: string;
/** Empty until the tool can be installed; say why in `status`. */
installs: Install[];
reel: ReelScene[];
Link?: LinkComponent;
}) {
} & ({ reel: ReelScene[]; shot?: never } | { shot: Shot; reel?: never })) {
return (
<section className="akt-hero">
<section className={shot ? 'akt-hero akt-hero-app' : 'akt-hero'}>
<div>
<h1>{headline.before}<em>{headline.accent}</em>{headline.after}</h1>
<p className="akt-sub">{sub}</p>
Expand All @@ -100,7 +112,39 @@ export function Hero({ headline, sub, status, docs = '/docs/', github, installs,
))}
</div>}
</div>
<Reel scenes={reel} />
{shot ? <Screen shot={shot} eager /> : <Reel scenes={reel ?? []} />}
</section>
);
}

/** A screenshot in a window frame, in the page's theme. */
export function Screen({ shot, eager = false }: { shot: Shot; eager?: boolean }) {
const img = (src: string, className?: string) => (
<img className={className} src={src} alt={shot.alt} width={shot.width} height={shot.height} loading={eager ? 'eager' : 'lazy'} decoding="async" />
);
return (
<figure className="akt-screen">
<div className="akt-chrome" aria-hidden="true"><i /><i /><i /></div>
{shot.dark ? <>{img(shot.light, 'akt-light')}{img(shot.dark, 'akt-dark')}</> : img(shot.light)}
</figure>
);
}

/** The app, screen by screen: what each one is for, beside it, sides alternating. */
export function Tour({ features, title = 'A look around' }: { features: Feature[]; title?: string }) {
return (
<section className="akt-tour">
<h2>{title}</h2>
{features.map((feature) => (
<div className="akt-feature" key={feature.title}>
<div className="akt-feature-text">
<div className="akt-dash" />
<h3>{feature.title}</h3>
<p>{feature.text}</p>
</div>
<Screen shot={feature.shot} />
</div>
))}
</section>
);
}
Expand Down
29 changes: 29 additions & 0 deletions src/tool/tool.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,33 @@
.akt-copy { flex: none; border: 1px solid var(--akt-faint); border-radius: 5px; background: transparent; padding: 2px 8px; font: 11px var(--akt-mono); color: var(--akt-soft); cursor: pointer; }
.akt-copy:hover { color: var(--akt-ink); }

/* An app's hero: the words, then the app as wide as the page. */
.akt-hero-app { grid-template-columns: minmax(0, 1fr); gap: 44px; padding-bottom: 40px; }
.akt-hero-app h1 { font-size: clamp(36px, 5vw, 60px); }
.akt-hero-app .akt-sub { max-width: 52ch; }

/* A screenshot in a window frame; both themes' images drawn, the theme shows one. */
.akt-screen { margin: 0; border: 1px solid var(--akt-faint); border-radius: 12px; overflow: hidden; background: var(--akt-card); box-shadow: 0 30px 70px -40px rgb(0 0 0 / .55); }
.akt-screen img { display: block; width: 100%; height: auto; }
.akt-chrome { display: flex; gap: 7px; padding: 10px 14px; border-bottom: 1px solid var(--akt-faint); }
.akt-chrome i { width: 10px; height: 10px; border-radius: 50%; background: var(--akt-faint); }
.akt-screen .akt-dark { display: none; }
:root[data-theme="dark"] .akt-screen .akt-light { display: none; }
:root[data-theme="dark"] .akt-screen .akt-dark { display: block; }
@media (prefers-color-scheme: dark) {
:root:not([data-theme="light"]) .akt-screen .akt-light { display: none; }
:root:not([data-theme="light"]) .akt-screen .akt-dark { display: block; }
}

/* The tour: a screen and what it's for, sides alternating. */
.akt-tour { padding: 40px 0 24px; }
.akt-tour h2 { font: 800 30px/1.1 var(--akt-display); letter-spacing: -0.02em; margin: 0 0 28px; }
.akt-feature { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); gap: 44px; align-items: center; padding: 28px 0; }
.akt-feature:nth-of-type(even) .akt-feature-text { order: 2; }
.akt-feature:nth-of-type(even) { grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); }
.akt-feature h3 { font: 700 22px/1.2 var(--akt-display); margin: 0 0 10px; }
.akt-feature p { margin: 0; color: var(--akt-soft); }

/* The demo reel: dark in both themes, tinted with the brand. */
.akt-reel { background: var(--akt-reel); color: #E8ECEF; border: 1px solid var(--akt-reelline); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; min-height: 340px; box-shadow: 0 20px 50px -30px rgb(0 0 0 / .5); }
.akt-stage { display: grid; flex: 1; }
Expand Down Expand Up @@ -142,6 +169,8 @@
.akt-code .akt-copy { position: absolute; top: 12px; right: 12px; }

@media (max-width: 860px) {
.akt-feature, .akt-feature:nth-of-type(even) { grid-template-columns: minmax(0, 1fr); gap: 18px; }
.akt-feature:nth-of-type(even) .akt-feature-text { order: 0; }
.akt-main { width: calc(100% - 32px); }
.akt > .ak-foot { width: calc(100% - 32px); }
.akt-hero { grid-template-columns: minmax(0, 1fr); padding: 44px 0 40px; gap: 36px; }
Expand Down
2 changes: 1 addition & 1 deletion src/tool/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type ToolInfo = {
};

export const TOOLS: ToolInfo[] = [
{ id: 'rixse', domain: 'rixse.dev', short: 'The gateway. Agents ask, you decide.' },
{ id: 'rixse', domain: 'rixse.addis.gg', short: 'The gateway. Agents ask, you decide.' },
{ id: 'mirab', domain: 'mirab.addis.gg', short: 'Agents in VMs on your own machine.' },
{ id: 'woreda', domain: 'woreda.addis.gg', short: 'Self-hosted GitHub Actions runners.' },
{ id: 'kebele', domain: 'kebele.addis.gg', short: 'Container stacks over the Docker socket.' },
Expand Down
29 changes: 29 additions & 0 deletions tests/tool.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,32 @@ test('a "works with" card takes the third benefit’s place: logos where given,
assert.equal(three.querySelector('.akt-works'), null);
assert.equal(three.querySelectorAll('.akt-cards > .akt-card').length, 4);
});

const shot = (name) => ({ light: `/shots/${name}-light.png`, dark: `/shots/${name}-dark.png`, alt: `the ${name} screen`, width: 1440, height: 900 });

test('an app’s hero shows the app: its screenshot in both themes, under the words, and no reel', () => {
const doc = page(h(kit.Hero, { headline: { before: 'a ', accent: 'b' }, sub: 's', installs: [], shot: shot('channel') }));
assert.ok(doc.querySelector('.akt-hero').classList.contains('akt-hero-app'));
assert.equal(doc.querySelector('.akt-reel'), null);
const imgs = [...doc.querySelectorAll('.akt-screen img')];
assert.deepEqual(imgs.map((i) => [i.getAttribute('src'), i.className, i.getAttribute('alt'), i.getAttribute('width'), i.getAttribute('loading')]), [
['/shots/channel-light.png', 'akt-light', 'the channel screen', '1440', 'eager'],
['/shots/channel-dark.png', 'akt-dark', 'the channel screen', '1440', 'eager'],
]);
});

test('the theme shows one of a screenshot’s two images', () => {
const css = readFileSync(new URL('../dist/tool.css', import.meta.url), 'utf8');
assert.match(css, /\.akt-screen \.akt-dark \{ display: none; \}/);
assert.match(css, /:root\[data-theme="dark"\] \.akt-screen \.akt-light \{ display: none; \}/);
assert.match(css, /:root:not\(\[data-theme="light"\]\) \.akt-screen \.akt-dark \{ display: block; \}/);
});

test('the tour shows each screen with what it’s for, loaded as the visitor scrolls', () => {
const features = [{ title: 'Org', text: 'seats', shot: shot('org') }, { title: 'Access', text: 'rules', shot: { ...shot('access'), dark: undefined } }];
const doc = page(h(kit.Tour, { features }));
const rows = [...doc.querySelectorAll('.akt-feature')];
assert.deepEqual(rows.map((r) => r.querySelector('h3').textContent), ['Org', 'Access']);
assert.deepEqual(rows.map((r) => r.querySelectorAll('img').length), [2, 1]);
assert.ok([...doc.querySelectorAll('img')].every((i) => i.getAttribute('loading') === 'lazy'));
});
Loading