atris 3.17.0 → 3.22.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.
- package/atris.md +3 -3
- package/bin/atris.js +14 -2
- package/commands/deck.js +77 -28
- package/commands/recap.js +16 -0
- package/commands/site.js +48 -0
- package/commands/slop.js +146 -12
- package/commands/theme.js +217 -0
- package/lib/deck-from-md.js +110 -0
- package/lib/html-render.js +257 -0
- package/lib/memory-view.js +95 -0
- package/lib/site.js +114 -0
- package/lib/slides-deck.js +3 -2
- package/lib/theme.js +264 -0
- package/package.json +1 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
// atris theme — brand themes for the whole design system. Define your colors and
|
|
2
|
+
// fonts once in .atris/theme.json; every deck, HTML page, and site uses them.
|
|
3
|
+
//
|
|
4
|
+
// atris theme create guided interview -> your own theme (alias: new)
|
|
5
|
+
// atris theme edit <name> re-run the interview to tweak an existing theme
|
|
6
|
+
// atris theme init scaffold a starter .atris/theme.json
|
|
7
|
+
// atris theme list list built-in + project themes
|
|
8
|
+
// atris theme show <name> print a resolved theme
|
|
9
|
+
|
|
10
|
+
const readline = require('readline');
|
|
11
|
+
const {
|
|
12
|
+
mergedThemes, writeStarterTheme, loadProjectThemes, loadThemeRecipe, PROJECT_THEME_FILE,
|
|
13
|
+
MOODS, MOOD_NAMES, FONT_PERSONALITIES, buildTheme, themeWarnings, upsertProjectTheme,
|
|
14
|
+
resolveMode, isHex, normHex, hexToRgb,
|
|
15
|
+
} = require('../lib/theme');
|
|
16
|
+
const { THEMES: HTML_THEMES } = require('../lib/html-render');
|
|
17
|
+
|
|
18
|
+
// ---------- small terminal helpers ----------
|
|
19
|
+
function parseFlags(argv) {
|
|
20
|
+
const flags = {}; const pos = [];
|
|
21
|
+
for (let i = 0; i < argv.length; i++) {
|
|
22
|
+
const a = argv[i];
|
|
23
|
+
if (a === '-y' || a === '--yes') { flags.yes = true; continue; }
|
|
24
|
+
if (a.startsWith('--')) {
|
|
25
|
+
const key = a.slice(2);
|
|
26
|
+
const next = argv[i + 1];
|
|
27
|
+
if (next != null && !next.startsWith('--')) { flags[key] = next; i++; }
|
|
28
|
+
else flags[key] = true;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
pos.push(a);
|
|
32
|
+
}
|
|
33
|
+
return { flags, pos };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// a colored block when we're on a real terminal, two blank cells otherwise (clean pipes)
|
|
37
|
+
function sw(hex) {
|
|
38
|
+
const c = hexToRgb(hex);
|
|
39
|
+
if (!c || !process.stdout.isTTY) return ' ';
|
|
40
|
+
return `\x1b[48;2;${c.r};${c.g};${c.b}m \x1b[0m`;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function printPreview(name, answers, theme) {
|
|
44
|
+
const c = theme.color;
|
|
45
|
+
const mode = resolveMode(answers.mood || 'editorial', answers.mode);
|
|
46
|
+
console.log(`\n ${name} · ${answers.mood || 'editorial'} ${mode}`);
|
|
47
|
+
const row = (label, hex) => console.log(` ${sw(hex)} ${label.padEnd(8)} ${hex}`);
|
|
48
|
+
row('bg', c.bg);
|
|
49
|
+
row('ink', c.ink);
|
|
50
|
+
row('accent', c.accent);
|
|
51
|
+
row('accent2', c.accent2);
|
|
52
|
+
console.log(` ${theme.fonts.display} display, ${theme.fonts.body} body`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ---------- the guided interview (tasteful vocabulary) ----------
|
|
56
|
+
async function interview(defaults = {}) {
|
|
57
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
58
|
+
const ask = (q) => new Promise((res) => rl.question(q, res));
|
|
59
|
+
const ans = {};
|
|
60
|
+
try {
|
|
61
|
+
console.log('\n let\'s make your theme. five quick choices, all changeable later.\n');
|
|
62
|
+
|
|
63
|
+
const dn = defaults.name || 'brand';
|
|
64
|
+
ans.name = (await ask(` 1/5 name it [${dn}]: `)).trim() || dn;
|
|
65
|
+
|
|
66
|
+
console.log('\n 2/5 what should it feel like?');
|
|
67
|
+
MOOD_NAMES.forEach((m, i) => console.log(` ${i + 1}. ${m.padEnd(10)} ${MOODS[m].blurb}`));
|
|
68
|
+
const dmIdx = Math.max(0, MOOD_NAMES.indexOf(defaults.mood || 'editorial'));
|
|
69
|
+
const moodPick = (await ask(` pick 1-${MOOD_NAMES.length} [${dmIdx + 1}]: `)).trim();
|
|
70
|
+
ans.mood = MOOD_NAMES[(parseInt(moodPick, 10) - 1)] || MOOD_NAMES[dmIdx];
|
|
71
|
+
const mood = MOODS[ans.mood];
|
|
72
|
+
|
|
73
|
+
if (mood.forceMode) {
|
|
74
|
+
ans.mode = mood.forceMode;
|
|
75
|
+
console.log(` (${ans.mood} is ${mood.forceMode}-only)`);
|
|
76
|
+
} else {
|
|
77
|
+
const dmode = defaults.mode || mood.defaultMode;
|
|
78
|
+
const mp = (await ask(`\n 3/5 light or dark? [${dmode[0]}]: `)).trim().toLowerCase();
|
|
79
|
+
ans.mode = mp.startsWith('l') ? 'light' : mp.startsWith('d') ? 'dark' : dmode;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
console.log('\n 4/5 your accent — the one color that is unmistakably yours:');
|
|
83
|
+
mood.swatches.forEach((s, i) => console.log(` ${i + 1}. ${sw(s)} ${s}`));
|
|
84
|
+
const dac = normHex(defaults.accent) || mood.swatches[0];
|
|
85
|
+
const ap = (await ask(` pick 1-${mood.swatches.length}, or paste a hex [${dac}]: `)).trim();
|
|
86
|
+
if (!ap) ans.accent = dac;
|
|
87
|
+
else if (/^[1-9]$/.test(ap) && mood.swatches[parseInt(ap, 10) - 1]) ans.accent = mood.swatches[parseInt(ap, 10) - 1];
|
|
88
|
+
else if (isHex(ap)) ans.accent = normHex(ap);
|
|
89
|
+
else { console.log(` '${ap}' is not 1-${mood.swatches.length} or a hex, keeping ${dac}`); ans.accent = dac; }
|
|
90
|
+
|
|
91
|
+
console.log('\n 5/5 type personality:');
|
|
92
|
+
const fontKeys = Object.keys(FONT_PERSONALITIES);
|
|
93
|
+
fontKeys.forEach((k, i) => console.log(` ${i + 1}. ${k.padEnd(15)} ${FONT_PERSONALITIES[k].display} / ${FONT_PERSONALITIES[k].body}`));
|
|
94
|
+
const dfIdx = fontKeys.indexOf(typeof defaults.fonts === 'string' ? defaults.fonts : mood.fonts);
|
|
95
|
+
const fp = (await ask(` pick 1-${fontKeys.length} [${(dfIdx < 0 ? 0 : dfIdx) + 1}]: `)).trim();
|
|
96
|
+
ans.fonts = fontKeys[(parseInt(fp, 10) - 1)] || fontKeys[dfIdx < 0 ? 0 : dfIdx];
|
|
97
|
+
} finally {
|
|
98
|
+
rl.close();
|
|
99
|
+
}
|
|
100
|
+
return ans;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function confirmSync(q) {
|
|
104
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
105
|
+
return new Promise((res) => rl.question(q, (a) => { rl.close(); res(!String(a).trim().toLowerCase().startsWith('n')); }));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// shared create/edit flow. defaults seed an edit; flags override anything; interactive
|
|
109
|
+
// only when there's a TTY and no defining flags.
|
|
110
|
+
async function createFlow({ name, defaults = {}, flags }) {
|
|
111
|
+
const answers = { ...defaults };
|
|
112
|
+
if (flags.mood) answers.mood = flags.mood;
|
|
113
|
+
if (flags.mode) answers.mode = flags.mode;
|
|
114
|
+
if (flags.accent) answers.accent = flags.accent;
|
|
115
|
+
if (flags.accent2) answers.accent2 = flags.accent2;
|
|
116
|
+
if (flags.fonts) answers.fonts = flags.fonts;
|
|
117
|
+
let themeName = name || flags.name || defaults.name || 'brand';
|
|
118
|
+
|
|
119
|
+
const hasDefiningFlag = Boolean(flags.mood || flags.mode || flags.accent || flags.accent2 || flags.fonts || flags.name);
|
|
120
|
+
const interactive = Boolean(process.stdin.isTTY) && !flags.yes && !hasDefiningFlag;
|
|
121
|
+
|
|
122
|
+
if (interactive) {
|
|
123
|
+
const r = await interview({ name: themeName, ...answers });
|
|
124
|
+
Object.assign(answers, r);
|
|
125
|
+
themeName = r.name || themeName;
|
|
126
|
+
}
|
|
127
|
+
themeName = String(themeName).trim() || 'brand';
|
|
128
|
+
|
|
129
|
+
if (answers.mood && !MOODS[answers.mood]) { console.error(` unknown mood "${answers.mood}". try: ${MOOD_NAMES.join(', ')}`); return 2; }
|
|
130
|
+
if (answers.accent && !isHex(answers.accent)) { console.error(` not a hex color: ${answers.accent}`); return 2; }
|
|
131
|
+
if (answers.accent2 && !isHex(answers.accent2)) { console.error(` not a hex color: ${answers.accent2}`); return 2; }
|
|
132
|
+
if (answers.fonts && typeof answers.fonts === 'string' && !FONT_PERSONALITIES[answers.fonts]) {
|
|
133
|
+
console.error(` unknown font personality "${answers.fonts}". try: ${Object.keys(FONT_PERSONALITIES).join(', ')}`); return 2;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const theme = buildTheme(answers);
|
|
137
|
+
printPreview(themeName, answers, theme);
|
|
138
|
+
const warns = themeWarnings(theme);
|
|
139
|
+
if (warns.length) { console.log('\n heads up:'); warns.forEach((w) => console.log(` ! ${w}`)); }
|
|
140
|
+
|
|
141
|
+
if (interactive) {
|
|
142
|
+
const ok = await confirmSync('\n save this theme? [enter = yes, n = cancel] ');
|
|
143
|
+
if (!ok) { console.log(' cancelled, nothing written.\n'); return 0; }
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const recipe = {
|
|
147
|
+
mood: answers.mood || 'editorial',
|
|
148
|
+
mode: resolveMode(answers.mood || 'editorial', answers.mode),
|
|
149
|
+
accent: theme.color.accent,
|
|
150
|
+
accent2: theme.color.accent2,
|
|
151
|
+
fonts: typeof answers.fonts === 'string' ? answers.fonts : (MOODS[answers.mood || 'editorial'].fonts),
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
let res;
|
|
155
|
+
try { res = upsertProjectTheme(themeName, theme, process.cwd(), recipe); }
|
|
156
|
+
catch (e) { console.error(` ${e.message}`); return 1; }
|
|
157
|
+
|
|
158
|
+
console.log(`\n ✓ ${res.action} theme "${res.name}" in ${PROJECT_THEME_FILE} (${res.count} theme${res.count === 1 ? '' : 's'})`);
|
|
159
|
+
console.log(' use it anywhere:');
|
|
160
|
+
console.log(` atris deck from doc.md --html --theme ${res.name}`);
|
|
161
|
+
console.log(` atris site ./docs --theme ${res.name}`);
|
|
162
|
+
console.log(` tweak it later: atris theme edit ${res.name}\n`);
|
|
163
|
+
return 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function run(argv) {
|
|
167
|
+
const sub = argv[0];
|
|
168
|
+
const rest = argv.slice(1);
|
|
169
|
+
|
|
170
|
+
if (sub === 'create' || sub === 'new') {
|
|
171
|
+
const { flags, pos } = parseFlags(rest);
|
|
172
|
+
return createFlow({ name: pos[0], flags });
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (sub === 'edit') {
|
|
176
|
+
const { flags, pos } = parseFlags(rest);
|
|
177
|
+
const name = pos[0] || flags.name;
|
|
178
|
+
if (!name) { console.error(' usage: atris theme edit <name>'); return 2; }
|
|
179
|
+
const existing = loadProjectThemes()[name];
|
|
180
|
+
if (!existing) { console.error(` no project theme "${name}". make one with: atris theme create ${name}`); return 2; }
|
|
181
|
+
// prefer the saved recipe; otherwise seed from the resolved colors/fonts
|
|
182
|
+
const recipe = loadThemeRecipe(name);
|
|
183
|
+
const defaults = recipe || { accent: existing.color.accent, accent2: existing.color.accent2, fonts: existing.fonts };
|
|
184
|
+
defaults.name = name;
|
|
185
|
+
return createFlow({ name, defaults, flags });
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (sub === 'init') {
|
|
189
|
+
const { file, already } = writeStarterTheme();
|
|
190
|
+
console.log(already
|
|
191
|
+
? `\n already exists: ${file}\n customize it with: atris theme edit brand\n`
|
|
192
|
+
: `\n ✓ brand theme scaffolded: ${file}\n or build one by feel: atris theme create\n`);
|
|
193
|
+
return 0;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (sub === 'show') {
|
|
197
|
+
const name = rest[0];
|
|
198
|
+
const t = mergedThemes(HTML_THEMES)[name];
|
|
199
|
+
if (!t) { console.error(` unknown theme "${name}"`); return 2; }
|
|
200
|
+
console.log(JSON.stringify(t, null, 2));
|
|
201
|
+
return 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// list (default)
|
|
205
|
+
const project = loadProjectThemes();
|
|
206
|
+
const all = mergedThemes(HTML_THEMES);
|
|
207
|
+
console.log('\n atris themes:\n');
|
|
208
|
+
for (const name of Object.keys(all)) {
|
|
209
|
+
const tag = project[name] ? 'project' : 'built-in';
|
|
210
|
+
console.log(` ${sw(all[name].color.accent)} ${name.padEnd(12)} accent ${all[name].color.accent} bg ${all[name].color.bg} (${tag})`);
|
|
211
|
+
}
|
|
212
|
+
console.log(`\n make your own by feel: atris theme create`);
|
|
213
|
+
console.log(` themes live in ${PROJECT_THEME_FILE}. Used by deck, html, and site.\n`);
|
|
214
|
+
return 0;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
module.exports = { run };
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Markdown -> deck spec. Lets a PM write an ordinary doc and get a designed deck.
|
|
2
|
+
// Pure: a markdown string in, a { theme, brand, slides } spec out (fed to buildDeck).
|
|
3
|
+
//
|
|
4
|
+
// Mapping (predictable on purpose):
|
|
5
|
+
// --- front matter --- theme / brand / accent
|
|
6
|
+
// # H1 (first) -> title slide (sub = the paragraph under it)
|
|
7
|
+
// ## H2 with 2-4 bullets -> columns slide (each bullet "**Lead** rest" -> a column)
|
|
8
|
+
// ## H2 with "**X** label" only -> bignumber slide
|
|
9
|
+
// ## H2 titled Close/CTA/Thanks -> close slide
|
|
10
|
+
// ## H2 otherwise -> statement slide (sub = the paragraph under it)
|
|
11
|
+
// Emphasis (**bold**) is preserved and rendered in the accent by the engine.
|
|
12
|
+
|
|
13
|
+
function parseFrontMatter(md) {
|
|
14
|
+
const out = { theme: null, brand: null, accent: null };
|
|
15
|
+
const m = md.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);
|
|
16
|
+
if (!m) return { body: md, fm: out };
|
|
17
|
+
for (const line of m[1].split(/\r?\n/)) {
|
|
18
|
+
const kv = line.match(/^([A-Za-z_]+):\s*(.+?)\s*$/);
|
|
19
|
+
if (!kv) continue;
|
|
20
|
+
const k = kv[1].toLowerCase();
|
|
21
|
+
const v = kv[2].trim().replace(/^["']|["']$/g, '');
|
|
22
|
+
if (k === 'theme') out.theme = v;
|
|
23
|
+
else if (k === 'brand') out.brand = v;
|
|
24
|
+
else if (k === 'accent') out.accent = v;
|
|
25
|
+
}
|
|
26
|
+
return { body: md.slice(m[0].length), fm: out };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// group a section's lines into bullets[] and paragraphs[]
|
|
30
|
+
function splitBody(lines) {
|
|
31
|
+
const bullets = [];
|
|
32
|
+
const paras = [];
|
|
33
|
+
let buf = [];
|
|
34
|
+
const flush = () => { if (buf.length) { paras.push(buf.join(' ').trim()); buf = []; } };
|
|
35
|
+
for (const raw of lines) {
|
|
36
|
+
const line = raw.replace(/\s+$/, '');
|
|
37
|
+
if (/^\s*[-*+]\s+/.test(line)) { flush(); bullets.push(line.replace(/^\s*[-*+]\s+/, '').trim()); }
|
|
38
|
+
else if (/^\s*$/.test(line)) flush();
|
|
39
|
+
else if (/^\s*>\s+/.test(line)) { flush(); paras.push(line.replace(/^\s*>\s+/, '').trim()); }
|
|
40
|
+
else buf.push(line.trim());
|
|
41
|
+
}
|
|
42
|
+
flush();
|
|
43
|
+
return { bullets, paras: paras.filter(Boolean) };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// "**Lead** rest" / "Lead: rest" / "Lead - rest" -> { h, b }
|
|
47
|
+
function toColumn(bullet) {
|
|
48
|
+
let m = bullet.match(/^\*\*(.+?)\*\*[\s:.-]*(.*)$/);
|
|
49
|
+
if (m) return { h: m[1].trim(), b: m[2].trim() };
|
|
50
|
+
m = bullet.match(/^([^:]{2,48}):\s+(.+)$/);
|
|
51
|
+
if (m) return { h: m[1].trim(), b: m[2].trim() };
|
|
52
|
+
return { h: bullet.trim(), b: '' };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// a single "**value** label" paragraph -> big number slide
|
|
56
|
+
function asBigNumber(paras, bullets) {
|
|
57
|
+
if (bullets.length || paras.length !== 1) return null;
|
|
58
|
+
const m = paras[0].match(/^\*\*([^*]{1,18})\*\*\s+(.+)$/);
|
|
59
|
+
if (!m) return null;
|
|
60
|
+
return { type: 'bignumber', number: m[1].trim(), label: m[2].trim() };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const CLOSE_TITLES = /^(close|thanks|thank you|cta|call to action|get started|wrap up|next steps?)$/i;
|
|
64
|
+
|
|
65
|
+
function parseMarkdownToSpec(md, opts = {}) {
|
|
66
|
+
const { body, fm } = parseFrontMatter(String(md || ''));
|
|
67
|
+
const theme = opts.theme || fm.theme || 'terminal';
|
|
68
|
+
const brand = {
|
|
69
|
+
name: opts.brandName || fm.brand || 'Atris',
|
|
70
|
+
accent: opts.accent || fm.accent || '.',
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// collect sections by heading
|
|
74
|
+
const sections = [];
|
|
75
|
+
let cur = null;
|
|
76
|
+
for (const raw of body.split(/\r?\n/)) {
|
|
77
|
+
const h1 = raw.match(/^#\s+(.+)/);
|
|
78
|
+
const h2 = raw.match(/^##\s+(.+)/);
|
|
79
|
+
if (h1) { cur = { level: 1, title: h1[1].trim(), lines: [] }; sections.push(cur); }
|
|
80
|
+
else if (h2) { cur = { level: 2, title: h2[1].trim(), lines: [] }; sections.push(cur); }
|
|
81
|
+
else if (cur) cur.lines.push(raw);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const slides = [];
|
|
85
|
+
sections.forEach((sec, idx) => {
|
|
86
|
+
const { bullets, paras } = splitBody(sec.lines);
|
|
87
|
+
const firstPara = paras[0] || '';
|
|
88
|
+
|
|
89
|
+
if (sec.level === 1 && slides.length === 0) {
|
|
90
|
+
slides.push({ type: 'title', headline: sec.title, sub: firstPara || undefined });
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (CLOSE_TITLES.test(sec.title)) {
|
|
94
|
+
slides.push({ type: 'close', tagline: firstPara || sec.title, footer: bullets[0] || undefined });
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const big = asBigNumber(paras, bullets);
|
|
98
|
+
if (big) { slides.push(big); return; }
|
|
99
|
+
if (bullets.length >= 2 && bullets.length <= 4 && bullets.every((b) => b.length <= 160)) {
|
|
100
|
+
slides.push({ type: 'columns', heading: sec.title, columns: bullets.map(toColumn) });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
slides.push({ type: 'statement', text: sec.title, sub: firstPara || undefined });
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
if (!slides.length) slides.push({ type: 'statement', text: brand.name });
|
|
107
|
+
return { theme, brand, slides };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = { parseMarkdownToSpec, parseFrontMatter, splitBody, toColumn };
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
// Atris HTML renderer — same content model as the deck engine, rendered to
|
|
2
|
+
// beautiful, anti-slop HTML made of semantic blocks. Pure: spec -> HTML string.
|
|
3
|
+
//
|
|
4
|
+
// Connects with the web apps: the `atris` theme matches atrisos-web tokens
|
|
5
|
+
// (amber #f59e0b on warm dark, --brand-* CSS variables), every section carries
|
|
6
|
+
// data-atris-block="<type>", and renderBlock() emits the AppBlock html shape
|
|
7
|
+
// ({ type:'html', config:{ html } }) so the output drops into an Atris app.
|
|
8
|
+
//
|
|
9
|
+
// Anti-slop by construction: one accent, fluid type, restraint, no gradient
|
|
10
|
+
// text, no glassmorphism, em dashes sanitized (shares slides-deck helpers).
|
|
11
|
+
|
|
12
|
+
const { THEMES: DECK_THEMES, sanitize, parseEmph } = require('./slides-deck');
|
|
13
|
+
|
|
14
|
+
// HTML themes reuse the deck design-system shape, plus `atris` (matches the web app).
|
|
15
|
+
const THEMES = {
|
|
16
|
+
atris: { // warm dark, amber accent, matches atrisos-web (--brand-* tokens, TWKLausanne)
|
|
17
|
+
fonts: { display: 'TWKLausanne', body: 'TWKLausanne', mono: 'ui-monospace, SFMono-Regular, monospace' },
|
|
18
|
+
color: { bg: '#141110', panel: '#1E1915', panelAlt: '#2C2520', line: '#3D332D',
|
|
19
|
+
ink: '#EAE3D9', soft: '#A39B92', faint: '#7C736B',
|
|
20
|
+
accent: '#F59E0B', accent2: '#FBBF24', onAccent: '#141110',
|
|
21
|
+
sev: ['#F59E0B', '#FBBF24', '#7F97A4'] },
|
|
22
|
+
},
|
|
23
|
+
terminal: DECK_THEMES.terminal,
|
|
24
|
+
paper: DECK_THEMES.paper,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function esc(s) {
|
|
28
|
+
return String(s == null ? '' : s)
|
|
29
|
+
.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// **emphasis** -> <span class="accent">; everything else escaped. Sanitized first.
|
|
33
|
+
function rich(markup) {
|
|
34
|
+
const { plain, ranges } = parseEmph(sanitize(markup));
|
|
35
|
+
if (!ranges.length) return esc(plain);
|
|
36
|
+
let out = '', i = 0;
|
|
37
|
+
for (const r of ranges) {
|
|
38
|
+
out += esc(plain.slice(i, r.start));
|
|
39
|
+
out += `<span class="accent">${esc(plain.slice(r.start, r.end))}</span>`;
|
|
40
|
+
i = r.end;
|
|
41
|
+
}
|
|
42
|
+
out += esc(plain.slice(i));
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function wordmark(brand) {
|
|
47
|
+
const name = esc((brand && brand.name) || 'Atris');
|
|
48
|
+
const ac = (brand && brand.accent) || '';
|
|
49
|
+
return `<div class="mark">${name}${ac ? `<b>${esc(ac)}</b>` : ''}</div>`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function panelHtml(p) {
|
|
53
|
+
const rows = (p.rows || []).map((r, i) => `
|
|
54
|
+
<div class="row${r.active ? ' active' : ''}">
|
|
55
|
+
<span class="sev s${(r.sev != null ? r.sev : 0) % 3}"></span>
|
|
56
|
+
<div class="name">${rich(r.title || '')}${r.sub ? `<small>${rich(r.sub)}</small>` : ''}</div>
|
|
57
|
+
${r.value != null ? `<div class="val"><b>${rich(String(r.value))}</b>${r.valueSub ? `<small>${rich(r.valueSub)}</small>` : ''}</div>` : ''}
|
|
58
|
+
</div>`).join('');
|
|
59
|
+
return `<div class="panel">
|
|
60
|
+
${p.header ? `<div class="panel-head"><span>${rich(p.header.title || '')}</span>${p.header.meta ? `<span class="meta">${rich(p.header.meta)}</span>` : ''}</div>` : ''}
|
|
61
|
+
${rows}
|
|
62
|
+
${p.footer ? `<div class="panel-foot"><span>${rich(p.footer.left || '')}</span>${p.footer.right ? `<a>${rich(p.footer.right)}</a>` : ''}</div>` : ''}
|
|
63
|
+
</div>`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const BLOCKS = {
|
|
67
|
+
title(s, spec) {
|
|
68
|
+
return `<section class="block hero" data-atris-block="hero">
|
|
69
|
+
<div class="lede">
|
|
70
|
+
${wordmark(spec.brand)}
|
|
71
|
+
<div class="rule"></div>
|
|
72
|
+
<h1>${rich(s.headline || s.title || '')}</h1>
|
|
73
|
+
${s.sub ? `<p class="sub">${rich(s.sub)}</p>` : ''}
|
|
74
|
+
</div>
|
|
75
|
+
${s.panel ? panelHtml(s.panel) : ''}
|
|
76
|
+
</section>`;
|
|
77
|
+
},
|
|
78
|
+
statement(s) {
|
|
79
|
+
return `<section class="block statement" data-atris-block="statement">
|
|
80
|
+
<h2 class="big">${rich(s.text || s.headline || '')}</h2>
|
|
81
|
+
${s.sub ? `<p class="sub">${rich(s.sub)}</p>` : ''}
|
|
82
|
+
</section>`;
|
|
83
|
+
},
|
|
84
|
+
columns(s) {
|
|
85
|
+
const cols = (s.columns || []).map((c) => `
|
|
86
|
+
<div class="col"><h3>${rich(c.h || c.title || '')}</h3>${(c.b || c.body) ? `<p>${rich(c.b || c.body)}</p>` : ''}</div>`).join('');
|
|
87
|
+
return `<section class="block columns" data-atris-block="columns">
|
|
88
|
+
${s.heading ? `<h2 class="heading">${rich(s.heading)}</h2>` : ''}
|
|
89
|
+
<div class="cols c${Math.min((s.columns || []).length, 4)}">${cols}</div>
|
|
90
|
+
</section>`;
|
|
91
|
+
},
|
|
92
|
+
panel(s) {
|
|
93
|
+
return `<section class="block panel-block" data-atris-block="panel">
|
|
94
|
+
<div class="panel-lede">${s.heading ? `<h2>${rich(s.heading)}</h2>` : ''}${s.sub ? `<p>${rich(s.sub)}</p>` : ''}</div>
|
|
95
|
+
${panelHtml(s.panel || { rows: [] })}
|
|
96
|
+
</section>`;
|
|
97
|
+
},
|
|
98
|
+
bignumber(s) {
|
|
99
|
+
return `<section class="block bignumber" data-atris-block="bignumber">
|
|
100
|
+
<div class="num">${rich(String(s.number || s.value || ''))}</div>
|
|
101
|
+
${s.label ? `<div class="num-label">${rich(s.label)}</div>` : ''}
|
|
102
|
+
${s.sub ? `<p class="sub">${rich(s.sub)}</p>` : ''}
|
|
103
|
+
</section>`;
|
|
104
|
+
},
|
|
105
|
+
quote(s) {
|
|
106
|
+
return `<section class="block quote" data-atris-block="quote">
|
|
107
|
+
<blockquote>${rich(s.text || s.quote || '')}</blockquote>
|
|
108
|
+
${s.by ? `<cite>${rich(s.by)}</cite>` : ''}
|
|
109
|
+
</section>`;
|
|
110
|
+
},
|
|
111
|
+
toc(s) {
|
|
112
|
+
const items = (s.items || []).map((it) =>
|
|
113
|
+
`<a class="toc-item" href="${esc(it.href)}"><h3>${rich(it.title || it.href)}</h3>${it.summary ? `<p>${rich(it.summary)}</p>` : ''}</a>`).join('');
|
|
114
|
+
return `<section class="block toc" data-atris-block="toc">
|
|
115
|
+
${s.heading ? `<h2 class="heading">${rich(s.heading)}</h2>` : ''}
|
|
116
|
+
<div class="toc-grid">${items}</div>
|
|
117
|
+
</section>`;
|
|
118
|
+
},
|
|
119
|
+
close(s, spec) {
|
|
120
|
+
const btns = (s.buttons || []).map((b) => `<a class="btn${b.primary ? ' primary' : ''}">${rich(b.label || 'Open')}</a>`).join('');
|
|
121
|
+
return `<section class="block close" data-atris-block="close">
|
|
122
|
+
<div class="rule center"></div>
|
|
123
|
+
${wordmark(spec.brand)}
|
|
124
|
+
${s.tagline ? `<p class="tagline">${rich(s.tagline)}</p>` : ''}
|
|
125
|
+
${btns ? `<div class="btns">${btns}</div>` : ''}
|
|
126
|
+
${s.footer ? `<p class="footer">${rich(s.footer)}</p>` : ''}
|
|
127
|
+
</section>`;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
function css(theme) {
|
|
132
|
+
const c = theme.color, f = theme.fonts;
|
|
133
|
+
const gFonts = (f.display === 'Fraunces' || f.body === 'Outfit')
|
|
134
|
+
? `<link rel="preconnect" href="https://fonts.googleapis.com"><link href="https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,500&family=Outfit:wght@300;400;500;600&display=swap" rel="stylesheet">`
|
|
135
|
+
: '';
|
|
136
|
+
const style = `:root{
|
|
137
|
+
--brand-bg:${c.bg};--brand-card:${c.panel};--brand-surface:${c.panelAlt || c.panel};--brand-line:${c.line};
|
|
138
|
+
--brand-text:${c.ink};--brand-text-secondary:${c.soft};--brand-faint:${c.faint};
|
|
139
|
+
--brand-primary:${c.accent};--brand-primary-2:${c.accent2};
|
|
140
|
+
--font-display:${f.display === 'TWKLausanne' ? "'TWKLausanne',system-ui,sans-serif" : `'${f.display}',serif`};
|
|
141
|
+
--font-body:${f.body === 'TWKLausanne' ? "'TWKLausanne',system-ui,sans-serif" : `'${f.body}',sans-serif`};
|
|
142
|
+
--ease:cubic-bezier(.25,1,.5,1);--measure:60ch;
|
|
143
|
+
}
|
|
144
|
+
*{margin:0;box-sizing:border-box}
|
|
145
|
+
html{-webkit-font-smoothing:antialiased}
|
|
146
|
+
body{font-family:var(--font-body);color:var(--brand-text);background:
|
|
147
|
+
radial-gradient(120% 80% at 88% -8%, ${c.accent}1f, transparent 56%),
|
|
148
|
+
radial-gradient(70% 60% at -6% 4%, ${c.soft}14, transparent 52%), var(--brand-bg);
|
|
149
|
+
line-height:1.5;font-variant-numeric:tabular-nums}
|
|
150
|
+
.wrap{max-width:1140px;margin:0 auto;padding:clamp(28px,5vw,72px) clamp(20px,5vw,56px)}
|
|
151
|
+
.block{padding:clamp(40px,7vw,96px) 0;border-bottom:1px solid var(--brand-line)}
|
|
152
|
+
.block:last-child{border-bottom:0}
|
|
153
|
+
.mark{font-family:var(--font-display);font-weight:500;font-size:20px;letter-spacing:-.01em}
|
|
154
|
+
.mark b{color:var(--brand-primary);font-weight:500}
|
|
155
|
+
.rule{width:40px;height:2px;background:var(--brand-primary);margin:22px 0}.rule.center{margin:0 auto 22px}
|
|
156
|
+
.hero{display:grid;grid-template-columns:1.05fr .95fr;gap:clamp(32px,6vw,80px);align-items:center;border-bottom:0;padding-top:clamp(24px,4vw,48px)}
|
|
157
|
+
@media(max-width:860px){.hero{grid-template-columns:1fr}}
|
|
158
|
+
h1{font-family:var(--font-display);font-weight:300;font-size:clamp(2.6rem,6vw,4.6rem);line-height:.99;letter-spacing:-.02em}
|
|
159
|
+
.accent{color:var(--brand-primary-2);font-style:italic}
|
|
160
|
+
.sub{max-width:var(--measure);color:var(--brand-text-secondary);font-size:clamp(1rem,1.4vw,1.15rem);margin-top:22px}
|
|
161
|
+
.big{font-family:var(--font-display);font-weight:300;font-size:clamp(2.2rem,5vw,3.6rem);line-height:1.02;letter-spacing:-.02em}
|
|
162
|
+
.heading{font-family:var(--font-display);font-weight:400;font-size:clamp(1.6rem,3vw,2rem);margin-bottom:34px}
|
|
163
|
+
.cols{display:grid;gap:clamp(20px,4vw,48px)}.cols.c2{grid-template-columns:repeat(2,1fr)}.cols.c3{grid-template-columns:repeat(3,1fr)}.cols.c4{grid-template-columns:repeat(4,1fr)}
|
|
164
|
+
@media(max-width:720px){.cols{grid-template-columns:1fr!important}}
|
|
165
|
+
.col{border-top:1px solid var(--brand-line);padding-top:18px}
|
|
166
|
+
.col h3{font-family:var(--font-display);font-weight:400;font-size:1.25rem;margin-bottom:8px}
|
|
167
|
+
.col p{color:var(--brand-text-secondary);font-size:.97rem;max-width:36ch}
|
|
168
|
+
.panel-block{display:grid;grid-template-columns:.85fr 1.15fr;gap:clamp(24px,5vw,64px);align-items:center}
|
|
169
|
+
@media(max-width:760px){.panel-block{grid-template-columns:1fr}}
|
|
170
|
+
.panel-lede h2{font-family:var(--font-display);font-weight:400;font-size:1.7rem;margin-bottom:14px}
|
|
171
|
+
.panel-lede p{color:var(--brand-text-secondary);max-width:34ch}
|
|
172
|
+
.panel{background:var(--brand-card);border:1px solid var(--brand-line);border-radius:14px;overflow:hidden;box-shadow:0 1px 2px rgba(0,0,0,.18)}
|
|
173
|
+
.panel-head{display:flex;justify-content:space-between;padding:14px 18px;border-bottom:1px solid var(--brand-line);font-size:14px}
|
|
174
|
+
.panel-head .meta{color:var(--brand-faint);font-size:12.5px}
|
|
175
|
+
.row{display:grid;grid-template-columns:auto 1fr auto;gap:14px;align-items:center;padding:14px 18px;border-bottom:1px solid var(--brand-surface)}
|
|
176
|
+
.row:last-child{border-bottom:0}.row.active{border-left:2px solid var(--brand-primary);padding-left:16px}
|
|
177
|
+
.sev{width:8px;height:8px;border-radius:50%}.sev.s0{background:var(--brand-primary)}.sev.s1{background:var(--brand-primary-2)}.sev.s2{background:#7f97a4}
|
|
178
|
+
.name{font-size:14.5px}.name small{display:block;color:var(--brand-faint);font-size:12.5px;margin-top:3px}
|
|
179
|
+
.val{text-align:right;font-size:12.5px;color:var(--brand-faint)}.val b{display:block;color:var(--brand-text);font-size:15px}
|
|
180
|
+
.panel-foot{display:flex;justify-content:space-between;padding:13px 18px;font-size:13px;color:var(--brand-faint)}
|
|
181
|
+
.panel-foot a{color:var(--brand-primary-2);text-decoration:none}
|
|
182
|
+
.bignumber .num{font-family:var(--font-display);font-weight:300;font-size:clamp(3.5rem,11vw,7rem);line-height:1;color:var(--brand-primary-2)}
|
|
183
|
+
.num-label{font-size:1.05rem;margin-top:18px}
|
|
184
|
+
.quote blockquote{font-family:var(--font-display);font-weight:300;font-style:italic;font-size:clamp(1.6rem,3.4vw,2.4rem);line-height:1.25;max-width:24ch;quotes:'\\201C''\\201D'}
|
|
185
|
+
.quote blockquote::before{content:open-quote;color:var(--brand-primary)}.quote blockquote::after{content:close-quote;color:var(--brand-primary)}
|
|
186
|
+
.quote cite{display:block;margin-top:20px;color:var(--brand-text-secondary);font-style:normal;font-size:.95rem}
|
|
187
|
+
.close{text-align:center;border-bottom:0}
|
|
188
|
+
.close .mark{font-family:var(--font-display);font-size:clamp(2.4rem,6vw,3.4rem);font-weight:400}
|
|
189
|
+
.tagline{color:var(--brand-text-secondary);margin-top:10px}
|
|
190
|
+
.btns{display:flex;gap:12px;justify-content:center;margin-top:28px}
|
|
191
|
+
.btn{padding:12px 22px;border-radius:11px;border:1px solid var(--brand-line);color:var(--brand-text);text-decoration:none;font-weight:500;font-size:15px;transition:transform 160ms var(--ease),background-color 160ms var(--ease)}
|
|
192
|
+
.btn:hover{transform:translateY(-1px)}.btn.primary{background:var(--brand-text);color:var(--brand-bg);border-color:var(--brand-text)}
|
|
193
|
+
.footer{margin-top:30px;color:var(--brand-faint);font-size:13px}
|
|
194
|
+
.sitenav{display:flex;justify-content:space-between;align-items:baseline;max-width:1140px;margin:0 auto;padding:20px clamp(20px,5vw,56px);border-bottom:1px solid var(--brand-line)}
|
|
195
|
+
.sitenav .mark{font-size:18px;text-decoration:none;color:var(--brand-text)}
|
|
196
|
+
.sitenav .nav-links{display:flex;gap:24px;font-size:14px;color:var(--brand-text-secondary)}
|
|
197
|
+
.sitenav .nav-links a{color:inherit;text-decoration:none;transition:color 160ms var(--ease)}
|
|
198
|
+
.sitenav .nav-links a:hover{color:var(--brand-text)}
|
|
199
|
+
.toc-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:clamp(16px,3vw,32px)}
|
|
200
|
+
.toc-item{display:block;border-top:1px solid var(--brand-line);padding-top:16px;text-decoration:none;color:inherit;transition:border-color 160ms var(--ease)}
|
|
201
|
+
.toc-item:hover{border-color:var(--brand-primary)}
|
|
202
|
+
.toc-item h3{font-family:var(--font-display);font-weight:400;font-size:1.15rem;margin-bottom:6px}
|
|
203
|
+
.toc-item p{color:var(--brand-text-secondary);font-size:.92rem;max-width:40ch}
|
|
204
|
+
@media(prefers-reduced-motion:reduce){*{transition:none!important}}`;
|
|
205
|
+
return { gFonts, style };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function renderBody(spec, opts = {}) {
|
|
209
|
+
const themes = opts.themes || THEMES;
|
|
210
|
+
const theme = themes[spec.theme] || THEMES.atris;
|
|
211
|
+
const blocks = (spec.slides || spec.blocks || [])
|
|
212
|
+
.map((s) => (BLOCKS[s.type] || BLOCKS.statement)(s, spec))
|
|
213
|
+
.join('\n ');
|
|
214
|
+
return { theme, html: `<div class="wrap">\n ${blocks}\n </div>` };
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function renderNav(nav) {
|
|
218
|
+
const links = (nav.links || []).map((l) => `<a href="${esc(l.href)}">${esc(l.label)}</a>`).join('');
|
|
219
|
+
return `<nav class="sitenav"><a class="mark" href="${esc(nav.home || 'index.html')}">${esc(nav.label || 'Atris')}${nav.accent ? `<b>${esc(nav.accent)}</b>` : ''}</a>${links ? `<div class="nav-links">${links}</div>` : ''}</nav>`;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// full standalone page (opts.nav renders a site header, opts.themes injects brand themes)
|
|
223
|
+
function renderHtml(spec, opts = {}) {
|
|
224
|
+
const { theme, html } = renderBody(spec, opts);
|
|
225
|
+
const { gFonts, style } = css(theme);
|
|
226
|
+
const title = esc(sanitize(opts.title || (spec.brand && spec.brand.name) || 'Atris'));
|
|
227
|
+
return `<!doctype html>
|
|
228
|
+
<html lang="en">
|
|
229
|
+
<head>
|
|
230
|
+
<meta charset="utf-8">
|
|
231
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
232
|
+
<title>${title}</title>
|
|
233
|
+
${gFonts}
|
|
234
|
+
<style>${style}</style>
|
|
235
|
+
</head>
|
|
236
|
+
<body data-atris-theme="${esc(spec.theme || 'atris')}">
|
|
237
|
+
${opts.nav ? renderNav(opts.nav) : ''}
|
|
238
|
+
${html}
|
|
239
|
+
</body>
|
|
240
|
+
</html>`;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// AppBlock html shape, ready to embed in an Atris app (ui_template 'html'/'block')
|
|
244
|
+
function renderBlock(spec, opts = {}) {
|
|
245
|
+
return {
|
|
246
|
+
type: 'html',
|
|
247
|
+
title: opts.title || (spec.brand && spec.brand.name) || 'Atris',
|
|
248
|
+
config: {
|
|
249
|
+
block_type: 'html',
|
|
250
|
+
title: opts.title || (spec.brand && spec.brand.name) || 'Atris',
|
|
251
|
+
html: renderHtml(spec, opts),
|
|
252
|
+
theme: spec.theme || 'atris',
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
module.exports = { renderHtml, renderBlock, renderBody, THEMES, BLOCKS, rich, esc };
|