'use client' import { createContext, useContext, type PropsWithChildren, type ReactNode } from 'react' import { createPortal } from 'react-dom' import { HeadingReel } from 'ui-patterns/Toc/heading-reel' interface SlotProviderProps extends PropsWithChildren { value: HTMLElement | null } export interface CrumbHeading { url: string title: ReactNode } interface HeadingSlotCrumbProps { heading: CrumbHeading | undefined index: number } const HeadingSlotContext = createContext(null) export const HeadingSlotProvider = ({ value, children }: SlotProviderProps) => ( {children} ) const HeadingSlotPortal = ({ children }: PropsWithChildren) => { const target = useContext(HeadingSlotContext) return target ? createPortal(children, target) : null } export const HeadingSlotCrumb = ({ heading, index }: HeadingSlotCrumbProps) => heading ? ( {heading.title} ) : null