@5cover/lectern 0.1.0 → 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 +1 -1
- package/dist/cli/index.js +7 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/cli/build.ts +0 -79
- package/src/cli/dev.ts +0 -58
- package/src/cli/index.ts +0 -126
- package/src/cli/paths.ts +0 -81
- package/src/cli/pdf.ts +0 -70
- package/src/cli/render.ts +0 -40
- package/src/cli/rules.ts +0 -31
- package/src/cli/serve.ts +0 -112
- package/src/client/entry.ts +0 -170
- package/src/client/graph.tsx +0 -207
- package/src/components/Deck.tsx +0 -19
- package/src/components/InfographDiscovery.tsx +0 -51
- package/src/components/layout.tsx +0 -145
- package/src/components/mechanics.tsx +0 -74
- package/src/components/util.ts +0 -12
- package/src/index.ts +0 -37
- package/src/infographDiscovery.ts +0 -188
- package/src/infographDiscoveryView.tsx +0 -202
- package/src/jsx-runtime.ts +0 -4
- package/src/profiles/engie/assets/engie-logo-dark.svg +0 -1
- package/src/profiles/engie/assets/engie-logo-white.svg +0 -6
- package/src/profiles/engie/assets.d.ts +0 -4
- package/src/profiles/engie/atoms.tsx +0 -203
- package/src/profiles/engie/index.ts +0 -44
- package/src/profiles/engie/profile.ts +0 -132
- package/src/profiles/engie/slides.tsx +0 -230
- package/src/profiles/index.ts +0 -30
- package/src/profiles/types.ts +0 -49
- package/src/render/renderDeck.tsx +0 -74
- package/src/render/template.ts +0 -68
- package/src/types.ts +0 -53
- /package/{src → dist}/profiles/engie/engie.css +0 -0
package/src/client/entry.ts
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Browser runtime for a `lectern` deck. Bundled by Vite (dev + build).
|
|
3
|
-
* Imports every core asset so the built output is fully self-contained:
|
|
4
|
-
* reveal.js core + plugins and Mermaid. The active profile's stylesheet is
|
|
5
|
-
* imported after this module by the CLI. Reads deck config from the
|
|
6
|
-
* `#lectern-config` JSON script tag.
|
|
7
|
-
*/
|
|
8
|
-
import mermaid from 'mermaid'
|
|
9
|
-
import Reveal from 'reveal.js'
|
|
10
|
-
import RevealHighlight from 'reveal.js/plugin/highlight'
|
|
11
|
-
import RevealNotes from 'reveal.js/plugin/notes'
|
|
12
|
-
|
|
13
|
-
import 'reveal.js/plugin/highlight/monokai.css'
|
|
14
|
-
import 'reveal.js/reveal.css'
|
|
15
|
-
|
|
16
|
-
interface PresentConfig {
|
|
17
|
-
profile?: string
|
|
18
|
-
transition?: string
|
|
19
|
-
reveal?: Record<string, unknown>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function readConfig(): PresentConfig {
|
|
23
|
-
const el = document.getElementById('lectern-config')
|
|
24
|
-
if (!el?.textContent) return {}
|
|
25
|
-
try {
|
|
26
|
-
return JSON.parse(el.textContent) as PresentConfig
|
|
27
|
-
} catch {
|
|
28
|
-
return {}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Profile tokens live on the `.reveal.profile-<name>` element, not :root.
|
|
33
|
-
function cssVar(name: string, fallback: string): string {
|
|
34
|
-
const root = document.querySelector('.reveal') ?? document.documentElement
|
|
35
|
-
const v = getComputedStyle(root).getPropertyValue(name).trim()
|
|
36
|
-
return v || fallback
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function main() {
|
|
40
|
-
const config = readConfig()
|
|
41
|
-
|
|
42
|
-
// Ensure the active profile class is lectern (the renderer sets it server-side).
|
|
43
|
-
const revealEl = document.querySelector('.reveal')
|
|
44
|
-
if (config.profile && revealEl && !revealEl.classList.contains(`profile-${config.profile}`)) {
|
|
45
|
-
revealEl.classList.add(`profile-${config.profile}`)
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Theme Mermaid to match the active profile before rendering.
|
|
49
|
-
const brand = cssVar('--lectern-brand', '#007bc5')
|
|
50
|
-
const brandStrong = cssVar('--lectern-brand-strong', '#004573')
|
|
51
|
-
const ink = cssVar('--lectern-ink', '#232d35')
|
|
52
|
-
const line = cssVar('--lectern-line', '#d6dde2')
|
|
53
|
-
const bgSoft = cssVar('--lectern-bg-soft', '#f6f8f9')
|
|
54
|
-
// The profile's *resolved* font stack (from Fluid) — we don't invent a font.
|
|
55
|
-
// Mermaid pins labels to this value in its generated stylesheet, so measured
|
|
56
|
-
// and rendered widths agree.
|
|
57
|
-
const font = getComputedStyle(revealEl ?? document.documentElement).fontFamily || 'sans-serif'
|
|
58
|
-
|
|
59
|
-
mermaid.initialize({
|
|
60
|
-
startOnLoad: false,
|
|
61
|
-
securityLevel: 'loose',
|
|
62
|
-
theme: 'base',
|
|
63
|
-
fontFamily: font,
|
|
64
|
-
flowchart: { htmlLabels: false, useMaxWidth: false, padding: 10, nodeSpacing: 50, rankSpacing: 55 },
|
|
65
|
-
themeVariables: {
|
|
66
|
-
fontFamily: font,
|
|
67
|
-
primaryColor: bgSoft,
|
|
68
|
-
primaryBorderColor: brand,
|
|
69
|
-
primaryTextColor: ink,
|
|
70
|
-
lineColor: brandStrong,
|
|
71
|
-
secondaryColor: '#ffffff',
|
|
72
|
-
tertiaryColor: bgSoft,
|
|
73
|
-
tertiaryBorderColor: line,
|
|
74
|
-
clusterBkg: '#ffffff',
|
|
75
|
-
clusterBorder: line,
|
|
76
|
-
},
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const deck = new Reveal({
|
|
80
|
-
width: 1280,
|
|
81
|
-
height: 720,
|
|
82
|
-
// Let the presentation fill any viewport. A deck may still explicitly
|
|
83
|
-
// cap either value through its `reveal` configuration.
|
|
84
|
-
minScale: 0,
|
|
85
|
-
maxScale: Infinity,
|
|
86
|
-
hash: true,
|
|
87
|
-
// In PDF export, keep one page per slide (show all fragments) instead of one page per fragment step: better for a handout.
|
|
88
|
-
pdfSeparateFragments: false,
|
|
89
|
-
transition: (config.transition as 'slide') ?? 'slide',
|
|
90
|
-
plugins: [RevealHighlight, RevealNotes],
|
|
91
|
-
...(config.reveal ?? {}),
|
|
92
|
-
})
|
|
93
|
-
|
|
94
|
-
await deck.initialize()
|
|
95
|
-
|
|
96
|
-
// Reveal marks its viewport during initialization; tag it with the profile so
|
|
97
|
-
// profile CSS can style the area around the scaled canvas.
|
|
98
|
-
const viewport = revealEl?.closest('.reveal-viewport')
|
|
99
|
-
if (config.profile && viewport) viewport.classList.add(`profile-${config.profile}`)
|
|
100
|
-
|
|
101
|
-
// Mermaid must render while its slide is VISIBLE: a diagram rendered inside a `display:none` slide collapses to zero size. So we render lazily: all at once for PDF (every slide is shown), otherwise per-slide on navigation.
|
|
102
|
-
async function renderMermaid(scope: ParentNode | null) {
|
|
103
|
-
const nodes = Array.from((scope ?? document).querySelectorAll<HTMLElement>('.mermaid:not([data-processed])'))
|
|
104
|
-
if (!nodes.length) return
|
|
105
|
-
// Mermaid measures SVG labels in screen coordinates. Reveal scales the
|
|
106
|
-
// `.slides` canvas with a CSS transform, which would make Mermaid bake
|
|
107
|
-
// that scale into node dimensions and then scale them a second time.
|
|
108
|
-
// Render in the unscaled 1280×720 coordinate system, then restore
|
|
109
|
-
// Reveal's transform for display.
|
|
110
|
-
const slides = document.querySelector<HTMLElement>('.reveal .slides')
|
|
111
|
-
const transform = slides?.style.transform
|
|
112
|
-
if (slides && transform?.includes('scale(')) {
|
|
113
|
-
slides.style.transform = transform.replace(/scale\([^)]*\)/, 'scale(1)')
|
|
114
|
-
}
|
|
115
|
-
try {
|
|
116
|
-
await mermaid.run({ nodes })
|
|
117
|
-
} catch (err) {
|
|
118
|
-
console.error('[lectern] mermaid render error', err)
|
|
119
|
-
} finally {
|
|
120
|
-
if (slides && transform !== undefined) {
|
|
121
|
-
slides.style.transform = transform
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
// Mermaid appends a shared tooltip to <body>. Its default absolute
|
|
125
|
-
// position extends the document by a few pixels, which becomes a
|
|
126
|
-
// trailing blank PDF page in print mode. Keep it available for hover
|
|
127
|
-
// interactions without letting it participate in document height.
|
|
128
|
-
document.querySelectorAll<HTMLElement>('body > .mermaidTooltip').forEach(tooltip => {
|
|
129
|
-
tooltip.style.position = 'fixed'
|
|
130
|
-
})
|
|
131
|
-
deck.layout()
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
const isPrint = /print-pdf/.test(location.search)
|
|
135
|
-
if (isPrint) {
|
|
136
|
-
const formatPdfSlideNumbers = () => {
|
|
137
|
-
const pages = Array.from(document.querySelectorAll<HTMLElement>('.pdf-page'))
|
|
138
|
-
pages.forEach((page, index) => {
|
|
139
|
-
const number = page.querySelector<HTMLElement>('.slide-number-pdf')
|
|
140
|
-
if (number) number.textContent = `${index + 1} / ${pages.length}`
|
|
141
|
-
})
|
|
142
|
-
}
|
|
143
|
-
deck.on('pdf-ready', formatPdfSlideNumbers)
|
|
144
|
-
await renderMermaid(document)
|
|
145
|
-
// Reveal's PDF renderer ignores the `c/t` slide-number format and
|
|
146
|
-
// injects a bare sequential number into each generated `.pdf-page`.
|
|
147
|
-
// Its asynchronous `pdf-ready` event is the point at which the total
|
|
148
|
-
// number of exported pages is known.
|
|
149
|
-
formatPdfSlideNumbers()
|
|
150
|
-
} else {
|
|
151
|
-
await renderMermaid(deck.getCurrentSlide())
|
|
152
|
-
deck.on('slidechanged', event => {
|
|
153
|
-
void renderMermaid((event as unknown as { currentSlide: HTMLElement }).currentSlide)
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// Opt-in infograph discovery. Dynamic import keeps Cytoscape out of decks
|
|
158
|
-
// that do not embed the component; in PDF mode it renders the seed graph
|
|
159
|
-
// without an interactive surface.
|
|
160
|
-
if (document.querySelector('[data-lectern-infograph-discovery]')) {
|
|
161
|
-
const { initInfographDiscovery } = await import('./graph')
|
|
162
|
-
const infographReady = initInfographDiscovery(deck as unknown as Parameters<typeof initInfographDiscovery>[0])
|
|
163
|
-
if (isPrint) await infographReady
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Expose for tooling (PDF export waits on this).
|
|
167
|
-
;(window as unknown as { Reveal: unknown }).Reveal = deck
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
void main()
|
package/src/client/graph.tsx
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import cytoscape from 'cytoscape'
|
|
2
|
-
import fcose from 'cytoscape-fcose'
|
|
3
|
-
cytoscape.use(fcose)
|
|
4
|
-
import { render } from 'preact'
|
|
5
|
-
import { InfographDiscoveryDetails } from '../infographDiscoveryView'
|
|
6
|
-
import {
|
|
7
|
-
searchLabel,
|
|
8
|
-
selectDiscoveryRelations,
|
|
9
|
-
type DiscoveryPayload,
|
|
10
|
-
type DiscoverySelection,
|
|
11
|
-
} from '../infographDiscovery'
|
|
12
|
-
|
|
13
|
-
const kindColor: Record<string, string> = {
|
|
14
|
-
actor: '#0891b2',
|
|
15
|
-
challenge: '#e0533d',
|
|
16
|
-
constraint: '#e0533d',
|
|
17
|
-
decision: '#d97706',
|
|
18
|
-
event: '#8b5cf6',
|
|
19
|
-
finding: '#a855f7',
|
|
20
|
-
jargon: '#a855f7',
|
|
21
|
-
learning: '#16a34a',
|
|
22
|
-
method: '#0d9488',
|
|
23
|
-
model: '#6c4796',
|
|
24
|
-
objective: '#16a34a',
|
|
25
|
-
problem: '#e0533d',
|
|
26
|
-
process: '#0d9488',
|
|
27
|
-
product: '#06b6d4',
|
|
28
|
-
project: '#0b57d0',
|
|
29
|
-
requirement: '#d97706',
|
|
30
|
-
skill: '#5b6b7a',
|
|
31
|
-
task: '#3b82f6',
|
|
32
|
-
tool: '#5b6b7a',
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface RevealLike {
|
|
36
|
-
getCurrentSlide: () => Element | undefined
|
|
37
|
-
on: (event: string, callback: () => void) => void
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function initInfographDiscovery(deck: RevealLike): Promise<void> {
|
|
41
|
-
const initialLayouts: Promise<void>[] = []
|
|
42
|
-
const isPrint = /print-pdf/.test(location.search)
|
|
43
|
-
document.querySelectorAll<HTMLElement>('[data-lectern-infograph-discovery]').forEach(root => {
|
|
44
|
-
const data = root.querySelector<HTMLScriptElement>('.lectern-infograph-data')
|
|
45
|
-
const details = root.querySelector<HTMLElement>('.lectern-infograph-details-panel')
|
|
46
|
-
const graphContainer = root.querySelector<HTMLElement>('.lectern-infograph-graph')
|
|
47
|
-
const searchId = root.querySelector<HTMLInputElement>('.lectern-infograph-discovery-search')?.id
|
|
48
|
-
const seed = root.dataset.discoverySeed
|
|
49
|
-
if (!data?.textContent || !details || !graphContainer || !searchId || !seed) return
|
|
50
|
-
|
|
51
|
-
let payload: DiscoveryPayload
|
|
52
|
-
try {
|
|
53
|
-
payload = JSON.parse(data.textContent) as DiscoveryPayload
|
|
54
|
-
} catch {
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const budget = Number(root.dataset.relationBudget ?? 16)
|
|
59
|
-
const nodesBySearchLabel = new Map(payload.nodes.map(node => [searchLabel(node), node.key]))
|
|
60
|
-
const slide = root.closest('section')
|
|
61
|
-
let selection: DiscoverySelection = { type: 'node', key: seed }
|
|
62
|
-
let cy: cytoscape.Core | undefined
|
|
63
|
-
let initialLayoutFinished = false
|
|
64
|
-
let finishInitialLayout: () => void
|
|
65
|
-
const initialLayout = new Promise<void>(resolve => {
|
|
66
|
-
finishInitialLayout = resolve
|
|
67
|
-
})
|
|
68
|
-
initialLayouts.push(initialLayout)
|
|
69
|
-
|
|
70
|
-
const updateDetails = () => {
|
|
71
|
-
render(
|
|
72
|
-
<InfographDiscoveryDetails
|
|
73
|
-
payload={payload}
|
|
74
|
-
selection={selection}
|
|
75
|
-
searchId={searchId}
|
|
76
|
-
onSearch={value => {
|
|
77
|
-
const key =
|
|
78
|
-
nodesBySearchLabel.get(value) ??
|
|
79
|
-
payload.nodes.find(node => node.key === value || node.title === value)?.key
|
|
80
|
-
if (key) select({ type: 'node', key })
|
|
81
|
-
}}
|
|
82
|
-
/>,
|
|
83
|
-
details
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const draw = () => {
|
|
88
|
-
if (!graphContainer.clientWidth) return
|
|
89
|
-
cy?.destroy()
|
|
90
|
-
const relations = selectDiscoveryRelations(payload, selection).slice(0, budget)
|
|
91
|
-
const nodeKeys = new Set(relations.flatMap(relation => [relation.edge.from, relation.edge.to]))
|
|
92
|
-
if (selection.type === 'node') nodeKeys.add(selection.key)
|
|
93
|
-
const selectedEdge =
|
|
94
|
-
selection.type === 'edge' ? payload.edges.find(edge => edge.key === selection.key) : undefined
|
|
95
|
-
const activeNodeKeys = new Set(
|
|
96
|
-
selection.type === 'node' ? [selection.key] : selectedEdge ? [selectedEdge.from, selectedEdge.to] : []
|
|
97
|
-
)
|
|
98
|
-
const nodes = payload.nodes.filter(node => nodeKeys.has(node.key))
|
|
99
|
-
const elements: cytoscape.ElementDefinition[] = [
|
|
100
|
-
...nodes.map(node => ({
|
|
101
|
-
data: { id: node.key, label: node.title, kind: node.kind },
|
|
102
|
-
classes: activeNodeKeys.has(node.key) ? 'is-active' : '',
|
|
103
|
-
})),
|
|
104
|
-
...relations.map(({ edge }) => ({
|
|
105
|
-
data: { id: edge.key, source: edge.from, target: edge.to, label: edge.verb },
|
|
106
|
-
})),
|
|
107
|
-
]
|
|
108
|
-
cy = cytoscape({
|
|
109
|
-
container: graphContainer,
|
|
110
|
-
elements,
|
|
111
|
-
style: [
|
|
112
|
-
{
|
|
113
|
-
selector: 'node',
|
|
114
|
-
style: {
|
|
115
|
-
'background-color': (element: cytoscape.NodeSingular) => kindColor[element.data('kind')] ?? '#5b6b7a',
|
|
116
|
-
label: 'data(label)',
|
|
117
|
-
color: '#000000',
|
|
118
|
-
'font-size': 9,
|
|
119
|
-
'font-weight': 400,
|
|
120
|
-
'text-wrap': 'wrap',
|
|
121
|
-
'text-max-width': '88px',
|
|
122
|
-
'text-valign': 'bottom',
|
|
123
|
-
'text-halign': 'center',
|
|
124
|
-
'text-margin-y': 3,
|
|
125
|
-
width: 18,
|
|
126
|
-
height: 18,
|
|
127
|
-
},
|
|
128
|
-
},
|
|
129
|
-
{ selector: 'node.is-active', style: { 'font-weight': 700 } },
|
|
130
|
-
{
|
|
131
|
-
selector: 'edge',
|
|
132
|
-
style: {
|
|
133
|
-
width: 1.5,
|
|
134
|
-
'line-color': '#9aa7b0',
|
|
135
|
-
'target-arrow-color': '#9aa7b0',
|
|
136
|
-
'target-arrow-shape': 'triangle',
|
|
137
|
-
'arrow-scale': 0.7,
|
|
138
|
-
'curve-style': 'straight',
|
|
139
|
-
label: 'data(label)',
|
|
140
|
-
'font-size': 8,
|
|
141
|
-
color: '#4d5c66',
|
|
142
|
-
'text-rotation': 'autorotate',
|
|
143
|
-
'text-background-color': '#ffffff',
|
|
144
|
-
'text-background-opacity': 1,
|
|
145
|
-
'text-background-padding': '1px',
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
{ selector: 'node:selected', style: { 'border-width': 3, 'border-color': '#00b8de' } },
|
|
149
|
-
{ selector: 'edge:selected', style: { width: 3, 'line-color': '#00b8de', 'target-arrow-color': '#00b8de' } },
|
|
150
|
-
] satisfies cytoscape.StylesheetStyle[],
|
|
151
|
-
layout: { name: 'grid', animate: false },
|
|
152
|
-
})
|
|
153
|
-
const layoutOptions: fcose.FcoseLayoutOptions = {
|
|
154
|
-
name: 'fcose',
|
|
155
|
-
animate: false,
|
|
156
|
-
idealEdgeLength: () => 50,
|
|
157
|
-
nodeRepulsion: () => 7000,
|
|
158
|
-
padding: 10,
|
|
159
|
-
nodeDimensionsIncludeLabels: true,
|
|
160
|
-
}
|
|
161
|
-
const layout = cy.layout(layoutOptions)
|
|
162
|
-
layout.one('layoutstop', () => {
|
|
163
|
-
cy?.fit(undefined, 24)
|
|
164
|
-
if (initialLayoutFinished) return
|
|
165
|
-
initialLayoutFinished = true
|
|
166
|
-
requestAnimationFrame(() =>
|
|
167
|
-
requestAnimationFrame(() => {
|
|
168
|
-
if (isPrint && cy) {
|
|
169
|
-
const snapshot = new Image()
|
|
170
|
-
snapshot.src = cy.png({ full: true, scale: 2, bg: '#ffffff' })
|
|
171
|
-
void snapshot.decode().finally(() => {
|
|
172
|
-
graphContainer.replaceChildren()
|
|
173
|
-
graphContainer.style.background = `center / contain no-repeat url("${snapshot.src}")`
|
|
174
|
-
requestAnimationFrame(finishInitialLayout)
|
|
175
|
-
})
|
|
176
|
-
} else {
|
|
177
|
-
finishInitialLayout()
|
|
178
|
-
}
|
|
179
|
-
})
|
|
180
|
-
)
|
|
181
|
-
})
|
|
182
|
-
layout.run()
|
|
183
|
-
cy.on('tap', 'node', event => select({ type: 'node', key: event.target.id() }))
|
|
184
|
-
cy.on('tap', 'edge', event => select({ type: 'edge', key: event.target.id() }))
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
const select = (next: DiscoverySelection) => {
|
|
188
|
-
selection = next
|
|
189
|
-
updateDetails()
|
|
190
|
-
draw()
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const renderWhenVisible = () => {
|
|
194
|
-
if (/print-pdf/.test(location.search) || deck.getCurrentSlide() === slide) draw()
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
renderWhenVisible()
|
|
198
|
-
deck.on('slidechanged', renderWhenVisible)
|
|
199
|
-
window.addEventListener('resize', () => {
|
|
200
|
-
if (cy) {
|
|
201
|
-
cy.resize()
|
|
202
|
-
cy.fit(undefined, 24)
|
|
203
|
-
}
|
|
204
|
-
})
|
|
205
|
-
})
|
|
206
|
-
return Promise.all(initialLayouts).then(() => undefined)
|
|
207
|
-
}
|
package/src/components/Deck.tsx
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { DeckProps } from '../types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Root of a presentation. Holds deck-level metadata (title, author, theme,
|
|
5
|
-
* transition, footer) and its slides as children.
|
|
6
|
-
*
|
|
7
|
-
* The renderer reads this node's props to assemble the HTML shell and reveal.js
|
|
8
|
-
* config, then renders the children into `.reveal > .slides`. Rendering `<Deck>`
|
|
9
|
-
* directly also works (it emits the slides), but metadata is only applied when
|
|
10
|
-
* the deck is passed to `lectern`'s renderer / CLI.
|
|
11
|
-
*/
|
|
12
|
-
export function Deck(props: DeckProps) {
|
|
13
|
-
return <>{props.children}</>
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** Type guard: is this VNode a <Deck>? Used by the renderer. */
|
|
17
|
-
export function isDeck(node: unknown): node is { props: DeckProps } {
|
|
18
|
-
return typeof node === 'object' && node !== null && 'type' in node && (node as { type?: unknown }).type === Deck
|
|
19
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { BaseKeys, Infograph, InfographNodeKey } from 'infograph'
|
|
2
|
-
import { toDiscoveryPayload, validateDiscoverySeed } from '../infographDiscovery'
|
|
3
|
-
import { InfographDiscoveryDetails } from '../infographDiscoveryView'
|
|
4
|
-
import type { StyleEscapeHatch } from '../types'
|
|
5
|
-
import { cx } from './util'
|
|
6
|
-
|
|
7
|
-
export interface InfographDiscoveryProps<Keys extends BaseKeys = BaseKeys> extends StyleEscapeHatch {
|
|
8
|
-
/** Parsed infograph to browse. The component never modifies it. */
|
|
9
|
-
infograph: Infograph<Keys>
|
|
10
|
-
/** Initial node key. Must identify a node in `infograph`. */
|
|
11
|
-
seed: InfographNodeKey<Keys>
|
|
12
|
-
/** Number of relation rows initially visible in the BFS neighborhood. */
|
|
13
|
-
relationBudget?: number
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Interactive, bounded exploration of an infograph for a presentation annex.
|
|
18
|
-
*
|
|
19
|
-
* The static HTML renders the seed state for PDF export. The browser client
|
|
20
|
-
* enhances it with search and click navigation between nodes and edges.
|
|
21
|
-
*/
|
|
22
|
-
export function InfographDiscovery<Keys extends BaseKeys>({
|
|
23
|
-
infograph,
|
|
24
|
-
seed,
|
|
25
|
-
relationBudget = 16,
|
|
26
|
-
class: cls,
|
|
27
|
-
style,
|
|
28
|
-
}: InfographDiscoveryProps<Keys>) {
|
|
29
|
-
if (!Number.isInteger(relationBudget) || relationBudget < 1)
|
|
30
|
-
throw new Error(`InfographDiscovery relationBudget must be a positive integer, got ${relationBudget}`)
|
|
31
|
-
const payload = toDiscoveryPayload(infograph)
|
|
32
|
-
validateDiscoverySeed(payload, seed)
|
|
33
|
-
const json = JSON.stringify(payload).replace(/</g, '\\u003c')
|
|
34
|
-
const searchId = `lectern-infograph-discovery-${encodeURIComponent(seed)}`
|
|
35
|
-
return (
|
|
36
|
-
<div
|
|
37
|
-
class={cx('lectern-infograph-discovery', cls)}
|
|
38
|
-
style={style}
|
|
39
|
-
data-lectern-infograph-discovery
|
|
40
|
-
data-relation-budget={relationBudget}
|
|
41
|
-
data-discovery-seed={seed}>
|
|
42
|
-
<div class="lectern-infograph-panel lectern-infograph-details-panel">
|
|
43
|
-
<InfographDiscoveryDetails payload={payload} selection={{ type: 'node', key: seed }} searchId={searchId} />
|
|
44
|
-
</div>
|
|
45
|
-
<div class="lectern-infograph-panel lectern-infograph-neighborhood-panel">
|
|
46
|
-
<div class="lectern-infograph-graph" aria-label="Sous-graphe exploré autour de la sélection" />
|
|
47
|
-
</div>
|
|
48
|
-
<script type="application/json" class="lectern-infograph-data" dangerouslySetInnerHTML={{ __html: json }} />
|
|
49
|
-
</div>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type { ComponentChildren } from 'preact'
|
|
2
|
-
import type { StyleEscapeHatch } from '../types'
|
|
3
|
-
import { cx, children as toArray } from './util'
|
|
4
|
-
|
|
5
|
-
type Align = 'start' | 'center' | 'end' | 'stretch'
|
|
6
|
-
type Justify = 'start' | 'center' | 'end' | 'between' | 'around'
|
|
7
|
-
|
|
8
|
-
const alignMap: Record<Align, string> = {
|
|
9
|
-
start: 'flex-start',
|
|
10
|
-
center: 'center',
|
|
11
|
-
end: 'flex-end',
|
|
12
|
-
stretch: 'stretch',
|
|
13
|
-
}
|
|
14
|
-
const justifyMap: Record<Justify, string> = {
|
|
15
|
-
start: 'flex-start',
|
|
16
|
-
center: 'center',
|
|
17
|
-
end: 'flex-end',
|
|
18
|
-
between: 'space-between',
|
|
19
|
-
around: 'space-around',
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function mergeStyle(
|
|
23
|
-
base: Record<string, string | number>,
|
|
24
|
-
extra?: StyleEscapeHatch['style']
|
|
25
|
-
): Record<string, string | number> | string {
|
|
26
|
-
if (extra == null) return base
|
|
27
|
-
if (typeof extra === 'string') {
|
|
28
|
-
const b = Object.entries(base)
|
|
29
|
-
.map(([k, v]) => `${k}:${v}`)
|
|
30
|
-
.join(';')
|
|
31
|
-
return `${b};${extra}`
|
|
32
|
-
}
|
|
33
|
-
return { ...base, ...extra }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Horizontal layout. Each child becomes an equal column unless `ratio` is
|
|
38
|
-
* given (e.g. `[2, 1]` → first column twice as wide). Uses Fluid spacing.
|
|
39
|
-
*/
|
|
40
|
-
export interface ColumnsProps extends StyleEscapeHatch {
|
|
41
|
-
children?: ComponentChildren
|
|
42
|
-
/** Gap between columns (any CSS length). Defaults to a Fluid spacing token. */
|
|
43
|
-
gap?: string
|
|
44
|
-
/** Cross-axis alignment. Defaults to "stretch". */
|
|
45
|
-
align?: Align
|
|
46
|
-
/** Relative widths of the columns. */
|
|
47
|
-
ratio?: number[]
|
|
48
|
-
/** Explicit CSS Grid tracks, for content-sized rather than proportional columns. */
|
|
49
|
-
tracks?: string[]
|
|
50
|
-
/** Occupy the remaining height of a flex slide body. */
|
|
51
|
-
fill?: boolean
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function Columns({
|
|
55
|
-
children,
|
|
56
|
-
gap,
|
|
57
|
-
align = 'stretch',
|
|
58
|
-
ratio,
|
|
59
|
-
tracks,
|
|
60
|
-
fill = false,
|
|
61
|
-
class: cls,
|
|
62
|
-
style,
|
|
63
|
-
}: ColumnsProps) {
|
|
64
|
-
const cols = toArray(children)
|
|
65
|
-
const usesGrid = tracks != null
|
|
66
|
-
const base = {
|
|
67
|
-
display: usesGrid ? 'grid' : 'flex',
|
|
68
|
-
...(usesGrid ? { 'grid-template-columns': tracks.join(' ') } : { 'flex-direction': 'row' }),
|
|
69
|
-
gap: gap ?? 'var(--lectern-gap, 1.5rem)',
|
|
70
|
-
'align-items': alignMap[align],
|
|
71
|
-
...(fill ? { flex: '1 1 0', 'min-height': 0 } : {}),
|
|
72
|
-
}
|
|
73
|
-
return (
|
|
74
|
-
<div class={cx('lectern-columns', fill && 'is-fill', cls)} style={mergeStyle(base, style)}>
|
|
75
|
-
{usesGrid
|
|
76
|
-
? cols
|
|
77
|
-
: cols.map((child, i) => (
|
|
78
|
-
<div
|
|
79
|
-
class="lectern-col"
|
|
80
|
-
style={{
|
|
81
|
-
...(!usesGrid ? { flex: ratio?.[i] ?? 1 } : {}),
|
|
82
|
-
'min-width': 0,
|
|
83
|
-
...(fill ? { display: 'flex', 'min-height': 0 } : {}),
|
|
84
|
-
}}>
|
|
85
|
-
{child}
|
|
86
|
-
</div>
|
|
87
|
-
))}
|
|
88
|
-
</div>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** Vertical stack with consistent spacing between children. */
|
|
93
|
-
export interface StackProps extends StyleEscapeHatch {
|
|
94
|
-
children?: ComponentChildren
|
|
95
|
-
gap?: string
|
|
96
|
-
align?: Align
|
|
97
|
-
justify?: Justify
|
|
98
|
-
/** Occupy the remaining height of a flex container. */
|
|
99
|
-
fill?: boolean
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function Stack({ children, gap, align, justify, fill = false, class: cls, style }: StackProps) {
|
|
103
|
-
const base: Record<string, string> = {
|
|
104
|
-
display: 'flex',
|
|
105
|
-
'flex-direction': 'column',
|
|
106
|
-
gap: gap ?? 'var(--lectern-gap, 1rem)',
|
|
107
|
-
}
|
|
108
|
-
if (fill) {
|
|
109
|
-
base.flex = '1 1 0'
|
|
110
|
-
base['min-height'] = '0'
|
|
111
|
-
}
|
|
112
|
-
if (align) base['align-items'] = alignMap[align]
|
|
113
|
-
if (justify) base['justify-content'] = justifyMap[justify]
|
|
114
|
-
return (
|
|
115
|
-
<div class={cx('lectern-stack', fill && 'is-fill', cls)} style={mergeStyle(base, style)}>
|
|
116
|
-
{children}
|
|
117
|
-
</div>
|
|
118
|
-
)
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/** Simple responsive grid with a fixed number of columns. */
|
|
122
|
-
export interface GridProps extends StyleEscapeHatch {
|
|
123
|
-
children?: ComponentChildren
|
|
124
|
-
/** Number of columns. Defaults to 2. */
|
|
125
|
-
cols?: number
|
|
126
|
-
gap?: string
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export function Grid({ children, cols = 2, gap, class: cls, style }: GridProps) {
|
|
130
|
-
const base = {
|
|
131
|
-
display: 'grid',
|
|
132
|
-
'grid-template-columns': `repeat(${cols}, minmax(0, 1fr))`,
|
|
133
|
-
gap: gap ?? 'var(--lectern-gap, 1.5rem)',
|
|
134
|
-
}
|
|
135
|
-
return (
|
|
136
|
-
<div class={cx('lectern-grid', cls)} style={mergeStyle(base, style)}>
|
|
137
|
-
{children}
|
|
138
|
-
</div>
|
|
139
|
-
)
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/** Vertical whitespace. */
|
|
143
|
-
export function Spacer({ size = '1rem' }: { size?: string }) {
|
|
144
|
-
return <div class="lectern-spacer" style={{ height: size }} aria-hidden="true" />
|
|
145
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import type { ComponentChildren } from 'preact'
|
|
2
|
-
import type { StyleEscapeHatch } from '../types'
|
|
3
|
-
import { cx } from './util'
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Neutral, reveal-mechanics components: structure only. Their look (if any) is
|
|
7
|
-
* supplied by the active profile's CSS via the `lectern-*` classes they emit.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* A code block, syntax-highlighted client-side by reveal's highlight plugin.
|
|
12
|
-
* The code is passed as a string child; it is HTML-escaped safely by the
|
|
13
|
-
* renderer, so `<`, `>` and `&` display correctly.
|
|
14
|
-
*/
|
|
15
|
-
export interface CodeProps extends StyleEscapeHatch {
|
|
16
|
-
children: string
|
|
17
|
-
/** Language for highlighting, e.g. "js", "json", "bash". */
|
|
18
|
-
lang?: string
|
|
19
|
-
/** Show line numbers, optionally with a highlight spec like "2-4|6". */
|
|
20
|
-
lineNumbers?: boolean | string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function Code({ children, lang, lineNumbers, class: cls, style }: CodeProps) {
|
|
24
|
-
const dataLineNumbers = typeof lineNumbers === 'string' ? lineNumbers : lineNumbers ? '' : undefined
|
|
25
|
-
return (
|
|
26
|
-
<pre class={cx('lectern-code', cls)} style={style}>
|
|
27
|
-
<code class={lang ? `language-${lang}` : undefined} data-trim data-line-numbers={dataLineNumbers}>
|
|
28
|
-
{children}
|
|
29
|
-
</code>
|
|
30
|
-
</pre>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* A Mermaid diagram. The diagram source is passed as a string child and
|
|
36
|
-
* rendered in the browser by the bundled Mermaid runtime (themed by the profile).
|
|
37
|
-
*/
|
|
38
|
-
export function Mermaid({ children, class: cls, style }: { children: string } & StyleEscapeHatch) {
|
|
39
|
-
return (
|
|
40
|
-
<pre class={cx('mermaid', cls)} style={style}>
|
|
41
|
-
{children}
|
|
42
|
-
</pre>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** Speaker notes: hidden on slides, shown in reveal's speaker view (press S). */
|
|
47
|
-
export function Notes({ children }: { children: ComponentChildren }) {
|
|
48
|
-
return <aside class="notes">{children}</aside>
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Wrap content so it appears as a reveal.js fragment (on the next advance). */
|
|
52
|
-
export interface FragmentProps {
|
|
53
|
-
children: ComponentChildren
|
|
54
|
-
/** Fragment animation type, e.g. "fade-in", "highlight-red". */
|
|
55
|
-
type?: string
|
|
56
|
-
/** Explicit ordering index. */
|
|
57
|
-
index?: number
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function Fragment({ children, type, index }: FragmentProps) {
|
|
61
|
-
return (
|
|
62
|
-
<span class={cx('fragment', type)} data-fragment-index={index}>
|
|
63
|
-
{children}
|
|
64
|
-
</span>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Escape hatch: inject raw HTML for one specific slide. You own its
|
|
70
|
-
* correctness and safety. Content is emitted verbatim (not escaped).
|
|
71
|
-
*/
|
|
72
|
-
export function Raw({ html }: { html: string }) {
|
|
73
|
-
return <div class="lectern-raw" dangerouslySetInnerHTML={{ __html: html }} />
|
|
74
|
-
}
|
package/src/components/util.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { ComponentChildren } from 'preact'
|
|
2
|
-
import { toChildArray } from 'preact'
|
|
3
|
-
|
|
4
|
-
/** Join truthy class names. */
|
|
5
|
-
export function cx(...parts: Array<string | false | null | undefined>): string {
|
|
6
|
-
return parts.filter(Boolean).join(' ')
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/** Normalize children into a flat array (drops null/boolean, keeps text). */
|
|
10
|
-
export function children(nodes: ComponentChildren) {
|
|
11
|
-
return toChildArray(nodes)
|
|
12
|
-
}
|