/* Big thanks to @jessebofil for this https://discord.com/channels/960281551428522045/960284327445418044/1209253688363716648 */ import { Focusable, ModalPosition, GamepadButton, ScrollPanelGroup, gamepadDialogClasses, scrollPanelClasses, FooterLegendProps } from "decky-frontend-lib"; import { FC, useLayoutEffect, useRef, useState } from "react"; export interface ScrollableWindowProps extends FooterLegendProps { height: string; fadeAmount?: string; scrollBarWidth?: string; alwaysFocus?: boolean; noScrollDescription?: boolean; onActivate?: (e: CustomEvent) => void; onCancel?: (e: CustomEvent) => void; } const ScrollableWindow: FC = ({ height, fadeAmount, scrollBarWidth, alwaysFocus, noScrollDescription, children, actionDescriptionMap, ...focusableProps }) => { const fade = fadeAmount === undefined || fadeAmount === '' ? '10px' : fadeAmount; const barWidth = scrollBarWidth === undefined || scrollBarWidth === '' ? '4px' : scrollBarWidth; const [isOverflowing, setIsOverflowing] = useState(false); const scrollPanelRef = useRef(); useLayoutEffect(() => { const { current } = scrollPanelRef; const trigger = () => { if (current) { const hasOverflow = current.scrollHeight > current.clientHeight; setIsOverflowing(hasOverflow); } }; if (current) trigger(); }, [children, height]); const panel = ( {children} ); return ( <>
{isOverflowing ? ( {panel} ) : (
{panel}
)}
); }; interface ScrollableWindowAutoProps extends Omit { heightPercent?: number; } export const ScrollableWindowRelative: FC = ({ heightPercent, ...props }) => { return (
); };