Repository navigation
Expand file tree
/
Copy pathtemplate.html
More file actions
2440 lines (2383 loc) · 136 KB
/
Copy pathtemplate.html
File metadata and controls
2440 lines (2383 loc) · 136 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>deckfile</title>
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 32 32%22%3E%3Crect width=%2232%22 height=%2232%22 rx=%224%22 fill=%22%23C2310A%22/%3E%3Crect x=%2210.5%22 y=%227.5%22 width=%2215%22 height=%2210%22 rx=%221%22 fill=%22%23fff%22 opacity=%22.55%22/%3E%3Crect x=%226.5%22 y=%2212.5%22 width=%2218%22 height=%2212%22 rx=%221%22 fill=%22%23fff%22/%3E%3C/svg%3E">
<!--
Built with deckfile: https://github.com/roaldnefs/deckfile
One self-contained file. The only network requests are for the Google Fonts below; every font stack
falls back to a generic family, so the deck also works offline from file://.
Fonts (all SIL Open Font License 1.1): Geist, Geist Mono.
<style data-deck="engine"> and <script data-deck="engine"> hold the engine. Don't edit them; update them with
`npx github:roaldnefs/deckfile update <this file>`. <style data-deck="theme"> is the theme and yours to change:
set its tokens to brand the deck. CSS for this deck alone goes in the last <style>.
Slides (this theme):
<section class="slide"> light content slide; <div class="kicker"> names its part in the top margin
<section class="slide title"> title card (icon logo)
<section class="slide divider"> section divider, usually with dark
<section class="slide dark"> dark emphasis slide (titles, dividers)
<section class="slide closing"> closing card (icon logo)
<div class="s-notes"> inside a slide speaker notes, shown in the presenter and edit views
class="build" on any element revealed one at a time with →
data-auto="500" on a section its builds reveal by themselves, one every 500 ms
data-skip on a section left out of the show, its numbers and the print; the edit view still shows it
Keys: → to step through, S for the presenter view, E for the edit view; the full list is at the top of the engine script.
-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Geist:wght@400..700&family=Geist+Mono:wght@400..600&display=swap" rel="stylesheet">
<style data-deck="engine">
/*! deckfile v0.5.0 · engine styles · MIT License · https://github.com/roaldnefs/deckfile
What the engine needs to place, show and print slides. The look of the slides is the theme's. */
/* stage: fixed 1920x1080, scaled to the viewport (--scale is set by the engine) */
html,body{margin:0;height:100%;overflow:hidden}
#stage{position:absolute;left:50%;top:50%;width:1920px;height:1080px;
transform:translate(-50%,-50%) scale(var(--scale,1))}
.slide{position:absolute;inset:0;box-sizing:border-box;overflow:hidden}
/* only the current slide shows; a theme sets the display each layout needs (flex, grid) */
@media screen{.slide:not(.current){display:none!important}}
.s-notes{display:none}
/* builds: hidden until the engine adds .on */
.build{opacity:0;transform:translateY(14px);transition:opacity .35s ease,transform .35s ease}
.build.on{opacity:1;transform:none}
@media (prefers-reduced-motion:reduce){.build{transition:none}}
/* speaker notes: placed by the presenter and edit views */
#notes{overflow:auto}
#notes::before{content:"Speaker notes";display:block}
[hidden]{display:none!important}
/* back, presenter, edit, shortcuts and forward: a dark bar with a light edge, near the bottom-left corner only, readable on any slide */
#deck-controls{position:fixed;left:20px;bottom:20px;z-index:15;display:flex;gap:2px;padding:3px;border-radius:4px;
background:#111110;box-shadow:0 0 0 1px rgba(255,255,255,.2);
opacity:0;pointer-events:none;transition:opacity .15s ease}
#deck-controls:is(.near,.open){opacity:1;pointer-events:auto}
html.editing #deck-controls{display:none}
#deck-controls button{display:grid;place-items:center;width:32px;height:32px;padding:0;border:0;border-radius:2px;
background:none;color:#B5B5B0;cursor:pointer}
#deck-controls button:hover{background:rgba(255,255,255,.14);color:#fff}
#deck-help{position:absolute;left:0;bottom:calc(100% + 8px);display:grid;grid-template-columns:auto auto;gap:8px 20px;align-items:center;
width:max-content;padding:14px 16px;border-radius:4px;background:#111110;color:#F2F2EF;
box-shadow:0 0 0 1px rgba(255,255,255,.2);font:400 13px/1.3 system-ui,sans-serif;-webkit-font-smoothing:antialiased}
.c-keys{display:flex;gap:4px}
.c-keys span{min-width:12px;padding:3px 6px;border:1px solid rgba(255,255,255,.32);border-radius:3px;
font:500 11px/1.3 system-ui,sans-serif;text-align:center}
/* print: one slide per page, all builds shown, skipped slides left out */
@media print{
html,body{overflow:visible;height:auto;background:#fff}
#stage{position:static;transform:none;width:1920px;height:auto}
.slide{position:relative;height:1080px;break-after:page;page-break-after:always}
.slide[data-skip]{display:none!important}
.build{opacity:1;transform:none;transition:none}
#notes,#deck-controls{display:none!important}
*{box-shadow:none!important;-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important}
@page{size:1920px 1080px;margin:0}
}
</style>
<style data-deck="theme">
/* deckfile default theme: paper-white slides set flush left on a grid, hairlines instead of boxes, one accent colour;
near-black .dark slides for emphasis.
Brand it by changing the tokens in :root; anything bigger goes in your deck's own <style> after this block.
See "Theming" in the README. */
/* tokens (the part to change per brand) */
:root{
--primary:#111110; --black:#0C0C0B;
--grey:#66665F; --light:#EDECE6; --white:#F7F6F2; --action:#C2310A; --action-dark:#FF6A3D;
--ink:var(--primary); --muted:var(--grey); --accent:var(--action); --panel:var(--light); --paper:var(--white);
/* lines on light slides, derived from --primary */
--line:rgba(17,17,16,.16);
/* OFL fonts only, the same on every platform; fallbacks are generic CSS families, never named system fonts */
--font-display:"Geist",system-ui,sans-serif;
--font-body:"Geist",system-ui,sans-serif;
--font-mono:"Geist Mono",ui-monospace,monospace;
/* logo slots: url("data:image/svg+xml,…") or none. --logo/--icon sit on light slides,
--logo-dark/--icon-dark on .dark slides. --watermark is an optional large mark. */
--logo:none; --icon:none; --logo-dark:none; --icon-dark:none;
--watermark:none; --watermark-dark:none;
}
/* slides (the engine places and scales them; the theme gives them their look) */
html,body{background:var(--black)}
/* a rule under the top margin, which holds the kicker and the slide number; the heading starts below it,
and what follows the heading stands on the bottom margin */
.slide{display:flex;flex-direction:column;padding:176px 120px 120px;color:var(--ink);font:400 36px/1.45 var(--font-body);letter-spacing:-.01em;
background:linear-gradient(var(--line),var(--line)) 120px 120px/1680px 1px no-repeat,var(--paper);
-webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility}
.slide>:is(.cols,.keys,.stats,.term,ul,ol){margin-top:auto}
/* title, closing and divider: everything stands on the bottom margin */
.slide:is(.title,.closing,.divider){justify-content:flex-end}
/* title card: each time it is shown, the text rises in */
.slide.title.current h1{animation:rise .7s cubic-bezier(.2,.7,.2,1) both}
.slide.title.current :is(.sub,.byline){animation:rise .7s .25s cubic-bezier(.2,.7,.2,1) both}
@keyframes rise{from{opacity:0;transform:translateY(20px)}}
@media (prefers-reduced-motion:reduce){.slide.title,.slide.title *{animation:none!important}}
/* optional watermark, large and low-contrast, off to the right */
.slide::before{content:"";position:absolute;inset:0;pointer-events:none;
background:var(--watermark) no-repeat right -260px bottom -300px/1250px auto}
/* logo in the bottom-left corner; icon only on title/closing cards */
.slide::after{content:"";position:absolute;left:120px;bottom:36px;width:240px;height:48px;
background:var(--logo) no-repeat left center/contain}
.slide.title::after,.slide.closing::after{width:48px;height:48px;background-image:var(--icon)}
.slide>*{position:relative;z-index:1}
/* dark emphasis slides */
.slide.dark{--ink:var(--white);--muted:rgba(247,246,242,.62);--accent:var(--action-dark);
--line:rgba(247,246,242,.2);--panel:rgba(247,246,242,.07);--paper:var(--black)}
.slide.dark::before{background-image:var(--watermark-dark)}
.slide.dark::after{background-image:var(--logo-dark)}
.slide.dark.title::after,.slide.dark.closing::after{background-image:var(--icon-dark)}
/* the top margin: where you are on the left, the slide number on the right */
.slide>.kicker,.counter{position:absolute;top:72px;font:500 22px/1 var(--font-mono);letter-spacing:.06em;text-transform:uppercase}
.slide>.kicker{left:120px;color:var(--accent)}
.counter{right:120px;color:var(--muted)}
/* type */
h1{font:600 144px/.98 var(--font-display);letter-spacing:-.045em;margin:0 0 40px}
h2{font:600 76px/1.04 var(--font-display);letter-spacing:-.035em;max-width:1400px;margin:0 0 36px}
/* a label over a column, with a rule under it */
h3{font:500 22px/1.2 var(--font-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--muted);
margin:0 0 28px;padding-bottom:18px;border-bottom:1px solid var(--line)}
p{margin:0 0 .7em}
.sub{font:400 40px/1.3 var(--font-body);letter-spacing:-.015em;color:var(--muted);max-width:1240px;margin:0 0 40px}
h2+.sub{margin-top:-12px}
.title h1{font-size:232px;margin-left:-.04em}
.title .sub{color:var(--ink);max-width:1100px}
.byline{font:500 22px/1.2 var(--font-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--muted);margin:24px 0 0}
.divider h1{font-size:232px;margin:0 0 0 -.04em}
.closing h1{font-size:120px}
ul,ol{margin:0;padding:0 0 0 1.1em}
li{margin:0 0 .5em;padding-left:.3em}
/* plain lines between rules; a rule belongs to its line, so it fades in with a build */
ul{list-style:none;padding-left:0}
ul li{margin:0;padding:26px 0;border-top:1px solid var(--line);font-size:44px;line-height:1.2;letter-spacing:-.02em}
ul li:last-child{border-bottom:1px solid var(--line)}
.agenda{font:500 44px/1.2 var(--font-display);letter-spacing:-.02em;counter-reset:agenda;list-style:none;padding:0}
.agenda li{counter-increment:agenda;display:flex;align-items:baseline;margin:0;padding:26px 0;border-top:1px solid var(--line)}
.agenda li:last-child{border-bottom:1px solid var(--line)}
.agenda li::before{content:counter(agenda,decimal-leading-zero);flex:0 0 96px;
font:500 22px/1 var(--font-mono);letter-spacing:.06em;color:var(--accent)}
small,.small{font-size:24px;letter-spacing:0;color:var(--muted)}
code{font:400 .88em var(--font-mono);letter-spacing:0}
a{color:inherit}
/* components */
.btn{display:inline-block;align-self:flex-start;padding:24px 32px;border:2px solid var(--ink);border-radius:2px;
font:500 26px/1 var(--font-body);letter-spacing:-.01em;color:var(--ink);text-decoration:none}
.btn::after{content:"\00a0\00a0→"}
.btn.action{border-color:var(--accent);background:var(--accent);color:var(--paper)}
/* figures under a heavy rule, each with a caption */
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:48px}
.stat{border-top:3px solid var(--ink);padding-top:28px}
.stat .n{font:600 136px/1 var(--font-display);letter-spacing:-.05em;font-variant-numeric:tabular-nums;display:block;margin-bottom:20px}
.stat .cap{font:500 22px/1.3 var(--font-mono);letter-spacing:.06em;text-transform:uppercase;color:var(--muted);display:block}
.cols{display:grid;grid-template-columns:1fr 1fr;gap:72px;align-items:start}
.term{background:var(--panel);border-radius:4px;padding:40px 44px;
font:400 26px/1.6 var(--font-mono);letter-spacing:0;color:var(--ink);white-space:pre;overflow:hidden}
.term .b{color:var(--accent)}
.term .d{color:var(--muted)}
.term .w{font-weight:600}
/* a screenshot or drawing in a thin frame */
.window{border-radius:6px;overflow:hidden;box-shadow:0 0 0 1px var(--line),0 24px 48px -28px rgba(0,0,0,.3)}
.window>*{display:block;width:100%;height:auto}
/* separate borders belong to the cells, so a row's line fades in with its build */
.keys{font-size:32px;line-height:1.3;border-collapse:separate;border-spacing:0;width:100%}
.keys td{padding:24px 24px 24px 0;border-top:1px solid var(--line)}
.keys tr:last-child td{border-bottom:1px solid var(--line)}
.keys td:first-child{width:320px}
kbd{display:inline-block;min-width:1.3em;padding:9px 12px;border:1.5px solid var(--ink);border-radius:4px;
font:500 .72em/1 var(--font-body);letter-spacing:0;text-align:center;margin-right:8px}
/* print: the title card without its entrance */
@media print{.slide.title *{animation:none!important}}
</style>
<style>
/* deck-specific */
</style>
</head>
<body>
<!-- what New slide offers in the edit view: yours to change, in the classes of the theme -->
<template data-deck="layouts">
<section class="slide dark title" data-layout="Title">
<h1>Title</h1>
<p class="sub">One sentence on what this is about</p>
</section>
<section class="slide" data-layout="Content">
<h2>New slide</h2>
<ul>
<li>First point</li>
</ul>
</section>
<section class="slide" data-layout="Two columns">
<h2>Two columns</h2>
<div class="cols">
<div>
<h3>First</h3>
<p>Some text</p>
</div>
<div>
<h3>Second</h3>
<p>Some text</p>
</div>
</div>
</section>
<section class="slide dark divider" data-layout="Section">
<div class="kicker">01</div>
<h1>Section</h1>
</section>
</template>
<div id="stage">
<!-- 1 · title card -->
<section class="slide dark title">
<div class="kicker">Example deck</div>
<h1>deckfile</h1>
<p class="sub">A presentation as one HTML file. No build step, no dependencies, and it works offline.</p>
<p class="byline">Press → to continue</p>
<div class="s-notes">
<p>These are speaker notes. The presenter view and the edit view show them, and no slide does.</p>
</div>
</section>
<!-- 2 · what is in the file, row by row -->
<section class="slide">
<div class="kicker">Overview</div>
<h2>Everything is in one file</h2>
<table class="keys" style="white-space:nowrap">
<tr class="build"><td style="width:540px"><code><style data-deck="engine"></code></td><td>Places, scales and prints the slides</td><td class="small">Replaced on update</td></tr>
<tr class="build"><td><code><style data-deck="theme"></code></td><td>Colours, fonts and slide layouts</td><td class="small">Yours to change</td></tr>
<tr class="build"><td><code><section class="slide"></code></td><td>One per slide, with its speaker notes</td><td class="small">Yours to write</td></tr>
<tr class="build"><td><code><script data-deck="engine"></code></td><td>Keys, builds, presenter view, edit view</td><td class="small">Replaced on update</td></tr>
</table>
<div class="s-notes">
<p>Open this file in a text editor and you will find these four parts, in this order, with one more style block after the theme for CSS of your own. Each press of → shows the next one.</p>
</div>
</section>
<!-- 3 · section divider -->
<section class="slide dark divider">
<div class="kicker">01</div>
<h1>Write</h1>
<div class="s-notes">
<p>How a slide is written: its markup, classes, builds, speaker notes and theme.</p>
</div>
</section>
<!-- 4 · markup and what it renders -->
<section class="slide">
<div class="kicker">01 · Write</div>
<h2>A slide is a section</h2>
<div class="cols">
<div>
<h3>Markup</h3>
<div class="term" style="box-sizing:border-box;min-height:452px"><section class="slide">
<h2>One idea per slide</h2>
<ul>
<li>Say one thing</li>
<li>Show it large</li>
</ul>
</section></div>
</div>
<div>
<h3>Result</h3>
<div class="window"><div style="zoom:.41875;box-sizing:border-box;aspect-ratio:16/9;display:flex;flex-direction:column;padding:176px 120px 120px;background:var(--paper)">
<h2>One idea per slide</h2>
<ul style="margin-top:auto">
<li>Say one thing</li>
<li>Show it large</li>
</ul>
</div></div>
</div>
</div>
<div class="s-notes">
<p>The markup on the left renders as the slide on the right. The engine shows one section at a time and scales it to the window.</p>
</div>
</section>
<!-- 5 · the classes of the theme -->
<section class="slide">
<div class="kicker">01 · Write</div>
<h2>Classes lay it out</h2>
<p class="sub">The theme has a class for each kind of slide and each block on it.</p>
<div class="cols" style="grid-template-columns:repeat(3,1fr)">
<div>
<h3>On the section</h3>
<p><code>title</code> opens the deck<br><code>divider</code> starts a part<br><code>closing</code> ends it<br><code>dark</code> turns any of them dark</p>
</div>
<div>
<h3>Blocks</h3>
<p><code>cols</code> for columns<br><code>stats</code> for figures<br><code>keys</code> for a table<br><code>term</code> for code</p>
</div>
<div>
<h3>Text</h3>
<p><code>kicker</code> says where you are<br><code>sub</code> leads in<br><code>small</code> for a source<br><code>build</code> waits for a press</p>
</div>
</div>
<div class="s-notes">
<p>This slide is three columns with a label over each. The components reference lists every class with its markup.</p>
</div>
</section>
<!-- 6 · builds, by hand -->
<section class="slide">
<div class="kicker">01 · Write</div>
<h2>A build waits for a press</h2>
<p class="sub">Add <code>class="build"</code> to any element. Press → now.</p>
<ul>
<li class="build">This line came on the first press.</li>
<li class="build">This one came on the second.</li>
<li class="build">Press ← to take it back.</li>
</ul>
<div class="s-notes">
<p>The items reveal in document order. ↓ skips to the next slide with every item shown, and printing to PDF shows them all.</p>
</div>
</section>
<!-- 7 · builds, on a timer -->
<section class="slide" data-auto="600">
<div class="kicker">01 · Write</div>
<h2>data-auto reveals them on a timer</h2>
<p class="sub">Add <code>data-auto="600"</code> to the section. Each item follows 600 ms after the last.</p>
<div class="stats">
<div class="stat build"><span class="n">0.6 s</span><span class="cap">First item</span></div>
<div class="stat build"><span class="n">1.2 s</span><span class="cap">Second item</span></div>
<div class="stat build"><span class="n">1.8 s</span><span class="cap">Third item</span></div>
</div>
<div class="s-notes">
<p>The timer starts when you arrive with →. ↓ and ↑ show every item at once. Pressing → or ← takes over from the timer.</p>
</div>
</section>
<!-- 8 · speaker notes -->
<section class="slide">
<div class="kicker">01 · Write</div>
<h2>Speaker notes live inside the slide</h2>
<div class="cols">
<div>
<h3>What the room sees</h3>
<p>Nothing. Notes show in the presenter view and the edit view, never on the slide or in the PDF.</p>
<p>Press <kbd>S</kbd> to read this slide's notes.</p>
</div>
<div>
<h3>Markup</h3>
<div class="term"><section class="slide">
<h2>…</h2>
<div class="s-notes">
<p>What to say here.</p>
</div>
</section></div>
</div>
</div>
<div class="s-notes">
<p>These are this slide's notes. The presenter view and the edit view show them.</p>
</div>
</section>
<!-- 9 · theme tokens -->
<section class="slide">
<div class="kicker">01 · Write</div>
<h2>A theme is a set of CSS tokens</h2>
<div class="cols">
<div>
<h3>To brand a deck</h3>
<p>Set your colours, fonts and logo in the theme block, and every slide follows.</p>
<p>CSS for one deck goes in the last <code><style></code> block.</p>
</div>
<div>
<h3>Theme block</h3>
<div class="term">:root{
--primary:<span class="b">#111110</span>;
--white:<span class="b">#F7F6F2</span>;
--action:<span class="b">#C2310A</span>;
--font-display:<span class="b">"Geist"</span>,…;
--font-mono:<span class="b">"Geist Mono"</span>,…;
--logo:<span class="b">none</span>;
}</div>
</div>
</div>
<div class="s-notes">
<p>These are real tokens from this file's theme block. The full list is in the theming reference.</p>
</div>
</section>
<!-- 10 · section divider -->
<section class="slide dark divider">
<div class="kicker">02</div>
<h1>Present</h1>
<div class="s-notes">
<p>What you get in front of a room: the presenter view, the keys and a PDF.</p>
</div>
</section>
<!-- 11 · presenter view -->
<section class="slide">
<div class="kicker">02 · Present</div>
<h2>S opens the presenter view</h2>
<div class="cols" style="grid-template-columns:1fr 1.6fr;align-items:end">
<div>
<p>A second window shows the current slide, what the next press brings, your notes, a timer and the clock.</p>
<p>Steer from either window. They stay in step.</p>
</div>
<div class="window">
<svg viewBox="0 0 960 600" role="img" aria-label="Drawing of the presenter view: timer on top, current slide on the left, next slide above the speaker notes on the right">
<rect width="960" height="600" fill="#111110"/>
<text x="26" y="45" fill="#F2F2EF" font-size="26" font-weight="500">08:42</text>
<rect x="112" y="21" width="28" height="28" rx="3" fill="#2A2A28"/><path d="M122 29v12M130 29v12" stroke="#F2F2EF" stroke-width="3" stroke-linecap="round"/>
<rect x="146" y="21" width="28" height="28" rx="3" fill="#2A2A28"/><path d="M154 35a6 6 0 1 0 2-4.5" fill="none" stroke="#F2F2EF" stroke-width="2" stroke-linecap="round"/>
<text x="934" y="42" text-anchor="end" fill="#8F8F8A" font-size="16" font-weight="500">10:24</text>
<rect x="26" y="96" width="584" height="329" rx="3" fill="#F7F6F2"/>
<text x="62" y="128" fill="#C2310A" font-size="9" font-weight="500" letter-spacing="1">01 · WRITE</text>
<path d="M62 138.5h512M62 330.5h512M62 362.5h512M62 394.5h512" stroke="#111110" stroke-opacity=".16"/>
<text x="62" y="182" fill="#111110" font-size="30" font-weight="600" letter-spacing="-1">One idea per slide</text>
<rect x="62" y="342" width="150" height="9" rx="2" fill="#111110"/><rect x="62" y="374" width="120" height="9" rx="2" fill="#111110"/>
<rect x="208.5" y="476.5" width="220" height="42" rx="4" fill="none" stroke="#F2F2EF" stroke-opacity=".2"/>
<path d="M232 488l-9 10 9 10M404 488l9 10-9 10" fill="none" stroke="#F2F2EF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<text x="318" y="502" text-anchor="middle" fill="#F2F2EF" font-size="12" font-weight="500" letter-spacing="1">SLIDE 11 OF 18</text>
<text x="634" y="88" fill="#8F8F8A" font-size="11" font-weight="500" letter-spacing="1">NEXT SLIDE</text>
<rect x="634" y="100" width="300" height="169" rx="3" fill="#F7F6F2"/>
<path d="M652 120.5h264" stroke="#111110" stroke-opacity=".16"/>
<rect x="652" y="136" width="170" height="14" rx="2" fill="#111110"/><rect x="652" y="160" width="120" height="8" rx="2" fill="#B9B8B2"/>
<rect x="634" y="290" width="300" height="284" rx="3" fill="#1C1C1A"/>
<text x="652" y="322" fill="#8F8F8A" font-size="11" font-weight="500" letter-spacing="1">SPEAKER NOTES</text>
<rect x="860" y="304" width="30" height="24" rx="3" fill="#2A2A28"/><text x="875" y="320" text-anchor="middle" fill="#F2F2EF" font-size="12" font-weight="500">A−</text>
<rect x="894" y="304" width="30" height="24" rx="3" fill="#2A2A28"/><text x="909" y="320" text-anchor="middle" fill="#F2F2EF" font-size="12" font-weight="500">A+</text>
<text fill="#F2F2EF" font-size="22"><tspan x="652" y="362">Open with the question,</tspan><tspan x="652" dy="32">then wait for a hand</tspan><tspan x="652" dy="32">to go up.</tspan></text>
</svg>
</div>
</div>
<div class="s-notes">
<p>Press S to open it. If nothing opens, allow pop-ups for this page. Drag the deck window to the projector and press F there.</p>
</div>
</section>
<!-- 12 · keys -->
<section class="slide">
<div class="kicker">02 · Present</div>
<h2>The keyboard steers the deck</h2>
<table class="keys">
<tr><td><kbd>→</kbd><kbd>Space</kbd></td><td>Next item, then next slide</td></tr>
<tr><td><kbd>←</kbd></td><td>Back one item, then previous slide</td></tr>
<tr><td><kbd>↓</kbd><kbd>↑</kbd></td><td>Next or previous slide, with every item shown</td></tr>
<tr><td><kbd>F</kbd></td><td>Fullscreen</td></tr>
<tr><td><kbd>S</kbd><kbd>E</kbd></td><td>Presenter view, edit view</td></tr>
</table>
<p class="small" style="margin:28px 0 0">Move the pointer to the bottom-left corner for buttons and the full list.</p>
<div class="s-notes">
<p>Clicking also works: the left 30 % of the screen goes back and the rest goes forward. On a touch screen, swipe.</p>
</div>
</section>
<!-- 13 · print -->
<section class="slide">
<div class="kicker">02 · Present</div>
<h2>P prints the deck to PDF</h2>
<p class="sub">Press <kbd>P</kbd> and choose Save as PDF in the print dialog.</p>
<ul>
<li>One page per slide, at 1920 × 1080</li>
<li>Every build shown</li>
<li>Speaker notes left out</li>
</ul>
<div class="s-notes">
<p>The PDF is the hand-out. Backgrounds print as they show, so a dark slide stays dark.</p>
</div>
</section>
<!-- 14 · section divider -->
<section class="slide dark divider">
<div class="kicker">03</div>
<h1>Change</h1>
<div class="s-notes">
<p>How a deck changes after it is written: edits in the browser, suggestions for a coding agent, and updates to the engine.</p>
</div>
</section>
<!-- 15 · edit view -->
<section class="slide">
<div class="kicker">03 · Change</div>
<h2>E opens the edit view</h2>
<div class="cols" style="grid-template-columns:1fr 1.6fr;align-items:end">
<div>
<p>In Edit, double-click text to change it, or click an element to move, copy or delete it. Save writes the file.</p>
<p>In Suggest, click an element and type what should change, for a coding agent.</p>
</div>
<div class="window">
<svg viewBox="0 0 960 600" role="img" aria-label="Drawing of the edit view in Suggest: thumbnails on the left, a slide with one element outlined in orange and a suggestion box beside it, speaker notes below, suggestions on the right with Copy prompt below them, and the buttons for the open suggestion in the toolbar">
<rect width="960" height="600" fill="#EFEFEC"/>
<rect width="960" height="44" fill="#fff"/><path d="M0 44.5h960" stroke="#D6D6D2"/>
<text x="18" y="28" fill="#111110" font-size="14" font-weight="600">my-talk</text>
<path transform="translate(540 14)" d="M8 13V3M3.5 7.5 8 3l4.5 4.5" stroke="#111110" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path transform="translate(566 14)" d="M8 3v10M3.5 8.5 8 13l4.5-4.5" stroke="#AEAEA9" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path transform="translate(592 14)" d="M2.5 4h11M6 4V2.5h4V4M4 4l.7 9.5h6.6L12 4" stroke="#111110" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path transform="translate(618 14)" d="M3 8.5 6.5 12 13 4.5" stroke="#111110" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M646.5 12v20" stroke="#D6D6D2"/>
<rect x="658.5" y="10.5" width="118" height="23" rx="4" fill="none" stroke="#C9C9C5"/><rect x="706" y="13" width="68" height="18" rx="2" fill="#111110"/>
<text x="682" y="26" text-anchor="middle" fill="#111110" font-size="12">Edit</text><text x="740" y="26" text-anchor="middle" fill="#fff" font-size="12">Suggest</text>
<path transform="translate(788 14)" d="M3 8a5 5 0 1 0 1.5-3.5L3 6V2.5M3 6h3.5" stroke="#AEAEA9" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path transform="translate(816 14)" d="M8 2v8M4.5 6.5 8 10l3.5-3.5M2.5 13.5h11" stroke="#111110" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><text x="852" y="27" text-anchor="middle" fill="#111110" font-size="13">Save</text>
<path d="M890 15v14l11-7z" fill="#111110"/><rect x="920" y="15" width="18" height="13" rx="2" fill="none" stroke="#111110" stroke-width="1.5"/>
<rect x="0" y="45" width="118" height="525" fill="#FAFAF8"/><path d="M118.5 45v525" stroke="#D6D6D2"/>
<rect x="16" y="60" width="88" height="50" rx="2" fill="#0C0C0B"/><rect x="24" y="92" width="34" height="8" rx="1" fill="#F7F6F2"/>
<rect x="16" y="124" width="88" height="50" rx="2" fill="#F7F6F2" stroke="#111110" stroke-width="2"/><rect x="24" y="136" width="50" height="6" rx="1" fill="#111110"/>
<rect x="96" y="116" width="16" height="16" rx="2" fill="#111110"/><text x="104" y="128" text-anchor="middle" fill="#fff" font-size="11" font-weight="600">1</text>
<rect x="16.5" y="188.5" width="87" height="49" rx="2" fill="#F7F6F2" stroke="#D6D6D2"/><rect x="24" y="200" width="40" height="6" rx="1" fill="#B9B8B2"/>
<rect x="16" y="252" width="88" height="50" rx="2" fill="#0C0C0B"/><rect x="24" y="284" width="28" height="8" rx="1" fill="#F7F6F2"/>
<rect x="16.5" y="316.5" width="87" height="49" rx="2" fill="#F7F6F2" stroke="#D6D6D2"/><rect x="24" y="328" width="46" height="6" rx="1" fill="#B9B8B2"/>
<rect x="142.5" y="66.5" width="559" height="314" fill="#F7F6F2" stroke="#CFCFCB"/>
<text x="178" y="98" fill="#C2310A" font-size="9" font-weight="500" letter-spacing="1">01 · WRITE</text>
<path d="M178 108.5h488" stroke="#111110" stroke-opacity=".16"/>
<text x="184" y="170" fill="#111110" font-size="30" font-weight="600" letter-spacing="-1">A heading that says the point</text>
<rect x="178" y="140" width="488" height="42" rx="2" fill="none" stroke="#FF9500" stroke-width="2.5"/>
<path d="M178 119h26a2 2 0 0 1 2 2v19h-28z" fill="#007AFF"/><text x="192" y="134" text-anchor="middle" fill="#fff" font-size="11" font-weight="600">01</text>
<rect x="186.5" y="194.5" width="360" height="104" rx="4" fill="#fff" stroke="#C9C9C5"/>
<text x="202" y="220" fill="#6B6B66" font-size="13">Slide 8 › h2 "A heading that says…"</text>
<text x="202" y="248" fill="#111110" font-size="16">Make this one line shorter</text>
<path transform="translate(474 266)" d="M2.5 4h11M6 4V2.5h4V4M4 4l.7 9.5h6.6L12 4" stroke="#6B6B66" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
<rect x="506" y="260" width="28" height="28" rx="3" fill="#111110"/><path d="M520 281v-14m-6 6 6-6 6 6" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<rect x="119" y="412" width="607" height="158" fill="#fff"/><path d="M119 412.5h607" stroke="#D6D6D2"/>
<text x="142" y="440" fill="#6B6B66" font-size="11" font-weight="500" letter-spacing="1">SPEAKER NOTES</text>
<rect x="142" y="458" width="380" height="8" rx="2" fill="#C9C9C5"/><rect x="142" y="478" width="280" height="8" rx="2" fill="#C9C9C5"/>
<rect x="726" y="45" width="234" height="525" fill="#FAFAF8"/><path d="M726.5 45v525M726 88.5h234" stroke="#D6D6D2"/>
<text x="744" y="72" fill="#111110" font-size="11" font-weight="500" letter-spacing="1">SUGGESTIONS</text>
<text x="744" y="116" fill="#6B6B66" font-size="12" font-weight="600">Slide 8 · A heading…</text>
<text x="744" y="142" fill="#007AFF" font-size="11" font-weight="600">01</text>
<text fill="#111110" font-size="14"><tspan x="768" y="142">Make this one line</tspan><tspan x="768" dy="19">shorter</tspan></text>
<path d="M726 520.5h234" stroke="#D6D6D2"/>
<rect x="744" y="530" width="108" height="26" rx="3" fill="#111110"/><text x="798" y="548" text-anchor="middle" fill="#fff" font-size="13" font-weight="500">Copy prompt</text>
<path transform="translate(884 535)" d="M2.5 4h11M6 4V2.5h4V4M4 4l.7 9.5h6.6L12 4" stroke="#111110" fill="none" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><text x="906" y="548" fill="#111110" font-size="13">Clear</text>
<rect y="570" width="960" height="30" fill="#EFEFEC"/><path d="M0 570.5h960" stroke="#D6D6D2"/>
<text x="18" y="590" fill="#6B6B66" font-size="12">Slide 8 of 18</text>
<path transform="translate(878 577)" d="M2.5 3h11a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM6 3v10" stroke="#6B6B66" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
<path transform="translate(904 577)" d="M3.5 2h9a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zM5.5 5.5h5M5.5 8h5M5.5 10.5h3" stroke="#6B6B66" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
<path transform="translate(930 577)" d="M2.5 3h11a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM10 3v10" stroke="#6B6B66" fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5"/>
</svg>
</div>
</div>
<div class="s-notes">
<p>Press E to try it on this slide. Changes stay in this window until you save them; suggestions are kept in this browser, per deck. Press E again to come back.</p>
</div>
</section>
<!-- 16 · the prompt it writes -->
<section class="slide">
<div class="kicker">03 · Change</div>
<h2>Copy prompt collects every suggestion</h2>
<p class="sub">Paste it into Claude Code or another coding agent. It names the file, the slide and the element.</p>
<div class="term">## 1. Slide 8: Speaker notes live inside the slide
Where: box x 120-1520, y 176-255, on `h2` "Speaker notes live inside the slide"
Element: `#stage > section:nth-child(8) > h2:nth-child(2)`
Suggestion: <span class="w">Make this heading shorter</span></div>
<div class="s-notes">
<p>This is one suggestion from a prompt, which starts by naming the deck file. The selector and the text tell the agent where to look.</p>
</div>
</section>
<!-- 17 · updating -->
<section class="slide">
<div class="kicker">03 · Change</div>
<h2>Updating replaces only the engine</h2>
<p class="sub">Your slides and theme stay as they are.</p>
<div class="term"><span class="b">$</span> <span class="w">npx github:roaldnefs/deckfile update my-talk/index.html</span>
<span class="d">my-talk/index.html: updated</span>
<span class="b">$</span> <span class="w">npx github:roaldnefs/deckfile update --check my-talk/index.html</span>
<span class="d">my-talk/index.html: up to date</span></div>
<div class="s-notes">
<p>With --check, nothing is written, and the command exits 1 if the deck is out of date.</p>
</div>
</section>
<!-- 18 · closing -->
<section class="slide dark closing">
<div class="kicker">Start</div>
<h1>Start from template.html</h1>
<ol class="agenda" style="margin-bottom:56px">
<li>Copy it to my-talk/index.html</li>
<li>Replace the slides with your own</li>
<li>Open it in a browser</li>
</ol>
<a class="btn action" href="https://github.com/roaldnefs/deckfile">deckfile on GitHub</a>
<div class="s-notes">
<p>deckfile is MIT licensed, by Roald Nefs. Delete these slides from your copy and keep the rest of the file.</p>
</div>
</section>
</div>
<script data-deck="engine">
/*! deckfile v0.5.0 · engine · MIT License · https://github.com/roaldnefs/deckfile
A presentation as one self-contained HTML file: no build step, no dependencies, opens offline from file://.
Keys: → / Space / PgDn next build or slide ← / PgUp previous
↓ / ↑ next / previous slide, all builds shown
Home / End first / last slide
F fullscreen P print to PDF
S presenter view, in a second window E edit view Esc leave the edit view
in the edit view: N notes pane Cmd/Ctrl+S save Cmd/Ctrl+Z undo Cmd/Ctrl+↑ / ↓ move the slide
click / tap: left 30 % of the screen back, the rest forward · swipe left / right on touch
pointer near the bottom-left corner: buttons for back, the presenter view, the edit view, the shortcuts and forward
Markup:
<div id="stage"> holding one <section class="slide"> per slide, in order
<div class="s-notes"> inside a slide speaker notes, shown in the presenter and edit views
class="build" on any element revealed one at a time with →
data-auto="500" on a section its builds reveal by themselves, one every 500 ms
data-skip on a section left out of the show, its numbers and the print; the edit view still shows it
data-public on the stage a public copy made in the edit view, to hand out: it has no edit view
The engine sets .current on the slide shown, .on on each build revealed, and adds a <span class="counter"> to every slide.
URL: ?print opens the print dialog once loaded; ?presenter is the presenter window; ?view is one read-only slide, used
for the presenter's panes and the edit view's thumbnails and layout previews.
The README describes the presenter and edit views.
*/
(() => {
const slides = [...document.querySelectorAll('.slide')];
// made here, placed by the presenter and edit views
const notes = Object.assign(document.body.appendChild(document.createElement('div')), { id: 'notes', hidden: true });
const timer = Object.assign(document.createElement('div'), { id: 'timer', textContent: '00:00' });
// ?presenter is the window that S opens, ?view is one read-only slide in an iframe; anything else is the deck
const params = new URLSearchParams(location.search);
const mode = params.has('presenter') ? 'presenter' : params.has('view') ? 'view' : 'deck';
const canEdit = mode === 'deck' && !document.querySelector('#stage[data-public]'); // a public copy has no edit view
const here = location.href.split(/[?#]/)[0];
const KEY = 'deck:' + location.pathname;
const EDIT_KEY = KEY + ':edit';
const MODE_KEY = KEY + ':mode';
const store = {
get: (key = KEY) => { try { return sessionStorage.getItem(key); } catch { return null; } },
set: (v, key = KEY) => { try { sessionStorage.setItem(key, v); } catch {} }
};
const local = {
get: key => { try { return JSON.parse(localStorage.getItem(key)); } catch { return null; } },
set: (key, v) => { try { localStorage.setItem(key, JSON.stringify(v)); } catch {} }
};
const clamp = (v, lo, hi) => Math.max(lo, Math.min(hi, v));
const builds = s => [...s.querySelectorAll('.build')];
const skips = s => s?.dataset.skip !== undefined;
const shown = () => slides.filter(s => !skips(s));
let i = Math.min(+store.get() || 0, slides.length - 1);
let autoTimer = null;
let presenterWin = null; // deck: the presenter window, once it has said hello
let pv = null; // presenter: its panes and labels
let editing = false; // deck: edit mode (E) is on
let suggesting = store.get(MODE_KEY) === 'suggest'; // deck: the edit view is in Suggest mode
const elementIds = new WeakMap(); // deck: an id shared by an element and its copies; see twin
let lastElementId = 0;
const leads = new WeakMap(); // deck: the whitespace and comment before each slide, kept while the slide is out of the deck
const HOME = Symbol('home'); // deck: key for the slide a suggestion belongs to; a symbol, so it stays out of localStorage
let ed = null; // deck: the edit panel, overlay and suggestions, built the first time E is pressed
// the edit view's panes around the slide, in px
const RAIL_W = 216, PANE_W = 320, BAR_H = 52, STATUS_H = 32, NOTES_H = 160, GAP = 24;
let railOn = true, paneOn = true; // the side panes of the edit view are showing
const OFF_SLIDE = '.counter, .s-notes'; // inside a slide, but not part of what it shows
// the slide number, in a <span class="counter"> the engine appends to every slide; skipped slides have none and are not counted
function renumber() {
const all = shown();
slides.forEach(s => {
const c = s.querySelector(':scope > .counter:last-child') || s.appendChild(Object.assign(document.createElement('span'), { className: 'counter' }));
c.textContent = skips(s) ? '' : `${all.indexOf(s) + 1} / ${all.length}`;
});
}
renumber();
function drawNotes() {
notes.innerHTML = slides[i].querySelector('.s-notes')?.innerHTML || '<em>No notes for this slide.</em>';
}
function show(n, built = false) {
built ||= editing; // the edit view shows every slide with all its builds
if (ed) { // commit what is being typed before the slide and the notes pane change
settle();
select(null);
}
clearTimeout(autoTimer);
i = clamp(n, 0, slides.length - 1);
slides.forEach((s, k) => s.classList.toggle('current', k === i));
builds(slides[i]).forEach(b => b.classList.toggle('on', built));
if (mode === 'deck') store.set(i);
drawNotes();
if (mode === 'deck' && !built && slides[i].dataset.auto !== undefined) autoBuild(+slides[i].dataset.auto || 500);
if (editing) drawEdit();
sync();
}
function autoBuild(delay) {
const step = () => {
const b = builds(slides[i]).find(x => !x.classList.contains('on'));
if (!b) return;
b.classList.add('on');
sync();
autoTimer = setTimeout(step, delay);
};
autoTimer = setTimeout(step, delay);
}
// slide n, or the first one from there on, going d, that is not skipped; the edit view passes over none.
// Where the deck ends first, it stays on the current slide. So the show never comes to a skipped slide, and only
// shows one when it starts there from the edit view: a backup slide, for the question it answers
function seek(n, d) {
while (!editing && skips(slides[n])) n += d;
return slides[n] ? n : i;
}
// where a deck opens when the current slide is skipped: on the next one shown, or else the one before
const land = () => seek(seek(i, 1), -1);
function next() {
clearTimeout(autoTimer);
const b = builds(slides[i]).find(x => !x.classList.contains('on'));
b ? b.classList.add('on') : show(seek(i + 1, 1));
sync();
}
function prev() {
clearTimeout(autoTimer);
const on = builds(slides[i]).filter(x => x.classList.contains('on'));
on.length ? on.pop().classList.remove('on') : show(seek(i - 1, -1), true);
sync();
}
// show slide n with its first k builds on, or all of them when k < 0 (presenter and view windows)
function apply(n, k) {
show(n, k < 0);
builds(slides[i]).slice(0, Math.max(k, 0)).forEach(b => b.classList.add('on'));
}
// deck: tell an open presenter window where we are, slide i with k builds on
function sync() {
if (mode !== 'deck' || !presenterWin || presenterWin.closed) return;
const k = builds(slides[i]).filter(b => b.classList.contains('on')).length;
presenterWin.postMessage({ deck: 'state', i, k }, '*');
}
// presenter: mirror the deck's state into the current and next panes, notes and labels
function render(n, k) {
if (pv.last && (pv.last[0] !== n || pv.last[1] !== k)) startTimer(); // the talk starts when the deck first moves
pv.last = [n, k];
apply(n, k);
const left = builds(slides[i]).length - k;
// the next press shows another build of this slide, unless it builds by itself;
// otherwise the next slide as it first appears (data-auto slides fully built, since that is where they end up)
const nextBuild = left > 0 && slides[i].dataset.auto === undefined;
const after = seek(i + 1, 1), all = shown();
pv.cur.contentWindow.postMessage({ deck: 'view', i, k }, '*');
pv.next.contentWindow.postMessage(nextBuild ? { deck: 'view', i, k: k + 1 }
: { deck: 'view', i: after, k: slides[after].dataset.auto !== undefined ? -1 : 0 }, '*');
pv.label.textContent = nextBuild ? 'Next build' : 'Next slide';
pv.end.hidden = nextBuild || after !== i;
pv.count.textContent = skips(slides[i]) ? 'Skipped slide' : `Slide ${all.indexOf(slides[i]) + 1} of ${all.length}`;
pv.left.textContent = left > 0 ? `${left} build${left > 1 ? 's' : ''} left on this slide` : '';
}
let t0 = null;
let paused = null; // when the timer was paused, or null while it runs
const pad = n => String(n).padStart(2, '0');
// icon paths, on a 16 px grid
const ICONS = {
play: 'M5 3.2v9.6L12.8 8z', pause: 'M5.5 3.5v9M10.5 3.5v9', reset: 'M3 8a5 5 0 1 0 1.5-3.5L3 6V2.5M3 6h3.5',
back: 'M10 3 5 8l5 5', forward: 'm6 3 5 5-5 5', up: 'M8 13V3M3.5 7.5 8 3l4.5 4.5', close: 'M4 4l8 8M12 4l-8 8',
display: 'M2.5 3h11a1 1 0 0 1 1 1v6.5a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM8 11.5V14M5.5 14h5',
copy: 'M6 5.5h6.5a1 1 0 0 1 1 1V13a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6.5a1 1 0 0 1 1-1zM11 5.5V3a1 1 0 0 0-1-1H3.5a1 1 0 0 0-1 1v6.5a1 1 0 0 0 1 1H5',
notes: 'M3.5 2h9a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1h-9a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1zM5.5 5.5h5M5.5 8h5M5.5 10.5h3',
paneLeft: 'M2.5 3h11a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM6 3v10',
paneRight: 'M2.5 3h11a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1zM10 3v10',
trash: 'M2.5 4h11M6 4V2.5h4V4M4 4l.7 9.5h6.6L12 4', pencil: 'M10.5 3 13 5.5 5.5 13H3v-2.5zM9 4.5 11.5 7',
help: 'M8 14.5a6.5 6.5 0 1 0 0-13 6.5 6.5 0 0 0 0 13zM6.2 6.2a1.9 1.9 0 1 1 2.8 1.7c-.6.3-1 .8-1 1.4M8 11.6v.1',
bubble: 'M3 2.5h10A1.5 1.5 0 0 1 14.5 4v6a1.5 1.5 0 0 1-1.5 1.5H8L4.5 14v-2.5H3A1.5 1.5 0 0 1 1.5 10V4A1.5 1.5 0 0 1 3 2.5z',
save: 'M8 2v8M4.5 6.5 8 10l3.5-3.5M2.5 13.5h11', down: 'M8 3v10M3.5 8.5 8 13l4.5-4.5', check: 'M3 8.5 6.5 12 13 4.5',
plus: 'M8 3v10M3 8h10', saveAs: 'M6.5 3v7M3.5 7l3 3 3-3M2.5 13.5h11M12.5 2v4M10.5 4h4', chevron: 'M4.5 6.5 8 10l3.5-3.5', skip: 'M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8zM8 10a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM3 2.5l10 11'
};
const icon = (name, size = 16) => `<svg width="${size}" height="${size}" viewBox="0 0 16 16" fill="none" stroke="currentColor" ` +
`stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${ICONS[name]}"/></svg>`;
// an icon-only button, and one with its label beside the icon
const tool = (cls, label, name, size) => `<button type="button" class="${cls}" aria-label="${label}" title="${label}">${icon(name, size)}</button>`;
const labelled = (cls, label, name, title) => `<button type="button" class="${cls}"${title ? ` title="${title}"` : ''}>${icon(name)}<span>${label}</span></button>`;
function tick() {
if (t0 === null) return;
const s = Math.floor(((paused ?? Date.now()) - t0) / 1000);
timer.textContent = `${pad(Math.floor(s / 60))}:${pad(s % 60)}`;
pv?.pause.setAttribute('d', ICONS[paused === null ? 'pause' : 'play']);
}
setInterval(tick, 500);
function startTimer() { if (t0 === null) t0 = Date.now(); tick(); }
function resetTimer() { t0 = Date.now(); paused &&= t0; tick(); }
// pause or resume; a timer not running yet starts
function pauseTimer() {
if (t0 === null) return startTimer();
if (paused === null) paused = Date.now();
else { t0 += Date.now() - paused; paused = null; }
tick();
}
const NAV = ['ArrowRight', ' ', 'PageDown', 'ArrowLeft', 'PageUp', 'ArrowDown', 'ArrowUp', 'Home', 'End'];
function act(key) {
// the presenter window steers the deck window, which answers with its new state
if (mode === 'presenter' && NAV.includes(key)) {
opener?.postMessage({ deck: 'key', key }, '*');
return true;
}
switch (key) {
case 'ArrowRight': case ' ': case 'PageDown': next(); break;
case 'ArrowLeft': case 'PageUp': editing ? show(i - 1, true) : prev(); break;
case 'ArrowDown': show(seek(i + 1, 1), true); break;
case 'ArrowUp': show(seek(i - 1, -1), true); break;
case 'Home': show(seek(0, 1)); break;
case 'End': show(seek(slides.length - 1, -1), true); break;
case 'n': case 'N':
if (!editing) return false;
notes.hidden = !notes.hidden;
fit();
break;
case 'f': case 'F':
document.fullscreenElement ? document.exitFullscreen() : document.documentElement.requestFullscreen();
break;
case 'p': case 'P': print(); break;
case 's': case 'S':
if (mode === 'deck') presenterWin = open(here + '?presenter', 'deck-presenter', 'popup,width=1280,height=800');
break;
case 'e': case 'E': if (canEdit) edit(!editing); break;
case 'Escape':
if (!editing) return false;
if (!ed.menu.hidden) showLayouts(false);
else if (!ed.copyBox.hidden) showCopy(false);
else if (ed.sel) select(null);
else edit(false);
break;
case 'Delete': case 'Backspace':
if (!editing || !ed.sel) return false;
alter('Deleted', { kind: 'delete' });
break;
default: return false;
}
return true;
}
addEventListener('keydown', e => {
const typing = e.target.closest('textarea, input, select') || e.target.isContentEditable;
// edit view shortcuts; while text is being typed, Cmd/Ctrl+Z and the arrows are left to the browser
if (editing && (e.metaKey || e.ctrlKey) && !e.altKey && !e.shiftKey) {
const key = e.key.toLowerCase();
if (key === 's') { e.preventDefault(); saveDeck(); }
if (key === 'z' && !typing) { e.preventDefault(); undoChange(); }
if ((key === 'arrowup' || key === 'arrowdown') && !typing && !suggesting) { e.preventDefault(); stepSlide(key === 'arrowup' ? -1 : 1); }
}
if (e.metaKey || e.ctrlKey || e.altKey) return;
// typing a suggestion or the notes: keys are text, Esc only leaves the text box
if (typing) { if (e.key === 'Escape') e.target.blur(); return; }
if (act(e.key)) e.preventDefault();
});
// file:// pages all have origin "null", so messages go to '*' and are checked by who sent them
addEventListener('message', e => {
const m = e.data || {};
if (mode === 'deck' && (m.deck === 'hello' || m.deck === 'key') && (e.source === presenterWin || e.source?.opener === window)) {
presenterWin = e.source;
m.deck === 'key' && NAV.includes(m.key) ? act(m.key) : sync();
} else if (mode === 'presenter' && m.deck === 'state' && e.source === opener) {
pv.seen = Date.now();
pv.link.hidden = true;
// the heartbeat repeats the state every 2 s; only redraw when it changed
if (!pv.last || pv.last[0] !== m.i || pv.last[1] !== m.k) render(m.i, m.k);
} else if (mode === 'view' && m.deck === 'view' && e.source === parent) {
// the edit view sends a thumbnail the current HTML of its slide; only accepted from this deck's own origin
if (m.html !== undefined && e.origin === self.origin) {
const t = document.createElement('template');
t.innerHTML = m.html;
const slide = t.content.firstChild;
slides[m.i].replaceWith(slide);
slides[m.i] = slide;
}
apply(m.i, m.k);
}
});
// click or tap: the left 30 % of the viewport goes back, the rest forward; links, buttons and other controls keep working;
// in edit mode a click selects or marks instead
const stage = document.getElementById('stage');
let swiped = false, tx = 0, ty = 0;
stage.addEventListener('click', e => {
if (swiped || editing || e.target.closest('a, button, input, select, textarea, label, summary, video, audio')) return;
(e.clientX < innerWidth * 0.3 ? prev : next)();
});
// swipe on touch: left is forward, right is back; a swipe suppresses the click that follows it
addEventListener('touchstart', e => { tx = e.touches[0].clientX; ty = e.touches[0].clientY; }, { passive: true });
addEventListener('touchend', e => {
const dx = e.changedTouches[0].clientX - tx, dy = e.changedTouches[0].clientY - ty;
if (editing || Math.abs(dx) < 50 || Math.abs(dx) < Math.abs(dy)) return;
swiped = true; setTimeout(() => { swiped = false; }, 300);
act(dx < 0 ? 'ArrowRight' : 'ArrowLeft');
}, { passive: true });
// slide view: buttons for back, the presenter view, the edit view, the shortcuts and forward, shown while the pointer
// is near the bottom-left corner. They never take focus, so Space and the arrows keep steering the deck
if (mode === 'deck') {
const box = document.createElement('div');
box.id = 'deck-controls';
const button = (cls, label, title, name) =>
`<button type="button" class="${cls}" tabindex="-1" aria-label="${label}" title="${title}">${icon(name)}</button>`;
const KEYS = [['→ Space PgDn', 'Next'], ['← PgUp', 'Previous'], ['↓ ↑', 'Whole slide forward / back'], ['Home End', 'First / last slide'],
['F', 'Fullscreen'], ['P', 'Print to PDF'],
['S', 'Presenter view'], ...canEdit ? [['E', 'Edit view']] : [], ['Esc', 'Close']];
box.innerHTML = '<div id="deck-help" hidden>' + KEYS.map(([keys, what]) =>
`<div class="c-keys">${keys.split(' ').map(k => `<span>${k}</span>`).join('')}</div><div>${what}</div>`).join('') + '</div>' +
button('c-back', 'Back', 'Back (←)', 'back') + button('c-present', 'Presenter view', 'Presenter view (S)', 'display') +
(canEdit ? button('c-edit', 'Edit view', 'Edit view (E)', 'pencil') : '') + button('c-help', 'Keyboard shortcuts', 'Keyboard shortcuts', 'help') +
button('c-fwd', 'Forward', 'Forward (→)', 'forward');
const help = box.firstChild, helpButton = box.querySelector('.c-help');
// the shortcuts stay up, with the buttons, until dismissed
const showHelp = on => {
help.hidden = !on;
box.classList.toggle('open', on);
helpButton.setAttribute('aria-expanded', on);
};
showHelp(false);
box.addEventListener('mousedown', e => e.preventDefault());
helpButton.addEventListener('click', () => showHelp(help.hidden));
box.querySelector('.c-back').addEventListener('click', () => act('ArrowLeft'));
box.querySelector('.c-edit')?.addEventListener('click', () => { showHelp(false); act('e'); });
box.querySelector('.c-fwd').addEventListener('click', () => act('ArrowRight'));
box.querySelector('.c-present').addEventListener('click', () => { showHelp(false); act('s'); });
// a click elsewhere only dismisses them: seen first, so the slide does not advance as well
addEventListener('click', e => {
if (help.hidden || box.contains(e.target)) return;
showHelp(false);
e.stopPropagation();
}, true);
addEventListener('keydown', e => { if (['Escape', 'e', 'E'].includes(e.key)) showHelp(false); });
document.body.append(box);
addEventListener('pointermove', e => box.classList.toggle('near', e.clientX < 320 && e.clientY > innerHeight - 140));
document.documentElement.addEventListener('mouseleave', () => box.classList.remove('near'));
}
// fit the slide to the window, or in the edit view to the room between its panes
function fit() {
const root = document.documentElement.style;
// a ?view pane is always 16:9, so it fills its frame: no sub-pixel bar of the page behind the slide
if (!editing) return root.setProperty('--scale', Math[mode === 'view' ? 'max' : 'min'](innerWidth / 1920, innerHeight / 1080));
const rail = railOn ? RAIL_W : 0, pane = paneOn ? PANE_W : 0;
const w = innerWidth - rail - pane - 2 * GAP, h = innerHeight - BAR_H - STATUS_H - (notes.hidden ? 0 : NOTES_H) - 2 * GAP;
root.setProperty('--scale', Math.max(.05, Math.min(w / 1920, h / 1080)));
root.setProperty('--edit-rail', rail + 'px');
root.setProperty('--edit-pane', pane + 'px');
root.setProperty('--edit-x', rail + GAP + w / 2 + 'px');
root.setProperty('--edit-y', BAR_H + GAP + h / 2 + 'px');
}
addEventListener('resize', fit);
fit();
// a refresh in the edit view is about to return to it, on the same slide
show(store.get(EDIT_KEY) ? i : land());
// keep the screen awake while the deck shows; the browser drops the lock when the tab is hidden, and may refuse it
const awake = () => { if (document.visibilityState === 'visible') navigator.wakeLock?.request('screen').catch(() => {}); };
if (mode !== 'view') { awake(); document.addEventListener('visibilitychange', awake); }
// ?print: print once images and fonts are in
if (params.has('print')) addEventListener('load', () => document.fonts.ready.then(() => print()));
// presenter window: current slide, next slide, notes and timer; both slides are this file opened as ?view
if (mode === 'presenter') {
const css = document.createElement('style');
css.textContent = `
@media screen{
html.presenter,html.presenter body{background:#111110}
html.presenter #stage{display:none}
/* timer on top, current slide left, next slide above the notes right */
#presenter{position:fixed;inset:0;box-sizing:border-box;padding:12px 20px 16px;display:grid;row-gap:12px;
grid-template:"top top top" auto "cur vbar side" minmax(0,1fr) / minmax(0,var(--cur-w,62%)) 20px minmax(0,1fr);
color:#F2F2EF;font:400 15px/1.4 system-ui,sans-serif;-webkit-font-smoothing:antialiased}
#presenter [hidden]{display:none!important}
.p-top{grid-area:top;display:flex;align-items:center;gap:8px}
html.presenter #timer{position:static;padding:0 8px 0 0;background:none;border:0;color:#F2F2EF;
font:500 26px/1 system-ui,sans-serif;font-variant-numeric:tabular-nums}
.p-link{padding:5px 10px;border-radius:3px;background:rgba(255,69,58,.18);color:#FF6961;font-size:13px;font-weight:500}
.p-clock{margin-left:auto;color:#8F8F8A;font:500 16px/1 system-ui,sans-serif;font-variant-numeric:tabular-nums}
#presenter button{display:grid;place-items:center;padding:0;border:0;background:rgba(255,255,255,.1);color:#F2F2EF;cursor:pointer}
#presenter button:hover{background:rgba(255,255,255,.18)}
.p-pause,.p-reset{width:30px;height:30px;border-radius:3px}
.p-pause svg{fill:currentColor}
.p-vbar{grid-area:vbar;cursor:col-resize}
.p-hbar{flex:none;height:20px;cursor:row-resize}
.p-vbar,.p-hbar{position:relative;touch-action:none}
/* a hairline that thickens under the pointer */
.p-vbar::after,.p-hbar::after{content:"";position:absolute;border-radius:2px;background:rgba(255,255,255,.12)}
.p-vbar::after{top:0;bottom:0;left:9.5px;width:1px}
.p-hbar::after{left:0;right:0;top:9.5px;height:1px}
.p-vbar:hover::after,.p-vbar.p-drag::after{left:8px;width:4px;background:rgba(255,255,255,.35)}
.p-hbar:hover::after,.p-hbar.p-drag::after{top:8px;height:4px;background:rgba(255,255,255,.35)}
/* a slide pane holds the largest 16:9 slide that fits */
.p-slide,.p-next{container-type:size;display:grid;place-items:center}
#presenter iframe{display:block;width:min(100cqw,calc(100cqh * 16 / 9));aspect-ratio:16/9;border:0;border-radius:3px;background:#000;pointer-events:none}
.p-cur{grid-area:cur;display:flex;flex-direction:column;gap:12px;min-height:0}