const { dispatch } = wp.data; import { handleDesktopBtnClick, handleMobileBtnClick, handleTabBtnClick, } from "../helpers"; export default function WithResButtons({ className, children, resRequiredProps, label, // this prop is passed only from background control }) { const { setAttributes, resOption } = resRequiredProps; const editorType = window?.betterDocsBlocksHelper?.editorType ?? editorType; return (
{/* 'label' prop is used in background-control */} {label && ( {label} )} handleDesktopBtnClick({ setAttributes, setPreviewDeviceType: dispatch(editorType) .__experimentalSetPreviewDeviceType, }) } className={`typoResButton dashicons dashicons-desktop ${ resOption === "Desktop" ? "active" : " " }`} > handleTabBtnClick({ setAttributes, setPreviewDeviceType: dispatch(editorType) .__experimentalSetPreviewDeviceType, }) } className={`typoResButton dashicons dashicons-tablet ${ resOption === "Tablet" ? "active" : " " }`} > handleMobileBtnClick({ setAttributes, setPreviewDeviceType: dispatch(editorType) .__experimentalSetPreviewDeviceType, }) } className={`typoResButton dashicons dashicons-smartphone ${ resOption === "Mobile" ? "active" : " " }`} >
{children}
); }