@ideasonpurpose/wp-theme-addons 0.4.0 → 0.5.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 +140 -7
- package/editor/Block/Variation/Group/Carousel/Carousel.php +102 -0
- package/editor/Block/Variation/Group/Carousel/carousel.css +325 -0
- package/editor/Block/Variation/Group/Carousel/carousel.js +336 -0
- package/editor/Block/Variation/Group/LinkedGroup/LinkedGroup.php +23 -0
- package/editor/Block/Variation/Group/LinkedGroup/linked-group.css +22 -0
- package/editor/Block/Variation/Group/LinkedGroup/linked-group.js +1 -1
- package/frontend/carousel.d.ts +23 -0
- package/frontend/carousel.js +360 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/lib/carousel-defaults.js +13 -0
- package/package.json +28 -9
- package/editor/Block/Variation/Group/LinkedGroup/linked-group.scss +0 -22
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# WordPress Theme Addons
|
|
2
2
|
|
|
3
|
-
#### Version 0.
|
|
3
|
+
#### Version 0.5.0
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@ideasonpurpose/wp-theme-addons)
|
|
6
6
|
[](https://packagist.org/packages/ideasonpurpose/wp-theme-addons)
|
|
@@ -15,9 +15,111 @@ This repository contains JavaScript and PHP add-ons for the WordPress Block Edit
|
|
|
15
15
|
|
|
16
16
|
A variation on the Group block which adds standard Link controls. The link implementation uses ideas from [Accessible cards](https://kittygiraudel.com/2022/04/02/accessible-cards/) and [Inclusive Components: Cards](https://inclusive-components.design/cards/).
|
|
17
17
|
|
|
18
|
+
`new LinkedGroup()` wraps the `core/group` render callback and, when the variation has a URL, appends an empty overlay link inside the group. The stretch-link rules live in `editor/Block/Variation/Group/LinkedGroup/linked-group.css`. The editor script imports that file. PHP reads the same file and inlines it on the `iop-linked-group` handle from `wp_enqueue_scripts`, so the rules print in the head. No theme copy is required.
|
|
19
|
+
|
|
18
20
|
#### Related Posts Query
|
|
19
21
|
|
|
20
|
-
A variation on the Query Loop block which replaces the query with ranked related posts. Ranking lives in `lib/RelatedPosts` (`IdeasOnPurpose\WP\RelatedPosts`) — weighted shared taxonomies, post type, and recency, with optional REST at `GET /wp-json/ideasonpurpose/v1/related_posts/{id}
|
|
22
|
+
A variation on the Query Loop block which replaces the query with ranked related posts. Ranking lives in `lib/RelatedPosts` (`IdeasOnPurpose\WP\RelatedPosts`) — weighted shared taxonomies, post type, and recency, with optional REST at `GET /wp-json/ideasonpurpose/v1/related_posts/{id}` (see [PHP usage](#php) to enable it).
|
|
23
|
+
|
|
24
|
+
#### Carousel
|
|
25
|
+
|
|
26
|
+
Three `core/group` variations — Carousel, Viewport, and Container — plus a front-end module. Any direct child of the container is a slide (cover, group, a pattern, or the items of a query loop). The editor shows the slides for editing and does not autoplay. The front end uses [Embla Carousel 9](https://www.embla-carousel.com/).
|
|
27
|
+
|
|
28
|
+
Namespaces and classes:
|
|
29
|
+
|
|
30
|
+
| Piece | Block | Namespace | Class |
|
|
31
|
+
| --------- | ---------------- | ----------------------------------- | -------------------------------------------------------- |
|
|
32
|
+
| Carousel | `core/group` | `ideasonpurpose/carousel` | `iop-carousel` |
|
|
33
|
+
| Viewport | `core/group` | `ideasonpurpose/carousel-viewport` | `iop-carousel__viewport` |
|
|
34
|
+
| Container | `core/group` | `ideasonpurpose/carousel-container` | `iop-carousel__container` |
|
|
35
|
+
| Slide | any direct child | — | `iop-carousel__slide` is added in the browser if missing |
|
|
36
|
+
|
|
37
|
+
Viewport and Container are hidden from the inserter. Insert Carousel; it starts with a viewport, a container, and two group slides. Replace those slides with whatever the site needs. For a query loop, put the loop inside the viewport and add `iop-carousel__container` to the post template. Each post item is then a slide.
|
|
38
|
+
|
|
39
|
+
Settings live on the Carousel variation and are copied to data attributes when PHP renders the block. The saved group markup is unchanged. Omitted attributes use the defaults below.
|
|
40
|
+
|
|
41
|
+
| Block attribute | Data attribute | Default |
|
|
42
|
+
| ------------------ | --------------- | ---------------------- |
|
|
43
|
+
| `carouselAutoplay` | `data-autoplay` | `true` |
|
|
44
|
+
| `carouselDuration` | `data-duration` | `6` (seconds) |
|
|
45
|
+
| `carouselArrows` | `data-arrows` | `true` |
|
|
46
|
+
| `carouselDots` | `data-dots` | `true` |
|
|
47
|
+
| `carouselLoop` | `data-loop` | `true` |
|
|
48
|
+
| `carouselRandom` | `data-random` | `0` (keep every slide) |
|
|
49
|
+
|
|
50
|
+
`carouselRandom` greater than 0 keeps that many slides, chosen in the browser on each visit, and removes the rest before Embla starts. That still varies when the HTML is served from a page cache.
|
|
51
|
+
|
|
52
|
+
A slide can set its own `slideDuration` (seconds) in the inspector. It is saved as `data-slide-duration` on that block and overrides `carouselDuration` for that slide only.
|
|
53
|
+
|
|
54
|
+
Arrow clicks and dot clicks both restart the autoplay timer. A pause button (WCAG 2.2.2) stops and resumes it. Autoplay does not start when `prefers-reduced-motion: reduce` is set, while the pointer is over the carousel, or while the carousel is off screen. Arrow keys move only the carousel that contains the focus, and they leave text fields alone.
|
|
55
|
+
|
|
56
|
+
Look is custom properties on `.iop-carousel`. Override these in the theme; the structural selectors can stay alone.
|
|
57
|
+
|
|
58
|
+
| Property | Default | Use |
|
|
59
|
+
| ----------------------------- | -------------------------- | ---------------------------------- |
|
|
60
|
+
| `--carousel-max-width` | `none` | Viewport max width |
|
|
61
|
+
| `--carousel-arrow-size` | `2.75rem` | Previous / next hit target |
|
|
62
|
+
| `--carousel-arrow-icon-size` | `1.25rem` | Icon inside the arrow |
|
|
63
|
+
| `--carousel-arrow-offset` | `0.75rem` | Inset from the sides |
|
|
64
|
+
| `--carousel-arrow-color` | `currentColor` | Icon color |
|
|
65
|
+
| `--carousel-arrow-bg` | translucent `Canvas` | Arrow and pause fill |
|
|
66
|
+
| `--carousel-arrow-radius` | `999px` | Arrow and pause radius |
|
|
67
|
+
| `--carousel-arrow-shadow` | `none` | Arrow and pause shadow |
|
|
68
|
+
| `--carousel-arrow-prev` | chevron | `mask-image` for the previous icon |
|
|
69
|
+
| `--carousel-arrow-next` | chevron | `mask-image` for the next icon |
|
|
70
|
+
| `--carousel-pause-icon` | pause bars | Pause icon |
|
|
71
|
+
| `--carousel-play-icon` | triangle | Play icon |
|
|
72
|
+
| `--carousel-pause-size` | `2.25rem` | Pause button |
|
|
73
|
+
| `--carousel-dot-width` | `0.625rem` | Pagination mark |
|
|
74
|
+
| `--carousel-dot-height` | `0.625rem` | Pagination mark |
|
|
75
|
+
| `--carousel-dot-radius` | `999px` | `0` makes bars |
|
|
76
|
+
| `--carousel-dot-gap` | `0.5rem` | Space between marks |
|
|
77
|
+
| `--carousel-dot-color` | translucent `currentColor` | Inactive mark |
|
|
78
|
+
| `--carousel-dot-active-color` | `currentColor` | Active mark and hover |
|
|
79
|
+
| `--carousel-controls-offset` | `1rem` | Distance from the bottom |
|
|
80
|
+
| `--carousel-controls-justify` | `center` | `flex-start` for left aligned |
|
|
81
|
+
| `--carousel-controls-padding` | `1rem` | Inline padding of the control row |
|
|
82
|
+
|
|
83
|
+
Embla's class-names plugin adds `is-snapped` and `is-in-view` on slides. Use those for motion that should wait until a slide is current. The package does not ship a slide-content animation.
|
|
84
|
+
|
|
85
|
+
Bars instead of dots, for example:
|
|
86
|
+
|
|
87
|
+
```css
|
|
88
|
+
.iop-carousel {
|
|
89
|
+
--carousel-dot-width: 1.5rem;
|
|
90
|
+
--carousel-dot-height: 3px;
|
|
91
|
+
--carousel-dot-radius: 0;
|
|
92
|
+
--carousel-dot-color: #fff;
|
|
93
|
+
--carousel-dot-active-color: var(--wp--preset--color--accent);
|
|
94
|
+
--carousel-controls-justify: flex-start;
|
|
95
|
+
--carousel-arrow-prev: var(--i-arrow-prev);
|
|
96
|
+
--carousel-arrow-next: var(--i-arrow-next);
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
An example slide pattern a theme can register. The carousel structure comes from the variation, so the pattern is only the slide:
|
|
101
|
+
|
|
102
|
+
```php
|
|
103
|
+
<?php
|
|
104
|
+
/**
|
|
105
|
+
* Title: Carousel slide
|
|
106
|
+
* Slug: theme/carousel-slide
|
|
107
|
+
* Inserter: true
|
|
108
|
+
*/
|
|
109
|
+
?>
|
|
110
|
+
<!-- wp:group {"className":"iop-carousel__slide"} -->
|
|
111
|
+
<div class="wp-block-group iop-carousel__slide">
|
|
112
|
+
<!-- wp:heading {"level":2} -->
|
|
113
|
+
<h2 class="wp-block-heading">Slide title</h2>
|
|
114
|
+
<!-- /wp:heading -->
|
|
115
|
+
<!-- wp:paragraph -->
|
|
116
|
+
<p>Slide text.</p>
|
|
117
|
+
<!-- /wp:paragraph -->
|
|
118
|
+
</div>
|
|
119
|
+
<!-- /wp:group -->
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
A carousel inserted from the variation is a `section` with no alignment and no color. Set those on the block, or in the theme pattern that wraps it.
|
|
21
123
|
|
|
22
124
|
### Block Extensions
|
|
23
125
|
|
|
@@ -50,7 +152,7 @@ Icons are displayed using CSS in the theme. Each icon maps to a mask variable th
|
|
|
50
152
|
|
|
51
153
|
Injects block color attributes as CSS custom properties (`--local-text-color`, `--local-bg-color`, `--local-border-color`) so theme styles can use them.
|
|
52
154
|
|
|
53
|
-
This feature
|
|
155
|
+
This feature includes a pair of front-end and block editor files:
|
|
54
156
|
|
|
55
157
|
| File | Runtime | Role |
|
|
56
158
|
| ---------------------------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -67,9 +169,11 @@ add_filter('iop/add_css_local_props_allowed_blocks', fn() => ['core/button', 'co
|
|
|
67
169
|
|
|
68
170
|
Both sides must stay in sync: enable PHP for frontend output and call `initCssLocalProps()` in the editor bundle so the canvas matches the saved markup.
|
|
69
171
|
|
|
172
|
+
The PHP block list is localized to the script handle `{stylesheet}-editor` (from `get_stylesheet()`). If the theme's editor script uses a different handle, or is enqueued after `enqueue_block_editor_assets` priority 10, the editor falls back to `core/button`. Pass the list to `initCssLocalProps(['core/button', 'core/group'])` directly in that case.
|
|
173
|
+
|
|
70
174
|
### Utilities
|
|
71
175
|
|
|
72
|
-
A few utility
|
|
176
|
+
A few utility hooks are exported. `usePublicPostTypes` and `usePublicTaxonomies` are direct lifts from the [WordPress Gutenberg source code](https://github.com/WordPress/gutenberg/blob/e90c88fee31120e0091e044c149f8b4f5f947f4a/packages/edit-site/src/components/add-new-template/utils.js#L91-L125). These functions are useful for pre-populating a WordPress data-store with all PostType and Taxonomy data for use in interfaces or block rendering.
|
|
73
177
|
|
|
74
178
|
## Installation
|
|
75
179
|
|
|
@@ -89,7 +193,7 @@ Or in `package.json`:
|
|
|
89
193
|
```json
|
|
90
194
|
{
|
|
91
195
|
"dependencies": {
|
|
92
|
-
"@ideasonpurpose/wp-theme-addons": "^0.
|
|
196
|
+
"@ideasonpurpose/wp-theme-addons": "^0.5.0"
|
|
93
197
|
}
|
|
94
198
|
}
|
|
95
199
|
```
|
|
@@ -120,29 +224,58 @@ Import into **editor.js**. Minimal required styles are bundled with the JS:
|
|
|
120
224
|
|
|
121
225
|
```javascript
|
|
122
226
|
// @link https://github.com/ideasonpurpose/wp-theme-addons
|
|
123
|
-
import {
|
|
227
|
+
import {
|
|
228
|
+
initButtonIconPicker,
|
|
229
|
+
initCarouselBlock,
|
|
230
|
+
initCssLocalProps,
|
|
231
|
+
initLinkedGroupBlock,
|
|
232
|
+
initRelatedPostsQueryBlock,
|
|
233
|
+
} from "@ideasonpurpose/wp-theme-addons";
|
|
124
234
|
|
|
125
235
|
initLinkedGroupBlock();
|
|
236
|
+
initRelatedPostsQueryBlock();
|
|
237
|
+
initCarouselBlock();
|
|
126
238
|
initCssLocalProps();
|
|
127
239
|
initButtonIconPicker([...]);
|
|
128
240
|
```
|
|
129
241
|
|
|
242
|
+
Call `initCarouselBlock()` while the editor script evaluates, same as the other inits. The import pulls `carousel.css` into the editor bundle. Autoplay does not run in the editor.
|
|
243
|
+
|
|
244
|
+
Front end, in `main.js`. This entry is separate so the editor bundle does not load Embla:
|
|
245
|
+
|
|
246
|
+
```javascript
|
|
247
|
+
import { initCarousels } from "@ideasonpurpose/wp-theme-addons/carousel";
|
|
248
|
+
|
|
249
|
+
initCarousels();
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Embla and its accessibility, autoplay, and class-names plugins are dependencies of this package, pinned to the 9.0.0 release candidate (`9.0.0-rc04`) because the carousel uses the v9 API. `initCarousels()` waits for `DOMContentLoaded` if the document is still loading.
|
|
253
|
+
|
|
254
|
+
The package ships untranspiled source: `.js` files contain JSX and import `.scss` files. The theme's build must transpile JSX and compile Sass for this package inside `node_modules`. `@wordpress/*` packages are expected to be provided as externals by the theme's build (for example `@wordpress/scripts`).
|
|
255
|
+
|
|
130
256
|
### PHP
|
|
131
257
|
|
|
132
258
|
```php
|
|
133
259
|
use IdeasOnPurpose\WP\RelatedPosts;
|
|
260
|
+
use IdeasOnPurpose\WP\Theme\Addons\Block\Variation\Group\Carousel\Carousel;
|
|
134
261
|
use IdeasOnPurpose\WP\Theme\Addons\Block\Variation\Group\LinkedGroup\LinkedGroup;
|
|
135
262
|
use IdeasOnPurpose\WP\Theme\Addons\Block\Variation\Query\RelatedPostsQuery\RelatedPostsQuery;
|
|
136
263
|
use IdeasOnPurpose\WP\Theme\Addons\CssLocalProps\CssLocalProps;
|
|
137
264
|
|
|
138
265
|
new LinkedGroup();
|
|
139
|
-
new
|
|
266
|
+
new Carousel(); // inlines carousel.css and writes data-* settings
|
|
267
|
+
new RelatedPostsQuery(); // uses RelatedPosts for ranking
|
|
140
268
|
new CssLocalProps();
|
|
141
269
|
|
|
270
|
+
// Optional: enables the REST endpoint. Must run before `rest_api_init`, e.g. in functions.php
|
|
271
|
+
new RelatedPosts();
|
|
272
|
+
|
|
142
273
|
// Optional: use the ranker directly
|
|
143
274
|
// $posts = (new RelatedPosts())->get(['post' => $id, 'posts_per_page' => 4]);
|
|
144
275
|
```
|
|
145
276
|
|
|
277
|
+
PHP components require WordPress 6.2 or later (`WP_HTML_Tag_Processor`).
|
|
278
|
+
|
|
146
279
|
## Coexistence
|
|
147
280
|
|
|
148
281
|
npm and Composer operate independently in the same repository:
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file is part of the WordPress Theme Addons.
|
|
5
|
+
* @link https://github.com/ideasonpurpose/wp-theme-addons
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
namespace IdeasOnPurpose\WP\Theme\Addons\Block\Variation\Group\Carousel;
|
|
9
|
+
|
|
10
|
+
class Carousel
|
|
11
|
+
{
|
|
12
|
+
public $namespace = 'ideasonpurpose/carousel';
|
|
13
|
+
|
|
14
|
+
public function __construct()
|
|
15
|
+
{
|
|
16
|
+
add_filter('render_block', [$this, 'add_data_attributes'], 10, 2);
|
|
17
|
+
add_action('wp_enqueue_scripts', [$this, 'enqueue_styles']);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Copy carousel settings onto data attributes at render time.
|
|
22
|
+
*
|
|
23
|
+
* The saved markup stays the core/group HTML. Unset attributes are
|
|
24
|
+
* omitted and the front end uses its own defaults.
|
|
25
|
+
*
|
|
26
|
+
* @param string $content
|
|
27
|
+
* @param array $block
|
|
28
|
+
* @return string
|
|
29
|
+
*/
|
|
30
|
+
public function add_data_attributes($content, $block)
|
|
31
|
+
{
|
|
32
|
+
if (($block['blockName'] ?? '') !== 'core/group') {
|
|
33
|
+
return $content;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
$attrs = $block['attrs'] ?? [];
|
|
37
|
+
if (($attrs['namespace'] ?? '') !== $this->namespace) {
|
|
38
|
+
return $content;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (!is_string($content) || $content === '') {
|
|
42
|
+
return $content;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
$tags = new \WP_HTML_Tag_Processor($content);
|
|
46
|
+
if (!$tags->next_tag()) {
|
|
47
|
+
return $content;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
foreach (
|
|
51
|
+
[
|
|
52
|
+
'carouselAutoplay' => 'data-autoplay',
|
|
53
|
+
'carouselArrows' => 'data-arrows',
|
|
54
|
+
'carouselDots' => 'data-dots',
|
|
55
|
+
'carouselLoop' => 'data-loop',
|
|
56
|
+
]
|
|
57
|
+
as $key => $attribute
|
|
58
|
+
) {
|
|
59
|
+
if (!array_key_exists($key, $attrs)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
$tags->set_attribute($attribute, $attrs[$key] ? 'true' : 'false');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (isset($attrs['carouselDuration']) && is_numeric($attrs['carouselDuration'])) {
|
|
66
|
+
$seconds = (float) $attrs['carouselDuration'];
|
|
67
|
+
if ($seconds > 0) {
|
|
68
|
+
$tags->set_attribute('data-duration', (string) $seconds);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (isset($attrs['carouselRandom']) && is_numeric($attrs['carouselRandom'])) {
|
|
73
|
+
$count = (int) $attrs['carouselRandom'];
|
|
74
|
+
if ($count > 0) {
|
|
75
|
+
$tags->set_attribute('data-random', (string) $count);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return $tags->get_updated_html();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Inline the same CSS the editor script imports.
|
|
84
|
+
*/
|
|
85
|
+
public function enqueue_styles()
|
|
86
|
+
{
|
|
87
|
+
static $done = false;
|
|
88
|
+
if ($done) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
$done = true;
|
|
92
|
+
|
|
93
|
+
$css = file_get_contents(__DIR__ . '/carousel.css');
|
|
94
|
+
if (!$css) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
wp_register_style('iop-carousel', false);
|
|
99
|
+
wp_add_inline_style('iop-carousel', $css);
|
|
100
|
+
wp_enqueue_style('iop-carousel');
|
|
101
|
+
}
|
|
102
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Structural carousel styles. Themes restyle by overriding the custom
|
|
3
|
+
* properties on .iop-carousel. Defaults are neutral on purpose: no brand
|
|
4
|
+
* color, no site breakpoint, no fixed max width.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.wp-block-group.iop-carousel {
|
|
8
|
+
--carousel-max-width: none;
|
|
9
|
+
--carousel-arrow-size: 2.75rem;
|
|
10
|
+
--carousel-arrow-icon-size: 1.25rem;
|
|
11
|
+
--carousel-arrow-offset: 0.75rem;
|
|
12
|
+
--carousel-arrow-color: currentColor;
|
|
13
|
+
--carousel-arrow-bg: color-mix(in srgb, Canvas 78%, transparent);
|
|
14
|
+
--carousel-arrow-radius: 999px;
|
|
15
|
+
--carousel-arrow-shadow: none;
|
|
16
|
+
--carousel-arrow-prev: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%23000%22%20d%3D%22M15.4%207.4%2014%206l-6%206%206%206%201.4-1.4L10.8%2012z%22%2F%3E%3C%2Fsvg%3E");
|
|
17
|
+
--carousel-arrow-next: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%23000%22%20d%3D%22M8.6%207.4%2010%206l6%206-6%206-1.4-1.4L13.2%2012z%22%2F%3E%3C%2Fsvg%3E");
|
|
18
|
+
--carousel-pause-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%23000%22%20d%3D%22M6%205h4v14H6zm8%200h4v14h-4z%22%2F%3E%3C%2Fsvg%3E");
|
|
19
|
+
--carousel-play-icon: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cpath%20fill%3D%22%23000%22%20d%3D%22M8%205v14l11-7z%22%2F%3E%3C%2Fsvg%3E");
|
|
20
|
+
--carousel-pause-size: 2.25rem;
|
|
21
|
+
--carousel-dot-width: 0.625rem;
|
|
22
|
+
--carousel-dot-height: 0.625rem;
|
|
23
|
+
--carousel-dot-radius: 999px;
|
|
24
|
+
--carousel-dot-gap: 0.5rem;
|
|
25
|
+
--carousel-dot-color: color-mix(in srgb, currentColor 40%, transparent);
|
|
26
|
+
--carousel-dot-active-color: currentColor;
|
|
27
|
+
--carousel-controls-offset: 1rem;
|
|
28
|
+
--carousel-controls-justify: center;
|
|
29
|
+
--carousel-controls-padding: 1rem;
|
|
30
|
+
--carousel-editor-thumb-gap: 0.75rem;
|
|
31
|
+
--carousel-editor-thumb-inset: 0.75rem;
|
|
32
|
+
--carousel-editor-thumb-scale: 0.15;
|
|
33
|
+
--carousel-editor-count: 2;
|
|
34
|
+
|
|
35
|
+
position: relative;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.iop-carousel__live {
|
|
39
|
+
position: absolute;
|
|
40
|
+
width: 1px;
|
|
41
|
+
height: 1px;
|
|
42
|
+
margin: -1px;
|
|
43
|
+
padding: 0;
|
|
44
|
+
overflow: hidden;
|
|
45
|
+
clip: rect(0, 0, 0, 0);
|
|
46
|
+
white-space: nowrap;
|
|
47
|
+
border: 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
body:not(.wp-admin, .block-editor-iframe__body) .wp-block-group.iop-carousel .iop-carousel__viewport {
|
|
51
|
+
width: 100%;
|
|
52
|
+
max-width: var(--carousel-max-width);
|
|
53
|
+
margin-inline: auto;
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
body:not(.wp-admin, .block-editor-iframe__body) .wp-block-group.iop-carousel .iop-carousel__viewport,
|
|
58
|
+
body:not(.wp-admin, .block-editor-iframe__body) .wp-block-group.iop-carousel .iop-carousel__container {
|
|
59
|
+
margin-block: 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
body:not(.wp-admin, .block-editor-iframe__body) .wp-block-group.iop-carousel .iop-carousel__container {
|
|
63
|
+
display: flex;
|
|
64
|
+
gap: 0;
|
|
65
|
+
padding: 0;
|
|
66
|
+
list-style: none;
|
|
67
|
+
touch-action: pan-y pinch-zoom;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
body:not(.wp-admin, .block-editor-iframe__body) .wp-block-group.iop-carousel .iop-carousel__container > * {
|
|
71
|
+
flex: 0 0 100%;
|
|
72
|
+
min-width: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.iop-carousel button.iop-carousel-arrow,
|
|
76
|
+
.iop-carousel button.iop-carousel-pause,
|
|
77
|
+
.iop-carousel button.iop-carousel-dotnav__dot {
|
|
78
|
+
all: unset;
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
/* all: unset inherits pointer-events from the control bar, which is none
|
|
81
|
+
so the bar itself does not block the slides. */
|
|
82
|
+
pointer-events: auto;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.iop-carousel button.iop-carousel-arrow:focus-visible,
|
|
87
|
+
.iop-carousel button.iop-carousel-pause:focus-visible,
|
|
88
|
+
.iop-carousel button.iop-carousel-dotnav__dot:focus-visible {
|
|
89
|
+
outline: 2px solid currentColor;
|
|
90
|
+
outline-offset: 2px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.iop-carousel button.iop-carousel-arrow {
|
|
94
|
+
position: absolute;
|
|
95
|
+
top: 50%;
|
|
96
|
+
z-index: 2;
|
|
97
|
+
transform: translateY(-50%);
|
|
98
|
+
|
|
99
|
+
display: grid;
|
|
100
|
+
place-items: center;
|
|
101
|
+
width: var(--carousel-arrow-size);
|
|
102
|
+
height: var(--carousel-arrow-size);
|
|
103
|
+
|
|
104
|
+
background: var(--carousel-arrow-bg);
|
|
105
|
+
border-radius: var(--carousel-arrow-radius);
|
|
106
|
+
box-shadow: var(--carousel-arrow-shadow);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.iop-carousel button.iop-carousel-arrow--prev {
|
|
110
|
+
left: var(--carousel-arrow-offset);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.iop-carousel button.iop-carousel-arrow--next {
|
|
114
|
+
right: var(--carousel-arrow-offset);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.iop-carousel button.iop-carousel-arrow::before,
|
|
118
|
+
.iop-carousel button.iop-carousel-pause::before {
|
|
119
|
+
content: "";
|
|
120
|
+
display: block;
|
|
121
|
+
background: var(--carousel-arrow-color);
|
|
122
|
+
mask-repeat: no-repeat;
|
|
123
|
+
mask-position: center;
|
|
124
|
+
mask-size: contain;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.iop-carousel button.iop-carousel-arrow::before {
|
|
128
|
+
width: var(--carousel-arrow-icon-size);
|
|
129
|
+
height: var(--carousel-arrow-icon-size);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.iop-carousel button.iop-carousel-arrow--next::before {
|
|
133
|
+
mask-image: var(--carousel-arrow-next);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.iop-carousel button.iop-carousel-arrow--prev::before {
|
|
137
|
+
mask-image: var(--carousel-arrow-prev);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.iop-carousel button.iop-carousel-arrow[aria-disabled="true"] {
|
|
141
|
+
opacity: 0.35;
|
|
142
|
+
pointer-events: none;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.iop-carousel-controls {
|
|
146
|
+
position: absolute;
|
|
147
|
+
right: 0;
|
|
148
|
+
bottom: var(--carousel-controls-offset);
|
|
149
|
+
left: 0;
|
|
150
|
+
z-index: 2;
|
|
151
|
+
|
|
152
|
+
display: flex;
|
|
153
|
+
gap: var(--carousel-dot-gap);
|
|
154
|
+
align-items: center;
|
|
155
|
+
justify-content: var(--carousel-controls-justify);
|
|
156
|
+
padding-inline: var(--carousel-controls-padding);
|
|
157
|
+
|
|
158
|
+
pointer-events: none;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.iop-carousel-controls > * {
|
|
162
|
+
pointer-events: auto;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.iop-carousel button.iop-carousel-pause {
|
|
166
|
+
display: grid;
|
|
167
|
+
place-items: center;
|
|
168
|
+
width: var(--carousel-pause-size);
|
|
169
|
+
height: var(--carousel-pause-size);
|
|
170
|
+
|
|
171
|
+
background: var(--carousel-arrow-bg);
|
|
172
|
+
border-radius: var(--carousel-arrow-radius);
|
|
173
|
+
box-shadow: var(--carousel-arrow-shadow);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.iop-carousel button.iop-carousel-pause::before {
|
|
177
|
+
width: 0.9rem;
|
|
178
|
+
height: 0.9rem;
|
|
179
|
+
mask-image: var(--carousel-pause-icon);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.iop-carousel button.iop-carousel-pause.is-paused::before {
|
|
183
|
+
mask-image: var(--carousel-play-icon);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.iop-carousel button.iop-carousel-pause[hidden] {
|
|
187
|
+
display: none;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.iop-carousel-dotnav {
|
|
191
|
+
display: flex;
|
|
192
|
+
gap: var(--carousel-dot-gap);
|
|
193
|
+
align-items: center;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.iop-carousel button.iop-carousel-dotnav__dot {
|
|
197
|
+
position: relative;
|
|
198
|
+
display: block;
|
|
199
|
+
flex: 0 0 auto;
|
|
200
|
+
width: var(--carousel-dot-width);
|
|
201
|
+
height: var(--carousel-dot-height);
|
|
202
|
+
|
|
203
|
+
background: var(--carousel-dot-color);
|
|
204
|
+
border-radius: var(--carousel-dot-radius);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.iop-carousel button.iop-carousel-dotnav__dot::after {
|
|
208
|
+
content: "";
|
|
209
|
+
position: absolute;
|
|
210
|
+
inset: -0.5rem;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.iop-carousel button.iop-carousel-dotnav__dot:hover,
|
|
214
|
+
.iop-carousel button.iop-carousel-dotnav__dot.is-active,
|
|
215
|
+
.iop-carousel button.iop-carousel-dotnav__dot[aria-current="true"] {
|
|
216
|
+
background: var(--carousel-dot-active-color);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/* Editor: slides stay in normal flow so they can be edited. An unselected
|
|
220
|
+
carousel shows later slides as scaled thumbnails. */
|
|
221
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel .iop-carousel__container {
|
|
222
|
+
position: relative;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel .iop-carousel__container > * {
|
|
226
|
+
min-height: 4rem;
|
|
227
|
+
transition:
|
|
228
|
+
opacity 180ms ease,
|
|
229
|
+
transform 180ms ease;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:is(.is-selected, .has-child-selected) .iop-carousel__container > *:not(:is(.is-selected, .has-child-selected)) {
|
|
233
|
+
opacity: 0.45;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) {
|
|
237
|
+
--carousel-editor-thumb-width: min(160px, calc((100% - ((var(--carousel-editor-count) - 2) * var(--carousel-editor-thumb-gap))) / (var(--carousel-editor-count) - 1)));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)):has(.iop-carousel__container > :nth-child(8)) {
|
|
241
|
+
--carousel-editor-count: 8;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)):has(.iop-carousel__container > :nth-child(2):last-child) {
|
|
245
|
+
--carousel-editor-count: 2;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)):has(.iop-carousel__container > :nth-child(3):last-child) {
|
|
249
|
+
--carousel-editor-count: 3;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)):has(.iop-carousel__container > :nth-child(4):last-child) {
|
|
253
|
+
--carousel-editor-count: 4;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)):has(.iop-carousel__container > :nth-child(5):last-child) {
|
|
257
|
+
--carousel-editor-count: 5;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)):has(.iop-carousel__container > :nth-child(6):last-child) {
|
|
261
|
+
--carousel-editor-count: 6;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)):has(.iop-carousel__container > :nth-child(7):last-child) {
|
|
265
|
+
--carousel-editor-count: 7;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(n + 9) {
|
|
269
|
+
display: none;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(2) {
|
|
273
|
+
--carousel-editor-slide-number: 2;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(3) {
|
|
277
|
+
--carousel-editor-slide-number: 3;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(4) {
|
|
281
|
+
--carousel-editor-slide-number: 4;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(5) {
|
|
285
|
+
--carousel-editor-slide-number: 5;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(6) {
|
|
289
|
+
--carousel-editor-slide-number: 6;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(7) {
|
|
293
|
+
--carousel-editor-slide-number: 7;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(8) {
|
|
297
|
+
--carousel-editor-slide-number: 8;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel:not(:is(.is-selected, .has-child-selected)) .iop-carousel__container > :nth-child(n + 2):nth-child(-n + 8) {
|
|
301
|
+
position: absolute;
|
|
302
|
+
right: calc(
|
|
303
|
+
var(--carousel-editor-thumb-inset) + (var(--carousel-editor-count) - var(--carousel-editor-slide-number)) *
|
|
304
|
+
(var(--carousel-editor-thumb-width) + var(--carousel-editor-thumb-gap))
|
|
305
|
+
);
|
|
306
|
+
bottom: var(--carousel-editor-thumb-inset);
|
|
307
|
+
z-index: 1;
|
|
308
|
+
|
|
309
|
+
box-sizing: border-box;
|
|
310
|
+
width: calc(var(--carousel-editor-thumb-width) / var(--carousel-editor-thumb-scale));
|
|
311
|
+
min-height: 0;
|
|
312
|
+
aspect-ratio: 2 / 1;
|
|
313
|
+
overflow: hidden;
|
|
314
|
+
|
|
315
|
+
border: 3px solid color-mix(in srgb, CanvasText 45%, transparent);
|
|
316
|
+
box-shadow: 8px 8px 16px color-mix(in srgb, CanvasText 25%, transparent);
|
|
317
|
+
transform: scale(var(--carousel-editor-thumb-scale));
|
|
318
|
+
transform-origin: bottom right;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
@media (prefers-reduced-motion: reduce) {
|
|
322
|
+
.editor-styles-wrapper .wp-block-group.iop-carousel .iop-carousel__container > * {
|
|
323
|
+
transition: none;
|
|
324
|
+
}
|
|
325
|
+
}
|