import { useEffect, useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { Icon } from '@wordpress/icons'; import classNames from 'classnames'; import { bannerButtonVariables, barVariables, buttonHoverClasses, colorsOf, } from '../colors'; import { DismissButton } from '../DismissButton'; import { iconFor } from '../icons'; import { externalLinkProps } from '../notification-link'; export const Bar = ({ notification, href, external, dismissible, onDismiss, onClick, }) => { const { title, content } = notification; const ctaLabel = notification['cta-label']; const icon = iconFor(notification.icon); const colors = colorsOf(notification); const ref = useRef(null); // The agent reads this to keep its panel and the scaled page off the bar. useEffect(() => { const root = document.documentElement; const publish = () => root.style.setProperty( '--extendify-notification-bar-height', // 0 below the breakpoint, where the bar is display:none. `${ref.current.offsetHeight}px`, ); publish(); const observer = new ResizeObserver(publish); observer.observe(ref.current); return () => { observer.disconnect(); root.style.removeProperty('--extendify-notification-bar-height'); }; }, []); return ( ); };