FEATURE Handling TextColor variable and behaviours
This commit is contained in:
parent
7d773401ed
commit
7d6d758b46
|
|
@ -65,6 +65,10 @@
|
|||
"type": "string",
|
||||
"default": "#ffffff"
|
||||
},
|
||||
"textColor": {
|
||||
"type": "string",
|
||||
"default": "#136f63"
|
||||
},
|
||||
"backgroundOrientation": {
|
||||
"type": "string",
|
||||
"default": "left",
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-primitives'), 'version' => '62a57819a79c88fe5e2d');
|
||||
<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-i18n', 'wp-primitives'), 'version' => 'd0e3316a30114b6e5e46');
|
||||
|
|
|
|||
|
|
@ -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"},"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"]}');
|
||||
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"},"textColor":{"type":"string","default":"#136f63"},"backgroundOrientation":{"type":"string","default":"left","enum":["left","right"]}},"usesContext":["postType","postId"]}');
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
|
@ -87,18 +87,14 @@ function Edit({
|
|||
hasBackgroundColor,
|
||||
backgroundColor,
|
||||
backgroundOrientation,
|
||||
blockWidth
|
||||
blockWidth,
|
||||
textColor
|
||||
} = attributes;
|
||||
function onDispositionChange(disposition) {
|
||||
setAttributes({
|
||||
disposition
|
||||
});
|
||||
}
|
||||
function onCoverSizeChange(coverSize) {
|
||||
setAttributes({
|
||||
coverSize
|
||||
});
|
||||
}
|
||||
function setCoverAttributes(cover) {
|
||||
setAttributes({
|
||||
coverId: cover.id,
|
||||
|
|
@ -195,7 +191,9 @@ function Edit({
|
|||
className: "deligraph-blocks__variant",
|
||||
isBlock: true,
|
||||
label: "Taille de l'image",
|
||||
onChange: onCoverSizeChange,
|
||||
onChange: coverSize => setAttributes({
|
||||
coverSize
|
||||
}),
|
||||
value: coverSize,
|
||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, {
|
||||
label: "Big",
|
||||
|
|
@ -218,32 +216,32 @@ function Edit({
|
|||
label: "Arri\xE8re plan color\xE9",
|
||||
checked: hasBackgroundColor,
|
||||
onChange: onHasBackgroundColorChange
|
||||
}), hasBackgroundColor && /*#__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__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ColorPalette, {
|
||||
}), hasBackgroundColor && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.Fragment, {
|
||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ColorPalette, {
|
||||
colors: colors,
|
||||
value: backgroundColor,
|
||||
onChange: onBackgroundColorChange
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsxs)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControl, {
|
||||
className: "deligraph-blocks__variant",
|
||||
isBlock: true,
|
||||
label: "Disposition",
|
||||
onChange: onBackgroundOrientationChange,
|
||||
value: backgroundOrientation,
|
||||
children: [/*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, {
|
||||
label: "Gauche",
|
||||
value: "left"
|
||||
}), /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.__experimentalToggleGroupControlOption, {
|
||||
label: "Droite",
|
||||
value: "right"
|
||||
})]
|
||||
})]
|
||||
})
|
||||
})]
|
||||
}), /*#__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__.__)("Couleur du texte", "deligraph-blocks"),
|
||||
children: /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)(_wordpress_components__WEBPACK_IMPORTED_MODULE_2__.ColorPalette, {
|
||||
colors: colors,
|
||||
value: textColor,
|
||||
onChange: value => setAttributes({
|
||||
textColor: value
|
||||
})
|
||||
})
|
||||
})]
|
||||
}), /*#__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}
|
||||
${blockWidth === "full" ? "chapter-section--width-full" : "chapter-section--width-contained"}
|
||||
${hasBackgroundColor && backgroundColor ? "chapter-section--has-background" : ""}`
|
||||
${hasBackgroundColor && backgroundColor ? "chapter-section--has-background" : ""}`,
|
||||
style: {
|
||||
"--chapter-section-text-color": textColor ? textColor : "#136f63"
|
||||
}
|
||||
}),
|
||||
children: [hasBackgroundColor && backgroundColor && /*#__PURE__*/(0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_4__.jsx)("svg", {
|
||||
className: `chapter-section__background chapter-section__background--${backgroundOrientation}`,
|
||||
|
|
@ -366,11 +364,15 @@ function save({
|
|||
backgroundColor,
|
||||
hasBackgroundColor,
|
||||
backgroundOrientation,
|
||||
blockWidth
|
||||
blockWidth,
|
||||
textColor
|
||||
} = 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" : ""} ${blockWidth === "full" ? "chapter-section--width-full" : "chapter-section--width-contained"}`
|
||||
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"}`,
|
||||
style: {
|
||||
"--chapter-section-text-color": textColor
|
||||
}
|
||||
}),
|
||||
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
|
|
@ -65,6 +65,10 @@
|
|||
"type": "string",
|
||||
"default": "#ffffff"
|
||||
},
|
||||
"textColor": {
|
||||
"type": "string",
|
||||
"default": "#136f63"
|
||||
},
|
||||
"backgroundOrientation": {
|
||||
"type": "string",
|
||||
"default": "left",
|
||||
|
|
|
|||
|
|
@ -30,14 +30,12 @@ export default function Edit({ attributes, setAttributes, ...props }) {
|
|||
backgroundColor,
|
||||
backgroundOrientation,
|
||||
blockWidth,
|
||||
textColor,
|
||||
} = attributes;
|
||||
|
||||
function onDispositionChange(disposition) {
|
||||
setAttributes({ disposition });
|
||||
}
|
||||
function onCoverSizeChange(coverSize) {
|
||||
setAttributes({ coverSize });
|
||||
}
|
||||
|
||||
function setCoverAttributes(cover) {
|
||||
setAttributes({
|
||||
|
|
@ -129,7 +127,7 @@ export default function Edit({ attributes, setAttributes, ...props }) {
|
|||
className="deligraph-blocks__variant"
|
||||
isBlock
|
||||
label="Taille de l'image"
|
||||
onChange={onCoverSizeChange}
|
||||
onChange={(coverSize) => setAttributes({ coverSize })}
|
||||
value={coverSize}
|
||||
>
|
||||
<ToggleGroupControlOption label="Big" value="large" />
|
||||
|
|
@ -155,19 +153,20 @@ export default function Edit({ attributes, setAttributes, ...props }) {
|
|||
value={backgroundColor}
|
||||
onChange={onBackgroundColorChange}
|
||||
/>
|
||||
<ToggleGroupControl
|
||||
className="deligraph-blocks__variant"
|
||||
isBlock
|
||||
label="Disposition"
|
||||
onChange={onBackgroundOrientationChange}
|
||||
value={backgroundOrientation}
|
||||
>
|
||||
<ToggleGroupControlOption label="Gauche" value="left" />
|
||||
<ToggleGroupControlOption label="Droite" value="right" />
|
||||
</ToggleGroupControl>
|
||||
</>
|
||||
)}
|
||||
</PanelBody>
|
||||
|
||||
<PanelBody
|
||||
className="deligraph-blocks-components-image__panel-body"
|
||||
title={__("Couleur du texte", "deligraph-blocks")}
|
||||
>
|
||||
<ColorPalette
|
||||
colors={colors}
|
||||
value={textColor}
|
||||
onChange={(value) => setAttributes({ textColor: value })}
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<section
|
||||
{...useBlockProps({
|
||||
|
|
@ -182,6 +181,9 @@ export default function Edit({ attributes, setAttributes, ...props }) {
|
|||
? "chapter-section--has-background"
|
||||
: ""
|
||||
}`,
|
||||
style: {
|
||||
"--chapter-section-text-color": textColor ? textColor : "#136f63",
|
||||
},
|
||||
})}
|
||||
>
|
||||
{hasBackgroundColor && backgroundColor && (
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export default function save({ attributes }) {
|
|||
hasBackgroundColor,
|
||||
backgroundOrientation,
|
||||
blockWidth,
|
||||
textColor,
|
||||
} = attributes;
|
||||
return (
|
||||
<section
|
||||
|
|
@ -20,6 +21,9 @@ export default function save({ attributes }) {
|
|||
? "chapter-section--width-full"
|
||||
: "chapter-section--width-contained"
|
||||
}`,
|
||||
style: {
|
||||
"--chapter-section-text-color": textColor,
|
||||
},
|
||||
})}
|
||||
>
|
||||
{hasBackgroundColor && backgroundColor && (
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user