FEATURE Adding numbering variant
This commit is contained in:
parent
6b1a2ba54e
commit
61503f2753
|
|
@ -15,5 +15,11 @@
|
||||||
"editorScript": "file:./index.js",
|
"editorScript": "file:./index.js",
|
||||||
"editorStyle": "file:./index.css",
|
"editorStyle": "file:./index.css",
|
||||||
"style": "file:./style-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 { __ } from "@wordpress/i18n";
|
||||||
import { useBlockProps, InnerBlocks } from "@wordpress/block-editor";
|
import { useBlockProps, InnerBlocks } from "@wordpress/block-editor";
|
||||||
import "./editor.scss";
|
import "./editor.scss";
|
||||||
|
import { PanelBody, CheckboxControl } from "@wordpress/components";
|
||||||
|
import { InspectorControls } from "@wordpress/block-editor";
|
||||||
|
|
||||||
export default function Edit({ attributes, setAttributes }) {
|
export default function Edit({ attributes, setAttributes }) {
|
||||||
|
const { hasNumbering } = attributes;
|
||||||
return (
|
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
|
<div
|
||||||
{...useBlockProps({
|
{...useBlockProps({
|
||||||
className: `scroll-story-block`,
|
className: `scroll-story-block ${
|
||||||
|
hasNumbering ? "scroll-story-block--has-numbering" : ""
|
||||||
|
}`,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<InnerBlocks
|
<InnerBlocks
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,15 @@
|
||||||
import { useBlockProps, InnerBlocks } from "@wordpress/block-editor";
|
import { useBlockProps, InnerBlocks } from "@wordpress/block-editor";
|
||||||
|
|
||||||
export default function save({ attributes }) {
|
export default function save({ attributes }) {
|
||||||
|
const { hasNumbering } = attributes;
|
||||||
return (
|
return (
|
||||||
<div {...useBlockProps.save({ className: "scroll-story-block" })}>
|
<div
|
||||||
|
{...useBlockProps.save({
|
||||||
|
className: `scroll-story-block ${
|
||||||
|
hasNumbering ? "scroll-story-block--has-numbering" : ""
|
||||||
|
}`,
|
||||||
|
})}
|
||||||
|
>
|
||||||
<InnerBlocks.Content />
|
<InnerBlocks.Content />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user