@reuse-sh/lightbox 0.0.2 → 0.0.4

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 CHANGED
@@ -11,7 +11,7 @@ function lockScroll(doc) {
11
11
  count: 0,
12
12
  overflow: doc.body.style.overflow,
13
13
  paddingRight: doc.body.style.paddingRight,
14
- gapProperty: doc.documentElement.style.getPropertyValue("--reuse-scrollbar-gap"),
14
+ gapProperty: doc.documentElement.style.getPropertyValue("--re-scrollbar-gap"),
15
15
  x: win.scrollX,
16
16
  y: win.scrollY,
17
17
  };
@@ -20,7 +20,7 @@ function lockScroll(doc) {
20
20
  if (gap)
21
21
  doc.body.style.paddingRight = `${Number.parseFloat(win.getComputedStyle(doc.body).paddingRight || "0") + gap}px`;
22
22
  // Fixed elements ignore body padding; they can add this gap themselves.
23
- doc.documentElement.style.setProperty("--reuse-scrollbar-gap", `${gap}px`);
23
+ doc.documentElement.style.setProperty("--re-scrollbar-gap", `${gap}px`);
24
24
  doc.body.style.overflow = "hidden";
25
25
  }
26
26
  lock.count++;
@@ -35,9 +35,9 @@ function lockScroll(doc) {
35
35
  doc.body.style.overflow = lock.overflow;
36
36
  doc.body.style.paddingRight = lock.paddingRight;
37
37
  if (lock.gapProperty)
38
- doc.documentElement.style.setProperty("--reuse-scrollbar-gap", lock.gapProperty);
38
+ doc.documentElement.style.setProperty("--re-scrollbar-gap", lock.gapProperty);
39
39
  else
40
- doc.documentElement.style.removeProperty("--reuse-scrollbar-gap");
40
+ doc.documentElement.style.removeProperty("--re-scrollbar-gap");
41
41
  if (win.scrollX !== lock.x || win.scrollY !== lock.y)
42
42
  win.scrollTo(lock.x, lock.y);
43
43
  locks.delete(doc);
@@ -309,9 +309,9 @@ export function createLightbox(options = {}) {
309
309
  const item = items[index];
310
310
  const doc = s.dialog.ownerDocument;
311
311
  const frame = doc.createElement("div");
312
- frame.className = "reuse-lightbox-frame";
312
+ frame.className = "re-lightbox-frame";
313
313
  const image = doc.createElement("img");
314
- image.className = "reuse-lightbox-image";
314
+ image.className = "re-lightbox-image";
315
315
  image.alt = item.alt || "";
316
316
  image.draggable = false;
317
317
  image.decoding = "async";
@@ -339,7 +339,7 @@ export function createLightbox(options = {}) {
339
339
  frame.dataset.error = "true";
340
340
  if (!item.previewSrc) {
341
341
  const error = doc.createElement("span");
342
- error.className = "reuse-lightbox-error";
342
+ error.className = "re-lightbox-error";
343
343
  error.setAttribute("role", "status");
344
344
  error.textContent = "Image could not be loaded.";
345
345
  frame.append(error);
@@ -718,7 +718,7 @@ export function createLightbox(options = {}) {
718
718
  if (!(target instanceof Element) ||
719
719
  target.closest("[data-lightbox-interactive],button,a,input,textarea,select"))
720
720
  return;
721
- if (!target.closest(".reuse-lightbox-frame")) {
721
+ if (!target.closest(".re-lightbox-frame")) {
722
722
  void close();
723
723
  return;
724
724
  }
@@ -781,17 +781,17 @@ export function createLightbox(options = {}) {
781
781
  const dialog = doc.createElement("dialog");
782
782
  if (typeof dialog.showModal !== "function")
783
783
  throw new Error("Lightbox requires native dialog support.");
784
- dialog.className = ["reuse-lightbox", options.className]
784
+ dialog.className = ["re-lightbox", options.className]
785
785
  .filter(Boolean)
786
786
  .join(" ");
787
787
  dialog.setAttribute("aria-label", options.label || "Image gallery");
788
788
  const viewport = doc.createElement("div");
789
- viewport.className = "reuse-lightbox-viewport";
789
+ viewport.className = "re-lightbox-viewport";
790
790
  viewport.tabIndex = 0;
791
791
  viewport.setAttribute("aria-label", "Images");
792
792
  const slides = items.map((_item, imageIndex) => {
793
793
  const slide = doc.createElement("div");
794
- slide.className = "reuse-lightbox-slide";
794
+ slide.className = "re-lightbox-slide";
795
795
  slide.dataset.carouselSlide = "";
796
796
  slide.setAttribute("role", "group");
797
797
  slide.setAttribute("aria-label", `${imageIndex + 1} of ${items.length}`);
@@ -799,14 +799,14 @@ export function createLightbox(options = {}) {
799
799
  return slide;
800
800
  });
801
801
  const backdrop = doc.createElement("div");
802
- backdrop.className = "reuse-lightbox-backdrop";
802
+ backdrop.className = "re-lightbox-backdrop";
803
803
  backdrop.setAttribute("aria-hidden", "true");
804
804
  dialog.append(backdrop, viewport);
805
805
  const abort = new AbortController();
806
806
  const button = (name, label, text, action) => {
807
807
  const element = doc.createElement("button");
808
808
  element.type = "button";
809
- element.className = `reuse-lightbox-button reuse-lightbox-${name}`;
809
+ element.className = `re-lightbox-button re-lightbox-${name}`;
810
810
  element.setAttribute("aria-label", label);
811
811
  const icon = options.icons?.[name]?.();
812
812
  if (icon)
@@ -825,18 +825,18 @@ export function createLightbox(options = {}) {
825
825
  const next = button("next", "Next image", "›", () => goTo(state.index + 1));
826
826
  const zoomButton = button("zoom", "Zoom in", "+", () => toggleZoom());
827
827
  const footer = doc.createElement("div");
828
- footer.className = "reuse-lightbox-footer";
828
+ footer.className = "re-lightbox-footer";
829
829
  const counter = doc.createElement("output");
830
- counter.className = "reuse-lightbox-counter";
830
+ counter.className = "re-lightbox-counter";
831
831
  counter.setAttribute("aria-live", "polite");
832
832
  const caption = doc.createElement("p");
833
- caption.className = "reuse-lightbox-caption";
833
+ caption.className = "re-lightbox-caption";
834
834
  footer.append(caption, counter);
835
835
  dialog.append(footer);
836
836
  const thumbs = [];
837
837
  if (options.thumbnails) {
838
838
  const strip = doc.createElement("div");
839
- strip.className = "reuse-lightbox-thumbnails";
839
+ strip.className = "re-lightbox-thumbnails";
840
840
  strip.setAttribute("role", "group");
841
841
  strip.setAttribute("aria-label", "Choose image");
842
842
  items.forEach((item, i) => {
package/dist/styles.css CHANGED
@@ -1,7 +1,7 @@
1
- .reuse-lightbox {
2
- --reuse-lightbox-background: rgb(15 15 17 / 96%);
3
- --reuse-lightbox-foreground: #fff;
4
- --reuse-lightbox-control: rgb(35 35 38 / 96%);
1
+ .re-lightbox {
2
+ --re-lightbox-background: rgb(15 15 17 / 96%);
3
+ --re-lightbox-foreground: #fff;
4
+ --re-lightbox-control: rgb(35 35 38 / 96%);
5
5
  position: fixed;
6
6
  inset: 0;
7
7
  width: 100%;
@@ -13,20 +13,20 @@
13
13
  overflow: hidden;
14
14
  border: 0;
15
15
  background: transparent;
16
- color: var(--reuse-lightbox-foreground);
16
+ color: var(--re-lightbox-foreground);
17
17
  overscroll-behavior: contain;
18
18
  font-family: inherit;
19
19
  }
20
- .reuse-lightbox::backdrop {
20
+ .re-lightbox::backdrop {
21
21
  background: transparent;
22
22
  }
23
- .reuse-lightbox-backdrop {
23
+ .re-lightbox-backdrop {
24
24
  position: absolute;
25
25
  inset: 0;
26
- background: var(--reuse-lightbox-background);
26
+ background: var(--re-lightbox-background);
27
27
  pointer-events: none;
28
28
  }
29
- .reuse-lightbox-viewport {
29
+ .re-lightbox-viewport {
30
30
  position: relative;
31
31
  display: flex;
32
32
  width: 100%;
@@ -39,10 +39,10 @@
39
39
  touch-action: pan-x;
40
40
  outline-offset: -4px;
41
41
  }
42
- .reuse-lightbox-viewport::-webkit-scrollbar {
42
+ .re-lightbox-viewport::-webkit-scrollbar {
43
43
  display: none;
44
44
  }
45
- .reuse-lightbox-slide {
45
+ .re-lightbox-slide {
46
46
  position: relative;
47
47
  display: grid;
48
48
  flex: 0 0 100%;
@@ -53,19 +53,19 @@
53
53
  scroll-snap-stop: always;
54
54
  overflow: hidden;
55
55
  }
56
- .reuse-lightbox-frame {
56
+ .re-lightbox-frame {
57
57
  position: relative;
58
58
  flex: none;
59
59
  transform-origin: center;
60
60
  cursor: zoom-in;
61
61
  }
62
- .reuse-lightbox[data-zoomed="true"] .reuse-lightbox-frame {
62
+ .re-lightbox[data-zoomed="true"] .re-lightbox-frame {
63
63
  cursor: grab;
64
64
  }
65
- .reuse-lightbox[data-zoomed="true"] .reuse-lightbox-frame:active {
65
+ .re-lightbox[data-zoomed="true"] .re-lightbox-frame:active {
66
66
  cursor: grabbing;
67
67
  }
68
- .reuse-lightbox-image {
68
+ .re-lightbox-image {
69
69
  display: block;
70
70
  width: 100%;
71
71
  height: 100%;
@@ -74,7 +74,7 @@
74
74
  user-select: none;
75
75
  -webkit-user-drag: none;
76
76
  }
77
- .reuse-lightbox-button {
77
+ .re-lightbox-button {
78
78
  position: absolute;
79
79
  z-index: 2;
80
80
  display: grid;
@@ -84,7 +84,7 @@
84
84
  place-items: center;
85
85
  border: 0;
86
86
  border-radius: 50%;
87
- background: var(--reuse-lightbox-control);
87
+ background: var(--re-lightbox-control);
88
88
  color: inherit;
89
89
  font: inherit;
90
90
  font-size: 26px;
@@ -93,39 +93,39 @@
93
93
  touch-action: manipulation;
94
94
  backdrop-filter: blur(16px);
95
95
  }
96
- .reuse-lightbox-button svg {
96
+ .re-lightbox-button svg {
97
97
  width: 24px;
98
98
  height: 24px;
99
99
  }
100
- .reuse-lightbox-button:hover {
100
+ .re-lightbox-button:hover {
101
101
  background: rgb(58 58 62 / 98%);
102
102
  }
103
- .reuse-lightbox-button:disabled {
103
+ .re-lightbox-button:disabled {
104
104
  opacity: 0.3;
105
105
  cursor: default;
106
106
  }
107
- .reuse-lightbox-button:focus-visible,
108
- .reuse-lightbox-thumbnails button:focus-visible {
107
+ .re-lightbox-button:focus-visible,
108
+ .re-lightbox-thumbnails button:focus-visible {
109
109
  outline: 2px solid currentColor;
110
110
  outline-offset: 3px;
111
111
  }
112
- .reuse-lightbox-close {
112
+ .re-lightbox-close {
113
113
  top: max(16px, env(safe-area-inset-top));
114
114
  right: max(16px, env(safe-area-inset-right));
115
115
  }
116
- .reuse-lightbox-zoom {
116
+ .re-lightbox-zoom {
117
117
  top: max(16px, env(safe-area-inset-top));
118
118
  right: calc(max(16px, env(safe-area-inset-right)) + 54px);
119
119
  }
120
- .reuse-lightbox-prev {
120
+ .re-lightbox-prev {
121
121
  top: calc(50% - 22px);
122
122
  left: max(16px, env(safe-area-inset-left));
123
123
  }
124
- .reuse-lightbox-next {
124
+ .re-lightbox-next {
125
125
  top: calc(50% - 22px);
126
126
  right: max(16px, env(safe-area-inset-right));
127
127
  }
128
- .reuse-lightbox-footer {
128
+ .re-lightbox-footer {
129
129
  position: absolute;
130
130
  z-index: 2;
131
131
  right: 72px;
@@ -136,32 +136,32 @@
136
136
  gap: 10px;
137
137
  pointer-events: none;
138
138
  }
139
- .reuse-lightbox-counter {
139
+ .re-lightbox-counter {
140
140
  padding: 6px 12px;
141
141
  border-radius: 20px;
142
- background: var(--reuse-lightbox-control);
142
+ background: var(--re-lightbox-control);
143
143
  font-size: 13px;
144
144
  font-variant-numeric: tabular-nums;
145
145
  backdrop-filter: blur(16px);
146
146
  }
147
- .reuse-lightbox-caption {
147
+ .re-lightbox-caption {
148
148
  max-width: 60ch;
149
149
  max-height: 20vh;
150
150
  margin: 0;
151
151
  overflow: auto;
152
152
  padding: 4px 10px;
153
153
  border-radius: 4px;
154
- background: var(--reuse-lightbox-background);
154
+ background: var(--re-lightbox-background);
155
155
  font-size: 14px;
156
156
  line-height: 1.5;
157
157
  text-align: center;
158
158
  overflow-wrap: anywhere;
159
159
  pointer-events: auto;
160
160
  }
161
- .reuse-lightbox-caption:empty {
161
+ .re-lightbox-caption:empty {
162
162
  display: none;
163
163
  }
164
- .reuse-lightbox-thumbnails {
164
+ .re-lightbox-thumbnails {
165
165
  display: flex;
166
166
  max-width: 100%;
167
167
  gap: 8px;
@@ -169,7 +169,7 @@
169
169
  padding: 4px;
170
170
  pointer-events: auto;
171
171
  }
172
- .reuse-lightbox-thumbnails button {
172
+ .re-lightbox-thumbnails button {
173
173
  flex: 0 0 44px;
174
174
  width: 44px;
175
175
  height: 44px;
@@ -181,17 +181,17 @@
181
181
  opacity: 0.6;
182
182
  cursor: pointer;
183
183
  }
184
- .reuse-lightbox-thumbnails button[aria-current="true"] {
185
- border-color: var(--reuse-lightbox-foreground);
184
+ .re-lightbox-thumbnails button[aria-current="true"] {
185
+ border-color: var(--re-lightbox-foreground);
186
186
  opacity: 1;
187
187
  }
188
- .reuse-lightbox-thumbnails img {
188
+ .re-lightbox-thumbnails img {
189
189
  width: 100%;
190
190
  height: 100%;
191
191
  object-fit: cover;
192
192
  }
193
193
 
194
- .reuse-lightbox-error {
194
+ .re-lightbox-error {
195
195
  position: absolute;
196
196
  inset: 0;
197
197
  display: grid;
@@ -200,19 +200,19 @@
200
200
  text-align: center;
201
201
  }
202
202
  @media (max-width: 480px) {
203
- .reuse-lightbox-prev {
203
+ .re-lightbox-prev {
204
204
  left: 8px;
205
205
  }
206
- .reuse-lightbox-next {
206
+ .re-lightbox-next {
207
207
  right: 8px;
208
208
  }
209
- .reuse-lightbox-footer {
209
+ .re-lightbox-footer {
210
210
  right: 16px;
211
211
  left: 16px;
212
212
  }
213
213
  }
214
214
  @media (prefers-reduced-motion: reduce) {
215
- .reuse-lightbox-viewport {
215
+ .re-lightbox-viewport {
216
216
  scroll-behavior: auto;
217
217
  }
218
218
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuse-sh/lightbox",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "An image lightbox on native scrolling, with thumbnail transitions, zoom, pan, and pinch.",
5
5
  "keywords": [
6
6
  "reuse",
@@ -51,7 +51,7 @@
51
51
  "@types/react": "19.3.0"
52
52
  },
53
53
  "dependencies": {
54
- "@reuse-sh/carousel": "0.0.2"
54
+ "@reuse-sh/carousel": "0.0.4"
55
55
  },
56
56
  "publishConfig": {
57
57
  "access": "public"