import {DocumentTextIcon} from '@heroicons/react/24/outline' import {JSONContent} from '@tiptap/react' import clsx from 'clsx' import {MouseEventHandler, ReactNode, useRef, useState} from 'react' import {Button} from 'web/components/buttons/button' import {SHOW_COLLAPSE_TRESHOLD} from 'web/components/widgets/collapsible-content' import {useSafeLayoutEffect} from 'web/hooks/use-safe-layout-effect' import {Col} from '../layout/col' import {Modal} from '../layout/modal' import {Row} from '../layout/row' import {Content} from './editor' export function ExpandButton(props: { onClick?: MouseEventHandler | undefined className?: string whatToRead?: string }) { const {onClick, className, whatToRead} = props return ( ) } export function ExpandableContent(props: { content: JSONContent | string modalContent: ReactNode whatToRead?: string className?: string }) { const {content, modalContent, whatToRead, className} = props const [shouldAllowCollapseOfContent, setShouldAllowCollapseOfContent] = useState(false) const contentRef = useRef(null) useSafeLayoutEffect(() => { if (contentRef.current) { if (contentRef.current.offsetHeight > SHOW_COLLAPSE_TRESHOLD) { setShouldAllowCollapseOfContent(true) } } }, [contentRef.current?.offsetHeight]) if (shouldAllowCollapseOfContent) { return (
) } return (
) } function ExpandsToModalContent(props: { content: JSONContent | string modalContent: ReactNode whatToRead?: string }) { const {content, modalContent, whatToRead} = props const [open, setOpen] = useState(false) return ( <> { setOpen(true) }} whatToRead={whatToRead} /> {modalContent} ) }