taleem-engine 1.0.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/package.json +51 -0
- package/readme.md +472 -0
- package/src/compiler/TaleemCompiler.js +122 -0
- package/src/compiler/animation-primtives/eqHighlightOne.js +41 -0
- package/src/compiler/animation-primtives/progressiveReveal.js +14 -0
- package/src/compiler/animation-primtives/runPrimitive.js +71 -0
- package/src/compiler/animation-primtives/showAllHighlightOne.js +34 -0
- package/src/compiler/animation-primtives/showOneAtATime.js +24 -0
- package/src/compiler/templates/compileBarChart.js +91 -0
- package/src/compiler/templates/compileBulletList.js +37 -0
- package/src/compiler/templates/compileEq.js +135 -0
- package/src/compiler/templates/compileFillImage.js +50 -0
- package/src/compiler/templates/compileFocusList.js +75 -0
- package/src/compiler/templates/compileImageGrid.js +60 -0
- package/src/compiler/templates/compileImageLeftBulletsRight.js +78 -0
- package/src/compiler/templates/compileImageRightBulletsLeft.js +79 -0
- package/src/compiler/templates/compileImageSlide.js +52 -0
- package/src/compiler/templates/compileImageStrip.js +60 -0
- package/src/compiler/templates/compileImageWithCaption.js +75 -0
- package/src/compiler/templates/compileImageWithTitle.js +75 -0
- package/src/compiler/templates/compileKeyIdeasSlide.js +62 -0
- package/src/compiler/templates/compileProgressbar.js +74 -0
- package/src/compiler/templates/compileQuoteSlide.js +72 -0
- package/src/compiler/templates/compileSkeletonSlide.js +80 -0
- package/src/compiler/templates/compileTable.js +70 -0
- package/src/compiler/templates/compileTextGrid.js +57 -0
- package/src/compiler/templates/compileTitleAndPara.js +79 -0
- package/src/compiler/templates/compileTitleAndSubtitle.js +84 -0
- package/src/compiler/templates/compileTwoColumnText.js +116 -0
- package/src/compiler/templates/helpers/addIdToItems.js +17 -0
- package/src/compiler/templates/helpers/buildSequentialStates.js +24 -0
- package/src/compiler/templates/index.js +108 -0
- package/src/compiler/utils/applyBackground.js +9 -0
- package/src/compiler/utils/assignMockTimings.js +47 -0
- package/src/compiler/utils/compileTimings.js +16 -0
- package/src/compiler/utils/getDeckImages.js +40 -0
- package/src/compiler/utils/resolveAssetPaths.js +42 -0
- package/src/compiler/utils/resolveBackground.js +29 -0
- package/src/dsl/Taleem.js +400 -0
- package/src/dsl/TimelineContext.js +256 -0
- package/src/dsl/slides/BarChart.js +31 -0
- package/src/dsl/slides/BulletListBuilder.js +23 -0
- package/src/dsl/slides/Eq.js +65 -0
- package/src/dsl/slides/FillImage.js +25 -0
- package/src/dsl/slides/FocusListBuilder.js +37 -0
- package/src/dsl/slides/ImageGrid.js +25 -0
- package/src/dsl/slides/ImageLeftBulletsRight.js +37 -0
- package/src/dsl/slides/ImageRightBulletsLeft.js +37 -0
- package/src/dsl/slides/ImageSlide.js +25 -0
- package/src/dsl/slides/ImageStrip.js +25 -0
- package/src/dsl/slides/ImageWithCaption.js +37 -0
- package/src/dsl/slides/ImageWithTitle.js +37 -0
- package/src/dsl/slides/KeyIdeasSlide.js +31 -0
- package/src/dsl/slides/Progressbar.js +31 -0
- package/src/dsl/slides/QuoteSlide.js +37 -0
- package/src/dsl/slides/SkeletonSlideBuilder.js +43 -0
- package/src/dsl/slides/Table.js +25 -0
- package/src/dsl/slides/TextGrid.js +25 -0
- package/src/dsl/slides/TitleAndPara.js +37 -0
- package/src/dsl/slides/TitleAndSubtitle.js +37 -0
- package/src/dsl/slides/TwoColumnText.js +61 -0
- package/src/index.js +4 -0
- package/src/primitives/index.js +0 -0
- package/src/types/index.js +0 -0
- package/src/utils/index.js +0 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// /src/compiler/animation-primtives/runPrimitive.js
|
|
2
|
+
|
|
3
|
+
import { progressiveReveal } from "./progressiveReveal.js";
|
|
4
|
+
|
|
5
|
+
import { showAllHighlightOne } from "./showAllHighlightOne.js";
|
|
6
|
+
|
|
7
|
+
import { showOneAtATime } from "./showOneAtATime.js";
|
|
8
|
+
|
|
9
|
+
import { eqHighlightOne } from "./eqHighlightOne.js";
|
|
10
|
+
|
|
11
|
+
export function runPrimitive({
|
|
12
|
+
type,
|
|
13
|
+
items
|
|
14
|
+
}) {
|
|
15
|
+
switch (type) {
|
|
16
|
+
case "progressiveReveal":
|
|
17
|
+
return {
|
|
18
|
+
actions:
|
|
19
|
+
progressiveReveal(items),
|
|
20
|
+
|
|
21
|
+
groups: {
|
|
22
|
+
hidden: ["hidden"]
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
case "highlightOne":
|
|
27
|
+
return {
|
|
28
|
+
actions:
|
|
29
|
+
showAllHighlightOne(items),
|
|
30
|
+
|
|
31
|
+
groups: {
|
|
32
|
+
focus: [],
|
|
33
|
+
|
|
34
|
+
dim: ["dim"]
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
case "eqHighlightOne":
|
|
39
|
+
return {
|
|
40
|
+
actions:
|
|
41
|
+
eqHighlightOne(items),
|
|
42
|
+
|
|
43
|
+
groups: {
|
|
44
|
+
focus: [],
|
|
45
|
+
|
|
46
|
+
dim: ["dim"],
|
|
47
|
+
|
|
48
|
+
visible: [],
|
|
49
|
+
|
|
50
|
+
hidden: ["hidden"]
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
case "oneAtATime":
|
|
55
|
+
return {
|
|
56
|
+
actions:
|
|
57
|
+
showOneAtATime(items),
|
|
58
|
+
|
|
59
|
+
groups: {
|
|
60
|
+
visible: [],
|
|
61
|
+
|
|
62
|
+
hidden: ["hidden"]
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
default:
|
|
67
|
+
throw new Error(
|
|
68
|
+
`Unknown primitive: ${type}`
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
// /src/compiler/animation-primitives/showAllHighlightOne.js
|
|
3
|
+
|
|
4
|
+
export function showAllHighlightOne(items, extraStateFn) {
|
|
5
|
+
const ids = items.map(item => item.id);
|
|
6
|
+
|
|
7
|
+
const actions = [];
|
|
8
|
+
|
|
9
|
+
for (const item of items) {
|
|
10
|
+
const focusId = item.id;
|
|
11
|
+
|
|
12
|
+
const dimIds = ids.filter(id => id !== focusId);
|
|
13
|
+
|
|
14
|
+
const baseState = {
|
|
15
|
+
focus: [focusId],
|
|
16
|
+
dim: dimIds
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const extraState = extraStateFn
|
|
20
|
+
? extraStateFn(focusId, items)
|
|
21
|
+
: {};
|
|
22
|
+
|
|
23
|
+
actions.push({
|
|
24
|
+
time: item.showAt,
|
|
25
|
+
|
|
26
|
+
state: {
|
|
27
|
+
...baseState,
|
|
28
|
+
...extraState
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return actions;
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// /src/compiler/animation-primitives/showOneAtATime.js
|
|
2
|
+
|
|
3
|
+
export function showOneAtATime(items) {
|
|
4
|
+
const ids = items.map(item => item.id);
|
|
5
|
+
|
|
6
|
+
const actions = [];
|
|
7
|
+
|
|
8
|
+
for (const item of items) {
|
|
9
|
+
const activeId = item.id;
|
|
10
|
+
|
|
11
|
+
const hiddenIds = ids.filter(id => id !== activeId);
|
|
12
|
+
|
|
13
|
+
actions.push({
|
|
14
|
+
time: item.showAt,
|
|
15
|
+
|
|
16
|
+
state: {
|
|
17
|
+
visible: [activeId],
|
|
18
|
+
hidden: hiddenIds
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return actions;
|
|
24
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
|
|
2
|
+
// /src/compiler/templates/compileBarChart.js
|
|
3
|
+
|
|
4
|
+
import { addIdToItems } from "./helpers/addIdToItems.js";
|
|
5
|
+
|
|
6
|
+
export function compileBarChart(slide) {
|
|
7
|
+
const rawItems = slide.data ?? [];
|
|
8
|
+
|
|
9
|
+
const items =
|
|
10
|
+
addIdToItems(rawItems);
|
|
11
|
+
|
|
12
|
+
const bars =
|
|
13
|
+
items.filter(
|
|
14
|
+
d => d.name === "bar"
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
const ids =
|
|
18
|
+
items.map(i => i.id);
|
|
19
|
+
|
|
20
|
+
const barsData =
|
|
21
|
+
bars.map(d => ({
|
|
22
|
+
id: d.id,
|
|
23
|
+
|
|
24
|
+
label: d.label,
|
|
25
|
+
|
|
26
|
+
value:
|
|
27
|
+
Number(d.value),
|
|
28
|
+
|
|
29
|
+
classes:
|
|
30
|
+
d.classes || ""
|
|
31
|
+
}));
|
|
32
|
+
|
|
33
|
+
const maxValue =
|
|
34
|
+
Math.max(
|
|
35
|
+
...barsData.map(
|
|
36
|
+
b => b.value
|
|
37
|
+
),
|
|
38
|
+
1
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const html = `
|
|
42
|
+
<section class="slide barChart">
|
|
43
|
+
|
|
44
|
+
<div class="bar-chart">
|
|
45
|
+
|
|
46
|
+
${barsData.map(bar => {
|
|
47
|
+
const width =
|
|
48
|
+
(bar.value / maxValue)
|
|
49
|
+
* 100;
|
|
50
|
+
|
|
51
|
+
return `
|
|
52
|
+
<div
|
|
53
|
+
id="${bar.id}"
|
|
54
|
+
|
|
55
|
+
class="bar-row hidden ${bar.classes}"
|
|
56
|
+
>
|
|
57
|
+
|
|
58
|
+
<div class="bar-label">
|
|
59
|
+
${bar.label}
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div class="bar-track">
|
|
63
|
+
<div
|
|
64
|
+
class="bar-fill"
|
|
65
|
+
|
|
66
|
+
style="width:${width}%"
|
|
67
|
+
></div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<div class="bar-value">
|
|
71
|
+
${bar.value}
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
</div>
|
|
75
|
+
`;
|
|
76
|
+
}).join("")}
|
|
77
|
+
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
</section>
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
html,
|
|
85
|
+
|
|
86
|
+
animation:
|
|
87
|
+
"progressiveReveal",
|
|
88
|
+
|
|
89
|
+
ids
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { addIdToItems } from "./helpers/addIdToItems.js";
|
|
3
|
+
|
|
4
|
+
export function compileBulletList(slide) {
|
|
5
|
+
const rawItems = slide.data ?? [];
|
|
6
|
+
|
|
7
|
+
const items = addIdToItems(rawItems);
|
|
8
|
+
|
|
9
|
+
const bullets = items.filter(d => d.name === "bullet");
|
|
10
|
+
|
|
11
|
+
const ids = items.map(i => i.id);
|
|
12
|
+
|
|
13
|
+
const html = `
|
|
14
|
+
<section class="slide bulletList">
|
|
15
|
+
<ul>
|
|
16
|
+
${bullets
|
|
17
|
+
.map(
|
|
18
|
+
b => `
|
|
19
|
+
<li
|
|
20
|
+
id="${b.id}"
|
|
21
|
+
class="hidden"
|
|
22
|
+
>
|
|
23
|
+
${b.content}
|
|
24
|
+
</li>
|
|
25
|
+
`
|
|
26
|
+
)
|
|
27
|
+
.join("")}
|
|
28
|
+
</ul>
|
|
29
|
+
</section>
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
html,
|
|
34
|
+
animation: "progressiveReveal",
|
|
35
|
+
ids
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { addIdToItems } from "./helpers/addIdToItems.js";
|
|
2
|
+
|
|
3
|
+
export function compileEq(slide) {
|
|
4
|
+
const rawItems = slide.data ?? [];
|
|
5
|
+
|
|
6
|
+
if (!rawItems.length) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
"eq: requires lines"
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const items =
|
|
13
|
+
addIdToItems(rawItems);
|
|
14
|
+
|
|
15
|
+
// --------------------------------------------------
|
|
16
|
+
// build lines + spItems
|
|
17
|
+
// --------------------------------------------------
|
|
18
|
+
|
|
19
|
+
const lines =
|
|
20
|
+
items.map(line => {
|
|
21
|
+
const spItems =
|
|
22
|
+
(line.spItems || []).map(
|
|
23
|
+
(sp, i) => ({
|
|
24
|
+
...sp,
|
|
25
|
+
|
|
26
|
+
id:
|
|
27
|
+
`${line.id}-sp-${i + 1}`
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
...line,
|
|
33
|
+
|
|
34
|
+
spItems
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// --------------------------------------------------
|
|
39
|
+
// primitive items
|
|
40
|
+
// --------------------------------------------------
|
|
41
|
+
|
|
42
|
+
const primitiveItems =
|
|
43
|
+
lines.map(line => ({
|
|
44
|
+
id: line.id,
|
|
45
|
+
|
|
46
|
+
showAt: line.showAt,
|
|
47
|
+
|
|
48
|
+
spIds:
|
|
49
|
+
line.spItems.map(
|
|
50
|
+
sp => sp.id
|
|
51
|
+
)
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
// --------------------------------------------------
|
|
55
|
+
// html
|
|
56
|
+
// --------------------------------------------------
|
|
57
|
+
|
|
58
|
+
const html = `
|
|
59
|
+
<section class="slide eq">
|
|
60
|
+
|
|
61
|
+
<ul class="eq-lines">
|
|
62
|
+
|
|
63
|
+
${lines.map(line => {
|
|
64
|
+
|
|
65
|
+
let content =
|
|
66
|
+
line.content;
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
line.name === "math"
|
|
70
|
+
) {
|
|
71
|
+
content =
|
|
72
|
+
"$$ " +
|
|
73
|
+
line.content +
|
|
74
|
+
" $$";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return `
|
|
78
|
+
<li
|
|
79
|
+
id="${line.id}"
|
|
80
|
+
|
|
81
|
+
class="
|
|
82
|
+
eq-item
|
|
83
|
+
eq-${line.name}
|
|
84
|
+
"
|
|
85
|
+
>
|
|
86
|
+
${content}
|
|
87
|
+
</li>
|
|
88
|
+
`;
|
|
89
|
+
}).join("")}
|
|
90
|
+
|
|
91
|
+
</ul>
|
|
92
|
+
|
|
93
|
+
<div class="eq-side-panel">
|
|
94
|
+
|
|
95
|
+
${lines.map(line =>
|
|
96
|
+
line.spItems.map(sp => {
|
|
97
|
+
|
|
98
|
+
if (sp.name === "image") {
|
|
99
|
+
return `
|
|
100
|
+
<div
|
|
101
|
+
id="${sp.id}"
|
|
102
|
+
|
|
103
|
+
class="eq-explain-item hidden"
|
|
104
|
+
>
|
|
105
|
+
<img src="${sp.content}" />
|
|
106
|
+
</div>
|
|
107
|
+
`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return `
|
|
111
|
+
<div
|
|
112
|
+
id="${sp.id}"
|
|
113
|
+
|
|
114
|
+
class="eq-explain-item hidden"
|
|
115
|
+
>
|
|
116
|
+
${sp.content}
|
|
117
|
+
</div>
|
|
118
|
+
`;
|
|
119
|
+
}).join("")
|
|
120
|
+
).join("")}
|
|
121
|
+
|
|
122
|
+
</div>
|
|
123
|
+
|
|
124
|
+
</section>
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
html,
|
|
129
|
+
|
|
130
|
+
animation:
|
|
131
|
+
"eqHighlightOne",
|
|
132
|
+
|
|
133
|
+
primitiveItems
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// /src/compiler/templates/compileFillImage.js
|
|
2
|
+
|
|
3
|
+
import { addIdToItems } from "./helpers/addIdToItems.js";
|
|
4
|
+
|
|
5
|
+
export function compileFillImage(slide) {
|
|
6
|
+
const rawItems = slide.data ?? [];
|
|
7
|
+
|
|
8
|
+
const items =
|
|
9
|
+
addIdToItems(rawItems);
|
|
10
|
+
|
|
11
|
+
const imageItem =
|
|
12
|
+
items.find(
|
|
13
|
+
d => d.name === "image"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (!imageItem?.content) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"fillImage: image required"
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ids =
|
|
23
|
+
items.map(i => i.id);
|
|
24
|
+
|
|
25
|
+
const html = `
|
|
26
|
+
<section class="slide fillImage">
|
|
27
|
+
|
|
28
|
+
<img
|
|
29
|
+
id="${imageItem.id}"
|
|
30
|
+
|
|
31
|
+
class="
|
|
32
|
+
hidden
|
|
33
|
+
${imageItem.classes || ""}
|
|
34
|
+
"
|
|
35
|
+
|
|
36
|
+
src="${imageItem.content}"
|
|
37
|
+
/>
|
|
38
|
+
|
|
39
|
+
</section>
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
html,
|
|
44
|
+
|
|
45
|
+
animation:
|
|
46
|
+
"progressiveReveal",
|
|
47
|
+
|
|
48
|
+
ids
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// /src/compiler/templates/compileFocusList.js
|
|
2
|
+
|
|
3
|
+
import { addIdToItems } from "./helpers/addIdToItems.js";
|
|
4
|
+
|
|
5
|
+
export function compileFocusList(slide) {
|
|
6
|
+
const rawItems = slide.data ?? [];
|
|
7
|
+
|
|
8
|
+
const items = addIdToItems(rawItems);
|
|
9
|
+
|
|
10
|
+
const bullets =
|
|
11
|
+
items.filter(
|
|
12
|
+
d => d.name === "bullet"
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const headingItem =
|
|
16
|
+
items.find(
|
|
17
|
+
d => d.name === "heading"
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
if (!bullets.length) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
"focusList: requires bullets"
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const ids =
|
|
27
|
+
items.map(i => i.id);
|
|
28
|
+
|
|
29
|
+
const html = `
|
|
30
|
+
<section class="slide focusList">
|
|
31
|
+
|
|
32
|
+
${
|
|
33
|
+
headingItem
|
|
34
|
+
? `
|
|
35
|
+
<h1
|
|
36
|
+
id="${headingItem.id}"
|
|
37
|
+
class="${
|
|
38
|
+
headingItem.classes || ""
|
|
39
|
+
}"
|
|
40
|
+
>
|
|
41
|
+
${headingItem.content}
|
|
42
|
+
</h1>
|
|
43
|
+
`
|
|
44
|
+
: ``
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
<ul>
|
|
48
|
+
${bullets
|
|
49
|
+
.map(
|
|
50
|
+
b => `
|
|
51
|
+
<li
|
|
52
|
+
id="${b.id}"
|
|
53
|
+
class="${
|
|
54
|
+
b.classes || ""
|
|
55
|
+
}"
|
|
56
|
+
>
|
|
57
|
+
${b.content}
|
|
58
|
+
</li>
|
|
59
|
+
`
|
|
60
|
+
)
|
|
61
|
+
.join("")}
|
|
62
|
+
</ul>
|
|
63
|
+
|
|
64
|
+
</section>
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
html,
|
|
69
|
+
|
|
70
|
+
animation:
|
|
71
|
+
"highlightOne",
|
|
72
|
+
|
|
73
|
+
ids
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// /src/compiler/templates/compileImageGrid.js
|
|
2
|
+
|
|
3
|
+
import { addIdToItems } from "./helpers/addIdToItems.js";
|
|
4
|
+
|
|
5
|
+
export function compileImageGrid(slide) {
|
|
6
|
+
const rawItems = slide.data ?? [];
|
|
7
|
+
|
|
8
|
+
const items =
|
|
9
|
+
addIdToItems(rawItems);
|
|
10
|
+
|
|
11
|
+
const images =
|
|
12
|
+
items.filter(
|
|
13
|
+
d => d.name === "image"
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
if (!images.length) {
|
|
17
|
+
throw new Error(
|
|
18
|
+
"imageGrid: requires images"
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const ids =
|
|
23
|
+
items.map(i => i.id);
|
|
24
|
+
|
|
25
|
+
const html = `
|
|
26
|
+
<section class="slide imageGrid">
|
|
27
|
+
|
|
28
|
+
<div class="image-grid">
|
|
29
|
+
|
|
30
|
+
${images.map(img => `
|
|
31
|
+
<div class="image-grid-item">
|
|
32
|
+
|
|
33
|
+
<img
|
|
34
|
+
id="${img.id}"
|
|
35
|
+
|
|
36
|
+
class="
|
|
37
|
+
hidden
|
|
38
|
+
${img.classes || ""}
|
|
39
|
+
"
|
|
40
|
+
|
|
41
|
+
src="${img.content}"
|
|
42
|
+
/>
|
|
43
|
+
|
|
44
|
+
</div>
|
|
45
|
+
`).join("")}
|
|
46
|
+
|
|
47
|
+
</div>
|
|
48
|
+
|
|
49
|
+
</section>
|
|
50
|
+
`;
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
html,
|
|
54
|
+
|
|
55
|
+
animation:
|
|
56
|
+
"progressiveReveal",
|
|
57
|
+
|
|
58
|
+
ids
|
|
59
|
+
};
|
|
60
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// /src/compiler/templates/compileImageLeftBulletsRight.js
|
|
2
|
+
|
|
3
|
+
import { addIdToItems } from "./helpers/addIdToItems.js";
|
|
4
|
+
|
|
5
|
+
export function compileImageLeftBulletsRight(
|
|
6
|
+
slide
|
|
7
|
+
) {
|
|
8
|
+
const rawItems =
|
|
9
|
+
slide.data ?? [];
|
|
10
|
+
|
|
11
|
+
const items =
|
|
12
|
+
addIdToItems(rawItems);
|
|
13
|
+
|
|
14
|
+
const imageItem =
|
|
15
|
+
items.find(
|
|
16
|
+
d => d.name === "image"
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const bullets =
|
|
20
|
+
items.filter(
|
|
21
|
+
d => d.name === "bullet"
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (
|
|
25
|
+
!imageItem ||
|
|
26
|
+
!bullets.length
|
|
27
|
+
) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
"imageLeftBulletsRight: requires image and bullets"
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const ids =
|
|
34
|
+
items.map(i => i.id);
|
|
35
|
+
|
|
36
|
+
const html = `
|
|
37
|
+
<section class="slide imageLeftBulletsRight">
|
|
38
|
+
|
|
39
|
+
<img
|
|
40
|
+
id="${imageItem.id}"
|
|
41
|
+
|
|
42
|
+
class="
|
|
43
|
+
hidden
|
|
44
|
+
${imageItem.classes || ""}
|
|
45
|
+
"
|
|
46
|
+
|
|
47
|
+
src="${imageItem.content}"
|
|
48
|
+
/>
|
|
49
|
+
|
|
50
|
+
<ul>
|
|
51
|
+
|
|
52
|
+
${bullets.map(b => `
|
|
53
|
+
<li
|
|
54
|
+
id="${b.id}"
|
|
55
|
+
|
|
56
|
+
class="
|
|
57
|
+
hidden
|
|
58
|
+
${b.classes || ""}
|
|
59
|
+
"
|
|
60
|
+
>
|
|
61
|
+
${b.content}
|
|
62
|
+
</li>
|
|
63
|
+
`).join("")}
|
|
64
|
+
|
|
65
|
+
</ul>
|
|
66
|
+
|
|
67
|
+
</section>
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
html,
|
|
72
|
+
|
|
73
|
+
animation:
|
|
74
|
+
"progressiveReveal",
|
|
75
|
+
|
|
76
|
+
ids
|
|
77
|
+
};
|
|
78
|
+
}
|