@riebeckite/plugin-image-compare 0.0.36 → 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/dist/index.js +2 -2
- package/package.json +2 -2
- package/style.css +90 -13
package/dist/index.js
CHANGED
|
@@ -131,8 +131,8 @@ import { escapeHtml, escapeHtmlAttribute } from "@riebeckite/core";
|
|
|
131
131
|
var IMAGE_COMPARE_CLASS = "rr-image-compare";
|
|
132
132
|
function renderImageCompare(spec) {
|
|
133
133
|
const label = spec.label ?? "Image comparison";
|
|
134
|
-
const before = `<img class="${IMAGE_COMPARE_CLASS}__image ${IMAGE_COMPARE_CLASS}__image--before" src="${escapeHtmlAttribute(spec.before)}" alt="${escapeHtmlAttribute(spec.beforeAlt)}" loading="
|
|
135
|
-
const after = `<div class="${IMAGE_COMPARE_CLASS}__layer"><img class="${IMAGE_COMPARE_CLASS}__image ${IMAGE_COMPARE_CLASS}__image--after" src="${escapeHtmlAttribute(spec.after)}" alt="${escapeHtmlAttribute(spec.afterAlt)}" loading="
|
|
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
136
|
return [
|
|
137
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
138
|
`<div class="${IMAGE_COMPARE_CLASS}__static">`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riebeckite/plugin-image-compare",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.37",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"./style.css": "./style.css"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@riebeckite/core": "0.0.
|
|
24
|
+
"@riebeckite/core": "0.0.37",
|
|
25
25
|
"@types/mdast": "^4.0.4",
|
|
26
26
|
"unist-util-visit": "^5.1.0",
|
|
27
27
|
"vfile-matter": "^5.0.1"
|
package/style.css
CHANGED
|
@@ -5,24 +5,98 @@
|
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
.rr-image-compare__static {
|
|
8
|
+
position: relative;
|
|
8
9
|
display: grid;
|
|
9
|
-
grid-template-
|
|
10
|
-
|
|
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;
|
|
11
36
|
}
|
|
12
37
|
|
|
13
38
|
.rr-image-compare__static-item {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
color: var(--rb-color-muted, #69645c);
|
|
18
|
-
font-size: 0.8125rem;
|
|
39
|
+
position: relative;
|
|
40
|
+
display: block;
|
|
41
|
+
grid-area: compare;
|
|
19
42
|
}
|
|
20
43
|
|
|
21
44
|
.rr-image-compare__static-item img {
|
|
22
45
|
display: block;
|
|
23
46
|
width: 100%;
|
|
24
|
-
height:
|
|
25
|
-
|
|
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;
|
|
26
100
|
}
|
|
27
101
|
|
|
28
102
|
.rr-image-compare__stage {
|
|
@@ -46,17 +120,20 @@
|
|
|
46
120
|
height: auto;
|
|
47
121
|
}
|
|
48
122
|
|
|
49
|
-
.rr-image-compare__image--before,
|
|
50
123
|
.rr-image-compare__layer {
|
|
51
124
|
grid-area: 1 / 1;
|
|
125
|
+
align-self: stretch;
|
|
52
126
|
}
|
|
53
127
|
|
|
54
|
-
.rr-image-compare__layer {
|
|
55
|
-
|
|
128
|
+
.rr-image-compare .rr-image-compare__layer > * {
|
|
129
|
+
display: block;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.rr-image-compare__layer--after {
|
|
56
133
|
clip-path: inset(0 0 0 var(--rr-image-compare-position));
|
|
57
134
|
}
|
|
58
135
|
|
|
59
|
-
.rr-image-compare[data-orientation="vertical"] .rr-image-compare__layer {
|
|
136
|
+
.rr-image-compare[data-orientation="vertical"] .rr-image-compare__layer--after {
|
|
60
137
|
clip-path: inset(var(--rr-image-compare-position) 0 0 0);
|
|
61
138
|
}
|
|
62
139
|
|