import type { ForwardedRef } from 'react'; import clsx from 'clsx'; import { NavigableRegion } from '@wordpress/admin-ui'; import { forwardRef, useEffect } from '@wordpress/element'; import { __unstableMotion as motion, __unstableAnimatePresence as AnimatePresence, } from '@wordpress/components'; import { __, _x } from '@wordpress/i18n'; import { useReducedMotion, useViewportMatch } from '@wordpress/compose'; import type { InterfaceSkeletonProps } from './types'; const ANIMATION_DURATION = 0.25; const commonTransition = { type: 'tween', duration: ANIMATION_DURATION, ease: [ 0.6, 0, 0.4, 1 ], }; function useHTMLClass( className: string ) { useEffect( () => { const element = document && document.querySelector( `html:not(.${ className })` ); if ( ! element ) { return; } element.classList.toggle( className ); return () => { element.classList.toggle( className ); }; }, [ className ] ); } const headerVariants = { hidden: { opacity: 1, marginTop: -60 }, visible: { opacity: 1, marginTop: 0 }, distractionFreeHover: { opacity: 1, marginTop: 0, transition: { ...commonTransition, delay: 0.2, delayChildren: 0.2, }, }, distractionFreeHidden: { opacity: 0, marginTop: -60, }, distractionFreeDisabled: { opacity: 0, marginTop: 0, transition: { ...commonTransition, delay: 0.8, delayChildren: 0.8, }, }, }; function InterfaceSkeleton( { isDistractionFree, footer, header, editorNotices, sidebar, secondarySidebar, content, actions, labels, className, }: InterfaceSkeletonProps, ref: ForwardedRef< HTMLDivElement > ) { const isMobileViewport = useViewportMatch( 'medium', '<' ); const disableMotion = useReducedMotion(); const defaultTransition = { type: 'tween', duration: disableMotion ? 0 : ANIMATION_DURATION, ease: [ 0.6, 0, 0.4, 1 ], }; useHTMLClass( 'interface-interface-skeleton__html-container' ); const defaultLabels = { /* translators: accessibility text for the top bar landmark region. */ header: _x( 'Header', 'header landmark area' ), /* translators: accessibility text for the content landmark region. */ body: __( 'Content' ), /* translators: accessibility text for the secondary sidebar landmark region. */ secondarySidebar: __( 'Block Library' ), /* translators: accessibility text for the settings landmark region. */ sidebar: _x( 'Settings', 'settings landmark area' ), /* translators: accessibility text for the publish landmark region. */ actions: __( 'Publish' ), /* translators: accessibility text for the footer landmark region. */ footer: __( 'Footer' ), }; const mergedLabels = { ...defaultLabels, ...labels }; return (