| 1 |
import { useMemo } from "@wordpress/element"; |
| 2 |
import { useBlockProps, InnerBlocks } from "@wordpress/block-editor"; |
| 3 |
import InspectorControl from "../../components/inspectorControls/inspectorControls"; |
| 4 |
import { panelBodyRightIcon, panelBodyTitleIcon } from "../../icons/icons"; |
| 5 |
import dynamicCssFn from "./dynamicCss"; |
| 6 |
import Inspector from "./inspect"; |
| 7 |
import { useDeviceType } from "../../controls/controls"; |
| 8 |
import { compose } from "@wordpress/compose"; |
| 9 |
import addInitialAttr from "../shared/addInitialAttr"; |
| 10 |
|
| 11 |
const ButtonsEdit = ({ attributes, setAttributes }) => { |
| 12 |
const { uniqueId, additionalCssClass, customCss } = attributes; |
| 13 |
const currentDevice = useDeviceType(); |
| 14 |
|
| 15 |
const dynamicCssValue = useMemo( |
| 16 |
() => dynamicCssFn(attributes, "frontend", currentDevice), |
| 17 |
[attributes, currentDevice] |
| 18 |
); |
| 19 |
const blockProps = useBlockProps({ |
| 20 |
className: additionalCssClass, |
| 21 |
}); |
| 22 |
|
| 23 |
return ( |
| 24 |
<div {...blockProps}> |
| 25 |
<style> |
| 26 |
{dynamicCssValue} |
| 27 |
{customCss} |
| 28 |
</style> |
| 29 |
|
| 30 |
<InspectorControl |
| 31 |
TitleIcon={panelBodyTitleIcon} |
| 32 |
RightIcon={panelBodyRightIcon} |
| 33 |
Inspector={Inspector} |
| 34 |
attributes={attributes} |
| 35 |
setAttributes={setAttributes} |
| 36 |
/> |
| 37 |
<div className="sp-smart-post-buttons-editor-page sp-smart-post-buttons-wrapper" id={uniqueId}> |
| 38 |
<InnerBlocks |
| 39 |
__experimentalCaptureToolbars={false} |
| 40 |
allowedBlocks={["sp-smart-post-show/button"]} |
| 41 |
template={[["sp-smart-post-show/button"]]} |
| 42 |
/> |
| 43 |
</div> |
| 44 |
</div> |
| 45 |
); |
| 46 |
}; |
| 47 |
|
| 48 |
export default compose(addInitialAttr)(ButtonsEdit); |
| 49 |
|