@wakeful-cloud/slidev-theme-illinois 0.0.0-stage → 0.1.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.
Files changed (82) hide show
  1. package/LICENSE +45 -0
  2. package/README.md +592 -2
  3. package/assets/logos/block-i-blue.svg +54 -0
  4. package/assets/logos/block-i-full.svg +54 -0
  5. package/assets/logos/block-i-orange.svg +54 -0
  6. package/assets/logos/wordmark-blue.svg +94 -0
  7. package/assets/logos/wordmark-formal-blue.svg +234 -0
  8. package/assets/logos/wordmark-formal-full.svg +234 -0
  9. package/assets/logos/wordmark-formal-orange.svg +234 -0
  10. package/assets/logos/wordmark-full.svg +94 -0
  11. package/assets/logos/wordmark-orange.svg +94 -0
  12. package/assets/logos/wordmark-vertical-blue.svg +94 -0
  13. package/assets/logos/wordmark-vertical-full.svg +94 -0
  14. package/assets/logos/wordmark-vertical-orange.svg +94 -0
  15. package/citations/engine.ts +738 -0
  16. package/citations/errors.ts +79 -0
  17. package/citations/plugin.ts +137 -0
  18. package/citations/styles.ts +300 -0
  19. package/citations/syntax.ts +357 -0
  20. package/components/bibliography.vue +185 -0
  21. package/components/callout.vue +42 -0
  22. package/components/card.vue +37 -0
  23. package/components/cite.vue +62 -0
  24. package/components/frame.vue +71 -0
  25. package/components/illinois-logo.vue +45 -0
  26. package/components/math-morph.vue +252 -0
  27. package/components/qr-code.vue +51 -0
  28. package/components/stat.vue +43 -0
  29. package/components/steps.vue +77 -0
  30. package/global.d.ts +14 -0
  31. package/internal/brand-logo.vue +48 -0
  32. package/internal/citations.ts +206 -0
  33. package/internal/kicker.vue +13 -0
  34. package/internal/layout-root.vue +42 -0
  35. package/internal/pattern.vue +20 -0
  36. package/internal/split.vue +147 -0
  37. package/internal/theme.ts +878 -0
  38. package/layouts/agenda.vue +82 -0
  39. package/layouts/appendix-right.vue +15 -0
  40. package/layouts/appendix.vue +25 -0
  41. package/layouts/canvas.vue +21 -0
  42. package/layouts/center.vue +17 -0
  43. package/layouts/compare.vue +48 -0
  44. package/layouts/cover-right.vue +15 -0
  45. package/layouts/cover.vue +170 -0
  46. package/layouts/default.vue +15 -0
  47. package/layouts/end-right.vue +15 -0
  48. package/layouts/end.vue +89 -0
  49. package/layouts/fact-right.vue +15 -0
  50. package/layouts/fact.vue +25 -0
  51. package/layouts/figure.vue +43 -0
  52. package/layouts/grid.vue +33 -0
  53. package/layouts/iframe-left.vue +16 -0
  54. package/layouts/iframe-right.vue +16 -0
  55. package/layouts/image-left.vue +16 -0
  56. package/layouts/image-right.vue +16 -0
  57. package/layouts/image.vue +40 -0
  58. package/layouts/media-left.vue +17 -0
  59. package/layouts/media-right.vue +17 -0
  60. package/layouts/people.vue +98 -0
  61. package/layouts/quote-right.vue +15 -0
  62. package/layouts/quote.vue +41 -0
  63. package/layouts/references.vue +36 -0
  64. package/layouts/section-right.vue +15 -0
  65. package/layouts/section.vue +53 -0
  66. package/layouts/statement-right.vue +15 -0
  67. package/layouts/statement.vue +30 -0
  68. package/layouts/two-cols-header.vue +32 -0
  69. package/layouts/two-cols.vue +31 -0
  70. package/package.json +114 -4
  71. package/setup/mermaid.ts +73 -0
  72. package/setup/shiki.ts +147 -0
  73. package/setup/transformers.ts +21 -0
  74. package/setup/unocss.ts +34 -0
  75. package/setup/vite-plugins.ts +8 -0
  76. package/slide-top.vue +149 -0
  77. package/styles/base.css +309 -0
  78. package/styles/components.css +336 -0
  79. package/styles/index.ts +19 -0
  80. package/styles/layouts.css +1242 -0
  81. package/styles/looks.css +307 -0
  82. package/styles/tokens.css +324 -0
@@ -0,0 +1,206 @@
1
+ /**
2
+ * @file Client-side citation state (hot-reloaded from the citations plugin) and in-text label
3
+ * formatting.
4
+ */
5
+
6
+ import initial from "virtual:illinois-citations";
7
+ import {shallowRef} from "vue";
8
+ import type {CitationData, CitationEntry} from "#citations/engine.ts";
9
+ import type {CiteItem} from "#citations/syntax.ts";
10
+
11
+ export type {CiteItem} from "#citations/syntax.ts";
12
+
13
+ /**
14
+ * A bibliography entry together with its key
15
+ */
16
+ interface KeyedEntry extends CitationEntry {
17
+ /**
18
+ * Cite key
19
+ */
20
+ key: string;
21
+ }
22
+
23
+ /**
24
+ * Current citation data (replaced on hot updates)
25
+ */
26
+ export const citations = shallowRef<CitationData>(initial);
27
+
28
+ if (import.meta.hot) {
29
+ import.meta.hot.accept("virtual:illinois-citations", mod => {
30
+ if (mod) {
31
+ citations.value = mod["default"] as CitationData;
32
+ }
33
+ });
34
+ }
35
+
36
+ /**
37
+ * Formatted entry of a cite key. Keys come from slides and bibliography files, so only the data's
38
+ * own entries count: a plain lookup would also find what every object inherits (`constructor`,
39
+ * `toString`, ...).
40
+ * @param data Citation data
41
+ * @param key Cite key
42
+ * @returns Entry, or `undefined` if the key is missing from the bibliography
43
+ */
44
+ export const entryOf = (data: CitationData, key: string): CitationEntry | undefined =>
45
+ Object.hasOwn(data.entries, key) ? data.entries[key] : undefined;
46
+
47
+ /**
48
+ * En dash used in collapsed citation ranges
49
+ */
50
+ const EN_DASH = "\u2013";
51
+
52
+ /**
53
+ * Collapse runs of 3+ consecutive numbers into ranges: `[1, 2, 3, 5]` -> `["1-3", "5"]` (joined with an en dash)
54
+ * @param numbers Citation numbers
55
+ * @returns Labels
56
+ */
57
+ const collapse = (numbers: number[]): string[] => {
58
+ const sorted = [...new Set(numbers)].toSorted((a, b) => a - b);
59
+ const labels: string[] = [];
60
+
61
+ let start = 0;
62
+ for (let index = 1; index <= sorted.length; index++) {
63
+ // Still inside a run of consecutive numbers
64
+ if (index < sorted.length && sorted[index] === (sorted[index - 1] ?? 0) + 1) {
65
+ continue;
66
+ }
67
+
68
+ const run = sorted.slice(start, index);
69
+ if (run.length >= 3) {
70
+ labels.push(`${run[0]}${EN_DASH}${run.at(-1)}`);
71
+ } else {
72
+ labels.push(...run.map(String));
73
+ }
74
+ start = index;
75
+ }
76
+
77
+ return labels;
78
+ };
79
+
80
+ /**
81
+ * Format a citation group for a numeric style (`[1]`, `[1, p. 3]`, `[1-3]`)
82
+ * @param items Cited works
83
+ * @param data Citation data
84
+ * @returns In-text label
85
+ */
86
+ const formatNumeric = (items: CiteItem[], data: CitationData): string => {
87
+ const simple = items.every(item => !item.prefix && !item.locator && entryOf(data, item.key));
88
+
89
+ /**
90
+ * Label of a single item
91
+ * @param item Cited work
92
+ * @returns Label without brackets
93
+ */
94
+ const label = (item: CiteItem) => {
95
+ const entry = entryOf(data, item.key);
96
+ const number = entry ? String(entry.n) : `?${item.key}`;
97
+ const body = item.locator ? `${number}, ${item.locator}` : number;
98
+ return item.prefix ? `${item.prefix} ${body}` : body;
99
+ };
100
+
101
+ // IEEE: every item in its own brackets, in numeric order
102
+ if (data.grouping === "separate") {
103
+ const ordered = simple
104
+ ? items.toSorted((a, b) => (entryOf(data, a.key)?.n ?? 0) - (entryOf(data, b.key)?.n ?? 0))
105
+ : items;
106
+ return ordered.map(item => `[${label(item)}]`).join(", ");
107
+ }
108
+
109
+ // Most numeric styles: one bracket, ranges collapsed
110
+ if (simple) {
111
+ return `[${collapse(items.map(item => entryOf(data, item.key)?.n ?? 0)).join(", ")}]`;
112
+ }
113
+
114
+ const separator = items.some(item => item.locator) ? "; " : ", ";
115
+ return `[${items.map(item => label(item)).join(separator)}]`;
116
+ };
117
+
118
+ /**
119
+ * Format a citation group for an author-date style (`(Smith et al., 2024, p. 3)`)
120
+ * @param items Cited works
121
+ * @param data Citation data
122
+ * @returns In-text label
123
+ */
124
+ const formatAuthorDate = (items: CiteItem[], data: CitationData): string => {
125
+ const parts = items.map(item => {
126
+ const entry = entryOf(data, item.key);
127
+
128
+ let text = `?${item.key}`;
129
+ if (entry) {
130
+ text = item.suppressAuthor ? entry.year : entry.label;
131
+ }
132
+ if (item.locator) {
133
+ text += `, ${item.locator}`;
134
+ }
135
+
136
+ return item.prefix ? `${item.prefix} ${text}` : text;
137
+ });
138
+
139
+ return `(${parts.join("; ")})`;
140
+ };
141
+
142
+ /**
143
+ * Format a citation group for in-text display
144
+ * @param items Cited works
145
+ * @param data Citation data
146
+ * @returns In-text label
147
+ */
148
+ export const formatCitation = (items: CiteItem[], data: CitationData): string =>
149
+ data.numeric ? formatNumeric(items, data) : formatAuthorDate(items, data);
150
+
151
+ /**
152
+ * Cite keys given as an array or as a string separated by commas, semicolons or spaces
153
+ * @param value Keys
154
+ * @returns Keys, or `undefined` when `value` is neither an array nor a string
155
+ */
156
+ export const splitKeys = (value: unknown): string[] | undefined => {
157
+ if (Array.isArray(value)) {
158
+ return value.map(String).filter(Boolean);
159
+ }
160
+ return typeof value === "string" ? value.split(/[,;\s]+/u).filter(Boolean) : undefined;
161
+ };
162
+
163
+ /**
164
+ * Bibliography entries (in bibliography order)
165
+ * @param keys Keys to include, as for `splitKeys` (default: cited entries, or every entry if `all`
166
+ * is set)
167
+ * @param data Citation data
168
+ * @param all Include uncited entries when `keys` is not given
169
+ * @returns Entries with their keys
170
+ */
171
+ export const entriesFor = (
172
+ keys: string[] | string | undefined,
173
+ data: CitationData,
174
+ all = false,
175
+ ): KeyedEntry[] => {
176
+ const list = splitKeys(keys);
177
+ const wanted = list === undefined ? undefined : new Set(list);
178
+ const result: KeyedEntry[] = [];
179
+
180
+ for (const key of data.order) {
181
+ const entry = entryOf(data, key);
182
+ if (entry === undefined) {
183
+ continue;
184
+ }
185
+
186
+ const included = wanted === undefined ? all || entry.cited : wanted.has(key);
187
+ if (included) {
188
+ result.push({...entry, key});
189
+ }
190
+ }
191
+
192
+ return result;
193
+ };
194
+
195
+ /**
196
+ * Decode citation items encoded by the markdown transformer
197
+ * @param encoded URI-encoded JSON
198
+ * @returns Cited works
199
+ */
200
+ export const decodeItems = (encoded: string): CiteItem[] => {
201
+ try {
202
+ return JSON.parse(decodeURIComponent(encoded)) as CiteItem[];
203
+ } catch {
204
+ return [];
205
+ }
206
+ };
@@ -0,0 +1,13 @@
1
+ <!--
2
+ Small uppercase label above a slide title, from the `kicker` frontmatter field.
3
+ -->
4
+
5
+ <script setup lang="ts">
6
+ import {useIllinois} from "./theme.ts";
7
+
8
+ const {kicker} = useIllinois();
9
+ </script>
10
+
11
+ <template>
12
+ <p v-if="kicker" class="il-kicker">{{ kicker }}</p>
13
+ </template>
@@ -0,0 +1,42 @@
1
+ <!--
2
+ Shared root for every theme layout: applies surface, density, font and the `background` image
3
+ (with a scrim). Layouts that draw their own image (`image`) set `own-background`.
4
+ -->
5
+
6
+ <script setup lang="ts">
7
+ import {computed, type StyleValue, useAttrs} from "vue";
8
+ import {useIllinois} from "./theme.ts";
9
+
10
+ // Slidev passes every frontmatter field to layouts as attributes; only `class` and `style` are
11
+ // forwarded
12
+ defineOptions({inheritAttrs: false});
13
+
14
+ const {name, ownBackground = false} = defineProps<{
15
+ /**
16
+ * Layout name (adds an `il-<name>` class)
17
+ */
18
+ name: string;
19
+
20
+ /**
21
+ * The layout draws the `background` image itself
22
+ */
23
+ ownBackground?: boolean;
24
+ }>();
25
+
26
+ const attrs = useAttrs();
27
+ const {background, backgroundStyle, classes} = useIllinois();
28
+
29
+ // Draw the `background` frontmatter image (with a scrim) unless the layout does
30
+ const showBackground = computed(() => background.value !== undefined && !ownBackground);
31
+ </script>
32
+
33
+ <template>
34
+ <div
35
+ class="slidev-layout il-layout"
36
+ :class="[`il-${name}`, classes, attrs['class']]"
37
+ :style="[showBackground ? backgroundStyle : {}, attrs['style'] as StyleValue]"
38
+ >
39
+ <div v-if="showBackground" aria-hidden="true" class="il-scrim" />
40
+ <slot />
41
+ </div>
42
+ </template>
@@ -0,0 +1,20 @@
1
+ <!--
2
+ Decorative background pattern of cover, section and end slides (`pattern` option: `dots` |
3
+ `grid` | `lines` | `none`). It sits on the right of the slide, or on the left in mirrored
4
+ (`-right`) layouts.
5
+ -->
6
+
7
+ <script setup lang="ts">
8
+ import {useIllinois} from "./theme.ts";
9
+
10
+ const {pattern} = useIllinois();
11
+ </script>
12
+
13
+ <template>
14
+ <div
15
+ v-if="pattern !== 'none'"
16
+ aria-hidden="true"
17
+ class="il-pattern"
18
+ :class="`il-pattern-${pattern}`"
19
+ />
20
+ </template>
@@ -0,0 +1,147 @@
1
+ <!--
2
+ Content + media split, shared by the media-left / media-right / image-left / image-right /
3
+ iframe-left / iframe-right layouts.
4
+
5
+ Frontmatter:
6
+ - `alt`: description of the image (title of the iframe)
7
+ - `caption`: small caption, over the bottom of an image, video or iframe, or under the
8
+ `::media::` slot content
9
+ - `fit`: `contain` | `cover` (default)
10
+ - `frame`: `bleed` (edge to edge, default) | `inset` (inside the slide margins, rounded)
11
+ - `image` | `iframe` (or `url`, like Slidev's iframe layouts) | `video`: media source (or use the
12
+ `::media::` slot for anything else). Iframes are sandboxed (see `IFRAME_SANDBOX`); a page that
13
+ needs more goes into the `::media::` slot as an `<iframe>` of its own
14
+ - `mediaBackground`: background of the media panel (color)
15
+ - `ratio`: media share of the width (default `1/2`)
16
+ -->
17
+
18
+ <script setup lang="ts">
19
+ import {resolveAssetUrl} from "@slidev/client";
20
+ import {computed} from "vue";
21
+ import Kicker from "./kicker.vue";
22
+ import LayoutRoot from "./layout-root.vue";
23
+ import {altText, mediaShare, safeUrl, tracks, useIllinois} from "./theme.ts";
24
+
25
+ /**
26
+ * Supported media types
27
+ */
28
+ type MediaKind = "iframe" | "image" | "video";
29
+
30
+ /**
31
+ * What an embedded page may do: run scripts, keep its own storage and logins, submit forms, open
32
+ * links in new tabs and present (e.g. video players). Left out on purpose: navigating the deck away
33
+ * (`allow-top-navigation`), dialogs that block the presentation (`allow-modals`) and downloads
34
+ */
35
+ const IFRAME_SANDBOX = [
36
+ "allow-forms",
37
+ "allow-popups",
38
+ "allow-popups-to-escape-sandbox",
39
+ "allow-presentation",
40
+ "allow-same-origin",
41
+ "allow-scripts",
42
+ ].join(" ");
43
+
44
+ const {kind, name, side} = defineProps<{
45
+ /**
46
+ * Media type to read from frontmatter (defaults to whichever is set)
47
+ */
48
+ kind?: MediaKind;
49
+
50
+ /**
51
+ * Layout name
52
+ */
53
+ name: string;
54
+
55
+ /**
56
+ * Media side
57
+ */
58
+ side: "left" | "right";
59
+ }>();
60
+
61
+ const {frontmatter} = useIllinois();
62
+
63
+ const alt = computed(() => altText(frontmatter.value));
64
+ const caption = computed(() => frontmatter.value["caption"] as string | undefined);
65
+ const fit = computed(() => (frontmatter.value["fit"] === "contain" ? "contain" : "cover"));
66
+ const frame = computed(() => (frontmatter.value["frame"] === "inset" ? "inset" : "bleed"));
67
+ const mediaFraction = computed(() => mediaShare(frontmatter.value));
68
+
69
+ // First media source set in frontmatter (`url` is accepted as an alias of `iframe`)
70
+ const media = computed(() => {
71
+ const kinds: MediaKind[] = kind === undefined ? ["image", "video", "iframe"] : [kind];
72
+
73
+ for (const candidate of kinds) {
74
+ const value =
75
+ frontmatter.value[candidate] ??
76
+ (candidate === "iframe" ? frontmatter.value["url"] : undefined);
77
+ if (typeof value === "string" && value.length > 0) {
78
+ if (candidate !== "iframe") {
79
+ return {kind: candidate, src: resolveAssetUrl(value)};
80
+ }
81
+
82
+ // An iframe runs its source: only web pages
83
+ const src = safeUrl(value);
84
+ if (src !== undefined) {
85
+ return {kind: candidate, src};
86
+ }
87
+ }
88
+ }
89
+
90
+ return undefined;
91
+ });
92
+
93
+ // The grid's first track is whichever column comes first visually
94
+ const gridStyle = computed(() => ({
95
+ gridTemplateColumns:
96
+ side === "left" ? tracks(mediaFraction.value) : tracks(1 - mediaFraction.value),
97
+ }));
98
+
99
+ const mediaStyle = computed(() => {
100
+ const background = frontmatter.value["mediaBackground"];
101
+ return typeof background === "string" ? {background} : {};
102
+ });
103
+ </script>
104
+
105
+ <template>
106
+ <LayoutRoot
107
+ class="il-split"
108
+ :class="[`il-split-${frame}`, `il-split-${side}`, {'il-split-slot': !media}]"
109
+ :name="name"
110
+ :style="gridStyle"
111
+ >
112
+ <div class="il-split-content">
113
+ <Kicker />
114
+ <slot />
115
+ </div>
116
+
117
+ <figure class="il-split-media">
118
+ <div class="il-split-panel" :style="mediaStyle">
119
+ <slot name="media">
120
+ <img
121
+ v-if="media?.kind === 'image'"
122
+ :alt="alt"
123
+ :class="`il-fit-${fit}`"
124
+ :src="media.src"
125
+ />
126
+ <video
127
+ v-else-if="media?.kind === 'video'"
128
+ autoplay
129
+ :class="`il-fit-${fit}`"
130
+ loop
131
+ muted
132
+ playsinline
133
+ :src="media.src"
134
+ />
135
+ <iframe
136
+ v-else-if="media?.kind === 'iframe'"
137
+ referrerpolicy="strict-origin-when-cross-origin"
138
+ :sandbox="IFRAME_SANDBOX"
139
+ :src="media.src"
140
+ :title="alt || 'Embedded page'"
141
+ />
142
+ </slot>
143
+ <figcaption v-if="caption" class="il-split-caption">{{ caption }}</figcaption>
144
+ </div>
145
+ </figure>
146
+ </LayoutRoot>
147
+ </template>