@hogoshi/ui 0.1.6 → 0.1.7

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hogoshi/ui",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,16 @@
1
+ import type { IconSvgElement } from "@hugeicons/react";
2
+
3
+ const stroke = {
4
+ fill: "none",
5
+ stroke: "currentColor",
6
+ strokeWidth: 2.4,
7
+ strokeLinecap: "round",
8
+ strokeLinejoin: "round",
9
+ } as const;
10
+
11
+ export const CollapseScreenIcon: IconSvgElement = [
12
+ ["path", { d: "M9 5 V9 H5", ...stroke, key: "0" }],
13
+ ["path", { d: "M15 5 V9 H19", ...stroke, key: "1" }],
14
+ ["path", { d: "M9 19 V15 H5", ...stroke, key: "2" }],
15
+ ["path", { d: "M15 19 V15 H19", ...stroke, key: "3" }],
16
+ ];
@@ -1,6 +1,7 @@
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";
4
5
  import {
5
6
  ArrowLeft01Icon,
6
7
  ArrowRight01Icon,
@@ -23,7 +24,9 @@ import {
23
24
  import { cn } from "../lib/cn";
24
25
  import { ContextMenuContent, ContextMenuItem, ContextMenuRoot, ContextMenuTrigger } from "./context-menu";
25
26
  import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "./dropdown-menu";
27
+ import { CollapseScreenIcon } from "./collapse-screen-icon";
26
28
  import { Icon } from "./icon";
29
+ import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip";
27
30
  import { backdropMotion, popupMotion } from "./popup";
28
31
 
29
32
  export interface ViewerImage {
@@ -317,11 +320,28 @@ export function ImageGallery({
317
320
  className?: string;
318
321
  imageClassName?: string;
319
322
  }) {
323
+ const root = useRef<HTMLDivElement>(null);
320
324
  const [open, setOpen] = useState(false);
321
325
  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
+ };
322
338
  return (
323
339
  <>
324
- <div className={cn("grid grid-cols-[repeat(auto-fill,minmax(8rem,1fr))] gap-2", className)}>
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)}>
325
345
  {images.map((image, at) => (
326
346
  <button
327
347
  key={`${image.src}-${at}`}
@@ -346,6 +366,23 @@ export function ImageGallery({
346
366
  </button>
347
367
  ))}
348
368
  </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>
349
386
  <ImageViewer images={images} index={index} open={open} onOpenChange={setOpen} onIndexChange={setIndex} />
350
387
  </>
351
388
  );
@@ -3,7 +3,6 @@
3
3
  import {
4
4
  Alert02Icon,
5
5
  FullScreenIcon,
6
- MinimizeScreenIcon,
7
6
  PauseIcon,
8
7
  PictureInPictureOnIcon,
9
8
  PlayIcon,
@@ -23,6 +22,7 @@ import {
23
22
  type RefObject,
24
23
  } from "react";
25
24
  import { cn } from "../lib/cn";
25
+ import { CollapseScreenIcon } from "./collapse-screen-icon";
26
26
  import { Icon, type AppIcon } from "./icon";
27
27
  import { Popover, PopoverContent, PopoverTrigger } from "./popover";
28
28
  import { Slider } from "./slider";
@@ -549,7 +549,7 @@ export function VideoPlayer({
549
549
  <Control label="Picture in picture" icon={PictureInPictureOnIcon} onClick={togglePip} />
550
550
  <Control
551
551
  label={fullscreen ? "Exit fullscreen" : "Fullscreen"}
552
- icon={fullscreen ? MinimizeScreenIcon : FullScreenIcon}
552
+ icon={fullscreen ? CollapseScreenIcon : FullScreenIcon}
553
553
  onClick={toggleFullscreen}
554
554
  />
555
555
  </div>