taleem-slides 0.4.0 β 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -131
- package/package.json +5 -4
- package/src/SlideTemplates.js +0 -1
- package/src/index.js +1 -0
- package/src/resolveBackground.js +10 -0
- package/src/slides/BarChartSlide.js +5 -5
- package/src/slides/BigNumberSlide.js +7 -6
- package/src/slides/BulletListSlide.js +5 -6
- package/src/slides/ContactSlide.js +3 -4
- package/src/slides/CornerWordsSlide.js +15 -10
- package/src/slides/DonutChartSlide.js +16 -16
- package/src/slides/EqSlide.js +13 -9
- package/src/slides/FillImageSlide.js +4 -2
- package/src/slides/ImageLeftBulletsRightSlide.js +6 -14
- package/src/slides/ImageRightBulletsLeftSlide.js +6 -14
- package/src/slides/ImageSlide.js +0 -1
- package/src/slides/ImageWithCaptionSlide.js +2 -1
- package/src/slides/ImageWithTitleSlide.js +2 -1
- package/src/slides/QuoteSlide.js +8 -5
- package/src/slides/QuoteWithImageSlide.js +2 -3
- package/src/slides/StatisticSlide.js +5 -6
- package/src/slides/TableSlide.js +17 -22
- package/src/slides/TitleAndParaSlide.js +1 -4
- package/src/slides/TitleAndSubtitleSlide.js +1 -6
- package/src/slides/TitleSlide.js +5 -5
- package/src/slides/TwoColumnTextSlide.js +7 -38
- package/tests/slide.title.test.js +15 -0
- package/tests/slides.barChart.test.js +15 -20
- package/tests/slides.bigNumber.test.js +8 -19
- package/tests/slides.bulletList.test.js +9 -23
- package/tests/slides.contactSlide.test.js +8 -18
- package/tests/slides.cornerWordsSlide.test.js +8 -14
- package/tests/slides.donutChart.test.js +10 -20
- package/tests/slides.eq.test.js +9 -20
- package/tests/slides.fillImage.test.js +8 -14
- package/tests/slides.imageLeftBulletsRight.test.js +9 -12
- package/tests/slides.imageRightBulletsLeft.test.js +9 -12
- package/tests/slides.imageSlide.test.js +8 -15
- package/tests/slides.imageWithCaption.test.js +8 -18
- package/tests/slides.imageWithTitle.test.js +8 -18
- package/tests/slides.quoteSlide.test.js +8 -19
- package/tests/slides.quoteWithImage.test.js +9 -18
- package/tests/slides.statistic.test.js +8 -18
- package/tests/slides.table.test.js +8 -33
- package/tests/slides.titleAndPara.test.js +8 -20
- package/tests/slides.titleAndSubtitle.test.js +8 -20
- package/tests/slides.twoColumnText.test.js +7 -20
- package/decks/angles_and_transversals.json +0 -85
- package/decks/congruent_triangles.json +0 -169
- package/decks/demo_deck.json +0 -22
- package/decks/eq_28aug2025.json +0 -67
- package/decks/goldstandar_eq_28aug25.json +0 -69
- package/decks/parallelogram_properties.json +0 -164
- package/decks/parallelogram_properties_no_sound.json +0 -164
- package/decks/posultate_and_SAS_postulate.json +0 -76
- package/decks/qanoon.md +0 -136
- package/decks/theorem_revision_ch10_11.fixed.json +0 -265
- package/decks/theorem_revision_ch10_11.json +0 -269
- package/decks/theorems9old_11.1.1.json +0 -382
- package/decks/theorems9old_11.1.2.json +0 -162
- package/decks/theorems9old_11.1.3.json +0 -857
- package/index.html +0 -88
- package/tests/slides.svgPointer.test.js +0 -25
- package/tests/slides.test.js +0 -28
package/README.md
CHANGED
|
@@ -1,108 +1,71 @@
|
|
|
1
1
|
|
|
2
2
|
# π¦ taleem-slides
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
> **Simple HTML slide templates for JSON-based presentations**
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
`taleem-slides` is a **small, focused library** that turns
|
|
7
|
+
**plain slide JSON** into **HTML**.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
You give it slide data.
|
|
10
|
+
It gives you HTML.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
Thatβs it.
|
|
12
13
|
|
|
13
|
-
> **Given slide data + render state β return HTML**
|
|
14
|
-
|
|
15
|
-
It does **not** manage time, indexes, playback, or decks.
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## π Live Display Center (Important)
|
|
20
|
-
|
|
21
|
-
π **Official live display & reference implementation**
|
|
22
|
-
**[https://bilza2023.github.io/taleem/](https://bilza2023.github.io/taleem/)**
|
|
23
|
-
|
|
24
|
-
This is **not a mock demo**.This link is the **active display center** where:
|
|
25
|
-
|
|
26
|
-
- slide templates are rendered in real browsers
|
|
27
|
-
- visual behavior is validated
|
|
28
|
-
- browser/player integration is tested
|
|
29
14
|
---
|
|
30
15
|
|
|
31
|
-
##
|
|
16
|
+
## π Live Docs, Demo & Reference (START HERE)
|
|
32
17
|
|
|
33
|
-
**
|
|
34
|
-
**content-first learning tools**.
|
|
18
|
+
π **https://bilza2023.github.io/taleem**
|
|
35
19
|
|
|
36
|
-
|
|
20
|
+
This site is the **official reference** for:
|
|
37
21
|
|
|
38
|
-
|
|
39
|
-
|
|
22
|
+
- all supported slide types
|
|
23
|
+
- visual behavior
|
|
24
|
+
- real rendered output
|
|
25
|
+
- examples and demos
|
|
40
26
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* Slides already encode *layout + structure*
|
|
44
|
-
* Users provide **content only**
|
|
45
|
-
* There are **no configuration knobs**
|
|
46
|
-
* What you see is what the template decides
|
|
47
|
-
|
|
48
|
-
This removal of choice is **intentional**.
|
|
49
|
-
|
|
50
|
-
It makes the system:
|
|
51
|
-
|
|
52
|
-
* easy to learn
|
|
53
|
-
* hard to misuse
|
|
54
|
-
* consistent across platforms
|
|
55
|
-
|
|
56
|
-
If a different layout is needed, the solution is **not configuration** β
|
|
57
|
-
it is **a new slide template**.
|
|
58
|
-
|
|
59
|
-
Templates are cheap.
|
|
60
|
-
Even hundreds of templates add no runtime cost.
|
|
27
|
+
If something is unclear in this README,
|
|
28
|
+
**the website is the final authority**.
|
|
61
29
|
|
|
62
30
|
---
|
|
63
31
|
|
|
64
|
-
##
|
|
65
|
-
|
|
66
|
-
* A collection of **slide templates**
|
|
67
|
-
* Each template:
|
|
32
|
+
## β
What this library does
|
|
68
33
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Think of it as:
|
|
75
|
-
|
|
76
|
-
> *Handlebars / JSX for Taleem slides*
|
|
34
|
+
- Converts slide JSON into HTML
|
|
35
|
+
- Uses fixed, opinionated layouts
|
|
36
|
+
- Applies simple state-based CSS classes
|
|
37
|
+
- Works in any JS environment (browser, player, SSR)
|
|
77
38
|
|
|
78
39
|
---
|
|
79
40
|
|
|
80
|
-
## β What this library
|
|
41
|
+
## β What this library does NOT do
|
|
81
42
|
|
|
82
43
|
`taleem-slides` does **not**:
|
|
83
44
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
45
|
+
- play slides
|
|
46
|
+
- manage time or animations
|
|
47
|
+
- navigate slides
|
|
48
|
+
- validate full decks
|
|
49
|
+
- touch the DOM
|
|
50
|
+
- apply CSS styles
|
|
90
51
|
|
|
91
|
-
|
|
52
|
+
It only returns HTML strings.
|
|
92
53
|
|
|
93
54
|
---
|
|
94
55
|
|
|
95
56
|
## π§ Mental Model
|
|
96
57
|
|
|
97
58
|
```
|
|
98
|
-
slide JSON + render state
|
|
99
|
-
β
|
|
100
|
-
slide template
|
|
101
|
-
β
|
|
102
|
-
HTML
|
|
103
|
-
```
|
|
104
59
|
|
|
105
|
-
|
|
60
|
+
slide data + render state
|
|
61
|
+
β
|
|
62
|
+
taleem-slides
|
|
63
|
+
β
|
|
64
|
+
HTML
|
|
65
|
+
|
|
66
|
+
````
|
|
67
|
+
|
|
68
|
+
How slides are shown, timed, or styled is **your responsibility**.
|
|
106
69
|
|
|
107
70
|
---
|
|
108
71
|
|
|
@@ -110,77 +73,69 @@ How the state is calculated is **not this libraryβs concern**.
|
|
|
110
73
|
|
|
111
74
|
```bash
|
|
112
75
|
npm install taleem-slides
|
|
113
|
-
|
|
76
|
+
````
|
|
114
77
|
|
|
115
78
|
---
|
|
116
79
|
|
|
117
80
|
## π Basic Usage
|
|
118
81
|
|
|
119
|
-
### 1οΈβ£
|
|
82
|
+
### 1οΈβ£ Get a slide template
|
|
120
83
|
|
|
121
84
|
```js
|
|
122
85
|
import { getSlideTemplate } from "taleem-slides";
|
|
86
|
+
|
|
87
|
+
const Slide = getSlideTemplate("bulletList");
|
|
123
88
|
```
|
|
124
89
|
|
|
125
90
|
---
|
|
126
91
|
|
|
127
|
-
### 2οΈβ£ Load slide data
|
|
92
|
+
### 2οΈβ£ Load slide data
|
|
128
93
|
|
|
129
94
|
```js
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const slide = SlideTemplate.fromJSON({
|
|
95
|
+
const slide = Slide.fromJSON({
|
|
133
96
|
type: "bulletList",
|
|
134
97
|
data: [
|
|
135
98
|
{ name: "bullet", content: "First point" },
|
|
136
|
-
{ name: "bullet", content: "Second point" }
|
|
137
|
-
{ name: "bullet", content: "Third point" }
|
|
99
|
+
{ name: "bullet", content: "Second point" }
|
|
138
100
|
]
|
|
139
101
|
});
|
|
140
102
|
```
|
|
141
103
|
|
|
142
|
-
|
|
143
|
-
> No timing. No logic.
|
|
104
|
+
`fromJSON()` reads and stores structure only.
|
|
144
105
|
|
|
145
106
|
---
|
|
146
107
|
|
|
147
|
-
### 3οΈβ£ Render
|
|
108
|
+
### 3οΈβ£ Render HTML
|
|
148
109
|
|
|
149
110
|
```js
|
|
150
111
|
const html = slide.render({
|
|
151
|
-
visibleCount:
|
|
152
|
-
activeIndex:
|
|
112
|
+
visibleCount: 1,
|
|
113
|
+
activeIndex: 0
|
|
153
114
|
});
|
|
154
115
|
```
|
|
155
116
|
|
|
156
|
-
This will:
|
|
157
|
-
|
|
158
|
-
* render first 2 bullets
|
|
159
|
-
* highlight the second bullet
|
|
160
|
-
* dim the first
|
|
161
|
-
|
|
162
117
|
---
|
|
163
118
|
|
|
164
|
-
## π¨ Render State
|
|
119
|
+
## π¨ Render State (Simple)
|
|
165
120
|
|
|
166
|
-
|
|
121
|
+
Render state is just a plain object.
|
|
167
122
|
|
|
168
123
|
Common fields:
|
|
169
124
|
|
|
170
125
|
```ts
|
|
171
126
|
{
|
|
172
|
-
visibleCount?: number
|
|
173
|
-
activeIndex?: number
|
|
127
|
+
visibleCount?: number
|
|
128
|
+
activeIndex?: number
|
|
174
129
|
}
|
|
175
130
|
```
|
|
176
131
|
|
|
177
|
-
|
|
132
|
+
Each slide uses only what it needs.
|
|
178
133
|
|
|
179
134
|
---
|
|
180
135
|
|
|
181
|
-
## π― Class
|
|
136
|
+
## π― CSS Class Contract
|
|
182
137
|
|
|
183
|
-
|
|
138
|
+
Slides emit only these state classes:
|
|
184
139
|
|
|
185
140
|
```text
|
|
186
141
|
.is-active
|
|
@@ -188,60 +143,64 @@ Templates apply **standard class names only**:
|
|
|
188
143
|
.is-hidden
|
|
189
144
|
```
|
|
190
145
|
|
|
191
|
-
|
|
146
|
+
You control **all styling**.
|
|
192
147
|
|
|
193
148
|
---
|
|
194
149
|
|
|
195
|
-
##
|
|
196
|
-
|
|
197
|
-
`taleem-slides` is intentionally **small** and **focused**.
|
|
150
|
+
## π§© Supported Slide Types
|
|
198
151
|
|
|
199
|
-
|
|
152
|
+
See the **live site** for visuals and examples:
|
|
200
153
|
|
|
201
|
-
|
|
154
|
+
π [https://bilza2023.github.io/taleem](https://bilza2023.github.io/taleem)
|
|
202
155
|
|
|
203
|
-
|
|
204
|
-
Index-based slide viewer (manual navigation)
|
|
156
|
+
Supported categories include:
|
|
205
157
|
|
|
206
|
-
*
|
|
207
|
-
|
|
158
|
+
* titles and text slides
|
|
159
|
+
* bullet lists and columns
|
|
160
|
+
* images and image+text layouts
|
|
161
|
+
* tables and charts
|
|
162
|
+
* quotes and stats
|
|
163
|
+
* equation slides
|
|
208
164
|
|
|
209
|
-
|
|
165
|
+
Layouts are **fixed by design**.
|
|
210
166
|
|
|
211
|
-
|
|
212
|
-
* pass it to `taleem-slides`
|
|
213
|
-
* receive consistent HTML output
|
|
167
|
+
If you need a new layout, you add a new template.
|
|
214
168
|
|
|
215
169
|
---
|
|
216
170
|
|
|
217
|
-
## π§ͺ
|
|
171
|
+
## π§ͺ Stability & Guarantees
|
|
218
172
|
|
|
219
|
-
*
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
*
|
|
223
|
-
*(link can be added here when ready)*
|
|
173
|
+
* Deterministic output
|
|
174
|
+
* No hidden state
|
|
175
|
+
* No configuration knobs
|
|
176
|
+
* Same input β same HTML
|
|
224
177
|
|
|
225
178
|
---
|
|
226
179
|
|
|
227
|
-
##
|
|
180
|
+
## π Design Principle
|
|
228
181
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
* HTML output is intentionally simple and predictable
|
|
182
|
+
> **This library renders HTML only.
|
|
183
|
+
> It does not decide when or how slides appear.**
|
|
232
184
|
|
|
233
185
|
---
|
|
234
186
|
|
|
235
|
-
##
|
|
187
|
+
## π Where this fits
|
|
188
|
+
|
|
189
|
+
`taleem-slides` is meant to be used by:
|
|
190
|
+
|
|
191
|
+
* slide viewers
|
|
192
|
+
* presentation players
|
|
193
|
+
* educational tools
|
|
194
|
+
* static or dynamic renderers
|
|
236
195
|
|
|
237
|
-
|
|
238
|
-
> It does not decide *when* or *why*.**
|
|
196
|
+
It is intentionally small so it can be reused everywhere.
|
|
239
197
|
|
|
240
198
|
---
|
|
241
199
|
|
|
242
|
-
|
|
200
|
+
## β
Status
|
|
243
201
|
|
|
244
|
-
*
|
|
245
|
-
*
|
|
202
|
+
* Actively used
|
|
203
|
+
* Fully tested
|
|
204
|
+
* Backed by live reference site
|
|
205
|
+
* Ready for production
|
|
246
206
|
|
|
247
|
-
This README now correctly **anchors the entire ecosystem**.
|
package/package.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "taleem-slides",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Convert json taleem schema into html for slides",
|
|
6
|
-
|
|
7
6
|
"exports": {
|
|
8
7
|
".": "./src/index.js"
|
|
9
8
|
},
|
|
10
|
-
|
|
11
9
|
"scripts": {
|
|
12
10
|
"test": "vitest run",
|
|
13
11
|
"test:watch": "vitest",
|
|
14
12
|
"test:ui": "vitest --ui",
|
|
15
13
|
"lint": "echo \"no lint yet\""
|
|
16
14
|
},
|
|
17
|
-
|
|
18
15
|
"devDependencies": {
|
|
19
16
|
"vite": "^5.0.0",
|
|
20
17
|
"vitest": "^1.5.0"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"taleem-core": "^1.3.2",
|
|
21
|
+
"zod": "^4.3.5"
|
|
21
22
|
}
|
|
22
23
|
}
|
package/src/SlideTemplates.js
CHANGED
package/src/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
// BarChartSlide.js
|
|
2
1
|
export const BarChartSlide = {
|
|
3
2
|
type: "barChart",
|
|
4
3
|
|
|
5
4
|
fromJSON(raw) {
|
|
5
|
+
// Consume canonical deck-v1 shape directly
|
|
6
6
|
const bars = raw.data
|
|
7
7
|
?.filter(d => d.name === "bar")
|
|
8
8
|
.map(d => ({
|
|
9
|
-
label: d.
|
|
10
|
-
value: d.
|
|
9
|
+
label: d.label,
|
|
10
|
+
value: d.value
|
|
11
11
|
}));
|
|
12
12
|
|
|
13
|
-
if (!bars
|
|
13
|
+
if (!bars || bars.length === 0) {
|
|
14
14
|
throw new Error("barChart: requires at least one bar");
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -27,7 +27,7 @@ export const BarChartSlide = {
|
|
|
27
27
|
const cls =
|
|
28
28
|
i === activeIndex
|
|
29
29
|
? "is-active"
|
|
30
|
-
: i < activeIndex
|
|
30
|
+
: activeIndex !== null && i < activeIndex
|
|
31
31
|
? "is-dim"
|
|
32
32
|
: "";
|
|
33
33
|
return `
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
// BigNumberSlide.js
|
|
2
1
|
export const BigNumberSlide = {
|
|
3
2
|
type: "bigNumber",
|
|
4
3
|
|
|
5
4
|
fromJSON(raw) {
|
|
6
|
-
const
|
|
7
|
-
const label
|
|
5
|
+
const number = raw.data?.find(d => d.name === "number")?.content;
|
|
6
|
+
const label = raw.data?.find(d => d.name === "label")?.content;
|
|
8
7
|
|
|
9
|
-
if (!
|
|
8
|
+
if (!number) {
|
|
9
|
+
throw new Error("bigNumber: number required");
|
|
10
|
+
}
|
|
10
11
|
|
|
11
12
|
return Object.freeze({
|
|
12
13
|
type: "bigNumber",
|
|
13
|
-
|
|
14
|
+
number,
|
|
14
15
|
label,
|
|
15
16
|
|
|
16
17
|
render() {
|
|
17
18
|
return `
|
|
18
19
|
<section class="slide bigNumber">
|
|
19
|
-
<div class="number">${
|
|
20
|
+
<div class="number">${number}</div>
|
|
20
21
|
${label ? `<div class="label">${label}</div>` : ""}
|
|
21
22
|
</section>
|
|
22
23
|
`;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
// BulletListSlide.js
|
|
2
1
|
export const BulletListSlide = {
|
|
3
2
|
type: "bulletList",
|
|
4
3
|
|
|
5
4
|
fromJSON(raw) {
|
|
6
5
|
const bullets = raw.data
|
|
7
6
|
?.filter(d => d.name === "bullet")
|
|
8
|
-
.map(d =>
|
|
7
|
+
.map(d => d.content);
|
|
9
8
|
|
|
10
|
-
if (!bullets
|
|
9
|
+
if (!bullets || bullets.length === 0) {
|
|
11
10
|
throw new Error("bulletList: requires at least one bullet");
|
|
12
11
|
}
|
|
13
12
|
|
|
@@ -19,15 +18,15 @@ export const BulletListSlide = {
|
|
|
19
18
|
return `
|
|
20
19
|
<section class="slide bulletList">
|
|
21
20
|
<ul>
|
|
22
|
-
${bullets.map((
|
|
21
|
+
${bullets.map((text, i) => {
|
|
23
22
|
if (i >= visibleCount) return "";
|
|
24
23
|
const cls =
|
|
25
24
|
i === activeIndex
|
|
26
25
|
? "is-active"
|
|
27
|
-
: i < activeIndex
|
|
26
|
+
: activeIndex !== null && i < activeIndex
|
|
28
27
|
? "is-dim"
|
|
29
28
|
: "";
|
|
30
|
-
return `<li class="${cls}">${
|
|
29
|
+
return `<li class="${cls}">${text}</li>`;
|
|
31
30
|
}).join("")}
|
|
32
31
|
</ul>
|
|
33
32
|
</section>
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// ContactSlide.js
|
|
2
1
|
export const ContactSlide = {
|
|
3
2
|
type: "contactSlide",
|
|
4
3
|
|
|
5
4
|
fromJSON(raw) {
|
|
6
|
-
const items = raw.data?.map(d =>
|
|
5
|
+
const items = raw.data?.map(d => d.content);
|
|
7
6
|
|
|
8
|
-
if (!items
|
|
7
|
+
if (!items || items.length === 0) {
|
|
9
8
|
throw new Error("contactSlide: content required");
|
|
10
9
|
}
|
|
11
10
|
|
|
@@ -16,7 +15,7 @@ export const ContactSlide = {
|
|
|
16
15
|
render() {
|
|
17
16
|
return `
|
|
18
17
|
<section class="slide contactSlide">
|
|
19
|
-
${items.map(
|
|
18
|
+
${items.map(text => `<div>${text}</div>`).join("")}
|
|
20
19
|
</section>
|
|
21
20
|
`;
|
|
22
21
|
}
|
|
@@ -1,26 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
export const CornerWordsSlide = {
|
|
3
3
|
type: "cornerWordsSlide",
|
|
4
4
|
|
|
5
5
|
fromJSON(raw) {
|
|
6
|
-
const
|
|
7
|
-
?.filter(d => d.name === "
|
|
8
|
-
.map(d => ({
|
|
6
|
+
const cards = raw.data
|
|
7
|
+
?.filter(d => d.name === "card")
|
|
8
|
+
.map(d => ({ icon: d.icon, label: d.label }));
|
|
9
9
|
|
|
10
|
-
if (!
|
|
11
|
-
throw new Error("cornerWordsSlide: requires at least one
|
|
10
|
+
if (!cards || cards.length === 0) {
|
|
11
|
+
throw new Error("cornerWordsSlide: requires at least one card");
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
return Object.freeze({
|
|
15
15
|
type: "cornerWordsSlide",
|
|
16
|
-
|
|
16
|
+
cards,
|
|
17
17
|
|
|
18
|
-
render({ visibleCount =
|
|
18
|
+
render({ visibleCount = cards.length } = {}) {
|
|
19
19
|
return `
|
|
20
20
|
<section class="slide cornerWordsSlide">
|
|
21
|
-
${
|
|
21
|
+
${cards.map((c, i) => {
|
|
22
22
|
if (i >= visibleCount) return "";
|
|
23
|
-
return
|
|
23
|
+
return `
|
|
24
|
+
<span class="corner-card corner-${i + 1}">
|
|
25
|
+
<span class="icon">${c.icon}</span>
|
|
26
|
+
<span class="label">${c.label}</span>
|
|
27
|
+
</span>
|
|
28
|
+
`;
|
|
24
29
|
}).join("")}
|
|
25
30
|
</section>
|
|
26
31
|
`;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
// DonutChartSlide.js
|
|
2
1
|
export const DonutChartSlide = {
|
|
3
2
|
type: "donutChart",
|
|
4
3
|
|
|
5
4
|
fromJSON(raw) {
|
|
6
|
-
const segments =
|
|
7
|
-
|
|
8
|
-
.map(d => ({
|
|
9
|
-
label: d.content.label,
|
|
10
|
-
value: d.content.value
|
|
11
|
-
}));
|
|
5
|
+
const segments = [];
|
|
6
|
+
let current = null;
|
|
12
7
|
|
|
13
|
-
|
|
8
|
+
for (const d of raw.data || []) {
|
|
9
|
+
if (d.name === "percent") {
|
|
10
|
+
current = { percent: d.content };
|
|
11
|
+
segments.push(current);
|
|
12
|
+
} else if (current && d.name === "label") {
|
|
13
|
+
current.label = d.content;
|
|
14
|
+
} else if (current && d.name === "color") {
|
|
15
|
+
current.color = d.content;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!segments.length) {
|
|
14
20
|
throw new Error("donutChart: requires at least one segment");
|
|
15
21
|
}
|
|
16
22
|
|
|
@@ -18,19 +24,13 @@ export const DonutChartSlide = {
|
|
|
18
24
|
type: "donutChart",
|
|
19
25
|
segments,
|
|
20
26
|
|
|
21
|
-
render({ visibleCount = segments.length
|
|
27
|
+
render({ visibleCount = segments.length } = {}) {
|
|
22
28
|
return `
|
|
23
29
|
<section class="slide donutChart">
|
|
24
30
|
<ul>
|
|
25
31
|
${segments.map((s, i) => {
|
|
26
32
|
if (i >= visibleCount) return "";
|
|
27
|
-
|
|
28
|
-
i === activeIndex
|
|
29
|
-
? "is-active"
|
|
30
|
-
: i < activeIndex
|
|
31
|
-
? "is-dim"
|
|
32
|
-
: "";
|
|
33
|
-
return `<li class="${cls}">${s.label}: ${s.value}</li>`;
|
|
33
|
+
return `<li>${s.label}: ${s.percent}%</li>`;
|
|
34
34
|
}).join("")}
|
|
35
35
|
</ul>
|
|
36
36
|
</section>
|
package/src/slides/EqSlide.js
CHANGED
|
@@ -1,28 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
export const EqSlide = {
|
|
3
3
|
type: "eq",
|
|
4
4
|
|
|
5
5
|
fromJSON(raw) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const lines = raw.data
|
|
7
|
+
?.filter(d => d.name === "line")
|
|
8
|
+
.map(d => ({
|
|
9
|
+
type: d.type,
|
|
10
|
+
content: d.content
|
|
11
|
+
}));
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
+
if (!lines || lines.length === 0) {
|
|
14
|
+
throw new Error("eq: requires at least one line");
|
|
15
|
+
}
|
|
13
16
|
|
|
14
17
|
return Object.freeze({
|
|
15
18
|
type: "eq",
|
|
16
19
|
lines,
|
|
17
20
|
|
|
18
|
-
render({ activeIndex = null } = {}) {
|
|
21
|
+
render({ visibleCount = lines.length, activeIndex = null } = {}) {
|
|
19
22
|
return `
|
|
20
23
|
<section class="slide eq">
|
|
21
24
|
${lines.map((l, i) => {
|
|
25
|
+
if (i >= visibleCount) return "";
|
|
22
26
|
const cls =
|
|
23
27
|
i === activeIndex
|
|
24
28
|
? "is-active"
|
|
25
|
-
: i < activeIndex
|
|
29
|
+
: activeIndex !== null && i < activeIndex
|
|
26
30
|
? "is-dim"
|
|
27
31
|
: "";
|
|
28
32
|
return `<div class="eq-line ${cls}">${l.content}</div>`;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
// FillImageSlide.js
|
|
2
1
|
export const FillImageSlide = {
|
|
3
2
|
type: "fillImage",
|
|
4
3
|
|
|
5
4
|
fromJSON(raw) {
|
|
6
5
|
const image = raw.data?.find(d => d.name === "image")?.content;
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
if (!image) {
|
|
8
|
+
throw new Error("fillImage: image required");
|
|
9
|
+
}
|
|
8
10
|
|
|
9
11
|
return Object.freeze({
|
|
10
12
|
type: "fillImage",
|