FEATURE introducing hte block width variation
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2025-07-03 10:24:36 +02:00
parent 92084f7826
commit 714bc5b3a1
7 changed files with 76 additions and 9 deletions

View File

@ -22,6 +22,14 @@
"type": "string",
"default": "full"
},
"blockWidth": {
"type": "string",
"default": "full",
"enum": [
"full",
"contained"
]
},
"coverUrl": {
"type": "string"
},

View File

@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-primitives'), 'version' => '4148e87939fccf7f9ff3');
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-primitives'), 'version' => '62a57819a79c88fe5e2d');

View File

@ -41,7 +41,7 @@ const trash = /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx
\************************/
/***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"carhop-blocks/chapter-section","version":"0.1.0","title":" Section Chapitre","category":"carhop-blocks","icon":"smiley","description":"Example block scaffolded with Create Block tool.","example":{},"supports":{"html":false},"textdomain":"carhop-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","viewScript":"file:./view.js","render":"file:./render.php","attributes":{"align":{"type":"string","default":"full"},"coverUrl":{"type":"string"},"coverAlt":{"type":"string"},"coverId":{"type":"number"},"coverSize":{"type":"string","default":"large","enum":["small","medium","grande","large"]},"disposition":{"type":"string","default":"left","enum":["left","right"]},"hasBackgroundColor":{"type":"boolean","default":false},"backgroundColor":{"type":"string","default":"#ffffff"},"backgroundOrientation":{"type":"string","default":"left","enum":["left","right"]}},"usesContext":["postType","postId"]}');
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"carhop-blocks/chapter-section","version":"0.1.0","title":" Section Chapitre","category":"carhop-blocks","icon":"smiley","description":"Example block scaffolded with Create Block tool.","example":{},"supports":{"html":false},"textdomain":"carhop-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","viewScript":"file:./view.js","render":"file:./render.php","attributes":{"align":{"type":"string","default":"full"},"blockWidth":{"type":"string","default":"full","enum":["full","contained"]},"coverUrl":{"type":"string"},"coverAlt":{"type":"string"},"coverId":{"type":"number"},"coverSize":{"type":"string","default":"large","enum":["small","medium","grande","large"]},"disposition":{"type":"string","default":"left","enum":["left","right"]},"hasBackgroundColor":{"type":"boolean","default":false},"backgroundColor":{"type":"string","default":"#ffffff"},"backgroundOrientation":{"type":"string","default":"left","enum":["left","right"]}},"usesContext":["postType","postId"]}');
/***/ }),
@ -86,7 +86,8 @@ function Edit({
coverSize,
hasBackgroundColor,
backgroundColor,
backgroundOrientation
backgroundOrientation,
blockWidth
} = attributes;
function onDispositionChange(disposition) {
setAttributes({
@ -134,7 +135,26 @@ function Edit({
}
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.Fragment, {
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InspectorControls, {
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
className: "deligraph-blocks-components-image__panel-body",
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)("Largeur", "deligraph-blocks"),
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControl, {
className: "deligraph-blocks__variant",
isBlock: true,
label: "Largeur du bloc",
onChange: value => setAttributes({
blockWidth: value
}),
value: blockWidth,
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, {
label: "Contenue",
value: "contained"
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, {
label: "Pleine largeur",
value: "full"
})]
})
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, {
className: "deligraph-blocks-components-image__panel-body",
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)("Image d'accompagnement", "deligraph-blocks"),
children: [coverUrl && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("img", {
@ -221,7 +241,9 @@ function Edit({
})]
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)("section", {
...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps)({
className: `deligraph-blocks-chapter-section chapter-section chapter-section--${disposition} ${hasBackgroundColor && backgroundColor ? "chapter-section--has-background" : ""}`
className: `deligraph-blocks-chapter-section chapter-section chapter-section--${disposition}
${blockWidth === "full" ? "chapter-section--width-full" : "chapter-section--width-contained"}
${hasBackgroundColor && backgroundColor ? "chapter-section--has-background" : ""}`
}),
children: [hasBackgroundColor && backgroundColor && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("svg", {
className: `chapter-section__background chapter-section__background--${backgroundOrientation}`,
@ -343,11 +365,12 @@ function save({
coverSize,
backgroundColor,
hasBackgroundColor,
backgroundOrientation
backgroundOrientation,
blockWidth
} = attributes;
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsxs)("section", {
..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0__.useBlockProps.save({
className: `deligraph-blocks-chapter-section chapter-section chapter-section--${disposition} ${backgroundColor ? "chapter-section--has-background" : ""}`
className: `deligraph-blocks-chapter-section chapter-section chapter-section--${disposition} ${backgroundColor ? "chapter-section--has-background" : ""} ${blockWidth === "full" ? "chapter-section--width-full" : "chapter-section--width-contained"}`
}),
children: [hasBackgroundColor && backgroundColor && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_1__.jsx)("svg", {
className: `chapter-section__background chapter-section__background--${backgroundOrientation}`,

File diff suppressed because one or more lines are too long

View File

@ -22,6 +22,14 @@
"type": "string",
"default": "full"
},
"blockWidth": {
"type": "string",
"default": "full",
"enum": [
"full",
"contained"
]
},
"coverUrl": {
"type": "string"
},

View File

@ -29,6 +29,7 @@ export default function Edit({ attributes, setAttributes, ...props }) {
hasBackgroundColor,
backgroundColor,
backgroundOrientation,
blockWidth,
} = attributes;
function onDispositionChange(disposition) {
@ -68,6 +69,21 @@ export default function Edit({ attributes, setAttributes, ...props }) {
return (
<>
<InspectorControls>
<PanelBody
className="deligraph-blocks-components-image__panel-body"
title={__("Largeur", "deligraph-blocks")}
>
<ToggleGroupControl
className="deligraph-blocks__variant"
isBlock
label="Largeur du bloc"
onChange={(value) => setAttributes({ blockWidth: value })}
value={blockWidth}
>
<ToggleGroupControlOption label="Contenue" value="contained" />
<ToggleGroupControlOption label="Pleine largeur" value="full" />
</ToggleGroupControl>
</PanelBody>
<PanelBody
className="deligraph-blocks-components-image__panel-body"
title={__("Image d'accompagnement", "deligraph-blocks")}
@ -122,6 +138,7 @@ export default function Edit({ attributes, setAttributes, ...props }) {
<ToggleGroupControlOption label="Petite" value="small" />
</ToggleGroupControl>
</PanelBody>
<PanelBody
className="deligraph-blocks-components-image__panel-body"
title={__("Arrière plan", "deligraph-blocks")}
@ -154,7 +171,13 @@ export default function Edit({ attributes, setAttributes, ...props }) {
</InspectorControls>
<section
{...useBlockProps({
className: `deligraph-blocks-chapter-section chapter-section chapter-section--${disposition} ${
className: `deligraph-blocks-chapter-section chapter-section chapter-section--${disposition}
${
blockWidth === "full"
? "chapter-section--width-full"
: "chapter-section--width-contained"
}
${
hasBackgroundColor && backgroundColor
? "chapter-section--has-background"
: ""

View File

@ -8,12 +8,17 @@ export default function save({ attributes }) {
backgroundColor,
hasBackgroundColor,
backgroundOrientation,
blockWidth,
} = attributes;
return (
<section
{...useBlockProps.save({
className: `deligraph-blocks-chapter-section chapter-section chapter-section--${disposition} ${
backgroundColor ? "chapter-section--has-background" : ""
} ${
blockWidth === "full"
? "chapter-section--width-full"
: "chapter-section--width-contained"
}`,
})}
>