@reuse-sh/lightbox 0.2.1 → 0.3.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/ICONS-LICENSE.md +73 -0
- package/LICENSE +1 -1
- package/README.md +1 -0
- package/dist/base.css +37 -0
- package/dist/browser/audio.js +1 -1
- package/dist/browser/carousel-link.js +1 -1
- package/dist/browser/embed.js +1 -1
- package/dist/browser/html.js +1 -1
- package/dist/browser/iframe.js +1 -1
- package/dist/browser/lightbox.js +2 -2
- package/dist/browser/lightbox.js.map +1 -1
- package/dist/browser/video.js +1 -1
- package/dist/icons.d.ts +42 -12
- package/dist/icons.js +42 -18
- package/dist/index.js +119 -16
- package/dist/theme.css +126 -36
- package/dist/themes/dark.css +3 -0
- package/dist/themes/page.css +11 -0
- package/dist/unlayered/base.css +37 -0
- package/dist/unlayered/theme.css +126 -36
- package/dist/unlayered/themes/dark.css +3 -0
- package/dist/unlayered/themes/page.css +11 -0
- package/package.json +4 -3
package/ICONS-LICENSE.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Icon notices
|
|
2
|
+
|
|
3
|
+
The built-in icons in src/icons.ts copy path data from two icon sets.
|
|
4
|
+
|
|
5
|
+
Close, fullscreen, fullscreen exit and download come from Hugeicons free icons:
|
|
6
|
+
|
|
7
|
+
MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2025 Hugeicons
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Previous, next, zoom in and zoom out come from Lucide (chevron-left, chevron-right, zoom-in, zoom-out). Lucide is ISC, and these four icons derive from Feather, MIT:
|
|
30
|
+
|
|
31
|
+
ISC License
|
|
32
|
+
|
|
33
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
34
|
+
|
|
35
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
36
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
37
|
+
copyright notice and this permission notice appear in all copies.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
40
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
41
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
42
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
43
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
44
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
45
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
The following Lucide icons are derived from the Feather project:
|
|
50
|
+
|
|
51
|
+
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
|
|
52
|
+
|
|
53
|
+
The MIT License (MIT) (for the icons listed above)
|
|
54
|
+
|
|
55
|
+
Copyright (c) 2013-present Cole Bemis
|
|
56
|
+
|
|
57
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
58
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
59
|
+
in the Software without restriction, including without limitation the rights
|
|
60
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
61
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
62
|
+
furnished to do so, subject to the following conditions:
|
|
63
|
+
|
|
64
|
+
The above copyright notice and this permission notice shall be included in all
|
|
65
|
+
copies or substantial portions of the Software.
|
|
66
|
+
|
|
67
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
68
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
69
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
70
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
71
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
72
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
73
|
+
SOFTWARE.
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ These are the rules the code keeps. An adaptation on any framework keeps them to
|
|
|
18
18
|
- **Behave like the platform's photo viewer.** Gestures, keys and timing match iOS Photos, macOS Photos and Google Photos unless a recorded decision says otherwise.
|
|
19
19
|
- **Dismiss like a photos app.** A vertical swipe carries the photo, fades the backdrop and the controls with it, and closes past a distance or a speed. A cancelled pointer never closes, a second finger leaves the swipe with the first, and a close ends the gesture.
|
|
20
20
|
- **Let the photo lead.** Controls fade in after the photo starts moving and leave before it. They hide while zoomed and after a still pointer, and a still pointer never hides them while one is hovered or keyboard-focused. While zoomed only close and zoom come back, focus on any other control, or on one a zoom stops rendering, moves to the photo, and the photo pans to the window's edges under the room the other controls kept.
|
|
21
|
+
- **Frame a photo that reads as a page.** A photo more than twice as tall as it is wide rests in a window the padding below the toolbar, beside the arrows and above the bottom room, ringed with --re-lightbox-media-ring, and scrolls inside it, so no control sits on it, a one-line caption stays below it, and a pale page still shows its edge on a pale room. Zoomed in, during a dismiss drag and in the close flight the window opens to the whole screen, the open flight closes it around the landing photo, and the ring shows only at the photo's resting size.
|
|
21
22
|
- **Change the caption with the photo.** Each page fades the caption out while it rises 0.4em and fades the next one in as it rises from 0.4em below, over --re-lightbox-fade-duration, the other way when paging back, and swaps its text while it is hidden, so a caption of another height, or none, never jumps into view. A page during the fade goes on from the opacity and the shift on screen with the newest caption, the shift adds to a host's own translate, and reduced motion swaps it at once. The announcement of the settled photo reads its number and its caption once, through strings.slide(index, count, caption), so a translation sets the order and the separator.
|
|
22
23
|
- **Return to what is on screen.** Close goes back to the current photo's tile, after bringing it into view in its own carousel, and fades in place when the tile cannot be seen, in the window and in every container that clips it. A close during a mouse drag or a fling ends it, puts the strip on the current photo at once and flies from where the photo was, with no neighbor in view. The page scrolls and takes clicks during the flight and stays where it was scrolled once the viewer is gone, focus moved there stays, the tile's container does not cut the photo before it nears the tile, and the landing photo never changes the size of a scroll area.
|
|
23
24
|
- **Fetch the pixels the screen shows.** Each image loads the source that fits the rendered size, a zoom asks for more, and the preview stays until the sharper file has decoded and no finger holds the photo. A photo without a size fits the screen at its tile's proportions from the start and eases to its file's size once the file decodes.
|
package/dist/base.css
CHANGED
|
@@ -66,6 +66,39 @@
|
|
|
66
66
|
.re-lightbox-slide[data-re-cycle]:not([data-re-cycle="0"]) {
|
|
67
67
|
translate: var(--re-carousel-shift);
|
|
68
68
|
}
|
|
69
|
+
.re-lightbox-slide[data-framed] {
|
|
70
|
+
clip-path: inset(0px);
|
|
71
|
+
transition: clip-path var(--re-lightbox-zoom-duration, 350ms)
|
|
72
|
+
var(--re-lightbox-ease, cubic-bezier(0.32, 0.72, 0, 1));
|
|
73
|
+
}
|
|
74
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
75
|
+
.re-lightbox:is([data-phase="opening"], [data-phase="returning"])
|
|
76
|
+
.re-lightbox-slide[data-framed] {
|
|
77
|
+
transition-duration: var(--re-lightbox-open-duration, 400ms);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
.re-lightbox-slide[data-framed]::after {
|
|
81
|
+
content: "";
|
|
82
|
+
position: absolute;
|
|
83
|
+
inset: var(--re-lightbox-window, 0px);
|
|
84
|
+
opacity: 0;
|
|
85
|
+
pointer-events: none;
|
|
86
|
+
transition: opacity var(--re-lightbox-zoom-duration, 350ms) ease;
|
|
87
|
+
}
|
|
88
|
+
.re-lightbox:is(
|
|
89
|
+
[data-phase="opening"],
|
|
90
|
+
[data-phase="open"],
|
|
91
|
+
[data-phase="returning"]
|
|
92
|
+
):not([data-zoomed="true"])
|
|
93
|
+
.re-lightbox-slide[data-framed] {
|
|
94
|
+
clip-path: inset(var(--re-lightbox-window, 0px));
|
|
95
|
+
}
|
|
96
|
+
.re-lightbox:is([data-phase="open"], [data-phase="returning"]):not(
|
|
97
|
+
[data-zoomed="true"]
|
|
98
|
+
)
|
|
99
|
+
.re-lightbox-slide[data-framed="rest"]::after {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
}
|
|
69
102
|
.re-lightbox-frame {
|
|
70
103
|
position: relative;
|
|
71
104
|
flex: none;
|
|
@@ -598,5 +631,9 @@
|
|
|
598
631
|
.re-lightbox-viewport {
|
|
599
632
|
scroll-behavior: auto;
|
|
600
633
|
}
|
|
634
|
+
.re-lightbox-slide[data-framed],
|
|
635
|
+
.re-lightbox-slide[data-framed]::after {
|
|
636
|
+
transition: none;
|
|
637
|
+
}
|
|
601
638
|
}
|
|
602
639
|
}
|
package/dist/browser/audio.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.3.0 | MIT License */
|
|
2
2
|
import{playerOf as e}from"./video.js";function t(){return{type:`audio`,mount(t,{item:n,signal:r,autoplay:i}){let a=t.ownerDocument.createElement(`audio`);return a.className=`re-lightbox-audio`,a.controls=!0,a.preload=`metadata`,a.src=n.src??``,n.alt&&a.setAttribute(`aria-label`,n.alt),t.append(a),e(a,i,r)}}}export{t as audio};
|
|
3
3
|
//# sourceMappingURL=audio.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.3.0 | MIT License */
|
|
2
2
|
function e(e,t,{slideOf:n=e=>e}={}){let r=e=>t.hold(`lightbox`,e),i=e=>t.goTo(n(e.index),`instant`),a=[e.on(`open`,()=>r(!0)),e.on(`settle`,i),e.on(`beforeclose`,i),e.on(`closed`,()=>r(!1))];return e.getState().isOpen&&r(!0),()=>{for(let e of a)e();r(!1)}}export{e as connectCarousel};
|
|
3
3
|
//# sourceMappingURL=carousel-link.js.map
|
package/dist/browser/embed.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.3.0 | MIT License */
|
|
2
2
|
import{frameOf as e,loaded as t}from"./iframe.js";const n=e=>{try{let t=typeof e==`string`?JSON.parse(e):e;return typeof t==`object`&&t?t:void 0}catch{return}},r={greet:e=>e({event:`listening`,id:1,channel:`widget`}),command:e=>({event:`command`,func:e===`mute`?`mute`:`${e}Video`,args:[]}),state(e){let t=e.info?.playerState;return t===1?`playing`:t===3?`waiting`:t===2||t===0?`paused`:t===-1||t===5?`unstarted`:void 0}},i={greet(e){for(let t of[`play`,`pause`,`ended`])e({method:`addEventListener`,value:t})},command:e=>e===`mute`?{method:`setVolume`,value:0}:{method:e},state:e=>e.event===`play`?`playing`:e.event===`pause`||e.event===`ended`?`paused`:void 0},a=/* @__PURE__ */ new WeakMap,o=e=>`https://www.youtube-nocookie.com/embed/${e}?enablejsapi=1&playsinline=1`,s=[{name:`youtube-shorts`,pattern:/^https?:\/\/(?:www\.|m\.)?youtube\.com\/shorts\/([\w-]+)/,url:e=>o(e[1]),aspect:9/16},{name:`youtube`,pattern:/^https?:\/\/(?:(?:www\.|m\.)?youtube(?:-nocookie)?\.com\/(?:watch\?(?:.*&)?v=|embed\/|live\/)|youtu\.be\/)([\w-]+)/,url:e=>o(e[1])},{name:`vimeo`,pattern:/^https?:\/\/(?:player\.)?vimeo\.com\/(?:video\/)?(\d+)(?:\/([\da-f]+))?/,url:e=>`https://player.vimeo.com/video/${e[1]}${e[2]?`?h=${e[2]}`:``}`}];a.set(s[0],r),a.set(s[1],r),a.set(s[2],i);function c(e,t){try{let n=new URL(e);for(let[e,r]of new URL(t).searchParams)if(!(e===`v`||n.searchParams.has(e===`t`?`start`:e))){if(e!==`t`)n.searchParams.set(e,r);else{let[,e=0,t=0,i=0]=/^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s?)?$/.exec(r)??[],a=Number(e)*3600+Number(t)*60+Number(i);a&&n.searchParams.set(`start`,String(a))}}return n.href}catch{return e}}function l(r={}){let i=[...r.providers??[],...s];return{type:`embed`,mount(o,{item:s,signal:l,autoplay:u}){let d=s.src??``,f,p=null;for(let e of i)if(p=e.pattern.exec(d),p){f=e;break}let m=f&&p?c(f.url(p,s),d):``,h=e(o,m,s.alt??f?.name??``,r.sandbox),g=t(h,l),_={interactive:!0,aspect:f?.aspect,ready:g,unmount:()=>h.remove()},v=f&&a.get(f);if(!v)return _;let y=new URL(m).origin,b=e=>h.contentWindow?.postMessage(JSON.stringify(e),y),x=u,S=!1,C,w;return o.ownerDocument.defaultView?.addEventListener(`message`,e=>{if(e.source!==h.contentWindow||e.origin!==y)return;let t=n(e.data);C=(t&&v.state(t))??C,C===`playing`&&(x=!1,clearTimeout(w))},{signal:l}),l.addEventListener(`abort`,()=>clearTimeout(w)),g.then(()=>v.greet(b)),{..._,pause(){S=!1,clearTimeout(w),b(v.command(`pause`))},resume(){S=!0,x&&(x=!1,g.then(()=>{!l.aborted&&S&&(b(v.command(`play`)),w=setTimeout(()=>{C!==`playing`&&C!==`waiting`&&(b(v.command(`mute`)),b(v.command(`play`)))},1e3))}))}}}}}export{l as embed};
|
|
3
3
|
//# sourceMappingURL=embed.js.map
|
package/dist/browser/html.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.3.0 | MIT License */
|
|
2
2
|
function e(){return{type:`html`,mount(e,{item:t}){let n=e.ownerDocument.createElement(`div`);n.className=`re-lightbox-html`;let r=t.html?.();return r&&n.append(r),e.append(n),{interactive:!0,unmount:()=>n.remove()}}}}export{e as html};
|
|
3
3
|
//# sourceMappingURL=html.js.map
|
package/dist/browser/iframe.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/*! @reuse-sh/lightbox 0.
|
|
1
|
+
/*! @reuse-sh/lightbox 0.3.0 | MIT License */
|
|
2
2
|
function e(e,t,n,r){let i=e.ownerDocument,a=i.createElement(`iframe`);if(a.className=`re-lightbox-iframe`,a.allow=`autoplay; fullscreen; picture-in-picture`,a.referrerPolicy=`strict-origin-when-cross-origin`,a.loading=`lazy`,a.title=n,a.src=`about:blank`,t.trim())try{let e=new URL(t,i.baseURI);/^https?:$/.test(e.protocol)&&(a.src=e.href),e.origin!==i.location.origin&&(r??=`allow-scripts allow-same-origin allow-forms allow-presentation allow-popups`)}catch{}return r!=null&&(a.sandbox=r),e.append(a),a}function t(e,t){return new Promise(n=>e.addEventListener(`load`,n,{once:!0,signal:t}))}function n(n={}){return{type:`iframe`,mount(r,{item:i,signal:a}){let o=e(r,i.src??``,i.alt??``,n.sandbox);return{interactive:!0,ready:t(o,a),unmount:()=>o.remove()}}}}export{e as frameOf,n as iframe,t as loaded};
|
|
3
3
|
//# sourceMappingURL=iframe.js.map
|