@reuse-sh/lightbox 0.0.6 → 0.2.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 +65 -16
- package/dist/audio.d.ts +2 -0
- package/dist/audio.js +17 -0
- package/dist/base.css +602 -0
- package/dist/browser/audio.js +3 -0
- package/dist/browser/audio.js.map +1 -0
- package/dist/browser/carousel-link.js +3 -0
- package/dist/browser/carousel-link.js.map +1 -0
- package/dist/browser/embed.js +3 -0
- package/dist/browser/embed.js.map +1 -0
- package/dist/browser/html.js +3 -0
- package/dist/browser/html.js.map +1 -0
- package/dist/browser/iframe.js +3 -0
- package/dist/browser/iframe.js.map +1 -0
- package/dist/browser/lightbox.js +3 -0
- package/dist/browser/lightbox.js.map +1 -0
- package/dist/browser/video.js +3 -0
- package/dist/browser/video.js.map +1 -0
- package/dist/carousel.d.ts +6 -0
- package/dist/carousel.js +17 -0
- package/dist/chrome.d.ts +35 -0
- package/dist/chrome.js +53 -0
- package/dist/embed.d.ts +14 -0
- package/dist/embed.js +173 -0
- package/dist/geometry.d.ts +37 -1
- package/dist/geometry.js +75 -5
- package/dist/html.d.ts +2 -0
- package/dist/html.js +15 -0
- package/dist/icons.d.ts +15 -0
- package/dist/icons.js +40 -0
- package/dist/iframe.d.ts +8 -0
- package/dist/iframe.js +43 -0
- package/dist/index.d.ts +180 -47
- package/dist/index.js +3817 -398
- package/dist/react.d.ts +18 -9
- package/dist/react.js +71 -46
- package/dist/sources.d.ts +28 -0
- package/dist/sources.js +179 -0
- package/dist/theme.css +236 -0
- package/dist/themes/dark.css +12 -0
- package/dist/themes/light.css +12 -0
- package/dist/themes/page.css +28 -0
- package/dist/themes/photos.css +17 -0
- package/dist/unlayered/base.css +599 -0
- package/dist/unlayered/theme.css +233 -0
- package/dist/unlayered/themes/dark.css +9 -0
- package/dist/unlayered/themes/light.css +9 -0
- package/dist/unlayered/themes/page.css +25 -0
- package/dist/unlayered/themes/photos.css +14 -0
- package/dist/video.d.ts +3 -0
- package/dist/video.js +55 -0
- package/package.json +33 -4
- package/dist/styles.css +0 -218
package/dist/react.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { type Lightbox, type LightboxItem, type LightboxOptions, type LightboxState } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A lightbox for the component's lifetime. It is the same object on every render and holds no
|
|
4
|
+
* React state, so the component does not re-render on lightbox changes. Effect cleanup, on
|
|
5
|
+
* unmount, under StrictMode or when Activity hides the component, closes it at once and frees
|
|
6
|
+
* its DOM and listeners; it is never destroyed, so an effect that runs again opens it again. An
|
|
7
|
+
* option that changes reaches it through setOptions after the render; plain objects and arrays
|
|
8
|
+
* compare by value and functions by identity. container is read once.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useLightbox<Item extends LightboxItem = LightboxItem>(options?: LightboxOptions<Item>): Lightbox<Item>;
|
|
11
|
+
/**
|
|
12
|
+
* The part of a lightbox's state that selector picks, read with useSyncExternalStore. The
|
|
13
|
+
* component re-renders when the selected value changes by Object.is, so a selector that builds
|
|
14
|
+
* an object re-renders on each state change but never loops. The server and the hydrating render
|
|
15
|
+
* read the lightbox's state at creation, also when the lightbox opened before a boundary
|
|
16
|
+
* hydrates.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useLightboxState<Item extends LightboxItem, Selected>(lightbox: Lightbox<Item>, selector: (state: LightboxState<Item>) => Selected): Selected;
|
package/dist/react.js
CHANGED
|
@@ -1,52 +1,77 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useEffect,
|
|
2
|
+
import { useEffect, useRef, useState, useSyncExternalStore } from "react";
|
|
3
3
|
import { createLightbox, } from "./index.js";
|
|
4
|
+
const lightboxInternals = Symbol.for("@reuse-sh/lightbox internals");
|
|
5
|
+
function internalsOf(lightbox) {
|
|
6
|
+
return lightbox[lightboxInternals];
|
|
7
|
+
}
|
|
8
|
+
function isPlain(value) {
|
|
9
|
+
if (typeof value !== "object" || value === null)
|
|
10
|
+
return false;
|
|
11
|
+
const prototype = Object.getPrototypeOf(value);
|
|
12
|
+
return prototype === Object.prototype || prototype === null;
|
|
13
|
+
}
|
|
14
|
+
// Plain objects and arrays compare by value, everything else, functions included, by identity.
|
|
15
|
+
function same(a, b) {
|
|
16
|
+
if (Object.is(a, b))
|
|
17
|
+
return true;
|
|
18
|
+
if (Array.isArray(a))
|
|
19
|
+
return (Array.isArray(b) &&
|
|
20
|
+
a.length === b.length &&
|
|
21
|
+
a.every((value, index) => same(value, b[index])));
|
|
22
|
+
if (!isPlain(a) || !isPlain(b))
|
|
23
|
+
return false;
|
|
24
|
+
const keys = Object.keys(a);
|
|
25
|
+
return (keys.length === Object.keys(b).length &&
|
|
26
|
+
keys.every((key) => Object.hasOwn(b, key) && same(a[key], b[key])));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A lightbox for the component's lifetime. It is the same object on every render and holds no
|
|
30
|
+
* React state, so the component does not re-render on lightbox changes. Effect cleanup, on
|
|
31
|
+
* unmount, under StrictMode or when Activity hides the component, closes it at once and frees
|
|
32
|
+
* its DOM and listeners; it is never destroyed, so an effect that runs again opens it again. An
|
|
33
|
+
* option that changes reaches it through setOptions after the render; plain objects and arrays
|
|
34
|
+
* compare by value and functions by identity. container is read once.
|
|
35
|
+
*/
|
|
4
36
|
export function useLightbox(options = {}) {
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
37
|
+
const [lightbox] = useState(() => createLightbox(options));
|
|
38
|
+
const applied = useRef(options);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const changed = {};
|
|
41
|
+
const keys = new Set([
|
|
42
|
+
...Object.keys(options),
|
|
43
|
+
...Object.keys(applied.current),
|
|
44
|
+
]);
|
|
45
|
+
for (const key of keys)
|
|
46
|
+
if (key !== "container" && !same(options[key], applied.current[key]))
|
|
47
|
+
Object.assign(changed, { [key]: options[key] });
|
|
48
|
+
applied.current = options;
|
|
49
|
+
if (Object.keys(changed).length)
|
|
50
|
+
lightbox.setOptions(changed);
|
|
14
51
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!controller.current) {
|
|
18
|
-
controller.current = createLightbox({
|
|
19
|
-
...optionsRef.current,
|
|
20
|
-
onChange: (next) => {
|
|
21
|
-
setState(next);
|
|
22
|
-
optionsRef.current.onChange?.(next);
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
return controller.current;
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
open: (items, index) => ensure().open(items, index),
|
|
30
|
-
close: () => controller.current?.close() ?? Promise.resolve(),
|
|
31
|
-
next: () => controller.current?.next(),
|
|
32
|
-
prev: () => controller.current?.prev(),
|
|
33
|
-
goTo: (index) => controller.current?.goTo(index),
|
|
34
|
-
zoomTo: (scale, focus) => controller.current?.zoomTo(scale, focus),
|
|
35
|
-
toggleZoom: (focus) => controller.current?.toggleZoom(focus),
|
|
36
|
-
getState: () => ensure().getState(),
|
|
37
|
-
subscribe: (listener) => ensure().subscribe(listener),
|
|
38
|
-
destroy: () => {
|
|
39
|
-
controller.current?.destroy();
|
|
40
|
-
controller.current = null;
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}, []);
|
|
44
|
-
useEffect(() => () => {
|
|
45
|
-
controller.current?.destroy();
|
|
46
|
-
controller.current = null;
|
|
47
|
-
}, []);
|
|
48
|
-
return { ...handle, state };
|
|
52
|
+
useEffect(() => () => internalsOf(lightbox)?.release(), [lightbox]);
|
|
53
|
+
return lightbox;
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
/**
|
|
56
|
+
* The part of a lightbox's state that selector picks, read with useSyncExternalStore. The
|
|
57
|
+
* component re-renders when the selected value changes by Object.is, so a selector that builds
|
|
58
|
+
* an object re-renders on each state change but never loops. The server and the hydrating render
|
|
59
|
+
* read the lightbox's state at creation, also when the lightbox opened before a boundary
|
|
60
|
+
* hydrates.
|
|
61
|
+
*/
|
|
62
|
+
export function useLightboxState(lightbox, selector) {
|
|
63
|
+
// A cached value depends only on its state and selector, so an entry a discarded render
|
|
64
|
+
// wrote is still right for both.
|
|
65
|
+
const client = useRef(null);
|
|
66
|
+
const server = useRef(null);
|
|
67
|
+
const pick = (cache, state) => {
|
|
68
|
+
const last = cache.current;
|
|
69
|
+
if (last && last.state === state && last.selector === selector)
|
|
70
|
+
return last.value;
|
|
71
|
+
const value = selector(state);
|
|
72
|
+
cache.current = { state, selector, value };
|
|
73
|
+
return value;
|
|
74
|
+
};
|
|
75
|
+
const initial = internalsOf(lightbox)?.initial ?? lightbox.getState();
|
|
76
|
+
return useSyncExternalStore(lightbox.subscribe, () => pick(client, lightbox.getState()), () => pick(server, initial));
|
|
52
77
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type Candidate = {
|
|
2
|
+
url: string;
|
|
3
|
+
width?: number;
|
|
4
|
+
density?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare function parseSrcset(value: string): Candidate[];
|
|
7
|
+
/** The widest file a w-descriptor srcset offers, which a zoom can still fetch. */
|
|
8
|
+
export declare function largestWidth(srcset: string | undefined): number | undefined;
|
|
9
|
+
export declare function largestSource(srcset: string | undefined, src: string): string;
|
|
10
|
+
/** The file's own pixel width: a srcset makes naturalWidth a density-corrected size. */
|
|
11
|
+
export declare function fileWidth(image: HTMLImageElement, srcset: string | undefined, base: string): number;
|
|
12
|
+
export declare function isImageFile(url: string, base: string): boolean;
|
|
13
|
+
/** What a file's format says about its pixels: an SVG and an alpha-capable raster can be see-through. */
|
|
14
|
+
export type MediaFormat = "svg" | "transparent" | "opaque";
|
|
15
|
+
/** The format by the URL alone; undefined for a blob: URL or a path without an extension until lookupFormat has read its type. */
|
|
16
|
+
export declare function formatOf(url: string, base: string): MediaFormat | undefined;
|
|
17
|
+
/** Reads the type once per URL: a blob: URL's Blob type, else the Content-Type of a HEAD request. */
|
|
18
|
+
export declare function lookupFormat(url: string, base: string, fetcher: (url: string, init?: RequestInit) => Promise<Response>): Promise<MediaFormat>;
|
|
19
|
+
/** The root's width and height in absolute units, else the viewBox's, which also completes one of them. */
|
|
20
|
+
export declare function parseSvgSize(text: string, parser: DOMParser): {
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
} | undefined;
|
|
24
|
+
/** Fetches the SVG text, which works for same-origin, CORS, data: and blob: URLs. */
|
|
25
|
+
export declare function svgSize(url: string, fetcher: (url: string, init?: RequestInit) => Promise<Response>, parser: DOMParser): Promise<{
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
} | undefined>;
|
package/dist/sources.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
// The HTML candidate parser: a URL runs to whitespace, and a comma inside parentheses belongs to
|
|
2
|
+
// the descriptor.
|
|
3
|
+
export function parseSrcset(value) {
|
|
4
|
+
const candidates = [];
|
|
5
|
+
let at = 0;
|
|
6
|
+
while (at < value.length) {
|
|
7
|
+
while (at < value.length && /[\s,]/.test(value[at]))
|
|
8
|
+
at++;
|
|
9
|
+
if (at >= value.length)
|
|
10
|
+
break;
|
|
11
|
+
let start = at;
|
|
12
|
+
while (at < value.length && !/\s/.test(value[at]))
|
|
13
|
+
at++;
|
|
14
|
+
let url = value.slice(start, at);
|
|
15
|
+
let descriptor = "";
|
|
16
|
+
if (url.endsWith(","))
|
|
17
|
+
url = url.replace(/,+$/, "");
|
|
18
|
+
else {
|
|
19
|
+
start = at;
|
|
20
|
+
let depth = 0;
|
|
21
|
+
while (at < value.length && (value[at] !== "," || depth > 0)) {
|
|
22
|
+
if (value[at] === "(")
|
|
23
|
+
depth++;
|
|
24
|
+
else if (value[at] === ")")
|
|
25
|
+
depth--;
|
|
26
|
+
at++;
|
|
27
|
+
}
|
|
28
|
+
descriptor = value.slice(start, at).trim();
|
|
29
|
+
at++;
|
|
30
|
+
}
|
|
31
|
+
const width = /(?:^|\s)(\d+)w(?:\s|$)/.exec(descriptor);
|
|
32
|
+
const density = /(?:^|\s)(\d*\.?\d+(?:e[+-]?\d+)?)x(?:\s|$)/i.exec(descriptor);
|
|
33
|
+
candidates.push(width
|
|
34
|
+
? { url, width: Number(width[1]) }
|
|
35
|
+
: { url, density: density ? Number(density[1]) : 1 });
|
|
36
|
+
}
|
|
37
|
+
return candidates;
|
|
38
|
+
}
|
|
39
|
+
function resolve(url, base) {
|
|
40
|
+
try {
|
|
41
|
+
return new URL(url, base).href;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return url;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** The widest file a w-descriptor srcset offers, which a zoom can still fetch. */
|
|
48
|
+
export function largestWidth(srcset) {
|
|
49
|
+
let largest;
|
|
50
|
+
for (const { width } of parseSrcset(srcset ?? ""))
|
|
51
|
+
if (width && (!largest || width > largest))
|
|
52
|
+
largest = width;
|
|
53
|
+
return largest;
|
|
54
|
+
}
|
|
55
|
+
export function largestSource(srcset, src) {
|
|
56
|
+
let best;
|
|
57
|
+
for (const candidate of parseSrcset(srcset ?? ""))
|
|
58
|
+
if (!best ||
|
|
59
|
+
(candidate.width ?? 0) > (best.width ?? 0) ||
|
|
60
|
+
(!candidate.width &&
|
|
61
|
+
!best.width &&
|
|
62
|
+
(candidate.density ?? 1) > (best.density ?? 1)))
|
|
63
|
+
best = candidate;
|
|
64
|
+
return best?.url ?? src;
|
|
65
|
+
}
|
|
66
|
+
/** The file's own pixel width: a srcset makes naturalWidth a density-corrected size. */
|
|
67
|
+
export function fileWidth(image, srcset, base) {
|
|
68
|
+
const current = image.currentSrc || image.src;
|
|
69
|
+
const candidate = parseSrcset(srcset ?? "").find((entry) => resolve(entry.url, base) === current);
|
|
70
|
+
if (candidate?.width)
|
|
71
|
+
return candidate.width;
|
|
72
|
+
return image.naturalWidth * (candidate?.density ?? 1);
|
|
73
|
+
}
|
|
74
|
+
export function isImageFile(url, base) {
|
|
75
|
+
try {
|
|
76
|
+
return /\.(?:jpe?g|png|gif|webp|avif|svg)$/i.test(new URL(url, base).pathname);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const ALPHA = /^(?:png|apng|webp|avif|gif)$/;
|
|
83
|
+
function formatOfType(type) {
|
|
84
|
+
const subtype = /^image\/([^;,\s]+)/i.exec(type)?.[1].toLowerCase();
|
|
85
|
+
if (subtype === "svg+xml")
|
|
86
|
+
return "svg";
|
|
87
|
+
return subtype && ALPHA.test(subtype) ? "transparent" : "opaque";
|
|
88
|
+
}
|
|
89
|
+
const lookedUp = new Map();
|
|
90
|
+
/** The format by the URL alone; undefined for a blob: URL or a path without an extension until lookupFormat has read its type. */
|
|
91
|
+
export function formatOf(url, base) {
|
|
92
|
+
if (/^data:/i.test(url))
|
|
93
|
+
return formatOfType(url.slice(5));
|
|
94
|
+
const address = resolve(url, base);
|
|
95
|
+
if (/^blob:/i.test(url))
|
|
96
|
+
return lookedUp.get(address)?.format;
|
|
97
|
+
let extension;
|
|
98
|
+
try {
|
|
99
|
+
extension = /\.([^./]+)$/.exec(new URL(url, base).pathname)?.[1];
|
|
100
|
+
}
|
|
101
|
+
catch { }
|
|
102
|
+
const name = extension?.toLowerCase();
|
|
103
|
+
if (!name)
|
|
104
|
+
return lookedUp.get(address)?.format;
|
|
105
|
+
if (name === "svg")
|
|
106
|
+
return "svg";
|
|
107
|
+
return ALPHA.test(name) ? "transparent" : "opaque";
|
|
108
|
+
}
|
|
109
|
+
/** Reads the type once per URL: a blob: URL's Blob type, else the Content-Type of a HEAD request. */
|
|
110
|
+
export function lookupFormat(url, base, fetcher) {
|
|
111
|
+
const known = formatOf(url, base);
|
|
112
|
+
if (known)
|
|
113
|
+
return Promise.resolve(known);
|
|
114
|
+
const address = resolve(url, base);
|
|
115
|
+
const cached = lookedUp.get(address);
|
|
116
|
+
if (cached)
|
|
117
|
+
return cached.lookup;
|
|
118
|
+
// A blob: URL answers only GET.
|
|
119
|
+
const type = /^blob:/i.test(url)
|
|
120
|
+
? fetcher(url)
|
|
121
|
+
.then((response) => response.blob())
|
|
122
|
+
.then((blob) => blob.type)
|
|
123
|
+
: fetcher(url, { method: "HEAD" }).then((response) => response.headers.get("content-type") ?? "");
|
|
124
|
+
const entry = {
|
|
125
|
+
lookup: type
|
|
126
|
+
.then(formatOfType, () => "opaque")
|
|
127
|
+
.then((format) => {
|
|
128
|
+
entry.format = format;
|
|
129
|
+
return format;
|
|
130
|
+
}),
|
|
131
|
+
};
|
|
132
|
+
lookedUp.set(address, entry);
|
|
133
|
+
return entry.lookup;
|
|
134
|
+
}
|
|
135
|
+
const PIXELS = {
|
|
136
|
+
"": 1,
|
|
137
|
+
px: 1,
|
|
138
|
+
in: 96,
|
|
139
|
+
cm: 96 / 2.54,
|
|
140
|
+
mm: 96 / 25.4,
|
|
141
|
+
pt: 96 / 72,
|
|
142
|
+
pc: 16,
|
|
143
|
+
};
|
|
144
|
+
function absoluteLength(value) {
|
|
145
|
+
const match = /^\s*(\d*\.?\d+(?:e[+-]?\d+)?)\s*(px|in|cm|mm|pt|pc)?\s*$/i.exec(value ?? "");
|
|
146
|
+
if (!match)
|
|
147
|
+
return undefined;
|
|
148
|
+
const length = Number(match[1]) * PIXELS[(match[2] ?? "").toLowerCase()];
|
|
149
|
+
return length > 0 ? length : undefined;
|
|
150
|
+
}
|
|
151
|
+
/** The root's width and height in absolute units, else the viewBox's, which also completes one of them. */
|
|
152
|
+
export function parseSvgSize(text, parser) {
|
|
153
|
+
const root = parser.parseFromString(text, "image/svg+xml").documentElement;
|
|
154
|
+
if (root.localName !== "svg")
|
|
155
|
+
return undefined;
|
|
156
|
+
const width = absoluteLength(root.getAttribute("width"));
|
|
157
|
+
const height = absoluteLength(root.getAttribute("height"));
|
|
158
|
+
if (width && height)
|
|
159
|
+
return { width, height };
|
|
160
|
+
const box = (root.getAttribute("viewBox") ?? "")
|
|
161
|
+
.trim()
|
|
162
|
+
.split(/[\s,]+/)
|
|
163
|
+
.map(Number);
|
|
164
|
+
if (box.length !== 4 || !(box[2] > 0) || !(box[3] > 0))
|
|
165
|
+
return undefined;
|
|
166
|
+
const ratio = box[3] / box[2];
|
|
167
|
+
if (width)
|
|
168
|
+
return { width, height: width * ratio };
|
|
169
|
+
if (height)
|
|
170
|
+
return { width: height / ratio, height };
|
|
171
|
+
return { width: box[2], height: box[3] };
|
|
172
|
+
}
|
|
173
|
+
/** Fetches the SVG text, which works for same-origin, CORS, data: and blob: URLs. */
|
|
174
|
+
export async function svgSize(url, fetcher, parser) {
|
|
175
|
+
const response = await fetcher(url);
|
|
176
|
+
if (!response.ok)
|
|
177
|
+
return undefined;
|
|
178
|
+
return parseSvgSize(await response.text(), parser);
|
|
179
|
+
}
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
@layer re.base, re.theme;
|
|
2
|
+
@layer re.theme {
|
|
3
|
+
.re-lightbox {
|
|
4
|
+
--re-lightbox-background: rgb(15 15 17 / 96%);
|
|
5
|
+
--re-lightbox-foreground: #fff;
|
|
6
|
+
--re-lightbox-control: rgb(35 35 38 / 96%);
|
|
7
|
+
--re-lightbox-control-hover: color-mix(
|
|
8
|
+
in srgb,
|
|
9
|
+
var(--re-lightbox-control) 88%,
|
|
10
|
+
var(--re-lightbox-foreground)
|
|
11
|
+
);
|
|
12
|
+
--re-lightbox-panel: rgb(24 24 27 / 96%);
|
|
13
|
+
--re-lightbox-button-size: 44px;
|
|
14
|
+
--re-lightbox-button-padding: 10px;
|
|
15
|
+
--re-lightbox-button-radius: 50%;
|
|
16
|
+
--re-lightbox-press-scale: 0.96;
|
|
17
|
+
--re-lightbox-icon-size: 24px;
|
|
18
|
+
--re-lightbox-font-size: 14px;
|
|
19
|
+
--re-lightbox-counter-font-size: 13px;
|
|
20
|
+
--re-lightbox-blur: 16px;
|
|
21
|
+
--re-lightbox-inset: 16px;
|
|
22
|
+
--re-lightbox-gap: 10px;
|
|
23
|
+
--re-lightbox-arrow-inset: 16px;
|
|
24
|
+
--re-lightbox-footer-inset: 72px;
|
|
25
|
+
--re-lightbox-counter-padding: 6px 12px;
|
|
26
|
+
--re-lightbox-counter-radius: 20px;
|
|
27
|
+
--re-lightbox-caption-padding: 4px 10px;
|
|
28
|
+
--re-lightbox-caption-radius: 4px;
|
|
29
|
+
--re-lightbox-thumbnail-size: 44px;
|
|
30
|
+
--re-lightbox-thumbnail-radius: 5px;
|
|
31
|
+
--re-lightbox-thumbnail-gap: 8px;
|
|
32
|
+
--re-lightbox-thumbnails-padding: 4px;
|
|
33
|
+
--re-lightbox-error-padding: 24px;
|
|
34
|
+
--re-lightbox-placeholder: rgb(255 255 255 / 6%);
|
|
35
|
+
--re-lightbox-media-background: #f2f2f2;
|
|
36
|
+
--re-lightbox-retry-padding: 8px 16px;
|
|
37
|
+
--re-lightbox-retry-radius: 20px;
|
|
38
|
+
--re-lightbox-aside-width: 320px;
|
|
39
|
+
--re-lightbox-aside-height: 40%;
|
|
40
|
+
--re-lightbox-open-duration: 400ms;
|
|
41
|
+
--re-lightbox-close-duration: 300ms;
|
|
42
|
+
--re-lightbox-zoom-duration: 350ms;
|
|
43
|
+
--re-lightbox-fade-duration: 240ms;
|
|
44
|
+
--re-lightbox-ease: cubic-bezier(0.32, 0.72, 0, 1);
|
|
45
|
+
--re-lightbox-control-duration: 300ms;
|
|
46
|
+
--re-lightbox-ring-duration: 150ms;
|
|
47
|
+
color: var(--re-lightbox-foreground);
|
|
48
|
+
font-family: var(
|
|
49
|
+
--re-lightbox-font,
|
|
50
|
+
system-ui,
|
|
51
|
+
-apple-system,
|
|
52
|
+
"Segoe UI",
|
|
53
|
+
Roboto,
|
|
54
|
+
sans-serif
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
.re-lightbox-backdrop {
|
|
58
|
+
background: var(--re-lightbox-background);
|
|
59
|
+
transition: background-color var(--re-lightbox-background-duration, 0ms) ease;
|
|
60
|
+
}
|
|
61
|
+
.re-lightbox-button {
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
width: var(--re-lightbox-button-size);
|
|
64
|
+
height: var(--re-lightbox-button-size);
|
|
65
|
+
padding: var(--re-lightbox-button-padding);
|
|
66
|
+
border: 0;
|
|
67
|
+
border-radius: var(--re-lightbox-button-radius);
|
|
68
|
+
background: var(--re-lightbox-control);
|
|
69
|
+
color: inherit;
|
|
70
|
+
font: inherit;
|
|
71
|
+
line-height: 1;
|
|
72
|
+
backdrop-filter: blur(var(--re-lightbox-blur));
|
|
73
|
+
}
|
|
74
|
+
.re-lightbox-button svg {
|
|
75
|
+
width: var(--re-lightbox-icon-size);
|
|
76
|
+
height: var(--re-lightbox-icon-size);
|
|
77
|
+
}
|
|
78
|
+
.re-lightbox-button:hover {
|
|
79
|
+
background: var(--re-lightbox-control-hover);
|
|
80
|
+
}
|
|
81
|
+
.re-lightbox-button:active:not(:disabled) {
|
|
82
|
+
scale: var(--re-lightbox-press-scale);
|
|
83
|
+
}
|
|
84
|
+
/* Hit testing follows the scale, so a press held on the edge would end off the button and fire no click. */
|
|
85
|
+
.re-lightbox-button:active:not(:disabled)::before {
|
|
86
|
+
content: "";
|
|
87
|
+
position: absolute;
|
|
88
|
+
inset: calc(-50% * (1 / var(--re-lightbox-press-scale) - 1));
|
|
89
|
+
border-radius: inherit;
|
|
90
|
+
}
|
|
91
|
+
.re-lightbox-button:disabled {
|
|
92
|
+
opacity: calc(0.3 * var(--re-lightbox-chrome-opacity, 1));
|
|
93
|
+
}
|
|
94
|
+
.re-lightbox-close {
|
|
95
|
+
transition: rotate var(--re-lightbox-control-duration) ease;
|
|
96
|
+
}
|
|
97
|
+
.re-lightbox-download {
|
|
98
|
+
text-decoration: none;
|
|
99
|
+
}
|
|
100
|
+
.re-lightbox-slideshow {
|
|
101
|
+
position: relative;
|
|
102
|
+
}
|
|
103
|
+
.re-lightbox[data-slideshow] .re-lightbox-slideshow::after {
|
|
104
|
+
content: "";
|
|
105
|
+
position: absolute;
|
|
106
|
+
inset: 0;
|
|
107
|
+
border-radius: inherit;
|
|
108
|
+
background: conic-gradient(
|
|
109
|
+
currentColor calc(var(--re-lightbox-slideshow-progress, 0) * 1turn),
|
|
110
|
+
transparent 0
|
|
111
|
+
);
|
|
112
|
+
mask: radial-gradient(
|
|
113
|
+
farthest-side,
|
|
114
|
+
transparent calc(100% - 2px),
|
|
115
|
+
#000 calc(100% - 2px)
|
|
116
|
+
);
|
|
117
|
+
pointer-events: none;
|
|
118
|
+
}
|
|
119
|
+
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
|
|
120
|
+
.re-lightbox-close:hover {
|
|
121
|
+
rotate: 90deg;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
.re-lightbox-button:focus-visible,
|
|
125
|
+
.re-lightbox-thumbnails button:focus-visible {
|
|
126
|
+
outline: 2px solid currentColor;
|
|
127
|
+
outline-offset: 3px;
|
|
128
|
+
}
|
|
129
|
+
[data-re-focus-quiet]:focus-visible {
|
|
130
|
+
outline: none;
|
|
131
|
+
}
|
|
132
|
+
.re-lightbox-counter {
|
|
133
|
+
padding: var(--re-lightbox-counter-padding);
|
|
134
|
+
border-radius: var(--re-lightbox-counter-radius);
|
|
135
|
+
background: var(--re-lightbox-control);
|
|
136
|
+
font-size: var(--re-lightbox-counter-font-size);
|
|
137
|
+
font-variant-numeric: tabular-nums;
|
|
138
|
+
backdrop-filter: blur(var(--re-lightbox-blur));
|
|
139
|
+
}
|
|
140
|
+
.re-lightbox-caption {
|
|
141
|
+
padding: var(--re-lightbox-caption-padding);
|
|
142
|
+
border-radius: var(--re-lightbox-caption-radius);
|
|
143
|
+
background: var(--re-lightbox-background);
|
|
144
|
+
font-size: var(--re-lightbox-font-size);
|
|
145
|
+
line-height: 1.5;
|
|
146
|
+
text-align: center;
|
|
147
|
+
}
|
|
148
|
+
.re-lightbox-thumbnails {
|
|
149
|
+
gap: var(--re-lightbox-thumbnail-gap);
|
|
150
|
+
}
|
|
151
|
+
.re-lightbox[data-thumbnails="bottom"] .re-lightbox-thumbnails {
|
|
152
|
+
padding-block: 12px max(14px, env(safe-area-inset-bottom));
|
|
153
|
+
}
|
|
154
|
+
.re-lightbox[data-thumbnails="side"] .re-lightbox-thumbnails {
|
|
155
|
+
padding: 0 var(--re-lightbox-thumbnails-padding);
|
|
156
|
+
}
|
|
157
|
+
.re-lightbox-thumbnails button {
|
|
158
|
+
width: var(--re-lightbox-thumbnail-size);
|
|
159
|
+
height: var(--re-lightbox-thumbnail-size);
|
|
160
|
+
padding: 0;
|
|
161
|
+
border: 0;
|
|
162
|
+
border-radius: var(--re-lightbox-thumbnail-radius);
|
|
163
|
+
background: none;
|
|
164
|
+
opacity: 0.45;
|
|
165
|
+
transition: opacity var(--re-lightbox-control-duration) ease;
|
|
166
|
+
}
|
|
167
|
+
.re-lightbox[data-thumbnails="bottom"] .re-lightbox-thumbnails button {
|
|
168
|
+
width: auto;
|
|
169
|
+
min-width: 24px;
|
|
170
|
+
aspect-ratio: 1;
|
|
171
|
+
}
|
|
172
|
+
@media (hover: hover) {
|
|
173
|
+
.re-lightbox-thumbnails button:hover {
|
|
174
|
+
opacity: 0.8;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
.re-lightbox-thumbnails button:is([aria-current="true"], :focus-visible) {
|
|
178
|
+
opacity: 1;
|
|
179
|
+
}
|
|
180
|
+
.re-lightbox-thumbnail-ring {
|
|
181
|
+
border-radius: var(--re-lightbox-thumbnail-radius);
|
|
182
|
+
outline: 2px solid var(--re-lightbox-foreground);
|
|
183
|
+
outline-offset: 2px;
|
|
184
|
+
transition:
|
|
185
|
+
width var(--re-lightbox-ring-duration) ease,
|
|
186
|
+
height var(--re-lightbox-ring-duration) ease;
|
|
187
|
+
}
|
|
188
|
+
@media (prefers-reduced-motion: reduce) {
|
|
189
|
+
.re-lightbox-thumbnail-ring {
|
|
190
|
+
transition: none;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
.re-lightbox-aside {
|
|
194
|
+
background: var(--re-lightbox-panel);
|
|
195
|
+
}
|
|
196
|
+
.re-lightbox-aside > .re-lightbox-caption {
|
|
197
|
+
padding: calc(
|
|
198
|
+
var(--re-lightbox-inset) +
|
|
199
|
+
var(--re-lightbox-button-size) +
|
|
200
|
+
var(--re-lightbox-gap)
|
|
201
|
+
)
|
|
202
|
+
var(--re-lightbox-inset) var(--re-lightbox-inset);
|
|
203
|
+
border-radius: 0;
|
|
204
|
+
background: none;
|
|
205
|
+
text-align: start;
|
|
206
|
+
}
|
|
207
|
+
.re-lightbox-frame:is([data-loading], [data-error]) {
|
|
208
|
+
background: var(--re-lightbox-placeholder);
|
|
209
|
+
}
|
|
210
|
+
.re-lightbox-error {
|
|
211
|
+
padding: var(--re-lightbox-error-padding);
|
|
212
|
+
font-size: var(--re-lightbox-font-size);
|
|
213
|
+
line-height: 1.5;
|
|
214
|
+
}
|
|
215
|
+
.re-lightbox-retry {
|
|
216
|
+
padding: var(--re-lightbox-retry-padding);
|
|
217
|
+
border: 0;
|
|
218
|
+
border-radius: var(--re-lightbox-retry-radius);
|
|
219
|
+
background: var(--re-lightbox-control);
|
|
220
|
+
color: inherit;
|
|
221
|
+
font: inherit;
|
|
222
|
+
}
|
|
223
|
+
.re-lightbox-retry:hover {
|
|
224
|
+
background: var(--re-lightbox-control-hover);
|
|
225
|
+
}
|
|
226
|
+
.re-lightbox-retry:focus-visible {
|
|
227
|
+
outline: 2px solid currentColor;
|
|
228
|
+
outline-offset: 3px;
|
|
229
|
+
}
|
|
230
|
+
@media (max-width: 480px) {
|
|
231
|
+
.re-lightbox {
|
|
232
|
+
--re-lightbox-arrow-inset: 8px;
|
|
233
|
+
--re-lightbox-footer-inset: 16px;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@layer re.base, re.theme;
|
|
2
|
+
@layer re.theme {
|
|
3
|
+
.re-lightbox {
|
|
4
|
+
--re-lightbox-background: rgb(15 15 17 / 96%);
|
|
5
|
+
--re-lightbox-foreground: #fff;
|
|
6
|
+
--re-lightbox-control: rgb(35 35 38 / 96%);
|
|
7
|
+
--re-lightbox-control-hover: rgb(58 58 62 / 98%);
|
|
8
|
+
--re-lightbox-panel: rgb(24 24 27 / 96%);
|
|
9
|
+
--re-lightbox-placeholder: rgb(255 255 255 / 6%);
|
|
10
|
+
--re-lightbox-media-background: #f2f2f2;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@layer re.base, re.theme;
|
|
2
|
+
@layer re.theme {
|
|
3
|
+
.re-lightbox {
|
|
4
|
+
--re-lightbox-background: rgb(250 250 250 / 97%);
|
|
5
|
+
--re-lightbox-foreground: #1c1c1e;
|
|
6
|
+
--re-lightbox-control: rgb(255 255 255 / 92%);
|
|
7
|
+
--re-lightbox-control-hover: rgb(236 236 238 / 96%);
|
|
8
|
+
--re-lightbox-panel: rgb(255 255 255 / 96%);
|
|
9
|
+
--re-lightbox-placeholder: rgb(0 0 0 / 5%);
|
|
10
|
+
--re-lightbox-media-background: #fff;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
@layer re.base, re.theme;
|
|
2
|
+
@layer re.theme {
|
|
3
|
+
.re-lightbox {
|
|
4
|
+
--re-lightbox-background: var(--re-lightbox-page, Canvas);
|
|
5
|
+
--re-lightbox-foreground: var(--re-lightbox-page-foreground, CanvasText);
|
|
6
|
+
--re-lightbox-control: color-mix(
|
|
7
|
+
in srgb,
|
|
8
|
+
var(--re-lightbox-page-foreground, CanvasText) 8%,
|
|
9
|
+
var(--re-lightbox-page, Canvas)
|
|
10
|
+
);
|
|
11
|
+
--re-lightbox-control-hover: color-mix(
|
|
12
|
+
in srgb,
|
|
13
|
+
var(--re-lightbox-page-foreground, CanvasText) 14%,
|
|
14
|
+
var(--re-lightbox-page, Canvas)
|
|
15
|
+
);
|
|
16
|
+
--re-lightbox-panel: var(--re-lightbox-page, Canvas);
|
|
17
|
+
--re-lightbox-placeholder: color-mix(
|
|
18
|
+
in srgb,
|
|
19
|
+
var(--re-lightbox-page-foreground, CanvasText) 6%,
|
|
20
|
+
transparent
|
|
21
|
+
);
|
|
22
|
+
--re-lightbox-media-background: color-mix(
|
|
23
|
+
in srgb,
|
|
24
|
+
var(--re-lightbox-page-foreground, CanvasText) 5%,
|
|
25
|
+
var(--re-lightbox-page, Canvas)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
@layer re.base, re.theme;
|
|
2
|
+
@layer re.theme {
|
|
3
|
+
.re-lightbox {
|
|
4
|
+
--re-lightbox-background: #fff;
|
|
5
|
+
--re-lightbox-foreground: #1d1d1f;
|
|
6
|
+
--re-lightbox-control: rgb(255 255 255 / 80%);
|
|
7
|
+
--re-lightbox-control-hover: rgb(242 242 247 / 90%);
|
|
8
|
+
--re-lightbox-panel: rgb(249 249 249 / 94%);
|
|
9
|
+
--re-lightbox-placeholder: rgb(0 0 0 / 4%);
|
|
10
|
+
--re-lightbox-media-background: #fff;
|
|
11
|
+
--re-lightbox-background-duration: 300ms;
|
|
12
|
+
}
|
|
13
|
+
.re-lightbox[data-chrome="hidden"] {
|
|
14
|
+
--re-lightbox-background: #000;
|
|
15
|
+
--re-lightbox-foreground: #8e8e93;
|
|
16
|
+
}
|
|
17
|
+
}
|