@5cover/lectern 0.0.0-stage → 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.
package/README.md CHANGED
@@ -1,3 +1,251 @@
1
- # Temporary Holding Version
1
+ # lectern
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > Author professional [reveal.js](https://revealjs.com) slide decks as typed TSX components, styled by the ENGIE [Fluid design system](https://www.engie.design/fluid-design-system/).
4
+
5
+ `lectern` separates the three concerns of a slideshow: what you show (content), how it looks (style), how it's laid out; and takes the last two off your plate. You describe a deck's _semantic content_ with components (`<Slide>`, `<Bullets>`, `<Columns>`, `<Mermaid>`, `<Metric>`…); reveal.js orchestrates the presentation and Fluid tokens supply a consistent, on-brand look. When a single slide needs manual control, every component takes a `class`/`style` escape hatch and `<Raw>` injects arbitrary HTML.
6
+
7
+ - TSX authoring, fully typed; your editor autocompletes the deck
8
+ - Fluid-themed reveal.js out of the box (ENGIE blue, Lato, spacing, elevation)
9
+ - Mermaid diagrams, syntax-highlighted code, KPI cards, timelines, speaker notes
10
+ - One command each for a live dev server, a self-contained static `index.html`, and a PDF
11
+
12
+ ## Requirements
13
+
14
+ - Node ≥ 20, a package manager (pnpm recommended)
15
+ - For `lectern pdf`: Playwright's Chromium: `npx playwright install chromium` (one-time)
16
+
17
+ ## Quick start
18
+
19
+ Write a deck as a `.tsx` file whose default export is a `<Deck>`:
20
+
21
+ Neutral primitives come from `@5cover/lectern`; the philosophy-bearing slides and styled atoms come from a **profile** (`@5cover/lectern/engie`) — see [Profiles](#profiles).
22
+
23
+ ```tsx
24
+ // deck.tsx
25
+ import { Columns, Code, Mermaid, Notes } from '@5cover/lectern'
26
+ import { Deck, TitleSlide, SectionSlide, Slide, Summary, Bullets, Metric, Timeline } from '@5cover/lectern/engie'
27
+
28
+ export default (
29
+ <Deck title="Alternance Engie — Point d'étape" author="Raphaël Bardini" date="Juin 2026" footer="Confidentiel">
30
+ <TitleSlide
31
+ eyebrow="ENGIE"
32
+ title="Point d'étape"
33
+ subtitle="Système de validation"
34
+ author="Raphaël Bardini"
35
+ date="Juin 2026"
36
+ />
37
+
38
+ <SectionSlide number="01" title="Contexte" />
39
+
40
+ <Slide heading="Le projet" kicker="Mission">
41
+ <Bullets items={['Automatiser la chaîne de validation', 'Sur Power Platform / Dataverse']} incremental />
42
+ <Notes>Rappeler le périmètre métier.</Notes>
43
+ </Slide>
44
+
45
+ <Slide heading="Architecture cible">
46
+ <Mermaid>{`flowchart LR
47
+ A[Demande] --> B{Validation}
48
+ B -->|OK| C[Terminé]
49
+ B -->|KO| D[Rejeté]`}</Mermaid>
50
+ </Slide>
51
+
52
+ <Slide heading="Détail technique">
53
+ <Columns ratio={[3, 2]}>
54
+ <Code lang="js">{`if (equals('fr', locale)) { /* … */ }`}</Code>
55
+ <Bullets items={["Génération d'expressions WDL", 'Macros et abstractions']} />
56
+ </Columns>
57
+ </Slide>
58
+
59
+ <Slide heading="Indicateurs">
60
+ <Columns>
61
+ <Metric value="12" label="Flows livrés" trend="+4 ce mois" tone="positive" />
62
+ <Metric value="3" label="Environnements" />
63
+ </Columns>
64
+ </Slide>
65
+ </Deck>
66
+ )
67
+ ```
68
+
69
+ Then:
70
+
71
+ ```bash
72
+ lectern dev deck.tsx # live-reload dev server (default http://localhost:4321)
73
+ lectern build deck.tsx -o dist # self-contained dist/index.html (open offline, host anywhere)
74
+ lectern serve deck.tsx # fresh production build served locally (default http://127.0.0.1:4321)
75
+ lectern pdf deck.tsx -o deck.pdf # PDF export via headless Chromium
76
+ ```
77
+
78
+ Running inside this repo, use `pnpm lectern <cmd>` (an alias for `node --import tsx ./src/cli/index.ts`).
79
+
80
+ ## Learn by example
81
+
82
+ The fastest way to learn `lectern` is to copy a working deck:
83
+
84
+ - `examples/engie-alternance/deck.tsx`: a full ~19-slide deck: title, section dividers, columns, a Mermaid flowchart, KPI cards, a timeline, code, quotes and speaker notes. This is the canonical "what can it do" reference.
85
+ - `examples/smoke/deck.tsx`: a minimal deck touching each component type.
86
+ - `examples/custom-profile/`: a deck in a house style defined outside the package (profile, stylesheet, components, asset). Start here to [define your own profile](#defining-your-own-profile).
87
+
88
+ Try one live: `pnpm lectern dev examples/engie-alternance/deck.tsx`.
89
+
90
+ Every component carries JSDoc, so your editor shows what each one does and which props it takes as you type: that's the up-to-date reference.
91
+
92
+ ## Authoring with TSX
93
+
94
+ Extend Lectern's authoring config in your project's `tsconfig.json`:
95
+
96
+ ```jsonc
97
+ {
98
+ "extends": "@5cover/lectern/tsconfig.json",
99
+ "include": ["deck.tsx"],
100
+ }
101
+ ```
102
+
103
+ The exported config sets Lectern's automatic JSX runtime and Vite asset typings, so imports such as `./diagram.svg?raw` are typed as strings. Keep your project's own target, strictness, module settings, and include paths alongside the `extends` entry. If you override `compilerOptions.types`, include `@5cover/lectern/vite-env` in that list. Typecheck the project configuration with `pnpm exec tsc --noEmit`; do not pass a source filename directly to `tsc`, because that bypasses `tsconfig.json`.
104
+
105
+ Components render to static HTML at build time (via `preact-render-to-string`); there is no Preact runtime in the browser. reveal.js and Mermaid run client-side on the produced HTML.
106
+
107
+ ### Components
108
+
109
+ Components split by **who owns the layout decision**. Neutral, structure-only primitives live in core `@5cover/lectern`; the philosophy-bearing slides and opinionated atoms live in a profile (`@5cover/lectern/engie`). A profile's CSS styles everything.
110
+
111
+ **Core `lectern`** (neutral — reusable across profiles):
112
+
113
+ | Component | Purpose |
114
+ | --------------------------------------------------------------------------- | ------------------------------------------------ |
115
+ | `<Deck>` | Root; holds metadata + slides |
116
+ | `<Columns ratio tracks fill>` / `<Stack fill>` / `<Grid cols>` / `<Spacer>` | Layout primitives |
117
+ | `<Code lang lineNumbers>` / `<Mermaid>` | Highlighted code · Mermaid diagram |
118
+ | `<Notes>` / `<Fragment>` / `<Raw html>` | Speaker notes · fragment · raw-HTML escape hatch |
119
+
120
+ **`@5cover/lectern/engie`** (the ENGIE authoring surface — template-accurate):
121
+
122
+ | Component | Purpose |
123
+ | ---------------------------------------------------- | --------------------------------------------------- |
124
+ | `<Deck>` | ENGIE-bound root (pins `profile="engie"`) |
125
+ | `<TitleSlide>` | Navy cover, white title, logo, confidentiality tag |
126
+ | `<SectionSlide number>` | Navy full-bleed section divider |
127
+ | `<Slide heading subtitle kicker>` | Content slide (navy title, ~25pt) |
128
+ | `<Summary items>` | Numbered chapters / agenda |
129
+ | `<Bullets>` / `<Steps>` | Lists |
130
+ | `<Metric value label trend tone>` | KPI figure |
131
+ | `<Timeline items>` | Opinionated **horizontal** timeline |
132
+ | `<Quote cite>` / `<Lead>` | Emphasis |
133
+ | `<Star.Situation>` / `.Task` / `.Action` / `.Result` | STAR stages in normal flow, with no wrapper |
134
+ | `<Swot strengths weaknesses opportunities threats>` | Editorial SWOT matrix with a central S/W/O/T marker |
135
+
136
+ ### Escape hatches
137
+
138
+ - Every layout/content component accepts `class` and `style` for a one-off tweak.
139
+ - `<Slide>` accepts `background`, `transition`, `autoAnimate`, and raw reveal attributes via `attrs={{ "data-…": … }}`.
140
+ - `<Raw html="…" />` for anything not yet covered by a component.
141
+
142
+ ## CLI
143
+
144
+ ```sh
145
+ lectern dev [deck.tsx] [--port 4321]
146
+ lectern build [deck.tsx] [--out dist] [--no-single-file]
147
+ lectern serve [deck.tsx] [--port 4321] [--host 127.0.0.1]
148
+ lectern pdf [deck.tsx] [--out deck.pdf]
149
+ lectern rules [profile | deck.tsx] # print a profile's guidelines (default: engie)
150
+ ```
151
+
152
+ - `build` inlines all JS/CSS/assets into a single `index.html` by default. Use `--no-single-file` to emit a folder of hashed assets instead.
153
+ - `serve` makes a fresh, single-file production build in a temporary directory and hosts it without file watching or Vite's development runtime. It listens on `127.0.0.1` by default; pass `--host 0.0.0.0` to make it reachable from other devices on your network.
154
+ - `pdf` reuses the build output and drives reveal's `?print-pdf` mode. It waits for reveal and every Mermaid diagram to finish before printing.
155
+ - `rules` prints the natural-language rulebook for a built-in profile by name, or for the profile a deck uses when given a deck path (see below).
156
+
157
+ ## Profiles
158
+
159
+ A **profile** is a deck authoring _philosophy_, not just a skin. It owns:
160
+
161
+ - its **component set** — the slides/atoms whose layout embodies the house style (`@5cover/lectern/engie` exports these; importing them selects the profile);
162
+ - its **look** — a `.profile-<name>`-scoped stylesheet that also styles the neutral core components (core `lectern` ships only reveal.js's base CSS and a code-highlighting theme; the `engie` stylesheet brings Fluid);
163
+ - its **reveal config** (aspect ratio, transitions, `center`, …);
164
+ - its **rules** — a natural-language rulebook (documentation today; no linting yet).
165
+
166
+ Because a profile owns components, **switching profile is an import change**, not a one-liner — and a profile need not even have the same components (it might have no `TitleSlide`, or a different `Timeline`). The `engie` profile reproduces the official ENGIE PowerPoint template (navy `#17255F` cover, restrained navy titles, numbered Summary, horizontal Timeline, 8pt © ENGIE footer). View its rules:
167
+
168
+ ```sh
169
+ lectern rules engie
170
+ ```
171
+
172
+ ### Defining your own profile
173
+
174
+ A profile does not have to live in this package. Yours goes through exactly the same path as `engie`: the built-in profile is defined with the same `Profile` object and bound to its `Deck` the same way. The only extra a built-in profile gets is a name shorthand (`profile="engie"`). See `examples/custom-profile/` for a complete, working example.
175
+
176
+ **1. The profile object**: metadata, look, reveal defaults and rules.
177
+
178
+ ```ts
179
+ // profile.ts
180
+ import type { Profile } from '@5cover/lectern'
181
+
182
+ export const paper: Profile = {
183
+ name: 'paper', // root class `.profile-paper`
184
+ label: 'Paper',
185
+ description: 'Monochrome editorial style, 4:3.',
186
+ stylesheet: new URL('./paper.css', import.meta.url),
187
+ reveal: { width: 1024, height: 768, center: true },
188
+ rules: [{ title: 'Structure', rules: [{ id: 'one-idea', statement: 'One idea per slide.', severity: 'should' }] }],
189
+ }
190
+ ```
191
+
192
+ `stylesheet` is anything Vite can import from your project: a file URL relative to the profile module (as above), an absolute path, or a package path such as `'my-brand/brand.css'`. It is bundled after lectern's core CSS, so its rules win, and it can `@import` other stylesheets (the `engie` stylesheet imports Fluid this way). `reveal` is merged under each deck's own `reveal` overrides.
193
+
194
+ **2. The stylesheet**: scope everything under `.reveal.profile-<name>`. Lectern ships no reveal theme, so set fonts, colours and the type scale yourself. The client also adds the profile class to reveal's viewport (`.reveal-viewport.profile-<name>`, the area around the scaled canvas). The runtime reads these custom properties from `.reveal` to theme Mermaid diagrams: `--lectern-brand`, `--lectern-brand-strong`, `--lectern-ink`, `--lectern-line`, `--lectern-bg-soft`. Core components emit these classes for you to style: `lectern-columns`, `lectern-col`, `lectern-stack`, `lectern-grid`, `lectern-spacer`, `lectern-code`, `mermaid`, `lectern-raw`, `lectern-infograph-*`, and the deck footer `lectern-footer` / `lectern-footer-brand`. Layout primitives set their grid geometry inline, so a profile only adds spacing and looks.
195
+
196
+ **3. Components and a bound `Deck`**: pin the profile once, like `@5cover/lectern/engie` does, and write the slides that embody your house style. Each slide is a `<section>`.
197
+
198
+ ```tsx
199
+ // components.tsx
200
+ import { Deck as CoreDeck } from '@5cover/lectern'
201
+ import type { DeckProps } from '@5cover/lectern'
202
+ import { paper } from './profile'
203
+ import mark from './mark.svg'
204
+
205
+ export function Deck(props: DeckProps) {
206
+ return <CoreDeck profile={paper} {...props} />
207
+ }
208
+
209
+ export function Cover({ title }: { title: string }) {
210
+ return (
211
+ <section class="paper-cover">
212
+ <img src={mark} alt="" />
213
+ <h1>{title}</h1>
214
+ </section>
215
+ )
216
+ }
217
+ ```
218
+
219
+ Assets imported by your components (like `mark.svg` above) are inlined into the built deck. Shared helpers for building components are exported from `@5cover/lectern`: `cx` and the `StyleEscapeHatch`, `Transition` and `DeckProps` types.
220
+
221
+ **4. Use it**: decks import your `Deck` and components; every command (`dev`, `build`, `serve`, `pdf`) picks the profile up from the deck, and `lectern rules deck.tsx` prints its rulebook. You can also skip the bound `Deck` and pass the object directly: `<Deck profile={paper}>` with `Deck` from `@5cover/lectern`.
222
+
223
+ Shared, genuinely-neutral atoms can be lifted into core `@5cover/lectern` once a second profile shows what's actually common.
224
+
225
+ ## How it works
226
+
227
+ ```mermaid
228
+ flowchart LR
229
+ D["deck.tsx"] -->|"Vite SSR + preact-render-to-string"| R["reveal HTML"]
230
+ R --> H["index.html"]
231
+ F["profile stylesheet (e.g. Fluid + ENGIE)"] --> H
232
+ C["reveal.js + mermaid (client, bundled)"] --> H
233
+ H --> O["dev / static / PDF"]
234
+ ```
235
+
236
+ The `@5cover/lectern/engie.css` stylesheet builds on Fluid's `--nj-*` design tokens, so an ENGIE deck is on-brand with zero per-slide styling.
237
+
238
+ ## Notes
239
+
240
+ - Fonts: the Fluid token stack leads with Lato; if it isn't available it falls back to the system sans-serif. Bundle the licensed brand font in your project if you need it embedded.
241
+ - Mermaid: diagrams render client-side and are pinned to a metric-stable font so labels never clip under the Fluid cascade.
242
+ - Built with reveal.js 6, Mermaid 11, Fluid 6, Preact + Vite.
243
+
244
+ ## Development
245
+
246
+ ```bash
247
+ pnpm install # (in this repo: uses --ignore-workspace)
248
+ pnpm build # bundle lib + CLI + d.ts (tsup)
249
+ pnpm test # vitest
250
+ pnpm typecheck # tsc --noEmit
251
+ ```
@@ -0,0 +1,110 @@
1
+ import * as preact from 'preact';
2
+ import { ComponentChildren, VNode } from 'preact';
3
+ import { RevealConfig } from 'reveal.js';
4
+
5
+ /**
6
+ * A profile is more than a theme: it bundles the *presentation* (CSS + reveal
7
+ * configuration) AND the *doctrine* (rules describing what a well-formed deck
8
+ * looks like) for a given house style — e.g. ENGIE / Fluid.
9
+ *
10
+ * Today profiles change look and configuration; rules are natural-language
11
+ * guidance surfaced by `lectern rules <profile>`. A future `check` hook could
12
+ * make a subset of them machine-verifiable (linting) without changing this shape.
13
+ */
14
+ interface Profile {
15
+ /** Stable identifier used on the CLI and as the `.profile-<name>` root class. */
16
+ name: string;
17
+ /** Human-readable name for display. */
18
+ label: string;
19
+ /** One-line description of the house style. */
20
+ description: string;
21
+ /** reveal.js config defaults merged under any per-deck overrides. */
22
+ reveal?: RevealConfig;
23
+ /**
24
+ * The look: a stylesheet bundled into the deck's client after lectern's core
25
+ * CSS (reveal.js, code highlighting). Any specifier Vite can import from the
26
+ * project: a file URL (`new URL('./brand.css', import.meta.url)`), an
27
+ * absolute path, or a package path (`'my-brand/brand.css'`). Scope its rules
28
+ * under `.reveal.profile-<name>`.
29
+ */
30
+ stylesheet?: string | URL;
31
+ /** The doctrine: what a well-formed deck in this profile looks like. */
32
+ rules: RuleGroup[];
33
+ }
34
+ /** How strongly a rule is held. Descriptive today; a linter could act on it later. */
35
+ type RuleSeverity = 'must' | 'should' | 'advisory';
36
+ interface Rule {
37
+ /** Stable kebab-case id, e.g. "title-max-lines". */
38
+ id: string;
39
+ /** Natural-language statement of the rule. Valuable on its own. */
40
+ statement: string;
41
+ /** How strongly it is held. */
42
+ severity: RuleSeverity;
43
+ }
44
+ /** Rules grouped by theme (Structure, Colours, Typography, …). */
45
+ interface RuleGroup {
46
+ title: string;
47
+ rules: Rule[];
48
+ }
49
+
50
+ /** reveal.js slide transition names. */
51
+ type Transition = 'none' | 'fade' | 'slide' | 'convex' | 'concave' | 'zoom';
52
+ /**
53
+ * Names of the house-style profiles shipped with `lectern`, usable as a
54
+ * shorthand for their `Profile` object. Currently only ENGIE / Fluid.
55
+ */
56
+ type ProfileName = 'engie';
57
+ /** Common props accepted by every visual component: a one-off escape hatch. */
58
+ interface StyleEscapeHatch {
59
+ /** Extra CSS class(es) appended after the component's own classes. */
60
+ class?: string;
61
+ /** Inline style for a single-slide tweak. Prefer Fluid tokens where possible. */
62
+ style?: string | Record<string, string | number>;
63
+ }
64
+ /** Top-level deck metadata, read by the renderer to build the HTML shell. */
65
+ interface DeckMeta {
66
+ /** Deck title used for the document `<title>` and speaker view. */
67
+ title: string;
68
+ /** Author / presenter name. */
69
+ author?: string;
70
+ /** Free-form date label, e.g. "Juin 2026". */
71
+ date?: string;
72
+ /**
73
+ * House-style profile to apply (look + reveal config + rules): a `Profile`
74
+ * object, yours or a built-in one, or a built-in profile's name. Defaults to "engie".
75
+ */
76
+ profile?: ProfileName | Profile;
77
+ /** Default slide transition. Defaults to "slide". */
78
+ transition?: Transition;
79
+ /** Persistent footer text shown on every slide (e.g. confidentiality note). */
80
+ footer?: string;
81
+ /** Extra reveal.js config, merged over the defaults. */
82
+ reveal?: Partial<RevealConfig>;
83
+ }
84
+ /** Deck metadata after rendering: the profile is resolved down to its name. */
85
+ interface ResolvedDeckMeta extends Omit<DeckMeta, 'profile'> {
86
+ profile: string;
87
+ }
88
+ interface DeckProps extends DeckMeta {
89
+ children?: ComponentChildren;
90
+ }
91
+ /** A VNode is what every `lectern` component returns. */
92
+ type Slide = VNode;
93
+
94
+ /**
95
+ * Root of a presentation. Holds deck-level metadata (title, author, theme,
96
+ * transition, footer) and its slides as children.
97
+ *
98
+ * The renderer reads this node's props to assemble the HTML shell and reveal.js
99
+ * config, then renders the children into `.reveal > .slides`. Rendering `<Deck>`
100
+ * directly also works (it emits the slides), but metadata is only applied when
101
+ * the deck is passed to `lectern`'s renderer / CLI.
102
+ */
103
+ declare function Deck(props: DeckProps): preact.JSX.Element;
104
+ /** Type guard: is this VNode a <Deck>? Used by the renderer. */
105
+ declare function isDeck(node: unknown): node is {
106
+ props: DeckProps;
107
+ };
108
+
109
+ export { Deck as c, isDeck as i };
110
+ export type { DeckProps as D, Profile as P, ResolvedDeckMeta as R, StyleEscapeHatch as S, Transition as T, ProfileName as a, DeckMeta as b, Rule as d, RuleGroup as e, RuleSeverity as f, Slide as g };