17 changed files with 233 additions and 34 deletions
@ -1,10 +1,20 @@
@@ -1,10 +1,20 @@
|
||||
import classNames from "classnames"; |
||||
import { ReactNode } from "react"; |
||||
|
||||
interface Props { |
||||
id: string; |
||||
children?: ReactNode; |
||||
className?: string; |
||||
} |
||||
|
||||
export function OverlayAnchor(props: Props) { |
||||
return <div id={`__overlayRouter::${props.id}`}>{props.children}</div>; |
||||
return ( |
||||
<div className={classNames("relative", props.className)}> |
||||
<div |
||||
id={`__overlayRouter::${props.id}`} |
||||
className="absolute inset-0 -z-10" |
||||
/> |
||||
{props.children} |
||||
</div> |
||||
); |
||||
} |
||||
|
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
import { useEffect } from "react"; |
||||
|
||||
import { Icons } from "@/components/Icon"; |
||||
import { OverlayAnchor } from "@/components/overlays/OverlayAnchor"; |
||||
import { Overlay } from "@/components/overlays/OverlayDisplay"; |
||||
import { OverlayPage } from "@/components/overlays/OverlayPage"; |
||||
import { OverlayRouter } from "@/components/overlays/OverlayRouter"; |
||||
import { VideoPlayerButton } from "@/components/player/internals/Button"; |
||||
import { useOverlayRouter } from "@/hooks/useOverlayRouter"; |
||||
import { usePlayerStore } from "@/stores/player/store"; |
||||
|
||||
function SettingsOverlay({ id }: { id: string }) { |
||||
return ( |
||||
<Overlay id={id}> |
||||
<OverlayRouter id={id}> |
||||
<OverlayPage id={id} path="/" width={400} height={400}> |
||||
<p>This is settings menu, welcome!</p> |
||||
</OverlayPage> |
||||
</OverlayRouter> |
||||
</Overlay> |
||||
); |
||||
} |
||||
|
||||
export function Settings() { |
||||
const router = useOverlayRouter("settings"); |
||||
const setHasOpenOverlay = usePlayerStore((s) => s.setHasOpenOverlay); |
||||
|
||||
useEffect(() => { |
||||
setHasOpenOverlay(router.isRouterActive); |
||||
}, [setHasOpenOverlay, router.isRouterActive]); |
||||
|
||||
return ( |
||||
<OverlayAnchor id={router.id}> |
||||
<VideoPlayerButton onClick={() => router.open()} icon={Icons.GEAR} /> |
||||
<SettingsOverlay id={router.id} /> |
||||
</OverlayAnchor> |
||||
); |
||||
} |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
import classNames from "classnames"; |
||||
|
||||
import { Transition } from "@/components/Transition"; |
||||
|
||||
export function CenterMobileControls(props: { |
||||
children: React.ReactNode; |
||||
show: boolean; |
||||
className?: string; |
||||
}) { |
||||
return ( |
||||
<Transition |
||||
animation="fade" |
||||
show={props.show} |
||||
className="pointer-events-none" |
||||
> |
||||
<div |
||||
className={classNames([ |
||||
"absolute inset-0 flex space-x-6 items-center justify-center pointer-events-none [&>*]:pointer-events-auto", |
||||
props.className, |
||||
])} |
||||
> |
||||
{props.children} |
||||
</div> |
||||
</Transition> |
||||
); |
||||
} |
@ -1,9 +1,20 @@
@@ -1,9 +1,20 @@
|
||||
import { PlayerHoverState } from "@/stores/player/slices/interface"; |
||||
import { usePlayerStore } from "@/stores/player/store"; |
||||
|
||||
export function useShouldShowControls() { |
||||
const { hovering } = usePlayerStore((s) => s.interface); |
||||
const { isPaused } = usePlayerStore((s) => s.mediaPlaying); |
||||
export function useShouldShowControls(opts?: { touchOnly: boolean }) { |
||||
const hovering = usePlayerStore((s) => s.interface.hovering); |
||||
const lastHoveringState = usePlayerStore( |
||||
(s) => s.interface.lastHoveringState |
||||
); |
||||
const isPaused = usePlayerStore((s) => s.mediaPlaying.isPaused); |
||||
const hasOpenOverlay = usePlayerStore((s) => s.interface.hasOpenOverlay); |
||||
|
||||
return hovering !== PlayerHoverState.NOT_HOVERING || isPaused; |
||||
const showTouchControls = |
||||
lastHoveringState === PlayerHoverState.MOBILE_TAPPED; |
||||
const notNotHovering = hovering !== PlayerHoverState.NOT_HOVERING; |
||||
|
||||
if (opts?.touchOnly) |
||||
return (showTouchControls && notNotHovering) || isPaused || hasOpenOverlay; |
||||
|
||||
return notNotHovering || isPaused || hasOpenOverlay; |
||||
} |
||||
|
Loading…
Reference in new issue