@escape-game-over/atlas 0.1.80 → 0.1.81
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/package.json +1 -1
- package/src/astro/Image.astro +19 -1
- package/src/astro/Zoom.astro +3 -2
package/package.json
CHANGED
package/src/astro/Image.astro
CHANGED
|
@@ -8,7 +8,15 @@
|
|
|
8
8
|
* are made at standard device widths up to the source's own. A lazy image
|
|
9
9
|
* gets `auto` in front, so browsers that can measure the real width do.
|
|
10
10
|
*
|
|
11
|
-
* `zoom` opens the image larger in a dialog.
|
|
11
|
+
* `zoom` opens the image larger in a dialog. Its close button shows the `close`
|
|
12
|
+
* slot, the site's own icon, which `zoom` requires: a text `×` centres by the
|
|
13
|
+
* font's metrics, not the button's.
|
|
14
|
+
*
|
|
15
|
+
* ```astro
|
|
16
|
+
* <Image src={photo} alt={alt} sizes="33vw" zoom={{ closeLabel: t("close") }}>
|
|
17
|
+
* <Icon slot="close" name="lucide:x" />
|
|
18
|
+
* </Image>
|
|
19
|
+
* ```
|
|
12
20
|
*/
|
|
13
21
|
import { Picture } from "astro:assets";
|
|
14
22
|
import type { ComponentProps } from "astro/types";
|
|
@@ -49,6 +57,12 @@ const DEVICE_WIDTHS = [640, 750, 828, 1080, 1280, 1668, 1920, 2048, 2560, 3840];
|
|
|
49
57
|
const given = Astro.props;
|
|
50
58
|
const { src, alt, priority = false, zoom } = given;
|
|
51
59
|
|
|
60
|
+
if (zoom !== undefined && !Astro.slots.has("close")) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
`Image: "${alt}" zooms but has no close icon. Pass one: <Icon slot="close" …>.`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
const shape =
|
|
53
67
|
given.sizes !== undefined
|
|
54
68
|
? (() => {
|
|
@@ -97,5 +111,9 @@ const picture: ComponentProps<typeof Picture> = {
|
|
|
97
111
|
closeLabel={zoom.closeLabel}
|
|
98
112
|
class={zoom.class}>
|
|
99
113
|
<Picture {...picture} />
|
|
114
|
+
<slot
|
|
115
|
+
name='close'
|
|
116
|
+
slot='close'
|
|
117
|
+
/>
|
|
100
118
|
</Zoom>
|
|
101
119
|
)}
|
package/src/astro/Zoom.astro
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Internal to `Image.astro`. No script: `command="show-modal"` opens the dialog
|
|
4
4
|
* and `closedby="any"` lets a click outside close it. The large image is lazy
|
|
5
|
-
* inside a closed dialog, so it is fetched on open.
|
|
5
|
+
* inside a closed dialog, so it is fetched on open. The close button shows the
|
|
6
|
+
* `close` slot.
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
9
|
import { getImage } from "astro:assets";
|
|
@@ -47,7 +48,7 @@ const id = `atlas-zoom${large.src.replace(/[^\w-]/g, "-")}`;
|
|
|
47
48
|
command="close"
|
|
48
49
|
aria-label={closeLabel}
|
|
49
50
|
>
|
|
50
|
-
|
|
51
|
+
<slot name="close" />
|
|
51
52
|
</button>
|
|
52
53
|
<img
|
|
53
54
|
src={large.src}
|