'use client' import { useBreakpoint } from 'common/hooks/useBreakpoint' import { createContext, useContext, type PropsWithChildren } from 'react' import { createPortal } from 'react-dom' import { ScrollBar, ScrollRoot, ScrollViewport } from 'ui' interface SlotProviderProps extends PropsWithChildren { value: HTMLElement | null } const RightRailContext = createContext(null) export const RightRailProvider = ({ value, children }: SlotProviderProps) => ( {children} ) export const RightRailPortal = ({ children }: PropsWithChildren) => { const target = useContext(RightRailContext) return target ? createPortal(children, target) : null } // the rail shows from lg, so below it the content stays in place for the mobile drawer export const RightRailOnDesktop = ({ children }: PropsWithChildren) => { const target = useContext(RightRailContext) const isBelowDesktop = useBreakpoint('lg') return target && !isBelowDesktop ? createPortal( {children} , target ) : children }