REBUILDING

This commit is contained in:
Antoine M 2025-07-15 10:37:56 +02:00
parent 5c17362daa
commit 235510e7ab
4 changed files with 31 additions and 16 deletions

View File

@ -25,6 +25,10 @@
"type": "string", "type": "string",
"default": "#136f63" "default": "#136f63"
}, },
"hasLightBackground": {
"type": "boolean",
"default": true
},
"textColor": { "textColor": {
"type": "string", "type": "string",
"default": "#ffffff" "default": "#ffffff"

View File

@ -1 +1 @@
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => 'a78cf784effd61db8731'); <?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => '1e925ab101f7d6d0270a');

View File

@ -41,7 +41,7 @@ function isColorLight(color) {
\************************/ \************************/
/***/ ((module) => { /***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"carhop-blocks/content-box","version":"0.1.0","title":"Content Box","category":"carhop-blocks","icon":"smiley","description":"Boite de contenu pour la mise en forme d\'éléments de contenu","example":{},"supports":{"html":false},"textdomain":"carhop-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","viewScript":"file:./view.js","attributes":{"hasBackgroundColor":{"type":"boolean","default":false},"backgroundColor":{"type":"string","default":"#136f63"},"textColor":{"type":"string","default":"#ffffff"}}}'); module.exports = /*#__PURE__*/JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":3,"name":"carhop-blocks/content-box","version":"0.1.0","title":"Content Box","category":"carhop-blocks","icon":"smiley","description":"Boite de contenu pour la mise en forme d\'éléments de contenu","example":{},"supports":{"html":false},"textdomain":"carhop-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","viewScript":"file:./view.js","attributes":{"hasBackgroundColor":{"type":"boolean","default":false},"backgroundColor":{"type":"string","default":"#136f63"},"hasLightBackground":{"type":"boolean","default":true},"textColor":{"type":"string","default":"#ffffff"}}}');
/***/ }), /***/ }),
@ -80,11 +80,22 @@ function Edit({
const { const {
hasBackgroundColor, hasBackgroundColor,
backgroundColor, backgroundColor,
textColor textColor,
hasLightBackground
} = attributes; } = attributes;
const isLightBackgroundColor = (0,_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.isColorLight)(backgroundColor);
console.log(isLightBackgroundColor);
function onBackgroundColorChange(value) { function onBackgroundColorChange(value) {
if (value === undefined) {
setAttributes({
hasBackgroundColor: false
});
setAttributes({
backgroundColor: "transparent"
});
}
const isLightBackgroundColor = (0,_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.isColorLight)(backgroundColor);
setAttributes({
hasLightBackground: isLightBackgroundColor
});
setAttributes({ setAttributes({
backgroundColor: value backgroundColor: value
}); });
@ -133,10 +144,10 @@ function Edit({
})] })]
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("section", { }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("section", {
...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps)({ ...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps)({
className: `content-box ${isLightBackgroundColor ? "content-box--bg-light" : "content-box--bg-dark"}`, className: `content-box ${hasLightBackground ? "content-box--bg-light" : "content-box--bg-dark"}`,
style: { style: {
"--content-box-background-color": backgroundColor, "--content-box-text-color": textColor !== null && textColor !== void 0 ? textColor : "inherit",
"--content-box-text-color": textColor "--content-box-background-color": hasBackgroundColor ? backgroundColor : "transparent"
} }
}), }),
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", { children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", {
@ -145,7 +156,7 @@ function Edit({
template: [["core/paragraph", { template: [["core/paragraph", {
placeholder: "Ajouter ici le texte" placeholder: "Ajouter ici le texte"
}]], }]],
allowedBlocks: ["core/heading", "core/paragraph", "core/list", "core/button", "core/buttons", "carhop-blocks/heading", "carhop-blocks/decorative-shapes", "acf/statistics-datas", "carhop-blocks/scroll-story-block", "carhop-blocks/cta-group", "ninja-forms/form"] allowedBlocks: ["core/heading", "core/paragraph", "core/group", "core/list", "core/button", "core/buttons", "carhop-blocks/heading", "carhop-blocks/decorative-shapes", "acf/statistics-datas", "carhop-blocks/scroll-story-block", "carhop-blocks/cta-group", "ninja-forms/form"]
}) })
}) })
})] })]
@ -231,17 +242,17 @@ function save({
attributes attributes
}) { }) {
const { const {
hasBackgroundColor,
backgroundColor, backgroundColor,
textColor textColor,
hasLightBackground,
hasBackgroundColor
} = attributes; } = attributes;
const isLightBackgroundColor = (0,_utilities_utilities__WEBPACK_IMPORTED_MODULE_1__.isColorLight)(backgroundColor);
return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("section", { return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("section", {
..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0__.useBlockProps.save({ ..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0__.useBlockProps.save({
className: `content-box ${isLightBackgroundColor ? "content-box--bg-light" : "content-box--bg-dark"}`, className: `content-box ${hasLightBackground ? "content-box--bg-light" : "content-box--bg-dark"}`,
style: { style: {
"--content-box-background-color": backgroundColor, "--content-box-text-color": textColor !== null && textColor !== void 0 ? textColor : "inherit",
"--content-box-text-color": textColor "--content-box-background-color": hasBackgroundColor ? backgroundColor : "transparent"
} }
}), }),
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", { children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", {

File diff suppressed because one or more lines are too long