import { clsx } from 'clsx' import { Button } from '../../_shared/Button' import { Icon } from '../../_shared/Icon' import { useLocalize } from '../../../context/localize' import styles from './Panel.module.scss' import { useEditorContext } from '../../../context/editor' import { useOutsideClickHandler } from '../../../utils/useOutsideClickHandler' import { useEscKeyDownHandler } from '../../../utils/useEscKeyDownHandler' import { getPagePath } from '@nanostores/router' import { router } from '../../../stores/router' type PanelProps = { shoutSlug: string } export const Panel = (props: PanelProps) => { const { t } = useLocalize() const { isEditorPanelVisible, wordCounter, actions: { toggleEditorPanel } } = useEditorContext() const containerRef: { current: HTMLElement } = { current: null } useOutsideClickHandler({ containerRef, predicate: () => isEditorPanelVisible(), handler: () => toggleEditorPanel() }) useEscKeyDownHandler(() => { if (isEditorPanelVisible()) { toggleEditorPanel() } }) return ( ) }