@riebeckite/plugin-image-compare 0.0.0-stage → 0.0.37

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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright Rerurate_514
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,123 @@
1
- # Temporary Holding Version
1
+ # @riebeckite/plugin-image-compare
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <!-- Generated from docs/docs/plugins/image-compare.md. Edit the canonical documentation in docs/docs/plugins and run `pnpm docs:sync`. -->
4
+
5
+ Before/after image sliders from a fenced `image-compare` block. The slider is
6
+ rendered at build time and enhanced by a small client script; without
7
+ JavaScript the same two images remain readable side by side.
8
+
9
+ [日本語](./README_ja.md)
10
+
11
+ ## Overview
12
+
13
+ ````markdown
14
+ ```image-compare
15
+ before: ./before.png
16
+ after: ../assets/after.png
17
+ beforeAlt: Draft
18
+ afterAlt: Published
19
+ orientation: horizontal
20
+ label: Home page
21
+ ```
22
+ ````
23
+
24
+ `before` and `after` are required. Image paths resolve relative to the note,
25
+ using the same rules as Markdown images. External URLs, protocol-relative URLs,
26
+ and paths that escape the content directory are rejected.
27
+
28
+ The block becomes a `<figure>` with a native range input. Mouse, touch, and
29
+ keyboard all work through that input. Multiple blocks can appear on one page,
30
+ and SPA navigation removes each slider's listener when its page is replaced.
31
+
32
+ ## Usage
33
+
34
+ ```ts
35
+ import { defineConfig } from "@riebeckite/core";
36
+ import { imageCompare } from "@riebeckite/plugin-image-compare";
37
+
38
+ export default defineConfig({
39
+ // ...
40
+ plugins: [imageCompare()],
41
+ });
42
+ ```
43
+
44
+ The plugin registers its own stylesheet and page-scoped client entry. Nothing is
45
+ emitted when the plugin is disabled.
46
+
47
+ ## Options
48
+
49
+ | Option | Type | Default | Description |
50
+ | ------ | ---- | ------- | ----------- |
51
+ | `language` | `string` | `"image-compare"` | Fenced code block language |
52
+
53
+ ## Block fields
54
+
55
+ | Field | Type | Default | Description |
56
+ | ----- | ---- | ------- | ----------- |
57
+ | `before` | `string` | Required | Before image path |
58
+ | `after` | `string` | Required | After image path |
59
+ | `beforeAlt` | `string` | `"Before"` | Before image alternative text |
60
+ | `afterAlt` | `string` | `"After"` | After image alternative text |
61
+ | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | Slider axis |
62
+ | `label` | `string` | - | Caption below the comparison |
63
+
64
+ ## Example
65
+
66
+ ````markdown
67
+ ```image-compare
68
+ ---
69
+ before: ../../assets/themes/theme-default-light.png
70
+ after: ../../assets/themes/theme-default-dark.png
71
+ beforeAlt: Default theme in light mode
72
+ afterAlt: Default theme in dark mode
73
+ label: Default theme, light to dark
74
+ ---
75
+ ```
76
+ ````
77
+
78
+ ```image-compare
79
+ ---
80
+ before: ../../assets/themes/theme-default-light.png
81
+ after: ../../assets/themes/theme-default-dark.png
82
+ beforeAlt: Default theme in light mode
83
+ afterAlt: Default theme in dark mode
84
+ label: Default theme, light to dark
85
+ ---
86
+ ```
87
+
88
+ ```image-compare
89
+ ---
90
+ before: ../../assets/themes/theme-default-light.png
91
+ after: ../../assets/themes/theme-default-dark.png
92
+ beforeAlt: Default theme in light mode
93
+ afterAlt: Default theme in dark mode
94
+ orientation: vertical
95
+ label: Vertical comparison
96
+ ---
97
+ ```
98
+
99
+ ## Output and accessibility
100
+
101
+ The static figure lists both images with visible Before and After labels. When
102
+ JavaScript runs, the plugin hides the static list and exposes the interactive
103
+ stage. The range input covers the stage, keeps its native keyboard behavior,
104
+ and shows a focus outline on the stage. The after image is clipped with
105
+ `clip-path`, so neither image is repositioned or rescaled while dragging. Each
106
+ image keeps its natural aspect ratio and the stage grows to the taller image.
107
+ Give both screenshots the same width so their content lines up at the split;
108
+ different heights are fine.
109
+
110
+ Styles use the existing `--rb-color-*` theme tokens and work in Default, Light,
111
+ and Dark themes. No gradients, glass effects, excessive rounding, or animations
112
+ are used.
113
+
114
+ ## Diagnostics
115
+
116
+ | Code | Severity | Meaning |
117
+ | ---- | -------- | ------- |
118
+ | `image-compare-invalid` | `error` | The block is malformed, an image is missing, or an image path is not supported. The block is replaced by an error box |
119
+
120
+ ## Related
121
+
122
+ - [Gallery](../gallery/README.md)
123
+ - [Plugin system](https://github.com/Rerurate514/riebeckite/blob/main/docs/docs/reference/plugin-api.md)
package/README_ja.md ADDED
@@ -0,0 +1,107 @@
1
+ # @riebeckite/plugin-image-compare
2
+
3
+ <!-- Generated from docs/docs/plugins/image-compare.ja.md. Edit the canonical documentation in docs/docs/plugins and run `pnpm docs:sync`. -->
4
+
5
+ `image-compare` フェンスコードブロックから、ビフォー・アフター比較スライダーを生成します。スライダーはビルド時に HTML を出力し、小さなクライアントスクリプトで操作を追加します。JavaScript が動かない場合も 2 枚の画像を並べて読めます。
6
+
7
+ [English](./README.md)
8
+
9
+ ## 概要
10
+
11
+ ````markdown
12
+ ```image-compare
13
+ before: ./before.png
14
+ after: ../assets/after.png
15
+ beforeAlt: 変更前
16
+ afterAlt: 変更後
17
+ orientation: horizontal
18
+ label: ホームページ
19
+ ```
20
+ ````
21
+
22
+ `before` と `after` は必須です。画像パスは Markdown 画像と同じ規則でノートからの相対パスとして解決します。外部 URL、プロトコル相対 URL、コンテンツディレクトリの外へ出るパスは拒否します。
23
+
24
+ ブロックは `<figure>` とネイティブの range input になります。マウス、タッチ、キーボードのすべてで操作でき、1 ページに複数のブロックを置けます。SPA でページが置き換わると、各スライダーのリスナーは破棄されます。
25
+
26
+ ## 設定
27
+
28
+ ```ts
29
+ import { defineConfig } from "@riebeckite/core";
30
+ import { imageCompare } from "@riebeckite/plugin-image-compare";
31
+
32
+ export default defineConfig({
33
+ // ...
34
+ plugins: [imageCompare()],
35
+ });
36
+ ```
37
+
38
+ プラグインは専用のスタイルシートとページ単位のクライアントエントリを登録します。無効にした場合は何も出力しません。
39
+
40
+ ## オプション
41
+
42
+ | オプション | 型 | 既定値 | 内容 |
43
+ | --- | --- | --- | --- |
44
+ | `language` | `string` | `"image-compare"` | フェンスコードブロックの言語 |
45
+
46
+ ## ブロックのフィールド
47
+
48
+ | フィールド | 型 | 既定値 | 内容 |
49
+ | --- | --- | --- | --- |
50
+ | `before` | `string` | 必須 | 変更前の画像パス |
51
+ | `after` | `string` | 必須 | 変更後の画像パス |
52
+ | `beforeAlt` | `string` | `"Before"` | 変更前画像の代替テキスト |
53
+ | `afterAlt` | `string` | `"After"` | 変更後画像の代替テキスト |
54
+ | `orientation` | `"horizontal" \| "vertical"` | `"horizontal"` | スライダーの軸 |
55
+ | `label` | `string` | - | 比較の下に出すキャプション |
56
+
57
+ ## 使用例
58
+
59
+ ````markdown
60
+ ```image-compare
61
+ ---
62
+ before: ../../assets/themes/theme-default-light.png
63
+ after: ../../assets/themes/theme-default-dark.png
64
+ beforeAlt: ライトモードの Default テーマ
65
+ afterAlt: ダークモードの Default テーマ
66
+ label: Default テーマのライト表示とダーク表示
67
+ ---
68
+ ```
69
+ ````
70
+
71
+ ```image-compare
72
+ ---
73
+ before: ../../assets/themes/theme-default-light.png
74
+ after: ../../assets/themes/theme-default-dark.png
75
+ beforeAlt: ライトモードの Default テーマ
76
+ afterAlt: ダークモードの Default テーマ
77
+ label: Default テーマのライト表示とダーク表示
78
+ ---
79
+ ```
80
+
81
+ ```image-compare
82
+ ---
83
+ before: ../../assets/themes/theme-default-light.png
84
+ after: ../../assets/themes/theme-default-dark.png
85
+ beforeAlt: ライトモードの Default テーマ
86
+ afterAlt: ダークモードの Default テーマ
87
+ orientation: vertical
88
+ label: 縦方向の比較
89
+ ---
90
+ ```
91
+
92
+ ## 出力とアクセシビリティ
93
+
94
+ 静的な figure には 2 枚の画像と Before / After のラベルを表示します。JavaScript が動くと静的な一覧を隠し、操作可能なステージを表示します。range input はステージ全体を覆い、ネイティブのキーボード操作を保ち、フォーカス時はステージに輪郭を出します。変更後の画像は `clip-path` で切り抜くため、ドラッグ中に画像の位置や縮尺は変わりません。各画像は元の縦横比のまま表示され、ステージの高さは高い方の画像に合わせて広がります。2 枚は同じ幅で撮影すると切り替え位置で内容がそろいます。高さが違っても構いません。
95
+
96
+ スタイルは既存の `--rb-color-*` テーマトークンを使い、Default、Light、Dark の各テーマで動作します。グラデーション、ガラス効果、過剰な角丸、アニメーションは使いません。
97
+
98
+ ## 診断
99
+
100
+ | コード | 重大度 | 内容 |
101
+ | --- | --- | --- |
102
+ | `image-compare-invalid` | `error` | ブロックが不正、画像が見つからない、または画像パスが未対応。ブロックはエラーボックスに置き換わります |
103
+
104
+ ## 関連資料
105
+
106
+ - [Gallery](../gallery/README_ja.md)
107
+ - [プラグインシステム](https://github.com/Rerurate514/riebeckite/blob/main/docs/docs/reference/plugin-api.ja.md)
@@ -0,0 +1 @@
1
+ export { initImageCompare } from "./src/init.js";
package/dist/client.js ADDED
@@ -0,0 +1,61 @@
1
+ // src/init.ts
2
+ function initImageCompare(context = {}) {
3
+ const root = context.root ?? document;
4
+ const cleanups = [];
5
+ for (const figure of root.querySelectorAll(
6
+ "[data-rr-image-compare]"
7
+ )) {
8
+ if (figure.dataset.enhanced === "true") continue;
9
+ const input = figure.querySelector(
10
+ "[data-image-compare-range]"
11
+ );
12
+ if (!input) continue;
13
+ const stage = input.closest(".rr-image-compare__stage") ?? figure;
14
+ const vertical = figure.dataset.orientation === "vertical";
15
+ const update = () => {
16
+ figure.style.setProperty(
17
+ "--rr-image-compare-position",
18
+ `${input.value}%`
19
+ );
20
+ };
21
+ const setFromPointer = (event) => {
22
+ const bounds = stage.getBoundingClientRect();
23
+ if (bounds.width === 0 || bounds.height === 0) return;
24
+ const ratio = vertical ? (event.clientY - bounds.top) / bounds.height : (event.clientX - bounds.left) / bounds.width;
25
+ input.value = String(Math.round(Math.min(1, Math.max(0, ratio)) * 100));
26
+ update();
27
+ };
28
+ const onPointerDown = (event) => {
29
+ event.preventDefault();
30
+ input.focus({ preventScroll: true });
31
+ input.setPointerCapture(event.pointerId);
32
+ setFromPointer(event);
33
+ };
34
+ const onPointerMove = (event) => {
35
+ if (!input.hasPointerCapture(event.pointerId)) return;
36
+ event.preventDefault();
37
+ setFromPointer(event);
38
+ };
39
+ const reset = () => {
40
+ delete figure.dataset.enhanced;
41
+ figure.style.removeProperty("--rr-image-compare-position");
42
+ };
43
+ figure.dataset.enhanced = "true";
44
+ update();
45
+ input.addEventListener("input", update);
46
+ input.addEventListener("pointerdown", onPointerDown);
47
+ input.addEventListener("pointermove", onPointerMove);
48
+ cleanups.push(() => {
49
+ input.removeEventListener("input", update);
50
+ input.removeEventListener("pointerdown", onPointerDown);
51
+ input.removeEventListener("pointermove", onPointerMove);
52
+ reset();
53
+ });
54
+ }
55
+ return () => {
56
+ for (const cleanup of cleanups) cleanup();
57
+ };
58
+ }
59
+ export {
60
+ initImageCompare
61
+ };
@@ -0,0 +1,9 @@
1
+ import type { ImageCompareOptions } from "./src/types.js";
2
+ export { initImageCompare } from "./src/init.js";
3
+ export { parseImageCompare } from "./src/parse.js";
4
+ export { createImageComparePlaceholder, createImageComparePlaceholderPattern, decodeImageCompareSource, encodeImageCompareSource, IMAGE_COMPARE_ATTRIBUTE, } from "./src/placeholder.js";
5
+ export { remarkImageCompare } from "./src/remark.js";
6
+ export { IMAGE_COMPARE_CLASS, renderImageCompare, renderImageCompareError, } from "./src/render.js";
7
+ export type { ImageCompareOptions, ImageCompareOrientation, ImageCompareParseResult, ImageCompareSpec, ResolvedImageCompareSpec, } from "./src/types.js";
8
+ export declare const IMAGE_COMPARE_PLUGIN_NAME = "image-compare";
9
+ export declare function imageCompare(options?: ImageCompareOptions): import("@riebeckite/core").RiebeckitePlugin<ImageCompareOptions>;
package/dist/index.js ADDED
@@ -0,0 +1,330 @@
1
+ // index.ts
2
+ import {
3
+ createClientEntry,
4
+ createStyleAsset,
5
+ definePlugin
6
+ } from "@riebeckite/core";
7
+
8
+ // src/remark.ts
9
+ import { visit } from "unist-util-visit";
10
+
11
+ // src/placeholder.ts
12
+ var IMAGE_COMPARE_ATTRIBUTE = "data-rr-image-compare-source";
13
+ function encodeImageCompareSource(source) {
14
+ return encodeURIComponent(source);
15
+ }
16
+ function decodeImageCompareSource(encoded) {
17
+ return decodeURIComponent(encoded);
18
+ }
19
+ function createImageComparePlaceholder(source) {
20
+ return `<div ${IMAGE_COMPARE_ATTRIBUTE}="${encodeImageCompareSource(source)}"></div>`;
21
+ }
22
+ function createImageComparePlaceholderPattern() {
23
+ return new RegExp(
24
+ `<div\\b[^>]*\\b${IMAGE_COMPARE_ATTRIBUTE}="([^"]*)"[^>]*>\\s*</div>`,
25
+ "g"
26
+ );
27
+ }
28
+
29
+ // src/remark.ts
30
+ function remarkImageCompare(options = {}) {
31
+ const language = options.language ?? "image-compare";
32
+ return (tree) => {
33
+ visit(tree, "code", (node, index, parent) => {
34
+ if (node.lang !== language) return;
35
+ if (!parent || index === void 0) return;
36
+ const html = {
37
+ type: "html",
38
+ value: createImageComparePlaceholder(node.value)
39
+ };
40
+ parent.children.splice(index, 1, html);
41
+ });
42
+ };
43
+ }
44
+
45
+ // src/runtime.ts
46
+ import {
47
+ resolveContentAssetUrl
48
+ } from "@riebeckite/core";
49
+
50
+ // src/parse.ts
51
+ import { matter } from "vfile-matter";
52
+ var ImageCompareParseError = class extends Error {
53
+ };
54
+ function parseImageCompare(source) {
55
+ try {
56
+ const root = parseMapping(source);
57
+ const before = readString(root.before);
58
+ const after = readString(root.after);
59
+ if (!before) {
60
+ throw new ImageCompareParseError("must define a `before` image.");
61
+ }
62
+ if (!after) {
63
+ throw new ImageCompareParseError("must define an `after` image.");
64
+ }
65
+ const orientation = parseOrientation(root.orientation);
66
+ const label = readString(root.label);
67
+ const spec = {
68
+ before,
69
+ after,
70
+ beforeAlt: readString(root.beforeAlt) ?? "Before",
71
+ afterAlt: readString(root.afterAlt) ?? "After",
72
+ orientation,
73
+ ...label ? { label } : {}
74
+ };
75
+ return { ok: true, spec };
76
+ } catch (error) {
77
+ if (error instanceof ImageCompareParseError) {
78
+ return { ok: false, reason: error.message };
79
+ }
80
+ throw error;
81
+ }
82
+ }
83
+ function parseMapping(source) {
84
+ let parsed;
85
+ try {
86
+ parsed = parseYamlMapping(source);
87
+ } catch (error) {
88
+ throw new ImageCompareParseError(
89
+ `is not valid YAML (${formatError(error)}).`
90
+ );
91
+ }
92
+ if (parsed === null || parsed === void 0) return {};
93
+ if (typeof parsed !== "object" || Array.isArray(parsed)) {
94
+ throw new ImageCompareParseError("must be a YAML mapping.");
95
+ }
96
+ return parsed;
97
+ }
98
+ function parseOrientation(value) {
99
+ if (value === void 0 || value === null) return "horizontal";
100
+ if (value === "horizontal" || value === "vertical") return value;
101
+ throw new ImageCompareParseError(
102
+ '`orientation` must be "horizontal" or "vertical".'
103
+ );
104
+ }
105
+ function readString(value) {
106
+ if (typeof value === "string") return value.trim() || void 0;
107
+ if (typeof value === "number" || typeof value === "boolean") {
108
+ return String(value);
109
+ }
110
+ return void 0;
111
+ }
112
+ function parseYamlMapping(source) {
113
+ const document2 = `---
114
+ ${source}
115
+ ---
116
+ `;
117
+ const file = {
118
+ value: document2,
119
+ data: {},
120
+ toString: () => document2
121
+ };
122
+ matter(file);
123
+ return file.data.matter;
124
+ }
125
+ function formatError(error) {
126
+ return error instanceof Error ? error.message : String(error);
127
+ }
128
+
129
+ // src/render.ts
130
+ import { escapeHtml, escapeHtmlAttribute } from "@riebeckite/core";
131
+ var IMAGE_COMPARE_CLASS = "rr-image-compare";
132
+ function renderImageCompare(spec) {
133
+ const label = spec.label ?? "Image comparison";
134
+ const before = `<div class="${IMAGE_COMPARE_CLASS}__layer ${IMAGE_COMPARE_CLASS}__layer--before"><img class="${IMAGE_COMPARE_CLASS}__image ${IMAGE_COMPARE_CLASS}__image--before" src="${escapeHtmlAttribute(spec.before)}" alt="${escapeHtmlAttribute(spec.beforeAlt)}" loading="eager" decoding="async"></div>`;
135
+ const after = `<div class="${IMAGE_COMPARE_CLASS}__layer ${IMAGE_COMPARE_CLASS}__layer--after"><img class="${IMAGE_COMPARE_CLASS}__image ${IMAGE_COMPARE_CLASS}__image--after" src="${escapeHtmlAttribute(spec.after)}" alt="${escapeHtmlAttribute(spec.afterAlt)}" loading="eager" decoding="async"></div>`;
136
+ return [
137
+ `<figure class="${IMAGE_COMPARE_CLASS}" data-rr-image-compare data-orientation="${spec.orientation}" style="--rr-image-compare-position:50%" aria-label="${escapeHtmlAttribute(label)}">`,
138
+ `<div class="${IMAGE_COMPARE_CLASS}__static">`,
139
+ `<span class="${IMAGE_COMPARE_CLASS}__static-item"><img src="${escapeHtmlAttribute(spec.before)}" alt="${escapeHtmlAttribute(spec.beforeAlt)}" loading="lazy" decoding="async"><span>Before</span></span>`,
140
+ `<span class="${IMAGE_COMPARE_CLASS}__static-item"><img src="${escapeHtmlAttribute(spec.after)}" alt="${escapeHtmlAttribute(spec.afterAlt)}" loading="lazy" decoding="async"><span>After</span></span>`,
141
+ "</div>",
142
+ `<div class="${IMAGE_COMPARE_CLASS}__stage">`,
143
+ before,
144
+ after,
145
+ `<input class="${IMAGE_COMPARE_CLASS}__range" type="range" min="0" max="100" value="50" step="1" aria-label="Comparison position" data-image-compare-range>`,
146
+ `<span class="${IMAGE_COMPARE_CLASS}__divider" aria-hidden="true"></span>`,
147
+ "</div>",
148
+ spec.label ? `<figcaption class="${IMAGE_COMPARE_CLASS}__caption">${escapeHtml(spec.label)}</figcaption>` : "",
149
+ "</figure>"
150
+ ].join("");
151
+ }
152
+ function renderImageCompareError(message) {
153
+ return `<div class="${IMAGE_COMPARE_CLASS} ${IMAGE_COMPARE_CLASS}--error" role="status">${escapeHtml(message)}</div>`;
154
+ }
155
+
156
+ // src/runtime.ts
157
+ function createImageCompareRuntime() {
158
+ return {
159
+ resolve(manifest, diagnostics) {
160
+ for (const entry of manifest.entries) {
161
+ if (!entry.html.includes(IMAGE_COMPARE_ATTRIBUTE)) continue;
162
+ const pattern = createImageComparePlaceholderPattern();
163
+ entry.html = entry.html.replace(
164
+ pattern,
165
+ (_match, encoded) => resolveBlock(entry.slug, encoded, diagnostics)
166
+ );
167
+ }
168
+ }
169
+ };
170
+ }
171
+ function resolveBlock(slug, encoded, diagnostics) {
172
+ let source;
173
+ try {
174
+ source = decodeImageCompareSource(encoded);
175
+ } catch (error) {
176
+ return fail(
177
+ slug,
178
+ `Image comparison block in \`${slug}\` could not be decoded (${formatError2(error)}).`,
179
+ diagnostics
180
+ );
181
+ }
182
+ const parsed = parseImageCompare(source);
183
+ if (parsed.ok === false) {
184
+ return fail(
185
+ slug,
186
+ `Image comparison block in \`${slug}\` ${parsed.reason}`,
187
+ diagnostics
188
+ );
189
+ }
190
+ const before = resolveContentAssetUrl(parsed.spec.before, slug);
191
+ const after = resolveContentAssetUrl(parsed.spec.after, slug);
192
+ if (!before || !after) {
193
+ const invalid = !before ? parsed.spec.before : parsed.spec.after;
194
+ return fail(
195
+ slug,
196
+ `Image comparison block in \`${slug}\` references an unsupported image: "${invalid}".`,
197
+ diagnostics
198
+ );
199
+ }
200
+ return renderImageCompare({
201
+ ...parsed.spec,
202
+ before: before.url,
203
+ after: after.url
204
+ });
205
+ }
206
+ function fail(slug, message, diagnostics) {
207
+ diagnostics.push({
208
+ code: "image-compare-invalid",
209
+ severity: "error",
210
+ pluginName: "image-compare",
211
+ slug,
212
+ message
213
+ });
214
+ return renderImageCompareError(message);
215
+ }
216
+ function formatError2(error) {
217
+ return error instanceof Error ? error.message : String(error);
218
+ }
219
+
220
+ // src/init.ts
221
+ function initImageCompare(context = {}) {
222
+ const root = context.root ?? document;
223
+ const cleanups = [];
224
+ for (const figure of root.querySelectorAll(
225
+ "[data-rr-image-compare]"
226
+ )) {
227
+ if (figure.dataset.enhanced === "true") continue;
228
+ const input = figure.querySelector(
229
+ "[data-image-compare-range]"
230
+ );
231
+ if (!input) continue;
232
+ const stage = input.closest(".rr-image-compare__stage") ?? figure;
233
+ const vertical = figure.dataset.orientation === "vertical";
234
+ const update = () => {
235
+ figure.style.setProperty(
236
+ "--rr-image-compare-position",
237
+ `${input.value}%`
238
+ );
239
+ };
240
+ const setFromPointer = (event) => {
241
+ const bounds = stage.getBoundingClientRect();
242
+ if (bounds.width === 0 || bounds.height === 0) return;
243
+ const ratio = vertical ? (event.clientY - bounds.top) / bounds.height : (event.clientX - bounds.left) / bounds.width;
244
+ input.value = String(Math.round(Math.min(1, Math.max(0, ratio)) * 100));
245
+ update();
246
+ };
247
+ const onPointerDown = (event) => {
248
+ event.preventDefault();
249
+ input.focus({ preventScroll: true });
250
+ input.setPointerCapture(event.pointerId);
251
+ setFromPointer(event);
252
+ };
253
+ const onPointerMove = (event) => {
254
+ if (!input.hasPointerCapture(event.pointerId)) return;
255
+ event.preventDefault();
256
+ setFromPointer(event);
257
+ };
258
+ const reset = () => {
259
+ delete figure.dataset.enhanced;
260
+ figure.style.removeProperty("--rr-image-compare-position");
261
+ };
262
+ figure.dataset.enhanced = "true";
263
+ update();
264
+ input.addEventListener("input", update);
265
+ input.addEventListener("pointerdown", onPointerDown);
266
+ input.addEventListener("pointermove", onPointerMove);
267
+ cleanups.push(() => {
268
+ input.removeEventListener("input", update);
269
+ input.removeEventListener("pointerdown", onPointerDown);
270
+ input.removeEventListener("pointermove", onPointerMove);
271
+ reset();
272
+ });
273
+ }
274
+ return () => {
275
+ for (const cleanup of cleanups) cleanup();
276
+ };
277
+ }
278
+
279
+ // index.ts
280
+ var IMAGE_COMPARE_PLUGIN_NAME = "image-compare";
281
+ function imageCompare(options = {}) {
282
+ const resolved = { language: options.language ?? "image-compare" };
283
+ const runtime = createImageCompareRuntime();
284
+ return definePlugin({
285
+ name: IMAGE_COMPARE_PLUGIN_NAME,
286
+ processedContentCache: {
287
+ version: "image-compare-v1",
288
+ dependencyMode: "none"
289
+ },
290
+ options,
291
+ extendMarkdownPipeline: (pipeline) => {
292
+ pipeline.use(remarkImageCompare, { language: resolved.language });
293
+ },
294
+ onManifestCreated: (context) => {
295
+ runtime.resolve(context.manifest, context.diagnostics);
296
+ },
297
+ assets: [
298
+ createStyleAsset(
299
+ IMAGE_COMPARE_PLUGIN_NAME,
300
+ "@riebeckite/plugin-image-compare/style.css"
301
+ )
302
+ ],
303
+ clientEntries: [
304
+ createClientEntry(
305
+ IMAGE_COMPARE_PLUGIN_NAME,
306
+ "@riebeckite/plugin-image-compare/client",
307
+ "initImageCompare",
308
+ void 0,
309
+ "page",
310
+ "context",
311
+ "[data-rr-image-compare]"
312
+ )
313
+ ]
314
+ });
315
+ }
316
+ export {
317
+ IMAGE_COMPARE_ATTRIBUTE,
318
+ IMAGE_COMPARE_CLASS,
319
+ IMAGE_COMPARE_PLUGIN_NAME,
320
+ createImageComparePlaceholder,
321
+ createImageComparePlaceholderPattern,
322
+ decodeImageCompareSource,
323
+ encodeImageCompareSource,
324
+ imageCompare,
325
+ initImageCompare,
326
+ parseImageCompare,
327
+ remarkImageCompare,
328
+ renderImageCompare,
329
+ renderImageCompareError
330
+ };
@@ -0,0 +1,5 @@
1
+ type ImageCompareContext = {
2
+ root?: ParentNode;
3
+ };
4
+ export declare function initImageCompare(context?: ImageCompareContext): () => void;
5
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { ImageCompareParseResult } from "./types.js";
2
+ export declare function parseImageCompare(source: string): ImageCompareParseResult;
@@ -0,0 +1,5 @@
1
+ export declare const IMAGE_COMPARE_ATTRIBUTE = "data-rr-image-compare-source";
2
+ export declare function encodeImageCompareSource(source: string): string;
3
+ export declare function decodeImageCompareSource(encoded: string): string;
4
+ export declare function createImageComparePlaceholder(source: string): string;
5
+ export declare function createImageComparePlaceholderPattern(): RegExp;
@@ -0,0 +1,6 @@
1
+ import type { Root } from "mdast";
2
+ type RemarkImageCompareOptions = {
3
+ language?: string;
4
+ };
5
+ export declare function remarkImageCompare(options?: RemarkImageCompareOptions): (tree: Root) => void;
6
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { ResolvedImageCompareSpec } from "./types.js";
2
+ export declare const IMAGE_COMPARE_CLASS = "rr-image-compare";
3
+ export declare function renderImageCompare(spec: ResolvedImageCompareSpec): string;
4
+ export declare function renderImageCompareError(message: string): string;
@@ -0,0 +1,4 @@
1
+ import { type ContentManifest, type Diagnostic } from "@riebeckite/core";
2
+ export declare function createImageCompareRuntime(): {
3
+ resolve(manifest: ContentManifest, diagnostics: Diagnostic[]): void;
4
+ };
@@ -0,0 +1,24 @@
1
+ export type ImageCompareOrientation = "horizontal" | "vertical";
2
+ export type ImageCompareOptions = {
3
+ /** Fenced code block language treated as an image comparison. */
4
+ language?: string;
5
+ };
6
+ export type ImageCompareSpec = {
7
+ readonly before: string;
8
+ readonly after: string;
9
+ readonly beforeAlt: string;
10
+ readonly afterAlt: string;
11
+ readonly orientation: ImageCompareOrientation;
12
+ readonly label?: string;
13
+ };
14
+ export type ResolvedImageCompareSpec = Omit<ImageCompareSpec, "before" | "after"> & {
15
+ readonly before: string;
16
+ readonly after: string;
17
+ };
18
+ export type ImageCompareParseResult = {
19
+ readonly ok: true;
20
+ readonly spec: ImageCompareSpec;
21
+ } | {
22
+ readonly ok: false;
23
+ readonly reason: string;
24
+ };
package/package.json CHANGED
@@ -1,6 +1,69 @@
1
1
  {
2
2
  "name": "@riebeckite/plugin-image-compare",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.37",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "source": "./index.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./client": {
16
+ "types": "./dist/client.d.ts",
17
+ "import": "./dist/client.js",
18
+ "source": "./client.ts",
19
+ "default": "./dist/client.js"
20
+ },
21
+ "./style.css": "./style.css"
22
+ },
23
+ "dependencies": {
24
+ "@riebeckite/core": "0.0.37",
25
+ "@types/mdast": "^4.0.4",
26
+ "unist-util-visit": "^5.1.0",
27
+ "vfile-matter": "^5.0.1"
28
+ },
29
+ "devDependencies": {
30
+ "tsx": "^4.22.4"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "files": [
36
+ "LICENSE",
37
+ "README.md",
38
+ "README_ja.md",
39
+ "dist",
40
+ "style.css"
41
+ ],
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/Rerurate514/riebeckite.git",
45
+ "directory": "packages/plugins/image-compare"
46
+ },
47
+ "homepage": "https://github.com/Rerurate514/riebeckite#readme",
48
+ "bugs": {
49
+ "url": "https://github.com/Rerurate514/riebeckite/issues"
50
+ },
51
+ "description": "Before/after image comparison sliders for Riebeckite code blocks.",
52
+ "keywords": [
53
+ "riebeckite",
54
+ "plugin",
55
+ "image",
56
+ "comparison",
57
+ "slider"
58
+ ],
59
+ "engines": {
60
+ "node": "^20.19.0 || >=22.12.0"
61
+ },
62
+ "sideEffects": [
63
+ "./style.css"
64
+ ],
65
+ "scripts": {
66
+ "build": "node ../../../scripts/build_package.mjs",
67
+ "test": "node --import tsx --test \"test/*.test.ts\""
68
+ }
6
69
  }
package/style.css ADDED
@@ -0,0 +1,202 @@
1
+ .rr-image-compare {
2
+ --rr-image-compare-position: 50%;
3
+
4
+ margin-block: 1.5rem;
5
+ }
6
+
7
+ .rr-image-compare__static {
8
+ position: relative;
9
+ display: grid;
10
+ grid-template-areas: "compare";
11
+ overflow: hidden;
12
+ border: 1px solid var(--rb-color-border, #d0d0d0);
13
+ background: var(--rb-color-surface, transparent);
14
+ }
15
+
16
+ .rr-image-compare__static::after {
17
+ position: absolute;
18
+ top: 0;
19
+ bottom: 0;
20
+ left: 50%;
21
+ width: 1px;
22
+ background: var(--rb-color-paper, #fff);
23
+ box-shadow: 0 0 0 1px var(--rb-color-border-strong, #9a9a9a);
24
+ content: "";
25
+ pointer-events: none;
26
+ }
27
+
28
+ .rr-image-compare[data-orientation="vertical"]
29
+ .rr-image-compare__static::after {
30
+ top: 50%;
31
+ right: 0;
32
+ bottom: auto;
33
+ left: 0;
34
+ width: auto;
35
+ height: 1px;
36
+ }
37
+
38
+ .rr-image-compare__static-item {
39
+ position: relative;
40
+ display: block;
41
+ grid-area: compare;
42
+ }
43
+
44
+ .rr-image-compare__static-item img {
45
+ display: block;
46
+ width: 100%;
47
+ height: 100%;
48
+ object-fit: cover;
49
+ }
50
+
51
+ .rr-image-compare__static-item:first-child img {
52
+ clip-path: inset(0 50% 0 0);
53
+ }
54
+
55
+ .rr-image-compare__static-item:last-child img {
56
+ clip-path: inset(0 0 0 50%);
57
+ }
58
+
59
+ .rr-image-compare[data-orientation="vertical"]
60
+ .rr-image-compare__static-item:first-child
61
+ img {
62
+ clip-path: inset(0 0 50% 0);
63
+ }
64
+
65
+ .rr-image-compare[data-orientation="vertical"]
66
+ .rr-image-compare__static-item:last-child
67
+ img {
68
+ clip-path: inset(50% 0 0 0);
69
+ }
70
+
71
+ .rr-image-compare__static-item span {
72
+ position: absolute;
73
+ bottom: 0.5rem;
74
+ padding: 0.125rem 0.375rem;
75
+ border-radius: 0.125rem;
76
+ background: var(--rb-color-surface, #fff);
77
+ color: var(--rb-color-muted, #69645c);
78
+ font-size: 0.75rem;
79
+ }
80
+
81
+ .rr-image-compare__static-item:first-child span {
82
+ left: 0.5rem;
83
+ }
84
+
85
+ .rr-image-compare__static-item:last-child span {
86
+ right: 0.5rem;
87
+ }
88
+
89
+ .rr-image-compare[data-orientation="vertical"]
90
+ .rr-image-compare__static-item:first-child
91
+ span {
92
+ bottom: auto;
93
+ top: 0.5rem;
94
+ }
95
+
96
+ .rr-image-compare[data-orientation="vertical"]
97
+ .rr-image-compare__static-item:last-child
98
+ span {
99
+ bottom: 0.5rem;
100
+ }
101
+
102
+ .rr-image-compare__stage {
103
+ position: relative;
104
+ display: none;
105
+ overflow: hidden;
106
+ background: var(--rb-color-surface, transparent);
107
+ }
108
+
109
+ .rr-image-compare[data-enhanced="true"] .rr-image-compare__static {
110
+ display: none;
111
+ }
112
+
113
+ .rr-image-compare[data-enhanced="true"] .rr-image-compare__stage {
114
+ display: grid;
115
+ }
116
+
117
+ .rr-image-compare__image {
118
+ display: block;
119
+ width: 100%;
120
+ height: auto;
121
+ }
122
+
123
+ .rr-image-compare__layer {
124
+ grid-area: 1 / 1;
125
+ align-self: stretch;
126
+ }
127
+
128
+ .rr-image-compare .rr-image-compare__layer > * {
129
+ display: block;
130
+ }
131
+
132
+ .rr-image-compare__layer--after {
133
+ clip-path: inset(0 0 0 var(--rr-image-compare-position));
134
+ }
135
+
136
+ .rr-image-compare[data-orientation="vertical"] .rr-image-compare__layer--after {
137
+ clip-path: inset(var(--rr-image-compare-position) 0 0 0);
138
+ }
139
+
140
+ .rr-image-compare__divider {
141
+ position: absolute;
142
+ top: 0;
143
+ bottom: 0;
144
+ left: var(--rr-image-compare-position);
145
+ width: 1px;
146
+ background: var(--rb-color-paper, #fff);
147
+ box-shadow: 0 0 0 1px var(--rb-color-border-strong, #9a9a9a);
148
+ pointer-events: none;
149
+ }
150
+
151
+ .rr-image-compare[data-orientation="vertical"] .rr-image-compare__divider {
152
+ top: var(--rr-image-compare-position);
153
+ right: 0;
154
+ bottom: auto;
155
+ left: 0;
156
+ width: auto;
157
+ height: 1px;
158
+ }
159
+
160
+ .rr-image-compare__range {
161
+ position: absolute;
162
+ inset: 0;
163
+ z-index: 1;
164
+ width: 100%;
165
+ height: 100%;
166
+ margin: 0;
167
+ padding: 0;
168
+ border: 0;
169
+ opacity: 0;
170
+ background: transparent;
171
+ appearance: none;
172
+ touch-action: none;
173
+ cursor: ew-resize;
174
+ }
175
+
176
+ .rr-image-compare[data-orientation="vertical"] .rr-image-compare__range {
177
+ cursor: ns-resize;
178
+ }
179
+
180
+ .rr-image-compare__stage:has(.rr-image-compare__range:focus-visible) {
181
+ outline: 2px solid var(--rb-color-accent, currentColor);
182
+ outline-offset: 2px;
183
+ }
184
+
185
+ .rr-image-compare__caption {
186
+ margin-top: 0.5rem;
187
+ color: var(--rb-color-muted, #69645c);
188
+ font-size: 0.8125rem;
189
+ }
190
+
191
+ .rr-image-compare--error {
192
+ padding: 0.75rem 1rem;
193
+ border: 1px solid var(--rb-color-border, #d0d0d0);
194
+ border-left: 3px solid var(--rb-color-error, #b3261e);
195
+ font-size: 0.9375rem;
196
+ }
197
+
198
+ @media (prefers-contrast: more) {
199
+ .rr-image-compare__divider {
200
+ background: var(--rb-color-ink, #1c1a17);
201
+ }
202
+ }