@wordpress/block-library
Version:
Block library for the WordPress editor.
29 lines (28 loc) • 945 B
JavaScript
import { jsx } from "react/jsx-runtime";
import clsx from "clsx";
import { useInnerBlocksProps, useBlockProps } from "@wordpress/block-editor";
function save({ attributes }) {
const { verticalAlignment, width } = attributes;
const wrapperClasses = clsx({
[`is-vertically-aligned-${verticalAlignment}`]: verticalAlignment
});
let style;
if (width && /\d/.test(width)) {
let flexBasis = Number.isFinite(width) ? width + "%" : width;
if (!Number.isFinite(width) && width?.endsWith("%")) {
const multiplier = 1e12;
flexBasis = Math.round(Number.parseFloat(width) * multiplier) / multiplier + "%";
}
style = { flexBasis };
}
const blockProps = useBlockProps.save({
className: wrapperClasses,
style
});
const innerBlocksProps = useInnerBlocksProps.save(blockProps);
return /* @__PURE__ */ jsx("div", { ...innerBlocksProps });
}
export {
save as default
};
//# sourceMappingURL=save.js.map