@hogoshi/ui 0.1.7 → 0.1.8
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
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
|
|
4
|
-
import { FullScreenIcon } from "@hugeicons-pro/core-solid-rounded";
|
|
5
4
|
import {
|
|
6
5
|
ArrowLeft01Icon,
|
|
7
6
|
ArrowRight01Icon,
|
|
@@ -24,9 +23,7 @@ import {
|
|
|
24
23
|
import { cn } from "../lib/cn";
|
|
25
24
|
import { ContextMenuContent, ContextMenuItem, ContextMenuRoot, ContextMenuTrigger } from "./context-menu";
|
|
26
25
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "./dropdown-menu";
|
|
27
|
-
import { CollapseScreenIcon } from "./collapse-screen-icon";
|
|
28
26
|
import { Icon } from "./icon";
|
|
29
|
-
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
|
|
30
27
|
import { backdropMotion, popupMotion } from "./popup";
|
|
31
28
|
|
|
32
29
|
export interface ViewerImage {
|
|
@@ -320,28 +317,11 @@ export function ImageGallery({
|
|
|
320
317
|
className?: string;
|
|
321
318
|
imageClassName?: string;
|
|
322
319
|
}) {
|
|
323
|
-
const root = useRef<HTMLDivElement>(null);
|
|
324
320
|
const [open, setOpen] = useState(false);
|
|
325
321
|
const [index, setIndex] = useState(0);
|
|
326
|
-
const [full, setFull] = useState(false);
|
|
327
|
-
useEffect(() => {
|
|
328
|
-
const sync = () => setFull(document.fullscreenElement === root.current);
|
|
329
|
-
document.addEventListener("fullscreenchange", sync);
|
|
330
|
-
return () => document.removeEventListener("fullscreenchange", sync);
|
|
331
|
-
}, []);
|
|
332
|
-
const toggleFull = () => {
|
|
333
|
-
const node = root.current as (HTMLDivElement & { webkitRequestFullscreen?: () => void }) | null;
|
|
334
|
-
if (document.fullscreenElement) void document.exitFullscreen();
|
|
335
|
-
else if (node?.requestFullscreen) void node.requestFullscreen();
|
|
336
|
-
else node?.webkitRequestFullscreen?.();
|
|
337
|
-
};
|
|
338
322
|
return (
|
|
339
323
|
<>
|
|
340
|
-
<div
|
|
341
|
-
ref={root}
|
|
342
|
-
className={cn("relative min-w-0 pb-10", full && "bg-bg flex h-full w-full items-center justify-center p-6 pb-16")}
|
|
343
|
-
>
|
|
344
|
-
<div className={cn("grid min-w-0 grid-cols-[repeat(auto-fill,minmax(min(100%,8rem),1fr))] gap-2", full && "w-full max-w-5xl", className)}>
|
|
324
|
+
<div className={cn("grid min-w-0 grid-cols-[repeat(auto-fill,minmax(min(100%,8rem),1fr))] gap-2", className)}>
|
|
345
325
|
{images.map((image, at) => (
|
|
346
326
|
<button
|
|
347
327
|
key={`${image.src}-${at}`}
|
|
@@ -366,23 +346,6 @@ export function ImageGallery({
|
|
|
366
346
|
</button>
|
|
367
347
|
))}
|
|
368
348
|
</div>
|
|
369
|
-
<Tooltip>
|
|
370
|
-
<TooltipTrigger
|
|
371
|
-
delay={0}
|
|
372
|
-
render={
|
|
373
|
-
<button
|
|
374
|
-
type="button"
|
|
375
|
-
aria-label={full ? "Exit fullscreen" : "Fullscreen"}
|
|
376
|
-
className="text-fg-muted hover:bg-bg-muted hover:text-fg absolute right-2 bottom-2 inline-flex size-7 items-center justify-center rounded-[var(--radius-sm)]"
|
|
377
|
-
onClick={toggleFull}
|
|
378
|
-
/>
|
|
379
|
-
}
|
|
380
|
-
>
|
|
381
|
-
<Icon icon={full ? CollapseScreenIcon : FullScreenIcon} size={16} />
|
|
382
|
-
</TooltipTrigger>
|
|
383
|
-
<TooltipContent>{full ? "Exit fullscreen" : "Fullscreen"}</TooltipContent>
|
|
384
|
-
</Tooltip>
|
|
385
|
-
</div>
|
|
386
349
|
<ImageViewer images={images} index={index} open={open} onOpenChange={setOpen} onIndexChange={setIndex} />
|
|
387
350
|
</>
|
|
388
351
|
);
|