import * as DropdownMenu from '@radix-ui/react-dropdown-menu' import styled from 'styles' import { breakpoints, DropdownMenuButton, DropdownMenuDivider, RowButton, MenuContent, FloatingContainer, IconWrapper, } from 'components/shared' import PageOptions from './page-options' import { PlusIcon, CheckIcon } from '@radix-ui/react-icons' import state, { useSelector } from 'state' import { useEffect, useRef, useState } from 'react' function handleCreatePage() { state.send('CREATED_PAGE') } export default function PagePanel(): JSX.Element { const rIsOpen = useRef(false) const [isOpen, setIsOpen] = useState(false) useEffect(() => { if (rIsOpen.current !== isOpen) { rIsOpen.current = isOpen } }, [isOpen]) const documentPages = useSelector((s) => s.data.document.pages) const currentPageId = useSelector((s) => s.data.currentPageId) if (!documentPages[currentPageId]) return null const sorted = Object.values(documentPages).sort( (a, b) => a.childIndex - b.childIndex ) return ( { if (rIsOpen.current !== isOpen) { setIsOpen(isOpen) } }} > {documentPages[currentPageId].name} { setIsOpen(false) state.send('CHANGED_PAGE', { id }) }} > {sorted.map((page) => ( {page.name} ))} Create Page ) } const ButtonWithOptions = styled('div', { display: 'grid', gridTemplateColumns: '1fr auto', gridAutoFlow: 'column', '& > *[data-shy="true"]': { opacity: 0, }, '&:hover > *[data-shy="true"]': { opacity: 1, }, })