feat(collection/presentation): button to enter full screen

This commit is contained in:
Elian Doran
2025-10-15 20:48:09 +03:00
parent 9f993363d7
commit 15fc98fca1
3 changed files with 40 additions and 9 deletions

View File

@@ -1,12 +1,14 @@
import { ComponentChildren, HTMLAttributes, JSX, render } from "preact";
import { useEffect, useRef, useState } from "preact/hooks";
import { ComponentChildren, HTMLAttributes, JSX, RefObject, render } from "preact";
import { useEffect, useState } from "preact/hooks";
import { useSyncedRef } from "./hooks";
interface ShadowDomProps extends HTMLAttributes<HTMLDivElement> {
interface ShadowDomProps extends Omit<HTMLAttributes<HTMLDivElement>, "ref"> {
children: ComponentChildren;
containerRef?: RefObject<HTMLDivElement>;
}
export default function ShadowDom({ children, ...containerProps }: ShadowDomProps) {
const containerRef = useRef<HTMLDivElement>(null);
export default function ShadowDom({ children, containerRef: externalContainerRef, ...containerProps }: ShadowDomProps) {
const containerRef = useSyncedRef<HTMLDivElement>(externalContainerRef, null);
const [ shadowRoot, setShadowRoot ] = useState<ShadowRoot | null>(null);
// Create the shadow root.