@excom/content-carousel 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.
- package/.rush/temp/chunked-rush-logs/content-carousel.apply-exports.chunks.jsonl +1 -0
- package/.rush/temp/chunked-rush-logs/content-carousel.build_docs.chunks.jsonl +1 -0
- package/.rush/temp/chunked-rush-logs/content-carousel.build_package-metas.chunks.jsonl +1 -0
- package/.rush/temp/operation/apply-exports/all.log +1 -0
- package/.rush/temp/operation/apply-exports/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/apply-exports/state.json +3 -0
- package/.rush/temp/operation/build_docs/all.log +1 -0
- package/.rush/temp/operation/build_docs/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/build_docs/state.json +3 -0
- package/.rush/temp/operation/build_package-metas/all.log +1 -0
- package/.rush/temp/operation/build_package-metas/log-chunks.jsonl +1 -0
- package/.rush/temp/operation/build_package-metas/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +3 -0
- package/config/rig.json +5 -0
- package/content-carousel-slide.ts +19 -0
- package/content-carousel.ts +218 -0
- package/index.css +5 -0
- package/index.ts +24 -0
- package/package.json +43 -0
- package/rush-logs/content-carousel.apply-exports.cache.log +1 -0
- package/rush-logs/content-carousel.apply-exports.log +1 -0
- package/rush-logs/content-carousel.build_docs.cache.log +1 -0
- package/rush-logs/content-carousel.build_docs.log +1 -0
- package/rush-logs/content-carousel.build_package-metas.cache.log +1 -0
- package/rush-logs/content-carousel.build_package-metas.log +1 -0
- package/src/content-carousel.css +239 -0
- package/support/custom-elements.json +398 -0
- package/support/demos/fade.html +7 -0
- package/support/demos/manual.html +9 -0
- package/support/demos/simple.html +7 -0
- package/support/dist-docs/content-carousel-slide.md +20 -0
- package/support/dist-docs/content-carousel.md +184 -0
- package/support/docs/INTERNAL.md +4 -0
- package/support/docs/README.md +66 -0
- package/support/package-meta.json +287 -0
- package/support/tests/content-carousel.test.ts +534 -0
- package/support/tests/fade.view.test.ts +23 -0
- package/support/tests/manual.view.test.ts +34 -0
- package/support/tests/simple.view.test.ts +24 -0
- package/tsconfig.json +5 -0
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"modules": [
|
|
4
|
+
{
|
|
5
|
+
"kind": "javascript-module",
|
|
6
|
+
"path": "content-carousel.ts",
|
|
7
|
+
"declarations": [
|
|
8
|
+
{
|
|
9
|
+
"kind": "class",
|
|
10
|
+
"name": "ContentCarousel",
|
|
11
|
+
"customElement": true,
|
|
12
|
+
"tagName": "content-carousel",
|
|
13
|
+
"summary": "Slide rotator — auto-play, manual nav, slide or fade transition.",
|
|
14
|
+
"description": "Position of a `<content-carousel>` among its own slides.",
|
|
15
|
+
"attributes": [
|
|
16
|
+
{
|
|
17
|
+
"name": "auto-play",
|
|
18
|
+
"type": {
|
|
19
|
+
"text": "number"
|
|
20
|
+
},
|
|
21
|
+
"description": "Seconds between automatic slide advances. Unset disables auto-play.",
|
|
22
|
+
"fieldName": "autoPlay"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "is-scrubbing",
|
|
26
|
+
"type": {
|
|
27
|
+
"text": "boolean"
|
|
28
|
+
},
|
|
29
|
+
"description": "Set when the element is being dragged. Used by CSS only to disable `transition`.",
|
|
30
|
+
"fieldName": "isScrubbing"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "slide-animation",
|
|
34
|
+
"type": {
|
|
35
|
+
"text": "string"
|
|
36
|
+
},
|
|
37
|
+
"description": "Transition used when the active slide changes.",
|
|
38
|
+
"fieldName": "slideAnimation",
|
|
39
|
+
"default": "slide",
|
|
40
|
+
"values": [
|
|
41
|
+
"slide",
|
|
42
|
+
"fade"
|
|
43
|
+
]
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "last-move",
|
|
47
|
+
"type": {
|
|
48
|
+
"text": "string"
|
|
49
|
+
},
|
|
50
|
+
"description": "Direction of the most recent slide change — drives the CSS animation direction.",
|
|
51
|
+
"fieldName": "lastMove",
|
|
52
|
+
"values": [
|
|
53
|
+
"forward",
|
|
54
|
+
"back"
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "auto-play-stopped",
|
|
59
|
+
"type": {
|
|
60
|
+
"text": "boolean"
|
|
61
|
+
},
|
|
62
|
+
"description": "Set automatically after manual navigation, or when the element leaves the document (a DOM move keeps auto-play running), to pause auto-play. Set it directly to pause / resume auto-play programmatically.",
|
|
63
|
+
"fieldName": "autoPlayStopped"
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
"members": [
|
|
67
|
+
{
|
|
68
|
+
"kind": "field",
|
|
69
|
+
"name": "autoPlay",
|
|
70
|
+
"type": {
|
|
71
|
+
"text": "number"
|
|
72
|
+
},
|
|
73
|
+
"privacy": "public",
|
|
74
|
+
"readonly": false,
|
|
75
|
+
"description": "Seconds between automatic slide advances. Unset disables auto-play.",
|
|
76
|
+
"_neutron": {
|
|
77
|
+
"surface": "option"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"kind": "field",
|
|
82
|
+
"name": "isScrubbing",
|
|
83
|
+
"type": {
|
|
84
|
+
"text": "boolean"
|
|
85
|
+
},
|
|
86
|
+
"privacy": "public",
|
|
87
|
+
"readonly": false,
|
|
88
|
+
"description": "Set when the element is being dragged. Used by CSS only to disable `transition`.",
|
|
89
|
+
"_neutron": {
|
|
90
|
+
"surface": "option"
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"kind": "field",
|
|
95
|
+
"name": "slideAnimation",
|
|
96
|
+
"type": {
|
|
97
|
+
"text": "string"
|
|
98
|
+
},
|
|
99
|
+
"privacy": "public",
|
|
100
|
+
"readonly": false,
|
|
101
|
+
"description": "Transition used when the active slide changes.",
|
|
102
|
+
"default": "slide",
|
|
103
|
+
"_neutron": {
|
|
104
|
+
"surface": "option"
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"kind": "field",
|
|
109
|
+
"name": "lastMove",
|
|
110
|
+
"type": {
|
|
111
|
+
"text": "string"
|
|
112
|
+
},
|
|
113
|
+
"privacy": "public",
|
|
114
|
+
"readonly": true,
|
|
115
|
+
"description": "Direction of the most recent slide change — drives the CSS animation direction.",
|
|
116
|
+
"_neutron": {
|
|
117
|
+
"surface": "state"
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"kind": "field",
|
|
122
|
+
"name": "autoPlayStopped",
|
|
123
|
+
"type": {
|
|
124
|
+
"text": "boolean"
|
|
125
|
+
},
|
|
126
|
+
"privacy": "public",
|
|
127
|
+
"readonly": false,
|
|
128
|
+
"description": "Set automatically after manual navigation, or when the element leaves the document (a DOM move keeps auto-play running), to pause auto-play. Set it directly to pause / resume auto-play programmatically.",
|
|
129
|
+
"_neutron": {
|
|
130
|
+
"surface": "hybrid"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"kind": "field",
|
|
135
|
+
"name": "provision",
|
|
136
|
+
"type": {
|
|
137
|
+
"text": "ContentCarouselProvision",
|
|
138
|
+
"expanded": "{ index: number; count: number; lastMove: \"forward\" | \"back\" | null; }"
|
|
139
|
+
},
|
|
140
|
+
"privacy": "public",
|
|
141
|
+
"readonly": false,
|
|
142
|
+
"description": "Position: `{ index, count, lastMove }` — the active slide's index among this carousel's own slides, how many there are, and the direction of the last move. Set on connect and after every slide change. Not reflected as an attribute.",
|
|
143
|
+
"_neutron": {
|
|
144
|
+
"surface": "option"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
],
|
|
148
|
+
"events": [
|
|
149
|
+
{
|
|
150
|
+
"name": "content-carousel-slide-changed",
|
|
151
|
+
"description": "After any slide change, manual or auto.",
|
|
152
|
+
"type": {
|
|
153
|
+
"text": "ContentCarouselSlideChangedEvent",
|
|
154
|
+
"expanded": "CustomEvent & { type: \"content-carousel-slide-changed\"; detail: { activeSlide: HTMLElement | null; previousSlide: HTMLElement | null; }; bubbles: true; cancelable: true; composed: true }"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"_neutron": {
|
|
159
|
+
"provisions": [
|
|
160
|
+
{
|
|
161
|
+
"name": "provision",
|
|
162
|
+
"type": {
|
|
163
|
+
"text": "ContentCarouselProvision",
|
|
164
|
+
"expanded": "{ index: number; count: number; lastMove: \"forward\" | \"back\" | null; }"
|
|
165
|
+
},
|
|
166
|
+
"description": "Position: `{ index, count, lastMove }` — the active slide's index among this carousel's own slides, how many there are, and the direction of the last move. Set on connect and after every slide change. Not reflected as an attribute.",
|
|
167
|
+
"fieldName": "provision"
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
"commands": [
|
|
171
|
+
{
|
|
172
|
+
"name": "--back",
|
|
173
|
+
"description": "Shows the previous slide (wraps to last). Stops auto-play."
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"name": "--next",
|
|
177
|
+
"description": "Shows the next slide (wraps to first). Stops auto-play."
|
|
178
|
+
}
|
|
179
|
+
],
|
|
180
|
+
"expectedChildren": [
|
|
181
|
+
{
|
|
182
|
+
"relationship": "descendant",
|
|
183
|
+
"selector": "content-carousel-slide",
|
|
184
|
+
"required": true,
|
|
185
|
+
"description": "Slides to rotate through. The first, or whichever has `is-active`, is shown initially."
|
|
186
|
+
}
|
|
187
|
+
],
|
|
188
|
+
"cssClasses": [
|
|
189
|
+
{
|
|
190
|
+
"name": "tag-content-carousel-prev",
|
|
191
|
+
"description": "Positions a direct child with `rel=\"prev\"` (or `.tag-content-carousel-prev`) as the \"previous slide\" nav control."
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"name": "tag-content-carousel-next",
|
|
195
|
+
"description": "Positions a direct child with `rel=\"next\"` (or `.tag-content-carousel-next`) as the \"next slide\" nav control."
|
|
196
|
+
}
|
|
197
|
+
],
|
|
198
|
+
"cssAliases": [
|
|
199
|
+
{
|
|
200
|
+
"name": ":--content-carousel",
|
|
201
|
+
"selectors": [
|
|
202
|
+
"content-carousel",
|
|
203
|
+
".tag-content-carousel"
|
|
204
|
+
],
|
|
205
|
+
"kind": "element"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"name": ":--content-carousel--last-move",
|
|
209
|
+
"selectors": [
|
|
210
|
+
"[last-move]",
|
|
211
|
+
"[data-last-move]"
|
|
212
|
+
],
|
|
213
|
+
"kind": "state"
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": ":--content-carousel--last-move-forward",
|
|
217
|
+
"selectors": [
|
|
218
|
+
"[last-move=\"forward\"]",
|
|
219
|
+
"[data-last-move=\"forward\"]"
|
|
220
|
+
],
|
|
221
|
+
"kind": "state"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": ":--content-carousel--last-move-back",
|
|
225
|
+
"selectors": [
|
|
226
|
+
"[last-move=\"back\"]",
|
|
227
|
+
"[data-last-move=\"back\"]"
|
|
228
|
+
],
|
|
229
|
+
"kind": "state"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": ":--content-carousel--slide-animation",
|
|
233
|
+
"selectors": [
|
|
234
|
+
"[slide-animation]",
|
|
235
|
+
"[data-slide-animation]"
|
|
236
|
+
],
|
|
237
|
+
"kind": "state"
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
"name": ":--content-carousel--slide-animation-slide",
|
|
241
|
+
"selectors": [
|
|
242
|
+
"[slide-animation=\"slide\"]",
|
|
243
|
+
"[data-slide-animation=\"slide\"]"
|
|
244
|
+
],
|
|
245
|
+
"kind": "state"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"name": ":--content-carousel--slide-animation-fade",
|
|
249
|
+
"selectors": [
|
|
250
|
+
"[slide-animation=\"fade\"]",
|
|
251
|
+
"[data-slide-animation=\"fade\"]"
|
|
252
|
+
],
|
|
253
|
+
"kind": "state"
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
"name": ":--content-carousel--slide-animation-track",
|
|
257
|
+
"selectors": [
|
|
258
|
+
"[slide-animation=\"track\"]",
|
|
259
|
+
"[data-slide-animation=\"track\"]"
|
|
260
|
+
],
|
|
261
|
+
"kind": "state"
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
"name": ":--content-carousel--is-scrubbing",
|
|
265
|
+
"selectors": [
|
|
266
|
+
"[is-scrubbing]",
|
|
267
|
+
"[data-scrubbing]"
|
|
268
|
+
],
|
|
269
|
+
"kind": "state"
|
|
270
|
+
}
|
|
271
|
+
]
|
|
272
|
+
},
|
|
273
|
+
"cssProperties": [
|
|
274
|
+
{
|
|
275
|
+
"name": "--content-carousel-slide-animation-duration",
|
|
276
|
+
"description": "Length of the slide / fade transition.",
|
|
277
|
+
"syntax": "<time>",
|
|
278
|
+
"default": "0.25s"
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
"name": "--content-carousel-transition-ease",
|
|
282
|
+
"description": "Easing used for the fade transition.",
|
|
283
|
+
"syntax": "<easing-function>",
|
|
284
|
+
"default": "ease-out"
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
"name": "--content-carousel-button-size",
|
|
288
|
+
"description": "Min-width of the nav buttons.",
|
|
289
|
+
"syntax": "<length>",
|
|
290
|
+
"default": "25px"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "--content-carousel-progress",
|
|
294
|
+
"description": "`slide-animation=\"track\"` only: how far the track is dragged, in slide widths — `1` shows the next slide, `-1` the previous. While `is-scrubbing` it follows a wrapping `<gesture-handler>`'s inherited `--gesture-progress` unless set explicitly — swipeable carousels.",
|
|
295
|
+
"syntax": "<number>",
|
|
296
|
+
"default": "0"
|
|
297
|
+
}
|
|
298
|
+
]
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
"exports": [
|
|
302
|
+
{
|
|
303
|
+
"kind": "js",
|
|
304
|
+
"name": "ContentCarousel",
|
|
305
|
+
"declaration": {
|
|
306
|
+
"name": "ContentCarousel",
|
|
307
|
+
"module": "content-carousel.ts"
|
|
308
|
+
}
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
"kind": "custom-element-definition",
|
|
312
|
+
"name": "content-carousel",
|
|
313
|
+
"declaration": {
|
|
314
|
+
"name": "ContentCarousel",
|
|
315
|
+
"module": "content-carousel.ts"
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
]
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
"kind": "javascript-module",
|
|
322
|
+
"path": "content-carousel-slide.ts",
|
|
323
|
+
"declarations": [
|
|
324
|
+
{
|
|
325
|
+
"kind": "class",
|
|
326
|
+
"name": "ContentCarouselSlide",
|
|
327
|
+
"customElement": true,
|
|
328
|
+
"tagName": "content-carousel-slide",
|
|
329
|
+
"summary": "One rotating slide of a content-carousel.",
|
|
330
|
+
"description": "A single slide within `<content-carousel>`.",
|
|
331
|
+
"attributes": [
|
|
332
|
+
{
|
|
333
|
+
"name": "is-active",
|
|
334
|
+
"type": {
|
|
335
|
+
"text": "boolean"
|
|
336
|
+
},
|
|
337
|
+
"description": "Marks this as the currently shown slide. The parent `<content-carousel>` keeps exactly one slide active.",
|
|
338
|
+
"fieldName": "isActive"
|
|
339
|
+
}
|
|
340
|
+
],
|
|
341
|
+
"members": [
|
|
342
|
+
{
|
|
343
|
+
"kind": "field",
|
|
344
|
+
"name": "isActive",
|
|
345
|
+
"type": {
|
|
346
|
+
"text": "boolean"
|
|
347
|
+
},
|
|
348
|
+
"privacy": "public",
|
|
349
|
+
"readonly": false,
|
|
350
|
+
"description": "Marks this as the currently shown slide. The parent `<content-carousel>` keeps exactly one slide active.",
|
|
351
|
+
"_neutron": {
|
|
352
|
+
"surface": "hybrid"
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
],
|
|
356
|
+
"_neutron": {
|
|
357
|
+
"cssAliases": [
|
|
358
|
+
{
|
|
359
|
+
"name": ":--content-carousel-slide",
|
|
360
|
+
"selectors": [
|
|
361
|
+
"content-carousel-slide",
|
|
362
|
+
".tag-content-carousel-slide"
|
|
363
|
+
],
|
|
364
|
+
"kind": "element"
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
"name": ":--content-carousel-slide--is-active",
|
|
368
|
+
"selectors": [
|
|
369
|
+
"[is-active]",
|
|
370
|
+
"[aria-current]"
|
|
371
|
+
],
|
|
372
|
+
"kind": "state"
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
],
|
|
378
|
+
"exports": [
|
|
379
|
+
{
|
|
380
|
+
"kind": "js",
|
|
381
|
+
"name": "ContentCarouselSlide",
|
|
382
|
+
"declaration": {
|
|
383
|
+
"name": "ContentCarouselSlide",
|
|
384
|
+
"module": "content-carousel-slide.ts"
|
|
385
|
+
}
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"kind": "custom-element-definition",
|
|
389
|
+
"name": "content-carousel-slide",
|
|
390
|
+
"declaration": {
|
|
391
|
+
"name": "ContentCarouselSlide",
|
|
392
|
+
"module": "content-carousel-slide.ts"
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
]
|
|
396
|
+
}
|
|
397
|
+
]
|
|
398
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<section>
|
|
2
|
+
<content-carousel auto-play="1.5" slide-animation="fade">
|
|
3
|
+
<content-carousel-slide is-active><h2>One</h2></content-carousel-slide>
|
|
4
|
+
<content-carousel-slide><h2>Two</h2></content-carousel-slide>
|
|
5
|
+
<content-carousel-slide><h2>Three</h2></content-carousel-slide>
|
|
6
|
+
</content-carousel>
|
|
7
|
+
</section>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<section>
|
|
2
|
+
<content-carousel id="demo-carousel-manual">
|
|
3
|
+
<button type="button" rel="prev" command="--back" commandfor="demo-carousel-manual">‹</button>
|
|
4
|
+
<button type="button" rel="next" command="--next" commandfor="demo-carousel-manual">›</button>
|
|
5
|
+
<content-carousel-slide is-active><h2>One</h2></content-carousel-slide>
|
|
6
|
+
<content-carousel-slide><h2>Two</h2></content-carousel-slide>
|
|
7
|
+
<content-carousel-slide><h2>Three</h2></content-carousel-slide>
|
|
8
|
+
</content-carousel>
|
|
9
|
+
</section>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<section>
|
|
2
|
+
<content-carousel auto-play="1.5">
|
|
3
|
+
<content-carousel-slide is-active><h2>One</h2></content-carousel-slide>
|
|
4
|
+
<content-carousel-slide><h2>Two</h2></content-carousel-slide>
|
|
5
|
+
<content-carousel-slide><h2>Three</h2></content-carousel-slide>
|
|
6
|
+
</content-carousel>
|
|
7
|
+
</section>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# `<content-carousel-slide>`
|
|
2
|
+
|
|
3
|
+
> One rotating slide of a content-carousel.
|
|
4
|
+
|
|
5
|
+
**Tag:** `<content-carousel-slide>`
|
|
6
|
+
|
|
7
|
+
## API
|
|
8
|
+
|
|
9
|
+
### Attributes
|
|
10
|
+
|
|
11
|
+
| Name | Surface | Type | Default | Values | Description |
|
|
12
|
+
| --- | --- | --- | --- | --- | --- |
|
|
13
|
+
| `is-active` | hybrid | `boolean` | | | Marks this as the currently shown slide. The parent `<content-carousel>` keeps exactly one slide active. |
|
|
14
|
+
|
|
15
|
+
### CSS Aliases
|
|
16
|
+
|
|
17
|
+
| Alias | Kind | Matches | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `:--content-carousel-slide` | element | `content-carousel-slide`, `.tag-content-carousel-slide` | |
|
|
20
|
+
| `:--content-carousel-slide--is-active` | state | `[is-active]`, `[aria-current]` | |
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# content-carousel
|
|
2
|
+
|
|
3
|
+
Rotate slides on autopilot or on click — galleries, hero banners, walkthroughs.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
```html
|
|
7
|
+
<section>
|
|
8
|
+
<content-carousel auto-play="1.5">
|
|
9
|
+
<content-carousel-slide is-active><h2>One</h2></content-carousel-slide>
|
|
10
|
+
<content-carousel-slide><h2>Two</h2></content-carousel-slide>
|
|
11
|
+
<content-carousel-slide><h2>Three</h2></content-carousel-slide>
|
|
12
|
+
</content-carousel>
|
|
13
|
+
</section>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **Auto-play** Rotate on a timer via `auto-play`
|
|
20
|
+
- **Manual nav** `--back` / `--next` commands from plain buttons; `rel="prev"` / `rel="next"` positions them
|
|
21
|
+
- **Slide or fade** Choose the transition with `slide-animation`
|
|
22
|
+
- **Swipeable** `slide-animation="track"` wrapped in [`gesture-handler`](/nucleus/packages/gesture-handler): drag and flick between slides
|
|
23
|
+
- **Pauses itself** Manual navigation stops auto-play automatically
|
|
24
|
+
- **Bindable position** `.provision` is `{ index, count, lastMove }` — a
|
|
25
|
+
progress readout is one Quark rule on `prop("provision")`
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
`@excom/content-carousel` v0.1.0
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pnpm add @excom/content-carousel
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm install @excom/content-carousel
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
yarn add @excom/content-carousel
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Import
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import "@excom/content-carousel";
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
Wrap `<content-carousel-slide>` elements in a `<content-carousel>`. Mark one
|
|
55
|
+
`is-active`, or leave it unset to default to the first.
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<content-carousel auto-play="5">
|
|
59
|
+
<content-carousel-slide is-active>One</content-carousel-slide>
|
|
60
|
+
<content-carousel-slide>Two</content-carousel-slide>
|
|
61
|
+
<content-carousel-slide>Three</content-carousel-slide>
|
|
62
|
+
</content-carousel>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
`.provision` is `{ index, count, lastMove }` — set on connect and after
|
|
66
|
+
every move, counting only this carousel's own slides. A "2 / 3" readout:
|
|
67
|
+
|
|
68
|
+
```quark
|
|
69
|
+
content-carousel {
|
|
70
|
+
$slide: prop("provision").index + 1;
|
|
71
|
+
$count: prop("provision").count;
|
|
72
|
+
[bind-progress] { content: "#{$slide} / #{$count}"; }
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### API Reference
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
#### Attributes
|
|
80
|
+
|
|
81
|
+
| Name | Surface | Type | Default | Values | Description |
|
|
82
|
+
| --- | --- | --- | --- | --- | --- |
|
|
83
|
+
| `auto-play` | option | `number` | | | Seconds between automatic slide advances. Unset disables auto-play. |
|
|
84
|
+
| `is-scrubbing` | option | `boolean` | | | Set when the element is being dragged. Used by CSS only to disable `transition`. |
|
|
85
|
+
| `slide-animation` | option | `string` | `"slide"` | `"slide"` \| `"fade"` | Transition used when the active slide changes. |
|
|
86
|
+
| `last-move` | state | `string` | | `"forward"` \| `"back"` | Direction of the most recent slide change — drives the CSS animation direction. |
|
|
87
|
+
| `auto-play-stopped` | hybrid | `boolean` | | | Set automatically after manual navigation, or when the element leaves the document (a DOM move keeps auto-play running), to pause auto-play. Set it directly to pause / resume auto-play programmatically. |
|
|
88
|
+
|
|
89
|
+
#### Provision
|
|
90
|
+
|
|
91
|
+
| Name | Type | Description |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| `provision` | `ContentCarouselProvision` (`{ index: number; count: number; lastMove: "forward" \| "back" \| null; }`) | Position: `{ index, count, lastMove }` — the active slide's index among this carousel's own slides, how many there are, and the direction of the last move. Set on connect and after every slide change. Not reflected as an attribute. |
|
|
94
|
+
|
|
95
|
+
#### Recognized Elements
|
|
96
|
+
|
|
97
|
+
| Relationship | Selector | Required | Description |
|
|
98
|
+
| --- | --- | --- | --- |
|
|
99
|
+
| `content-carousel-slide` | descendant | yes | Slides to rotate through. The first, or whichever has `is-active`, is shown initially. |
|
|
100
|
+
|
|
101
|
+
#### Fires
|
|
102
|
+
|
|
103
|
+
| Name | Type | Description |
|
|
104
|
+
| --- | --- | --- |
|
|
105
|
+
| `content-carousel-slide-changed` | `ContentCarouselSlideChangedEvent` (`CustomEvent & { type: "content-carousel-slide-changed"; detail: { activeSlide: HTMLElement \| null; previousSlide: HTMLElement \| null; }; bubbles: true; cancelable: true; composed: true }`) | After any slide change, manual or auto. |
|
|
106
|
+
|
|
107
|
+
#### Commands
|
|
108
|
+
|
|
109
|
+
| Command | Action |
|
|
110
|
+
| --- | --- |
|
|
111
|
+
| `--back` | Shows the previous slide (wraps to last). Stops auto-play. |
|
|
112
|
+
| `--next` | Shows the next slide (wraps to first). Stops auto-play. |
|
|
113
|
+
|
|
114
|
+
#### CSS Custom Properties
|
|
115
|
+
|
|
116
|
+
| Name | Syntax | Default | Description |
|
|
117
|
+
| --- | --- | --- | --- |
|
|
118
|
+
| `--content-carousel-slide-animation-duration` | `<time>` | `0.25s` | Length of the slide / fade transition. |
|
|
119
|
+
| `--content-carousel-transition-ease` | `<easing-function>` | `ease-out` | Easing used for the fade transition. |
|
|
120
|
+
| `--content-carousel-button-size` | `<length>` | `25px` | Min-width of the nav buttons. |
|
|
121
|
+
| `--content-carousel-progress` | `<number>` | `0` | `slide-animation="track"` only: how far the track is dragged, in slide widths — `1` shows the next slide, `-1` the previous. While `is-scrubbing` it follows a wrapping `<gesture-handler>`'s inherited `--gesture-progress` unless set explicitly — swipeable carousels. |
|
|
122
|
+
|
|
123
|
+
#### CSS Classes
|
|
124
|
+
|
|
125
|
+
| Name | Description |
|
|
126
|
+
| --- | --- |
|
|
127
|
+
| `.tag-content-carousel-prev` | Positions a direct child with `rel="prev"` (or `.tag-content-carousel-prev`) as the "previous slide" nav control. |
|
|
128
|
+
| `.tag-content-carousel-next` | Positions a direct child with `rel="next"` (or `.tag-content-carousel-next`) as the "next slide" nav control. |
|
|
129
|
+
|
|
130
|
+
#### CSS Aliases
|
|
131
|
+
|
|
132
|
+
| Alias | Kind | Matches | Description |
|
|
133
|
+
| --- | --- | --- | --- |
|
|
134
|
+
| `:--content-carousel` | element | `content-carousel`, `.tag-content-carousel` | |
|
|
135
|
+
| `:--content-carousel--last-move` | state | `[last-move]`, `[data-last-move]` | |
|
|
136
|
+
| `:--content-carousel--last-move-forward` | state | `[last-move="forward"]`, `[data-last-move="forward"]` | |
|
|
137
|
+
| `:--content-carousel--last-move-back` | state | `[last-move="back"]`, `[data-last-move="back"]` | |
|
|
138
|
+
| `:--content-carousel--slide-animation` | state | `[slide-animation]`, `[data-slide-animation]` | |
|
|
139
|
+
| `:--content-carousel--slide-animation-slide` | state | `[slide-animation="slide"]`, `[data-slide-animation="slide"]` | |
|
|
140
|
+
| `:--content-carousel--slide-animation-fade` | state | `[slide-animation="fade"]`, `[data-slide-animation="fade"]` | |
|
|
141
|
+
| `:--content-carousel--slide-animation-track` | state | `[slide-animation="track"]`, `[data-slide-animation="track"]` | |
|
|
142
|
+
| `:--content-carousel--is-scrubbing` | state | `[is-scrubbing]`, `[data-scrubbing]` | |
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
### Examples
|
|
147
|
+
|
|
148
|
+
#### Manual navigation
|
|
149
|
+
|
|
150
|
+
Invoke `--back` / `--next` from a `<button command commandfor>`. A direct
|
|
151
|
+
child with `rel="prev"` / `rel="next"` (or
|
|
152
|
+
`.tag-content-carousel-prev` / `.tag-content-carousel-next`) is
|
|
153
|
+
positioned as the nav control for you. If you want swipeable slides, you
|
|
154
|
+
must use the carousel in conjunction with the [<gesture-handler>](/nucleus/packages/gesture-handler).
|
|
155
|
+
A demo exists on that page.
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
```html
|
|
159
|
+
<section>
|
|
160
|
+
<content-carousel id="demo-carousel-manual">
|
|
161
|
+
<button type="button" rel="prev" command="--back" commandfor="demo-carousel-manual">‹</button>
|
|
162
|
+
<button type="button" rel="next" command="--next" commandfor="demo-carousel-manual">›</button>
|
|
163
|
+
<content-carousel-slide is-active><h2>One</h2></content-carousel-slide>
|
|
164
|
+
<content-carousel-slide><h2>Two</h2></content-carousel-slide>
|
|
165
|
+
<content-carousel-slide><h2>Three</h2></content-carousel-slide>
|
|
166
|
+
</content-carousel>
|
|
167
|
+
</section>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
#### Fade transition
|
|
172
|
+
|
|
173
|
+
`slide-animation="fade"` crossfades instead of sliding.
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
```html
|
|
177
|
+
<section>
|
|
178
|
+
<content-carousel auto-play="1.5" slide-animation="fade">
|
|
179
|
+
<content-carousel-slide is-active><h2>One</h2></content-carousel-slide>
|
|
180
|
+
<content-carousel-slide><h2>Two</h2></content-carousel-slide>
|
|
181
|
+
<content-carousel-slide><h2>Three</h2></content-carousel-slide>
|
|
182
|
+
</content-carousel>
|
|
183
|
+
</section>
|
|
184
|
+
```
|