FEATURE Adding numbering variant
This commit is contained in:
parent
6b1a2ba54e
commit
61503f2753
|
|
@ -15,5 +15,11 @@
|
|||
"editorScript": "file:./index.js",
|
||||
"editorStyle": "file:./index.css",
|
||||
"style": "file:./style-index.css",
|
||||
"viewScript": "file:./view.js"
|
||||
"viewScript": "file:./view.js",
|
||||
"attributes": {
|
||||
"hasNumbering": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,30 @@
|
|||
import { __ } from "@wordpress/i18n";
|
||||
import { useBlockProps, InnerBlocks } from "@wordpress/block-editor";
|
||||
import "./editor.scss";
|
||||
import { PanelBody, CheckboxControl } from "@wordpress/components";
|
||||
import { InspectorControls } from "@wordpress/block-editor";
|
||||
|
||||
export default function Edit({ attributes, setAttributes }) {
|
||||
const { hasNumbering } = attributes;
|
||||
return (
|
||||
<>
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
className="deligraph-blocks-components-image__panel-body"
|
||||
title={__("Numérotation", "deligraph-blocks")}
|
||||
>
|
||||
<CheckboxControl
|
||||
label="Afficher la numérotation"
|
||||
checked={hasNumbering}
|
||||
onChange={(value) => setAttributes({ hasNumbering: value })}
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<div
|
||||
{...useBlockProps({
|
||||
className: `scroll-story-block`,
|
||||
className: `scroll-story-block ${
|
||||
hasNumbering ? "scroll-story-block--has-numbering" : ""
|
||||
}`,
|
||||
})}
|
||||
>
|
||||
<InnerBlocks
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
import { useBlockProps, InnerBlocks } from "@wordpress/block-editor";
|
||||
|
||||
export default function save({ attributes }) {
|
||||
const { hasNumbering } = attributes;
|
||||
return (
|
||||
<div {...useBlockProps.save({ className: "scroll-story-block" })}>
|
||||
<div
|
||||
{...useBlockProps.save({
|
||||
className: `scroll-story-block ${
|
||||
hasNumbering ? "scroll-story-block--has-numbering" : ""
|
||||
}`,
|
||||
})}
|
||||
>
|
||||
<InnerBlocks.Content />
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user