@addiscorp/kit 0.0.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,210 @@
1
+ 'use client';
2
+ // The menu's behaviour, shared by every Addis site: what opens and closes it,
3
+ // search, keyboard movement, numbered shortcuts. What it lists, and how each
4
+ // item looks, is the app's.
5
+ import { useEffect, useMemo, useRef, useState } from 'react';
6
+ export function matches(item, query) {
7
+ if (!query)
8
+ return true;
9
+ return `${item.title} ${item.detail ?? ''} ${item.keywords ?? ''}`.toLowerCase().includes(query);
10
+ }
11
+ function isTyping(target) {
12
+ if (!(target instanceof HTMLElement))
13
+ return false;
14
+ const tag = target.tagName;
15
+ return tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || target.isContentEditable;
16
+ }
17
+ /**
18
+ * All of the menu's behaviour. `panel` is which popover is open: `'menu'`, or
19
+ * any name an app gives its own (`'account'`, `'notifications'`, …).
20
+ *
21
+ * Keys: ⌘M / Ctrl+M opens and closes the menu; ⌘S, Ctrl+S or `/` opens it on
22
+ * search; typing anywhere starts a search; ↑ ↓ move, Enter opens, 1–9 open a
23
+ * numbered tile, Esc closes, `?` shows the shortcuts.
24
+ */
25
+ export function useMenu({ groups, pathname, navigate }) {
26
+ const [panel, setPanel] = useState(null);
27
+ const [query, setQuery] = useState('');
28
+ const [active, setActive] = useState(-1);
29
+ const [help, setHelp] = useState(false);
30
+ const [scrolled, setScrolled] = useState(false);
31
+ const [mod, setMod] = useState('Ctrl+');
32
+ const launcherRef = useRef(null);
33
+ const searchRef = useRef(null);
34
+ const dialogRef = useRef(null);
35
+ const headerRef = useRef(null);
36
+ const helpRef = useRef(null);
37
+ const wantSearch = useRef(false);
38
+ const needle = query.trim().toLowerCase();
39
+ /** Each group with only what matches the search; search-only groups appear only while searching. */
40
+ const shown = useMemo(() => groups
41
+ .filter((group) => !group.searchOnly || needle)
42
+ .map((group) => ({ ...group, items: group.items.filter((item) => matches(item, needle)) }))
43
+ .filter((group) => group.items.length > 0), [groups, needle]);
44
+ /** Every visible item in order: what ↑ ↓ move through. */
45
+ const flat = useMemo(() => shown.flatMap((group) => group.items), [shown]);
46
+ /** The tiles 1–9 open. */
47
+ const numbered = useMemo(() => shown.filter((group) => (group.layout ?? 'tiles') === 'tiles' && !group.searchOnly).flatMap((g) => g.items).slice(0, 9), [shown]);
48
+ function close() {
49
+ setPanel(null);
50
+ setQuery('');
51
+ setActive(-1);
52
+ }
53
+ function openMenu(search) {
54
+ wantSearch.current = search;
55
+ setQuery('');
56
+ setActive(-1);
57
+ setPanel('menu');
58
+ }
59
+ function toggle(name) {
60
+ setPanel((current) => (current === name ? null : name));
61
+ }
62
+ function select(item) {
63
+ close();
64
+ if (item.onSelect)
65
+ item.onSelect();
66
+ else if (item.href)
67
+ navigate(item.href);
68
+ }
69
+ function search(value) {
70
+ setQuery(value);
71
+ setActive(value.trim() ? 0 : -1);
72
+ }
73
+ const here = (href) => !!href && !href.includes('#') && pathname === href;
74
+ useEffect(() => {
75
+ setMod(/Mac|iPhone|iPad/.test(navigator.platform) ? '⌘' : 'Ctrl+');
76
+ }, []);
77
+ useEffect(() => {
78
+ const onScroll = () => setScrolled(window.scrollY > 4);
79
+ onScroll();
80
+ window.addEventListener('scroll', onScroll, { passive: true });
81
+ return () => window.removeEventListener('scroll', onScroll);
82
+ }, []);
83
+ // A navigation closes whatever was open.
84
+ useEffect(() => {
85
+ setPanel(null);
86
+ }, [pathname]);
87
+ // A click outside the header closes the open popover.
88
+ useEffect(() => {
89
+ if (!panel)
90
+ return;
91
+ const onPointer = (event) => {
92
+ if (event.target instanceof Node && headerRef.current?.contains(event.target))
93
+ return;
94
+ close();
95
+ };
96
+ document.addEventListener('mousedown', onPointer);
97
+ return () => document.removeEventListener('mousedown', onPointer);
98
+ }, [panel]);
99
+ useEffect(() => {
100
+ if (panel !== 'menu')
101
+ return;
102
+ const frame = requestAnimationFrame(() => {
103
+ if (wantSearch.current)
104
+ searchRef.current?.focus();
105
+ else
106
+ dialogRef.current?.focus();
107
+ });
108
+ return () => cancelAnimationFrame(frame);
109
+ }, [panel]);
110
+ useEffect(() => {
111
+ if (help)
112
+ helpRef.current?.focus();
113
+ }, [help]);
114
+ useEffect(() => {
115
+ if (active < 0)
116
+ return;
117
+ document.getElementById(`ak-item-${flat[active]?.id}`)?.scrollIntoView({ block: 'nearest' });
118
+ }, [active, flat]);
119
+ useEffect(() => {
120
+ const onKey = (event) => {
121
+ const key = event.key.toLowerCase();
122
+ const chord = event.metaKey || event.ctrlKey;
123
+ if (event.repeat && (key === 'm' || key === 's' || event.key === '/' || event.key === '?'))
124
+ return;
125
+ if (help) {
126
+ if (event.key === 'Escape' || event.key === '?') {
127
+ event.preventDefault();
128
+ setHelp(false);
129
+ }
130
+ return;
131
+ }
132
+ if (event.key === '?' && !chord && !event.altKey) {
133
+ if (event.target !== searchRef.current && isTyping(event.target))
134
+ return;
135
+ event.preventDefault();
136
+ setHelp(true);
137
+ return;
138
+ }
139
+ if (chord && key === 'm' && !event.altKey && !event.shiftKey) {
140
+ event.preventDefault();
141
+ if (panel === 'menu') {
142
+ close();
143
+ launcherRef.current?.focus();
144
+ }
145
+ else
146
+ openMenu(false);
147
+ return;
148
+ }
149
+ if ((chord && key === 's' && !event.altKey) || (event.key === '/' && !chord && !event.altKey && !isTyping(event.target))) {
150
+ event.preventDefault();
151
+ if (panel === 'menu')
152
+ searchRef.current?.focus();
153
+ else
154
+ openMenu(true);
155
+ return;
156
+ }
157
+ if (panel !== 'menu') {
158
+ if (event.key === 'Escape')
159
+ setPanel(null);
160
+ return;
161
+ }
162
+ if (event.key === 'Escape') {
163
+ event.preventDefault();
164
+ close();
165
+ launcherRef.current?.focus();
166
+ return;
167
+ }
168
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
169
+ event.preventDefault();
170
+ setActive((current) => {
171
+ if (flat.length === 0)
172
+ return -1;
173
+ if (event.key === 'ArrowDown')
174
+ return current < flat.length - 1 ? current + 1 : 0;
175
+ return current <= 0 ? flat.length - 1 : current - 1;
176
+ });
177
+ return;
178
+ }
179
+ if (event.key === 'Enter' && active >= 0 && flat[active]) {
180
+ event.preventDefault();
181
+ select(flat[active]);
182
+ return;
183
+ }
184
+ if (/^[1-9]$/.test(event.key) && !chord && !event.altKey) {
185
+ const item = numbered[Number(event.key) - 1];
186
+ if (item) {
187
+ event.preventDefault();
188
+ select(item);
189
+ return;
190
+ }
191
+ }
192
+ if (event.key.length === 1 && !chord && !event.altKey && !isTyping(event.target)) {
193
+ event.preventDefault();
194
+ wantSearch.current = true;
195
+ setQuery((value) => value + event.key);
196
+ setActive(0);
197
+ searchRef.current?.focus();
198
+ }
199
+ };
200
+ window.addEventListener('keydown', onKey);
201
+ return () => window.removeEventListener('keydown', onKey);
202
+ });
203
+ return {
204
+ panel, setPanel, toggle, close, openMenu,
205
+ query, search, active, setActive,
206
+ shown, flat, numbered, select, here,
207
+ help, setHelp, scrolled, mod,
208
+ refs: { launcher: launcherRef, search: searchRef, dialog: dialogRef, header: headerRef, help: helpRef },
209
+ };
210
+ }
@@ -0,0 +1,4 @@
1
+ export * from './header/index.js';
2
+ export * from './footer/index.js';
3
+ export * from './theme/index.js';
4
+ export * from './tool/index.js';
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ // @addiscorp/kit: the header, footer, theme and tool-site layout every Addis site shares.
2
+ // Import the styles once: `import '@addiscorp/kit/kit.css'`, then set the
3
+ // brand's colours (see README).
4
+ export * from './header/index.js';
5
+ export * from './footer/index.js';
6
+ export * from './theme/index.js';
7
+ export * from './tool/index.js';
package/dist/kit.css ADDED
@@ -0,0 +1,126 @@
1
+ /* @addiscorp/kit: the header, footer and theme switch. Every colour and font
2
+ is a variable; a project sets its brand's (see README) and keeps the rest. */
3
+ :root {
4
+ --ak-ground: #fafaf8; /* the page */
5
+ --ak-panel: #ffffff; /* popovers, buttons */
6
+ --ak-menu: #f4f4f1; /* the open menu */
7
+ --ak-tile: #fbfbf9; /* a tile in the menu */
8
+ --ak-ink: #17181b; /* text */
9
+ --ak-soft: #5a5d64; /* secondary text */
10
+ --ak-accent: #2a6df4; /* the brand colour: focus, current page, badges */
11
+ --ak-edge: #e2e1dc; /* borders, hover */
12
+ --ak-header-bg: rgb(255 255 255 / .55);
13
+ --ak-topbar-h: 56px;
14
+ --ak-width: 1080px;
15
+ --ak-font: ui-monospace, monospace;
16
+ --ak-display: system-ui, sans-serif;
17
+ }
18
+ :root[data-theme="dark"] {
19
+ --ak-ground: #0b0c0e;
20
+ --ak-panel: #14161a;
21
+ --ak-menu: #14161a;
22
+ --ak-tile: #1b1d22;
23
+ --ak-ink: #eceae4;
24
+ --ak-soft: #b9b6ae;
25
+ --ak-accent: #6e9bff;
26
+ --ak-edge: #23252a;
27
+ --ak-header-bg: rgb(0 0 0 / .3);
28
+ }
29
+ @media (prefers-color-scheme: dark) {
30
+ :root:not([data-theme="light"]) {
31
+ --ak-ground: #0b0c0e;
32
+ --ak-panel: #14161a;
33
+ --ak-menu: #14161a;
34
+ --ak-tile: #1b1d22;
35
+ --ak-ink: #eceae4;
36
+ --ak-soft: #b9b6ae;
37
+ --ak-accent: #6e9bff;
38
+ --ak-edge: #23252a;
39
+ --ak-header-bg: rgb(0 0 0 / .3);
40
+ }
41
+ }
42
+
43
+ .ak-soft { color: var(--ak-soft); }
44
+
45
+ /* Header */
46
+ .ak-topbar { position: sticky; top: 0; z-index: 30; width: 100%; margin-top: 20px; border-bottom: 1px solid transparent; background: transparent; font-family: var(--ak-font); color: var(--ak-ink); }
47
+ .ak-topbar.is-scrolled { background: var(--ak-header-bg); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom-color: var(--ak-edge); }
48
+ .ak-topbar-inner { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: min(var(--ak-width), calc(100% - 36px)); height: var(--ak-topbar-h); margin: 0 auto; }
49
+ .ak-top-side { display: flex; align-items: center; gap: 8px; min-width: 0; }
50
+ .ak-top-side.ak-end { justify-content: flex-end; }
51
+ .ak-top-center { position: relative; }
52
+ .ak-anchor { position: relative; }
53
+ .ak-topbar :focus-visible, .ak-help :focus-visible { outline: 2px solid var(--ak-accent); outline-offset: 3px; }
54
+
55
+ .ak-profile-btn, .ak-icon-btn, .ak-launcher { border: 0; color: var(--ak-ink); cursor: pointer; background: transparent; font: inherit; }
56
+ .ak-profile-btn, .ak-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; padding: 0; }
57
+ .ak-profile-btn { background: var(--ak-ink); color: var(--ak-ground); }
58
+ .ak-icon-btn { border: 1px solid var(--ak-edge); background: var(--ak-panel); position: relative; }
59
+ .ak-icon-btn:hover, .ak-launcher:hover, .ak-launcher[aria-expanded="true"] { background: var(--ak-edge); }
60
+ .ak-profile-btn:hover { background: var(--ak-accent); color: var(--ak-ground); }
61
+ .ak-launcher { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; font-family: var(--ak-display); font-weight: 600; font-size: 16px; letter-spacing: -0.02em; }
62
+ .ak-launcher img, .ak-launcher svg:first-child { width: 22px; height: 22px; border-radius: 6px; }
63
+ .ak-launcher .ak-chev { width: 14px; height: 14px; border-radius: 0; }
64
+ .ak-chev { display: block; transition: transform 120ms ease; }
65
+ .ak-chev.ak-open { transform: rotate(180deg); }
66
+ .ak-badge { position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--ak-accent); color: var(--ak-ground); font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; }
67
+
68
+ /* The menu and popovers */
69
+ .ak-menu, .ak-popover { border: 1px solid var(--ak-edge); border-radius: 16px; box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 6px 16px rgb(0 0 0 / .06); color: var(--ak-ink); }
70
+ .ak-menu { position: absolute; top: -8px; left: 50%; z-index: 5; width: min(480px, calc(100vw - 120px)); max-height: min(72vh, 580px); overflow: auto; padding: 14px; background: var(--ak-menu); transform: translateX(-50%); transform-origin: top center; animation: ak-menu-in 100ms ease-out both; outline: none; }
71
+ @keyframes ak-menu-in {
72
+ from { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.98); }
73
+ to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
74
+ }
75
+ @media (prefers-reduced-motion: reduce) { .ak-menu { animation: none; } }
76
+ .ak-popover { position: absolute; top: calc(100% + 8px); left: 0; width: min(320px, calc(100vw - 24px)); padding: 12px 14px; display: grid; gap: 8px; z-index: 2; background: var(--ak-panel); }
77
+ .ak-popover.ak-end { left: auto; right: 0; }
78
+ .ak-popover p { margin: 0; }
79
+
80
+ .ak-search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--ak-accent); border-radius: 10px; padding: 0 10px; background: var(--ak-ground); color: var(--ak-soft); }
81
+ .ak-search input { flex: 1; min-width: 0; height: 40px; border: 0; outline: none; background: transparent; color: var(--ak-ink); font: inherit; }
82
+ .ak-search input::placeholder { color: var(--ak-soft); }
83
+ .ak-group-label { margin: 14px 4px 8px; font-size: 11px; color: color-mix(in srgb, var(--ak-soft) 72%, var(--ak-ground)); }
84
+ .ak-group + .ak-group { padding-top: 24px; }
85
+ .ak-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
86
+ .ak-list { display: grid; gap: 2px; }
87
+ .ak-favicon { width: 16px; height: 16px; }
88
+ .ak-tile { position: relative; display: grid; justify-items: center; align-content: center; gap: 6px; min-height: 72px; padding: 8px 6px 16px; border-radius: 12px; border: 0; width: 100%; cursor: pointer; background: var(--ak-tile); color: inherit; text-decoration: none; font-family: var(--ak-display); font-size: 12px; font-weight: 600; line-height: 1.2; text-align: center; }
89
+ .ak-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 10px; border-radius: 8px; border: 0; width: 100%; cursor: pointer; background: transparent; color: inherit; text-decoration: none; font: inherit; text-align: left; }
90
+ .ak-row b { font-family: var(--ak-display); font-weight: 600; }
91
+ .ak-tile.is-active, .ak-row.is-active, .ak-tile:hover, .ak-row:hover { background: var(--ak-edge); }
92
+ .ak-tile[aria-current="page"], .ak-row[aria-current="page"] { box-shadow: inset 0 0 0 1px var(--ak-accent); }
93
+ .ak-key-num { position: absolute; left: 6px; bottom: 4px; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; font-size: 9px; line-height: 1; color: color-mix(in srgb, var(--ak-soft) 72%, var(--ak-ground)); pointer-events: none; }
94
+ .ak-empty { color: var(--ak-soft); margin: 14px 4px 4px; }
95
+ .ak-menu kbd, .ak-help kbd { font-family: var(--ak-font); font-size: 10px; line-height: 14px; border: 1px solid var(--ak-edge); border-radius: 3px; padding: 0 4px; background: var(--ak-panel); color: var(--ak-soft); box-shadow: 2px 1px 0 rgb(0 0 0 / .28); }
96
+ .ak-menu .ak-key-num { border: 0; background: none; box-shadow: none; padding: 0; }
97
+
98
+ /* Keyboard shortcuts */
99
+ .ak-help-layer { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 24px; background: color-mix(in srgb, var(--ak-ground) 35%, transparent); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); font-family: var(--ak-font); color: var(--ak-ink); }
100
+ .ak-help { width: min(420px, 100%); outline: none; background: var(--ak-panel); border: 1px solid var(--ak-edge); border-radius: 16px; box-shadow: 0 1px 2px rgb(0 0 0 / .04), 0 6px 16px rgb(0 0 0 / .06); padding: 18px 18px 8px; }
101
+ .ak-help h2 { font-family: var(--ak-display); font-size: 16px; margin: 0 0 12px; }
102
+ .ak-help-list { list-style: none; margin: 0; padding: 0; }
103
+ .ak-help-list li { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 9px 0; border-top: 1px solid var(--ak-edge); }
104
+ .ak-help-keys { display: flex; gap: 6px; flex: none; }
105
+
106
+ /* Footer */
107
+ .ak-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px 18px; flex-wrap: wrap; width: min(var(--ak-width), calc(100% - 36px)); margin: 0 auto; padding: 18px 0 28px; border-top: 1px solid var(--ak-edge); color: var(--ak-soft); font-family: var(--ak-font); font-size: 13px; }
108
+ .ak-credit { display: inline-flex; align-items: center; gap: 8px; color: var(--ak-ink); text-decoration: none; }
109
+ .ak-credit img, .ak-owner-mark { width: 32px; height: 32px; border-radius: 50%; }
110
+ .ak-foot-end { display: inline-flex; align-items: center; gap: 12px; }
111
+
112
+ /* The theme switch */
113
+ .ak-theme-toggle { box-sizing: border-box; border: 0; background: transparent; border-radius: 4px; color: inherit; cursor: pointer; display: inline-flex; height: 32px; width: 32px; align-items: center; justify-content: center; padding: 8px; }
114
+ .ak-theme-toggle:hover { background: var(--ak-edge); }
115
+ .ak-theme-toggle .ak-sun { display: none; }
116
+ :root[data-theme="dark"] .ak-theme-toggle .ak-sun { display: block; }
117
+ :root[data-theme="dark"] .ak-theme-toggle .ak-moon { display: none; }
118
+ @media (prefers-color-scheme: dark) {
119
+ :root:not([data-theme="light"]) .ak-theme-toggle .ak-sun { display: block; }
120
+ :root:not([data-theme="light"]) .ak-theme-toggle .ak-moon { display: none; }
121
+ }
122
+
123
+ @media (max-width: 560px) {
124
+ .ak-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
125
+ .ak-menu { width: min(480px, calc(100vw - 24px)); }
126
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Runs before paint (put it in an inline <script> in <head>) so the page
3
+ * never flashes the wrong theme: sets <html data-theme>.
4
+ */
5
+ export declare const themeBoot = "(function(){try{var m=document.cookie.match(/(?:^|; )theme=(light|dark)(?:;|$)/);var dark=matchMedia('(prefers-color-scheme: dark)').matches;document.documentElement.dataset.theme=m?m[1]:(dark?'dark':'light');}catch(e){}})()";
6
+ /** The light/dark switch; remembers the choice in the `theme` cookie. */
7
+ export declare function ThemeToggle(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Light, dark, or the system's: a `theme` cookie wins, else the system.
4
+ import { useEffect, useState } from 'react';
5
+ const COOKIE = 'theme';
6
+ /**
7
+ * Runs before paint (put it in an inline <script> in <head>) so the page
8
+ * never flashes the wrong theme: sets <html data-theme>.
9
+ */
10
+ export const themeBoot = `(function(){try{var m=document.cookie.match(/(?:^|; )theme=(light|dark)(?:;|$)/);var dark=matchMedia('(prefers-color-scheme: dark)').matches;document.documentElement.dataset.theme=m?m[1]:(dark?'dark':'light');}catch(e){}})()`;
11
+ function savedTheme() {
12
+ const match = document.cookie.match(/(?:^|; )theme=(light|dark)(?:;|$)/);
13
+ return match ? match[1] : null;
14
+ }
15
+ function systemTheme() {
16
+ return matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
17
+ }
18
+ /** The light/dark switch; remembers the choice in the `theme` cookie. */
19
+ export function ThemeToggle() {
20
+ const [dark, setDark] = useState(false);
21
+ useEffect(() => {
22
+ const apply = (theme) => {
23
+ document.documentElement.dataset.theme = theme;
24
+ setDark(theme === 'dark');
25
+ };
26
+ apply(savedTheme() ?? systemTheme());
27
+ const media = matchMedia('(prefers-color-scheme: dark)');
28
+ const onChange = () => {
29
+ if (!savedTheme())
30
+ apply(systemTheme());
31
+ };
32
+ media.addEventListener('change', onChange);
33
+ return () => media.removeEventListener('change', onChange);
34
+ }, []);
35
+ const label = dark ? 'Switch to light mode' : 'Switch to dark mode';
36
+ return (_jsxs("button", { className: "ak-theme-toggle", type: "button", "aria-label": label, title: label, "aria-pressed": dark, onClick: () => {
37
+ const next = document.documentElement.dataset.theme === 'dark' ? 'light' : 'dark';
38
+ document.cookie = `${COOKIE}=${next}; Path=/; Max-Age=31536000; SameSite=Lax`;
39
+ document.documentElement.dataset.theme = next;
40
+ setDark(next === 'dark');
41
+ }, children: [_jsx("svg", { className: "ak-moon", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: _jsx("path", { d: "M20.5 14A8.5 8.5 0 0 1 10 3.5 8.5 8.5 0 1 0 20.5 14Z" }) }), _jsxs("svg", { className: "ak-sun", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "1.6", "aria-hidden": "true", children: [_jsx("circle", { cx: "12", cy: "12", r: "4" }), _jsx("path", { d: "M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.5 1.5m11 11L19 19M5 19l1.5-1.5m11-11L19 5" })] })] }));
42
+ }
@@ -0,0 +1,3 @@
1
+ export declare function CopyButton({ text }: {
2
+ text: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ // A copy button for a command: "copy", then "copied" for a moment.
4
+ import { useState } from 'react';
5
+ export function CopyButton({ text }) {
6
+ const [copied, setCopied] = useState(false);
7
+ return (_jsx("button", { type: "button", className: "akt-copy", "aria-label": copied ? 'Copied' : 'Copy to clipboard', onClick: () => {
8
+ navigator.clipboard.writeText(text).then(() => {
9
+ setCopied(true);
10
+ setTimeout(() => setCopied(false), 1500);
11
+ }, () => { });
12
+ }, children: copied ? 'copied' : 'copy' }));
13
+ }
@@ -0,0 +1,103 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { LinkComponent } from '../header/index.js';
3
+ import { type ToolId } from './tools.js';
4
+ export { TOOLS, toolInfo, type ToolId, type ToolInfo } from './tools.js';
5
+ export { MARKS } from './marks.js';
6
+ export { CopyButton } from './copy.js';
7
+ /** A tool's mark, drawn for light and dark; the theme picks one. */
8
+ export declare function Mark({ tool, size }: {
9
+ tool: ToolId;
10
+ size?: number;
11
+ }): import("react/jsx-runtime").JSX.Element;
12
+ /** Everything a tool site shows sits inside this: it sets the tool's colours, the header and the footer. */
13
+ export declare function ToolSite({ tool, home, docs, Link, children }: {
14
+ tool: ToolId;
15
+ home?: string;
16
+ docs?: string;
17
+ Link?: LinkComponent;
18
+ children: ReactNode;
19
+ }): import("react/jsx-runtime").JSX.Element;
20
+ /** The headline, with one phrase in the brand colour: `{ before: 'Agents in VMs on ', accent: 'your own machine', after: '.' }`. */
21
+ export type Headline = {
22
+ before: string;
23
+ accent: string;
24
+ after?: string;
25
+ };
26
+ export type Install = {
27
+ label: string;
28
+ command: string;
29
+ };
30
+ /** A line in the demo: a command (`$ `), output, a highlighted line, a line in the accent, or a quiet one. */
31
+ export type ReelLine = {
32
+ text: string;
33
+ kind?: 'command' | 'output' | 'highlight' | 'accent' | 'quiet';
34
+ };
35
+ export type ReelScene = {
36
+ title: string;
37
+ caption: string;
38
+ lines: ReelLine[];
39
+ };
40
+ /** The hero: headline, buttons, install commands under them, and the demo reel on the right. */
41
+ export declare function Hero({ headline, sub, status, docs, github, installs, reel, Link }: {
42
+ headline: Headline;
43
+ sub: string;
44
+ /** Where the tool stands, when a visitor should know before installing: "Early: not yet audited." */
45
+ status?: string;
46
+ docs?: string;
47
+ /** The source, when it's public. */
48
+ github?: string;
49
+ /** Empty until the tool can be installed; say why in `status`. */
50
+ installs: Install[];
51
+ reel: ReelScene[];
52
+ Link?: LinkComponent;
53
+ }): import("react/jsx-runtime").JSX.Element;
54
+ /**
55
+ * The demo: a terminal that plays its scenes in turn, a few seconds each,
56
+ * each scene's lines appearing one after another. CSS only, so it runs with
57
+ * no script; with reduced motion it shows the first scene, still.
58
+ */
59
+ export declare function Reel({ scenes }: {
60
+ scenes: ReelScene[];
61
+ }): import("react/jsx-runtime").JSX.Element;
62
+ export type Benefit = {
63
+ title: string;
64
+ text: string;
65
+ };
66
+ /** "Why <tool> · the short version": three benefits, and the family of Addis tools. */
67
+ export declare function Why({ tool, benefits }: {
68
+ tool: ToolId;
69
+ benefits: [Benefit, Benefit, Benefit];
70
+ }): import("react/jsx-runtime").JSX.Element;
71
+ export type DocsPage = {
72
+ href: string;
73
+ title: string;
74
+ };
75
+ /** The docs, after rixse.dev: the pages down the side, the page on the right. */
76
+ export declare function DocsLayout({ tool, pages, pathname, eyebrow, title, lede, note, home, Link, children }: {
77
+ tool: ToolId;
78
+ pages: DocsPage[];
79
+ pathname: string;
80
+ eyebrow?: string;
81
+ title: string;
82
+ lede?: string;
83
+ /** A small note under the page list, e.g. what the docs describe. */
84
+ note?: string;
85
+ home?: string;
86
+ Link?: LinkComponent;
87
+ children: ReactNode;
88
+ }): import("react/jsx-runtime").JSX.Element;
89
+ /** A boxed aside. */
90
+ export declare function Callout({ children }: {
91
+ children: ReactNode;
92
+ }): import("react/jsx-runtime").JSX.Element;
93
+ /** One numbered step: `<Step n={1} label="Install">…</Step>`. */
94
+ export declare function Step({ n, label, children }: {
95
+ n: number;
96
+ label: string;
97
+ children: ReactNode;
98
+ }): import("react/jsx-runtime").JSX.Element;
99
+ /** A command or code block, with a copy button. */
100
+ export declare function Code({ children, copy }: {
101
+ children: string;
102
+ copy?: boolean;
103
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Footer } from '../footer/index.js';
3
+ import { CopyButton } from './copy.js';
4
+ import { MARKS } from './marks.js';
5
+ import { TOOLS, toolInfo } from './tools.js';
6
+ export { TOOLS, toolInfo } from './tools.js';
7
+ export { MARKS } from './marks.js';
8
+ export { CopyButton } from './copy.js';
9
+ const PlainLink = (props) => _jsx("a", { ...props });
10
+ /** A tool's mark, drawn for light and dark; the theme picks one. */
11
+ export function Mark({ tool, size = 26 }) {
12
+ const mark = MARKS[tool];
13
+ return (_jsxs("span", { className: "akt-mark", style: { width: size, height: size }, "aria-hidden": "true", children: [_jsx("svg", { className: "akt-light", viewBox: "0 0 24 24", width: size, height: size, dangerouslySetInnerHTML: { __html: mark.light } }), _jsx("svg", { className: "akt-dark", viewBox: "0 0 24 24", width: size, height: size, dangerouslySetInnerHTML: { __html: mark.dark } })] }));
14
+ }
15
+ /** Everything a tool site shows sits inside this: it sets the tool's colours, the header and the footer. */
16
+ export function ToolSite({ tool, home = '/', docs = '/docs/', Link = PlainLink, children }) {
17
+ return (_jsxs("div", { className: "akt", "data-tool": tool, children: [_jsxs("main", { className: "akt-main", children: [_jsxs("header", { className: "akt-header", children: [_jsxs(Link, { className: "akt-brand", href: home, children: [_jsx(Mark, { tool: tool }), tool] }), _jsx("nav", { "aria-label": "Main", children: _jsx(Link, { href: docs, children: "docs" }) })] }), children] }), _jsx(Footer, { site: toolInfo(tool).domain })] }));
18
+ }
19
+ const SCENE_SECONDS = 5;
20
+ /** The hero: headline, buttons, install commands under them, and the demo reel on the right. */
21
+ export function Hero({ headline, sub, status, docs = '/docs/', github, installs, reel, Link = PlainLink }) {
22
+ return (_jsxs("section", { className: "akt-hero", children: [_jsxs("div", { children: [_jsxs("h1", { children: [headline.before, _jsx("em", { children: headline.accent }), headline.after] }), _jsx("p", { className: "akt-sub", children: sub }), status && _jsx("p", { className: "akt-status", children: status }), _jsxs("div", { className: "akt-btns", children: [_jsx(Link, { className: "akt-btn akt-main-btn", href: docs, children: "docs" }), github && _jsx("a", { className: "akt-btn", href: github, children: "GitHub" })] }), installs.length > 0 && _jsx("div", { className: "akt-installs", children: installs.map((install) => (_jsxs("div", { children: [_jsx("div", { className: "akt-ilabel", children: install.label }), _jsxs("div", { className: "akt-cmd", children: [_jsxs("code", { children: [_jsx("b", { children: "$ " }), install.command] }), _jsx(CopyButton, { text: install.command })] })] }, install.command))) })] }), _jsx(Reel, { scenes: reel })] }));
23
+ }
24
+ /**
25
+ * The demo: a terminal that plays its scenes in turn, a few seconds each,
26
+ * each scene's lines appearing one after another. CSS only, so it runs with
27
+ * no script; with reduced motion it shows the first scene, still.
28
+ */
29
+ export function Reel({ scenes }) {
30
+ const cycle = scenes.length * SCENE_SECONDS;
31
+ const share = 100 / scenes.length;
32
+ // Each reel gets keyframes for its own number of scenes.
33
+ const css = `@keyframes akt-scene-${scenes.length}{0%{opacity:0;transform:translateY(4px)}${(share * 0.06).toFixed(2)}%{opacity:1;transform:none}${(share * 0.94).toFixed(2)}%{opacity:1}${share.toFixed(2)}%,100%{opacity:0}}`
34
+ + `@keyframes akt-dot-${scenes.length}{0%,${(share - 0.01).toFixed(2)}%{background:var(--akt-accent);width:28px}${share.toFixed(2)}%,100%{background:var(--akt-dotoff);width:14px}}`;
35
+ return (_jsxs("div", { children: [_jsx("style", { children: css }), _jsx("div", { className: "akt-reel", children: _jsx("div", { className: "akt-stage", children: scenes.map((scene, i) => (_jsxs("div", { className: "akt-scene", style: { animation: `akt-scene-${scenes.length} ${cycle}s ${i * SCENE_SECONDS}s infinite both` }, children: [_jsxs("div", { className: "akt-tab", children: [_jsx("i", {}), scene.title] }), _jsx("div", { className: "akt-term", children: scene.lines.map((line, j) => (_jsxs("div", { className: `akt-ln akt-${line.kind ?? 'output'}`, style: { animation: `akt-line ${cycle}s ${(i * SCENE_SECONDS + 0.3 + j * 0.45).toFixed(2)}s infinite both` }, children: [_jsx("span", { className: "akt-no", children: j + 1 }), _jsx("span", { className: "akt-tx", children: line.text })] }, j))) }), _jsx("div", { className: "akt-cap", children: scene.caption })] }, i))) }) }), _jsx("div", { className: "akt-dots", "aria-hidden": "true", children: scenes.map((_, i) => _jsx("i", { style: { animation: `akt-dot-${scenes.length} ${cycle}s ${i * SCENE_SECONDS}s infinite` } }, i)) })] }));
36
+ }
37
+ /** "Why <tool> · the short version": three benefits, and the family of Addis tools. */
38
+ export function Why({ tool, benefits }) {
39
+ return (_jsxs("section", { className: "akt-why", children: [_jsxs("h2", { children: ["Why ", tool, _jsx("small", { children: "the short version" })] }), _jsxs("div", { className: "akt-cards", children: [benefits.map((benefit) => (_jsxs("div", { className: "akt-card", children: [_jsx("div", { className: "akt-dash" }), _jsx("h3", { children: benefit.title }), _jsx("p", { children: benefit.text })] }, benefit.title))), _jsxs("div", { className: "akt-card", children: [_jsxs("h3", { children: ["Addis tools", _jsx("small", { children: "they work together" })] }), _jsx("div", { className: "akt-family", children: TOOLS.map((t) => (_jsxs("a", { className: "akt-row", href: `https://${t.domain}`, "aria-current": t.id === tool ? 'page' : undefined, children: [_jsxs("strong", { children: [_jsx(Mark, { tool: t.id, size: 18 }), t.id] }), _jsx("span", { children: t.short })] }, t.id))) })] })] })] }));
40
+ }
41
+ /** The docs, after rixse.dev: the pages down the side, the page on the right. */
42
+ export function DocsLayout({ tool, pages, pathname, eyebrow = 'Documentation', title, lede, note, home = '/', Link = PlainLink, children }) {
43
+ const here = (href) => href.replace(/\/$/, '') === pathname.replace(/\/$/, '');
44
+ return (_jsxs("div", { className: "akt akt-docs", "data-tool": tool, children: [_jsxs("div", { className: "akt-docs-grid", children: [_jsxs("aside", { className: "akt-side", children: [_jsxs(Link, { className: "akt-brand", href: home, children: [_jsx(Mark, { tool: tool }), tool, _jsx("span", { className: "akt-brand-docs", children: "docs" })] }), _jsx("nav", { "aria-label": "Docs", children: pages.map((page) => (_jsx(Link, { href: page.href, "aria-current": here(page.href) ? 'page' : undefined, children: page.title }, page.href))) }), note && _jsx("p", { className: "akt-side-note", children: note })] }), _jsxs("article", { className: "akt-doc", children: [_jsx("div", { className: "akt-eyebrow", children: eyebrow }), _jsx("h1", { children: title }), lede && _jsx("p", { className: "akt-lede", children: lede }), _jsx("div", { className: "akt-prose", children: children })] })] }), _jsx(Footer, { site: toolInfo(tool).domain })] }));
45
+ }
46
+ /** A boxed aside. */
47
+ export function Callout({ children }) {
48
+ return _jsx("div", { className: "akt-callout", children: children });
49
+ }
50
+ /** One numbered step: `<Step n={1} label="Install">…</Step>`. */
51
+ export function Step({ n, label, children }) {
52
+ return (_jsxs("div", { className: "akt-step", children: [_jsxs("div", { className: "akt-step-label", children: [String(n).padStart(2, '0'), " \u00B7 ", label] }), children] }));
53
+ }
54
+ /** A command or code block, with a copy button. */
55
+ export function Code({ children, copy = true }) {
56
+ return (_jsxs("div", { className: "akt-code", children: [_jsx("pre", { children: _jsx("code", { children: children }) }), copy && _jsx(CopyButton, { text: children })] }));
57
+ }
@@ -0,0 +1,5 @@
1
+ import type { ToolId } from './tools.js';
2
+ export declare const MARKS: Record<ToolId, {
3
+ light: string;
4
+ dark: string;
5
+ }>;