From d72159c9e4e4eb2b6ec0d22ebfc13f15872be7a4 Mon Sep 17 00:00:00 2001 From: Antoine M Date: Wed, 27 Aug 2025 11:01:43 +0200 Subject: [PATCH] FEATURE Adapting content box to be handle by dynamic articles --- .../blocks/content-box/build/block.json | 4 + .../blocks/content-box/build/index.asset.php | 2 +- .../blocks/content-box/build/index.js | 185 +++++++++++++----- .../blocks/content-box/build/index.js.map | 2 +- .../blocks/content-box/src/block.json | 4 + .../blocks/content-box/src/edit.js | 128 ++++++++---- .../blocks/content-box/src/save.js | 16 +- .../blocks/content-box/src/utilities.js | 39 ++++ 8 files changed, 289 insertions(+), 91 deletions(-) create mode 100644 plugins/carhop-blocks/blocks/content-box/src/utilities.js diff --git a/plugins/carhop-blocks/blocks/content-box/build/block.json b/plugins/carhop-blocks/blocks/content-box/build/block.json index b416259..8db76ba 100644 --- a/plugins/carhop-blocks/blocks/content-box/build/block.json +++ b/plugins/carhop-blocks/blocks/content-box/build/block.json @@ -32,6 +32,10 @@ "textColor": { "type": "string", "default": "#ffffff" + }, + "blockVariant": { + "type": "string", + "default": "framed" } } } \ No newline at end of file diff --git a/plugins/carhop-blocks/blocks/content-box/build/index.asset.php b/plugins/carhop-blocks/blocks/content-box/build/index.asset.php index bd54fe1..08ba83c 100644 --- a/plugins/carhop-blocks/blocks/content-box/build/index.asset.php +++ b/plugins/carhop-blocks/blocks/content-box/build/index.asset.php @@ -1 +1 @@ - array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n'), 'version' => '1e925ab101f7d6d0270a'); + array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-i18n'), 'version' => 'fbe907136f52d95a3931'); diff --git a/plugins/carhop-blocks/blocks/content-box/build/index.js b/plugins/carhop-blocks/blocks/content-box/build/index.js index 31be8bf..c435c1a 100644 --- a/plugins/carhop-blocks/blocks/content-box/build/index.js +++ b/plugins/carhop-blocks/blocks/content-box/build/index.js @@ -41,7 +41,7 @@ function isColorLight(color) { \************************/ /***/ ((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"},"hasLightBackground":{"type":"boolean","default":true},"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"},"blockVariant":{"type":"string","default":"framed"}}}'); /***/ }), @@ -59,12 +59,18 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/block-editor */ "@wordpress/block-editor"); /* harmony import */ var _wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./editor.scss */ "./src/editor.scss"); -/* harmony import */ var _utilities_utilities__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../_utilities/utilities */ "../_utilities/utilities.js"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__); -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); -/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__); +/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); +/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); +/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__); +/* harmony import */ var _editor_scss__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./editor.scss */ "./src/editor.scss"); +/* harmony import */ var _utilities_utilities__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../_utilities/utilities */ "../_utilities/utilities.js"); +/* harmony import */ var _utilities__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./utilities */ "./src/utilities.js"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! react/jsx-runtime */ "react/jsx-runtime"); +/* harmony import */ var react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__); + + + @@ -81,8 +87,16 @@ function Edit({ hasBackgroundColor, backgroundColor, textColor, - hasLightBackground + hasLightBackground, + blockVariant } = attributes; + + // Détecter le type de post actuel + const postType = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => { + return select("core/editor").getCurrentPostType(); + }, []); + const filteredBgColors = (0,_utilities__WEBPACK_IMPORTED_MODULE_6__.filterBgColors)(colors, postType); + const filteredTextColors = (0,_utilities__WEBPACK_IMPORTED_MODULE_6__.filterTextColors)(colors, postType, backgroundColor); function onBackgroundColorChange(value) { if (value === undefined) { setAttributes({ @@ -92,13 +106,22 @@ function Edit({ backgroundColor: "transparent" }); } - const isLightBackgroundColor = (0,_utilities_utilities__WEBPACK_IMPORTED_MODULE_3__.isColorLight)(backgroundColor); + const isLightBackgroundColor = (0,_utilities_utilities__WEBPACK_IMPORTED_MODULE_5__.isColorLight)(value); setAttributes({ hasLightBackground: isLightBackgroundColor }); setAttributes({ backgroundColor: value }); + if (!isLightBackgroundColor) { + setAttributes({ + textColor: "#fff" + }); + } else { + setAttributes({ + textColor: "inherit" + }); + } } function onHasBackgroundColorChange(value) { setAttributes({ @@ -115,48 +138,72 @@ function Edit({ textColor: value }); } - return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.Fragment, { - children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InspectorControls, { - children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.PanelBody, { - className: "deligraph-blocks-components-image__panel-body", - title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)("Arrière plan", "deligraph-blocks"), - children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.CheckboxControl, { - label: "Arri\xE8re plan color\xE9", - checked: hasBackgroundColor, - onChange: onHasBackgroundColorChange - }), hasBackgroundColor && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.Fragment, { - children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.ColorPalette, { - colors: colors, - value: backgroundColor, - onChange: onBackgroundColorChange - }) + function onBlockVariantChange(value) { + setAttributes({ + blockVariant: value + }); + } + return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.Fragment, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InspectorControls, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.PanelBody, { + title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)("Aspect", "carhop-blocks"), + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControl, { + label: "Mod\xE8le de bloc", + value: blockVariant, + onChange: onBlockVariantChange, + isBlock: true, + __nextHasNoMarginBottom: true, + __next40pxDefaultSize: true, + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, { + value: "framed", + label: "Encadr\xE9" + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, { + value: "backgrounded", + label: "Fond color\xE9" + })] + }), blockVariant === "backgrounded" && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Card, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.CardHeader, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("h1", { + children: "Couleur de fond" + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.CardBody, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.Fragment, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ColorPalette, { + colors: filteredBgColors, + value: backgroundColor, + onChange: onBackgroundColorChange + }) + }) + })] + }), blockVariant === "backgrounded" && postType !== "articles" && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.Card, { + children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.CardHeader, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("h1", { + children: "Couleur du texte " + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.CardBody, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ColorPalette, { + colors: filteredTextColors, + value: textColor, + onChange: onTextColorChange + }) + })] })] - }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.PanelBody, { - className: "deligraph-blocks-components-image__panel-body", - title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_0__.__)("Couleur du texte", "deligraph-blocks"), - children: hasBackgroundColor && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.Fragment, { - children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__.ColorPalette, { - colors: colors, - value: textColor, - onChange: onTextColorChange - }) - }) - })] - }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("section", { + }) + }), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("section", { ...(0,_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.useBlockProps)({ - className: `content-box ${hasLightBackground ? "content-box--bg-light" : "content-box--bg-dark"}`, + className: `content-box content-box--variant-${blockVariant} ${hasLightBackground ? "content-box--bg-light" : "content-box--bg-dark"}`, style: { "--content-box-text-color": textColor !== null && textColor !== void 0 ? textColor : "inherit", - "--content-box-background-color": hasBackgroundColor ? backgroundColor : "transparent" + "--content-box-background-color": blockVariant === "backgrounded" ? backgroundColor : "transparent" } }), - children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)("div", { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)("div", { className: "content-box__innerblocks", - children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_5__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InnerBlocks, { + children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_7__.jsx)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_1__.InnerBlocks, { template: [["core/paragraph", { placeholder: "Ajouter ici le texte" }]], - 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"] + allowedBlocks: ["core/heading", "core/paragraph", "core/group", "core/list", "core/button", "core/image", "core/buttons", "carhop-blocks/heading", "carhop-blocks/decorative-shapes", "acf/statistics-datas", "carhop-blocks/scroll-story-block", "carhop-blocks/cta-group", "ninja-forms/form"] }) }) })] @@ -245,14 +292,15 @@ function save({ backgroundColor, textColor, hasLightBackground, - hasBackgroundColor + hasBackgroundColor, + blockVariant } = attributes; return /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("section", { ..._wordpress_block_editor__WEBPACK_IMPORTED_MODULE_0__.useBlockProps.save({ - className: `content-box ${hasLightBackground ? "content-box--bg-light" : "content-box--bg-dark"}`, + className: `content-box content-box--variant-${blockVariant} ${hasLightBackground ? "content-box--bg-light" : "content-box--bg-dark"}`, style: { "--content-box-text-color": textColor !== null && textColor !== void 0 ? textColor : "inherit", - "--content-box-background-color": hasBackgroundColor ? backgroundColor : "transparent" + "--content-box-background-color": blockVariant === "backgrounded" ? backgroundColor : "transparent" } }), children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_2__.jsx)("div", { @@ -274,6 +322,45 @@ __webpack_require__.r(__webpack_exports__); // extracted by mini-css-extract-plugin +/***/ }), + +/***/ "./src/utilities.js": +/*!**************************!*\ + !*** ./src/utilities.js ***! + \**************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ filterBgColors: () => (/* binding */ filterBgColors), +/* harmony export */ filterTextColors: () => (/* binding */ filterTextColors) +/* harmony export */ }); +/* harmony import */ var _utilities_utilities__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../_utilities/utilities */ "../_utilities/utilities.js"); + +const filterBgColors = (colors, postType) => { + if (!postType) return colors || []; + if (postType === "articles") { + return colors?.filter(color => { + // Garder seulement certaines couleurs pour les articles + const allowedColors = ["carhop-green-light", "carhop-blue-light", "carhop-orange-light", "carhop-red-light", "carhop-purple-light"]; + return allowedColors.includes(color.slug); + }) || []; + } + return colors || []; +}; +const filterTextColors = (colors, postType, backgroundColor) => { + if (!postType) return colors || []; + if (postType === "page" && !(0,_utilities_utilities__WEBPACK_IMPORTED_MODULE_0__.isColorLight)(backgroundColor)) { + // Retourner seulement du blanc pour les pages avec arrière-plan sombre + return [{ + name: "White", + slug: "white", + color: "#ffffff" + }]; + } + return colors || []; +}; + /***/ }), /***/ "@wordpress/block-editor": @@ -306,6 +393,16 @@ module.exports = window["wp"]["components"]; /***/ }), +/***/ "@wordpress/data": +/*!******************************!*\ + !*** external ["wp","data"] ***! + \******************************/ +/***/ ((module) => { + +module.exports = window["wp"]["data"]; + +/***/ }), + /***/ "@wordpress/i18n": /*!******************************!*\ !*** external ["wp","i18n"] ***! diff --git a/plugins/carhop-blocks/blocks/content-box/build/index.js.map b/plugins/carhop-blocks/blocks/content-box/build/index.js.map index 0fac97f..3976312 100644 --- a/plugins/carhop-blocks/blocks/content-box/build/index.js.map +++ b/plugins/carhop-blocks/blocks/content-box/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;AAAA;AACO,SAASA,YAAYA,CAACC,KAAK,EAAE;EACnC;EACA,IAAI,CAACA,KAAK,EAAE,OAAO,IAAI;;EAEvB;EACA,IAAIC,GAAG,GAAGD,KAAK,CAACE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;EAChC,IAAID,GAAG,CAACE,MAAM,KAAK,CAAC,EAAE;IACrBF,GAAG,GAAGA,GAAG,CACPG,KAAK,CAAC,EAAE,CAAC,CACTC,GAAG,CAAEC,IAAI,IAAKA,IAAI,GAAGA,IAAI,CAAC,CAC1BC,IAAI,CAAC,EAAE,CAAC;EACX;EAEA,MAAMC,CAAC,GAAGC,QAAQ,CAACR,GAAG,CAACS,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;EACxC,MAAMC,CAAC,GAAGF,QAAQ,CAACR,GAAG,CAACS,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;EACxC,MAAME,CAAC,GAAGH,QAAQ,CAACR,GAAG,CAACS,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;;EAExC;EACA,MAAMG,SAAS,GAAG,CAAC,KAAK,GAAGL,CAAC,GAAG,KAAK,GAAGG,CAAC,GAAG,KAAK,GAAGC,CAAC,IAAI,GAAG;;EAE3D;EACA,OAAOC,SAAS,GAAG,GAAG;AACvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACvBqC;AAQJ;AACV;AACmC;AAS3B;AAAA;AAEhB,SAASsB,IAAIA,CAAC;EAAEC,UAAU;EAAEC,aAAa;EAAE,GAAGC;AAAM,CAAC,EAAE;EACrE,MAAMC,MAAM,GAAGtB,mEAAU,CAAC,qBAAqB,CAAC;EAChD,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UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://front-header/../_utilities/utilities.js","webpack://front-header/./src/edit.js","webpack://front-header/./src/editor.scss","webpack://front-header/./src/index.js","webpack://front-header/./src/save.js","webpack://front-header/./src/style.scss","webpack://front-header/external window [\"wp\",\"blockEditor\"]","webpack://front-header/external window [\"wp\",\"blocks\"]","webpack://front-header/external window [\"wp\",\"components\"]","webpack://front-header/external window [\"wp\",\"i18n\"]","webpack://front-header/external window \"ReactJSXRuntime\"","webpack://front-header/webpack/bootstrap","webpack://front-header/webpack/runtime/chunk loaded","webpack://front-header/webpack/runtime/compat get default export","webpack://front-header/webpack/runtime/define property getters","webpack://front-header/webpack/runtime/hasOwnProperty shorthand","webpack://front-header/webpack/runtime/make namespace object","webpack://front-header/webpack/runtime/jsonp chunk loading","webpack://front-header/webpack/before-startup","webpack://front-header/webpack/startup","webpack://front-header/webpack/after-startup"],"sourcesContent":["// Fonction pour déterminer si une couleur est claire ou sombre\r\nexport function isColorLight(color) {\r\n\t// Si pas de couleur, considérer comme claire\r\n\tif (!color) return true;\r\n\r\n\t// Convertir hex en RGB\r\n\tlet hex = color.replace(\"#\", \"\");\r\n\tif (hex.length === 3) {\r\n\t\thex = hex\r\n\t\t\t.split(\"\")\r\n\t\t\t.map((char) => char + char)\r\n\t\t\t.join(\"\");\r\n\t}\r\n\r\n\tconst r = parseInt(hex.substr(0, 2), 16);\r\n\tconst g = parseInt(hex.substr(2, 2), 16);\r\n\tconst b = parseInt(hex.substr(4, 2), 16);\r\n\r\n\t// Calculer la luminance relative (formule standard)\r\n\tconst luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\r\n\r\n\t// Si luminance > 0.5, la couleur est claire\r\n\treturn luminance > 0.5;\r\n}\r\n","import { __ } from \"@wordpress/i18n\";\nimport {\n\tuseBlockProps,\n\tInnerBlocks,\n\tuseSetting,\n\tInspectorControls,\n\tMediaReplaceFlow,\n\tMediaPlaceholder,\n} from \"@wordpress/block-editor\";\nimport \"./editor.scss\";\nimport { isColorLight } from \"../../_utilities/utilities\";\n\nimport {\n\tPanelBody,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tButton,\n\tCheckboxControl,\n\tColorPalette,\n} from \"@wordpress/components\";\n\nexport default function Edit({ attributes, setAttributes, ...props }) {\n\tconst colors = useSetting(\"color.palette.theme\");\n\tconst { hasBackgroundColor, backgroundColor, textColor, hasLightBackground } =\n\t\tattributes;\n\n\tfunction onBackgroundColorChange(value) {\n\t\tif (value === undefined) {\n\t\t\tsetAttributes({ hasBackgroundColor: false });\n\t\t\tsetAttributes({ backgroundColor: \"transparent\" });\n\t\t}\n\t\tconst isLightBackgroundColor = isColorLight(backgroundColor);\n\t\tsetAttributes({ hasLightBackground: isLightBackgroundColor });\n\n\t\tsetAttributes({ backgroundColor: value });\n\t}\n\tfunction onHasBackgroundColorChange(value) {\n\t\tsetAttributes({ hasBackgroundColor: value });\n\t\tif (!value) {\n\t\t\tsetAttributes({ backgroundColor: null });\n\t\t}\n\t}\n\tfunction onTextColorChange(value) {\n\t\tsetAttributes({ textColor: value });\n\t}\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t{hasBackgroundColor && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t{hasBackgroundColor && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t)}\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","import { registerBlockType } from \"@wordpress/blocks\";\nimport \"./style.scss\";\n\nimport Edit from \"./edit\";\nimport save from \"./save\";\nimport metadata from \"./block.json\";\n\nregisterBlockType(metadata.name, {\n\ticon: {\n\t\tforeground: \"#136f63\",\n\t\tsrc: (\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t),\n\t},\n\tedit: Edit,\n\tsave,\n});\n","import { useBlockProps, InnerBlocks } from \"@wordpress/block-editor\";\nimport { isColorLight } from \"../../_utilities/utilities\";\n\nexport default function save({ attributes }) {\n\tconst { backgroundColor, textColor, hasLightBackground, hasBackgroundColor } =\n\t\tattributes;\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t
\n\t\t\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkfront_header\"] = globalThis[\"webpackChunkfront_header\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["isColorLight","color","hex","replace","length","split","map","char","join","r","parseInt","substr","g","b","luminance","__","useBlockProps","InnerBlocks","useSetting","InspectorControls","MediaReplaceFlow","MediaPlaceholder","PanelBody","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","Button","CheckboxControl","ColorPalette","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","Edit","attributes","setAttributes","props","colors","hasBackgroundColor","backgroundColor","textColor","hasLightBackground","onBackgroundColorChange","value","undefined","isLightBackgroundColor","onHasBackgroundColorChange","onTextColorChange","children","className","title","label","checked","onChange","style","template","placeholder","allowedBlocks","registerBlockType","save","metadata","name","icon","foreground","src","width","height","viewBox","d","edit","Content"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;;AAAA;AACO,SAASA,YAAYA,CAACC,KAAK,EAAE;EACnC;EACA,IAAI,CAACA,KAAK,EAAE,OAAO,IAAI;;EAEvB;EACA,IAAIC,GAAG,GAAGD,KAAK,CAACE,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC;EAChC,IAAID,GAAG,CAACE,MAAM,KAAK,CAAC,EAAE;IACrBF,GAAG,GAAGA,GAAG,CACPG,KAAK,CAAC,EAAE,CAAC,CACTC,GAAG,CAAEC,IAAI,I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M,IAAI,EAAE;EAClC,IAAIM,QAAQ,KAAK,MAAM,IAAI,CAACtD,kEAAY,CAACkD,eAAe,CAAC,EAAE;IAC1D;IACA,OAAO,CACN;MACC+B,IAAI,EAAE,OAAO;MACba,IAAI,EAAE,OAAO;MACb7F,KAAK,EAAE;IACR,CAAC,CACD;EACF;EAEA,OAAO+C,MAAM,IAAI,EAAE;AACpB,CAAC;;;;;;;;;;ACtCD;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;UAEA;UACA;;;;;WCzBA;WACA;WACA;WACA;WACA,+BAA+B,wCAAwC;WACvE;WACA;WACA;WACA;WACA,iBAAiB,qBAAqB;WACtC;WACA;WACA,kBAAkB,qBAAqB;WACvC;WACA;WACA,KAAK;WACL;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;;;WC3BA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;WCNA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,MAAM,qBAAqB;WAC3B;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;WAEA;WACA;WACA;;;;;UEjDA;UACA;UACA;UACA;UACA","sources":["webpack://front-header/../_utilities/utilities.js","webpack://front-header/./src/edit.js","webpack://front-header/./src/editor.scss","webpack://front-header/./src/index.js","webpack://front-header/./src/save.js","webpack://front-header/./src/style.scss","webpack://front-header/./src/utilities.js","webpack://front-header/external window [\"wp\",\"blockEditor\"]","webpack://front-header/external window [\"wp\",\"blocks\"]","webpack://front-header/external window [\"wp\",\"components\"]","webpack://front-header/external window [\"wp\",\"data\"]","webpack://front-header/external window [\"wp\",\"i18n\"]","webpack://front-header/external window \"ReactJSXRuntime\"","webpack://front-header/webpack/bootstrap","webpack://front-header/webpack/runtime/chunk loaded","webpack://front-header/webpack/runtime/compat get default export","webpack://front-header/webpack/runtime/define property getters","webpack://front-header/webpack/runtime/hasOwnProperty shorthand","webpack://front-header/webpack/runtime/make namespace object","webpack://front-header/webpack/runtime/jsonp chunk loading","webpack://front-header/webpack/before-startup","webpack://front-header/webpack/startup","webpack://front-header/webpack/after-startup"],"sourcesContent":["// Fonction pour déterminer si une couleur est claire ou sombre\r\nexport function isColorLight(color) {\r\n\t// Si pas de couleur, considérer comme claire\r\n\tif (!color) return true;\r\n\r\n\t// Convertir hex en RGB\r\n\tlet hex = color.replace(\"#\", \"\");\r\n\tif (hex.length === 3) {\r\n\t\thex = hex\r\n\t\t\t.split(\"\")\r\n\t\t\t.map((char) => char + char)\r\n\t\t\t.join(\"\");\r\n\t}\r\n\r\n\tconst r = parseInt(hex.substr(0, 2), 16);\r\n\tconst g = parseInt(hex.substr(2, 2), 16);\r\n\tconst b = parseInt(hex.substr(4, 2), 16);\r\n\r\n\t// Calculer la luminance relative (formule standard)\r\n\tconst luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;\r\n\r\n\t// Si luminance > 0.5, la couleur est claire\r\n\treturn luminance > 0.5;\r\n}\r\n","import { __ } from \"@wordpress/i18n\";\nimport {\n\tuseBlockProps,\n\tInnerBlocks,\n\tuseSetting,\n\tInspectorControls,\n\tMediaReplaceFlow,\n\tMediaPlaceholder,\n} from \"@wordpress/block-editor\";\nimport {\n\tCard,\n\tCardHeader,\n\tCardBody,\n\tHeading,\n\tText,\n} from \"@wordpress/components\";\nimport { useSelect } from \"@wordpress/data\";\nimport \"./editor.scss\";\nimport { isColorLight } from \"../../_utilities/utilities\";\nimport {\n\tPanelBody,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tButton,\n\tCheckboxControl,\n\tColorPalette,\n} from \"@wordpress/components\";\n\nimport { filterBgColors, filterTextColors } from \"./utilities\";\n\nexport default function Edit({ attributes, setAttributes, ...props }) {\n\tconst colors = useSetting(\"color.palette.theme\");\n\n\tconst {\n\t\thasBackgroundColor,\n\t\tbackgroundColor,\n\t\ttextColor,\n\t\thasLightBackground,\n\t\tblockVariant,\n\t} = attributes;\n\n\t// Détecter le type de post actuel\n\tconst postType = useSelect((select) => {\n\t\treturn select(\"core/editor\").getCurrentPostType();\n\t}, []);\n\n\tconst filteredBgColors = filterBgColors(colors, postType);\n\tconst filteredTextColors = filterTextColors(\n\t\tcolors,\n\t\tpostType,\n\t\tbackgroundColor,\n\t);\n\n\tfunction onBackgroundColorChange(value) {\n\t\tif (value === undefined) {\n\t\t\tsetAttributes({ hasBackgroundColor: false });\n\t\t\tsetAttributes({ backgroundColor: \"transparent\" });\n\t\t}\n\t\tconst isLightBackgroundColor = isColorLight(value);\n\t\tsetAttributes({ hasLightBackground: isLightBackgroundColor });\n\t\tsetAttributes({ backgroundColor: value });\n\n\t\tif (!isLightBackgroundColor) {\n\t\t\tsetAttributes({ textColor: \"#fff\" });\n\t\t} else {\n\t\t\tsetAttributes({ textColor: \"inherit\" });\n\t\t}\n\t}\n\tfunction onHasBackgroundColorChange(value) {\n\t\tsetAttributes({ hasBackgroundColor: value });\n\t\tif (!value) {\n\t\t\tsetAttributes({ backgroundColor: null });\n\t\t}\n\t}\n\tfunction onTextColorChange(value) {\n\t\tsetAttributes({ textColor: value });\n\t}\n\tfunction onBlockVariantChange(value) {\n\t\tsetAttributes({ blockVariant: value });\n\t}\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\n\t\t\t\t\t{blockVariant === \"backgrounded\" && (\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t

Couleur de fond

\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t)}\n\n\t\t\t\t\t{blockVariant === \"backgrounded\" && postType !== \"articles\" && (\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t

Couleur du texte

\n\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
\n\t\t\t\t\t)}\n\t\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t\t\t
\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","import { registerBlockType } from \"@wordpress/blocks\";\nimport \"./style.scss\";\n\nimport Edit from \"./edit\";\nimport save from \"./save\";\nimport metadata from \"./block.json\";\n\nregisterBlockType(metadata.name, {\n\ticon: {\n\t\tforeground: \"#136f63\",\n\t\tsrc: (\n\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t),\n\t},\n\tedit: Edit,\n\tsave,\n});\n","import { useBlockProps, InnerBlocks } from \"@wordpress/block-editor\";\nimport { isColorLight } from \"../../_utilities/utilities\";\n\nexport default function save({ attributes }) {\n\tconst {\n\t\tbackgroundColor,\n\t\ttextColor,\n\t\thasLightBackground,\n\t\thasBackgroundColor,\n\t\tblockVariant,\n\t} = attributes;\n\treturn (\n\t\t\n\t\t\t
\n\t\t\t\t\n\t\t\t
\n\t\t\n\t);\n}\n","// extracted by mini-css-extract-plugin\nexport {};","import { isColorLight } from \"../../_utilities/utilities\";\r\n\r\nexport const filterBgColors = (colors, postType) => {\r\n\tif (!postType) return colors || [];\r\n\r\n\tif (postType === \"articles\") {\r\n\t\treturn (\r\n\t\t\tcolors?.filter((color) => {\r\n\t\t\t\t// Garder seulement certaines couleurs pour les articles\r\n\t\t\t\tconst allowedColors = [\r\n\t\t\t\t\t\"carhop-green-light\",\r\n\t\t\t\t\t\"carhop-blue-light\",\r\n\t\t\t\t\t\"carhop-orange-light\",\r\n\t\t\t\t\t\"carhop-red-light\",\r\n\t\t\t\t\t\"carhop-purple-light\",\r\n\t\t\t\t];\r\n\t\t\t\treturn allowedColors.includes(color.slug);\r\n\t\t\t}) || []\r\n\t\t);\r\n\t}\r\n\r\n\treturn colors || [];\r\n};\r\n\r\nexport const filterTextColors = (colors, postType, backgroundColor) => {\r\n\tif (!postType) return colors || [];\r\n\tif (postType === \"page\" && !isColorLight(backgroundColor)) {\r\n\t\t// Retourner seulement du blanc pour les pages avec arrière-plan sombre\r\n\t\treturn [\r\n\t\t\t{\r\n\t\t\t\tname: \"White\",\r\n\t\t\t\tslug: \"white\",\r\n\t\t\t\tcolor: \"#ffffff\",\r\n\t\t\t},\r\n\t\t];\r\n\t}\r\n\r\n\treturn colors || [];\r\n};\r\n","module.exports = window[\"wp\"][\"blockEditor\"];","module.exports = window[\"wp\"][\"blocks\"];","module.exports = window[\"wp\"][\"components\"];","module.exports = window[\"wp\"][\"data\"];","module.exports = window[\"wp\"][\"i18n\"];","module.exports = window[\"ReactJSXRuntime\"];","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t\"index\": 0,\n\t\"./style-index\": 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = globalThis[\"webpackChunkfront_header\"] = globalThis[\"webpackChunkfront_header\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [\"./style-index\"], () => (__webpack_require__(\"./src/index.js\")))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n",""],"names":["isColorLight","color","hex","replace","length","split","map","char","join","r","parseInt","substr","g","b","luminance","__","useBlockProps","InnerBlocks","useSetting","InspectorControls","MediaReplaceFlow","MediaPlaceholder","Card","CardHeader","CardBody","Heading","Text","useSelect","PanelBody","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","Button","CheckboxControl","ColorPalette","filterBgColors","filterTextColors","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","Edit","attributes","setAttributes","props","colors","hasBackgroundColor","backgroundColor","textColor","hasLightBackground","blockVariant","postType","select","getCurrentPostType","filteredBgColors","filteredTextColors","onBackgroundColorChange","value","undefined","isLightBackgroundColor","onHasBackgroundColorChange","onTextColorChange","onBlockVariantChange","children","title","label","onChange","isBlock","__nextHasNoMarginBottom","__next40pxDefaultSize","className","style","template","placeholder","allowedBlocks","registerBlockType","save","metadata","name","icon","foreground","src","width","height","viewBox","d","edit","Content","filter","allowedColors","includes","slug"],"sourceRoot":""} \ No newline at end of file diff --git a/plugins/carhop-blocks/blocks/content-box/src/block.json b/plugins/carhop-blocks/blocks/content-box/src/block.json index 7a43422..fa7e96f 100644 --- a/plugins/carhop-blocks/blocks/content-box/src/block.json +++ b/plugins/carhop-blocks/blocks/content-box/src/block.json @@ -32,6 +32,10 @@ "textColor": { "type": "string", "default": "#ffffff" + }, + "blockVariant": { + "type": "string", + "default": "framed" } } } \ No newline at end of file diff --git a/plugins/carhop-blocks/blocks/content-box/src/edit.js b/plugins/carhop-blocks/blocks/content-box/src/edit.js index aa840b7..5f3ae2d 100644 --- a/plugins/carhop-blocks/blocks/content-box/src/edit.js +++ b/plugins/carhop-blocks/blocks/content-box/src/edit.js @@ -7,9 +7,16 @@ import { MediaReplaceFlow, MediaPlaceholder, } from "@wordpress/block-editor"; +import { + Card, + CardHeader, + CardBody, + Heading, + Text, +} from "@wordpress/components"; +import { useSelect } from "@wordpress/data"; import "./editor.scss"; import { isColorLight } from "../../_utilities/utilities"; - import { PanelBody, __experimentalToggleGroupControl as ToggleGroupControl, @@ -19,20 +26,45 @@ import { ColorPalette, } from "@wordpress/components"; +import { filterBgColors, filterTextColors } from "./utilities"; + export default function Edit({ attributes, setAttributes, ...props }) { const colors = useSetting("color.palette.theme"); - const { hasBackgroundColor, backgroundColor, textColor, hasLightBackground } = - attributes; + + const { + hasBackgroundColor, + backgroundColor, + textColor, + hasLightBackground, + blockVariant, + } = attributes; + + // Détecter le type de post actuel + const postType = useSelect((select) => { + return select("core/editor").getCurrentPostType(); + }, []); + + const filteredBgColors = filterBgColors(colors, postType); + const filteredTextColors = filterTextColors( + colors, + postType, + backgroundColor, + ); function onBackgroundColorChange(value) { if (value === undefined) { setAttributes({ hasBackgroundColor: false }); setAttributes({ backgroundColor: "transparent" }); } - const isLightBackgroundColor = isColorLight(backgroundColor); + const isLightBackgroundColor = isColorLight(value); setAttributes({ hasLightBackground: isLightBackgroundColor }); - setAttributes({ backgroundColor: value }); + + if (!isLightBackgroundColor) { + setAttributes({ textColor: "#fff" }); + } else { + setAttributes({ textColor: "inherit" }); + } } function onHasBackgroundColorChange(value) { setAttributes({ hasBackgroundColor: value }); @@ -43,55 +75,72 @@ export default function Edit({ attributes, setAttributes, ...props }) { function onTextColorChange(value) { setAttributes({ textColor: value }); } + function onBlockVariantChange(value) { + setAttributes({ blockVariant: value }); + } return ( <> - - - {hasBackgroundColor && ( - <> - - + + + + + + + {blockVariant === "backgrounded" && ( + + +

Couleur de fond

+
+ + <> + + + +
)} -
- - {hasBackgroundColor && ( - <> - - + + {blockVariant === "backgrounded" && postType !== "articles" && ( + + +

Couleur du texte

+
+ + + +
)}
@@ -106,6 +155,7 @@ export default function Edit({ attributes, setAttributes, ...props }) { "core/group", "core/list", "core/button", + "core/image", "core/buttons", "carhop-blocks/heading", "carhop-blocks/decorative-shapes", diff --git a/plugins/carhop-blocks/blocks/content-box/src/save.js b/plugins/carhop-blocks/blocks/content-box/src/save.js index 281319d..15b053f 100644 --- a/plugins/carhop-blocks/blocks/content-box/src/save.js +++ b/plugins/carhop-blocks/blocks/content-box/src/save.js @@ -2,19 +2,23 @@ import { useBlockProps, InnerBlocks } from "@wordpress/block-editor"; import { isColorLight } from "../../_utilities/utilities"; export default function save({ attributes }) { - const { backgroundColor, textColor, hasLightBackground, hasBackgroundColor } = - attributes; + const { + backgroundColor, + textColor, + hasLightBackground, + hasBackgroundColor, + blockVariant, + } = attributes; return (
diff --git a/plugins/carhop-blocks/blocks/content-box/src/utilities.js b/plugins/carhop-blocks/blocks/content-box/src/utilities.js new file mode 100644 index 0000000..2cb2d57 --- /dev/null +++ b/plugins/carhop-blocks/blocks/content-box/src/utilities.js @@ -0,0 +1,39 @@ +import { isColorLight } from "../../_utilities/utilities"; + +export const filterBgColors = (colors, postType) => { + if (!postType) return colors || []; + + if (postType === "articles") { + return ( + colors?.filter((color) => { + // Garder seulement certaines couleurs pour les articles + const allowedColors = [ + "carhop-green-light", + "carhop-blue-light", + "carhop-orange-light", + "carhop-red-light", + "carhop-purple-light", + ]; + return allowedColors.includes(color.slug); + }) || [] + ); + } + + return colors || []; +}; + +export const filterTextColors = (colors, postType, backgroundColor) => { + if (!postType) return colors || []; + if (postType === "page" && !isColorLight(backgroundColor)) { + // Retourner seulement du blanc pour les pages avec arrière-plan sombre + return [ + { + name: "White", + slug: "white", + color: "#ffffff", + }, + ]; + } + + return colors || []; +};