= (props) => {
const {icon, title, subtitle, className} = props;
return (
{icon && }
{title}
{subtitle && {subtitle}
}
);
};
export function SideTrayContent(props: SideTrayContentProps) {
const {children, className} = props;
const ctx = useContext(SideTrayContext);
if (ctx === null) {
throw new Error('SideContent must be within SideTray');
}
const [context, setContext] = ctx;
const target = useRef(null);
const size = useSize(target);
function onScroll() {
processScroll(target.current);
}
function processScroll(element: HTMLDivElement | null) {
if (element === null) return;
const hasScrollRemaining = element.scrollHeight > element.clientHeight + element.scrollTop + 10;
const hasScrolled = element.scrollTop > 10;
setContext({...context, hasScrollRemaining, hasScrolled});
}
useLayoutEffect(() => {
processScroll(target.current);
}, [size, children]);
return {children}
;
}
export function SideTrayBodyContent(props: SideTrayContentProps) {
const {children, className} = props;
return {children}
;
}
export function SideTrayBody(props: SideTrayBodyProps) {
const {children, className, transition} = props;
const ctx = useContext(SideTrayContext);
if (ctx === null) {
throw new Error('SideTrayBody must be within SideTray');
}
const [context, setContext] = ctx;
const enableTransition = transition ?? context.transition ?? true;
return (
);
}
export function SideTrayFooter(props: SideTrayFooterProps) {
const {children, className, transition} = props;
const ctx = useContext(SideTrayContext);
if (ctx === null) {
throw new Error('SideTrayBody must be within SideTray');
}
const [context] = ctx;
const enableTransition = transition ?? context.transition ?? true;
return (
);
}