introducing component cover size attribute
This commit is contained in:
parent
057d01f2ae
commit
eea0ba7253
|
|
@ -53,6 +53,10 @@
|
||||||
},
|
},
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"coverSize": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "medium"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1 +1 @@
|
||||||
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '707cbf4f5eee20e6f5ce');
|
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '00a2ba43b23fe2f7862c');
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,8 @@ function Edit({
|
||||||
hasCustomImage,
|
hasCustomImage,
|
||||||
imageId,
|
imageId,
|
||||||
imageAlt,
|
imageAlt,
|
||||||
imageUrl
|
imageUrl,
|
||||||
|
coverSize
|
||||||
} = attributes;
|
} = attributes;
|
||||||
const pageTitle = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
|
const pageTitle = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_3__.useSelect)(select => {
|
||||||
const {
|
const {
|
||||||
|
|
@ -131,6 +132,11 @@ function Edit({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function onCoverSizeChange(coverSize) {
|
||||||
|
setAttributes({
|
||||||
|
coverSize
|
||||||
|
});
|
||||||
|
}
|
||||||
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.InspectorControls, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelBody, {
|
return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.InspectorControls, null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelBody, {
|
||||||
className: "homegrade-blocks-content-page-header__panel-cta",
|
className: "homegrade-blocks-content-page-header__panel-cta",
|
||||||
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Titre du bloc", "homegrade-blocks")
|
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Titre du bloc", "homegrade-blocks")
|
||||||
|
|
@ -163,7 +169,22 @@ function Edit({
|
||||||
icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_6__["default"],
|
icon: _wordpress_icons__WEBPACK_IMPORTED_MODULE_6__["default"],
|
||||||
label: "Supprimer",
|
label: "Supprimer",
|
||||||
onClick: removeImageAttributes
|
onClick: removeImageAttributes
|
||||||
}))))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelBody, {
|
})))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.__experimentalToggleGroupControl, {
|
||||||
|
className: "homegrade-blocks-highlight__variant",
|
||||||
|
isBlock: true,
|
||||||
|
label: "Taille de la couverture",
|
||||||
|
onChange: onCoverSizeChange,
|
||||||
|
value: coverSize
|
||||||
|
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.__experimentalToggleGroupControlOption, {
|
||||||
|
label: "S",
|
||||||
|
value: "small"
|
||||||
|
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.__experimentalToggleGroupControlOption, {
|
||||||
|
label: "M",
|
||||||
|
value: "medium"
|
||||||
|
}), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.__experimentalToggleGroupControlOption, {
|
||||||
|
label: "L",
|
||||||
|
value: "large"
|
||||||
|
}))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.PanelBody, {
|
||||||
className: "homegrade-blocks-content-page-header__panel-cta",
|
className: "homegrade-blocks-content-page-header__panel-cta",
|
||||||
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Call to action", "homegrade-blocks")
|
title: (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_1__.__)("Call to action", "homegrade-blocks")
|
||||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToggleControl, {
|
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_components__WEBPACK_IMPORTED_MODULE_5__.ToggleControl, {
|
||||||
|
|
@ -216,7 +237,7 @@ function Edit({
|
||||||
}), hasCustomImage && imageUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
}), hasCustomImage && imageUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
|
||||||
src: imageUrl,
|
src: imageUrl,
|
||||||
alt: imageAlt,
|
alt: imageAlt,
|
||||||
className: "block-content-page-header__page-icon"
|
className: `block-content-page-header__page-icon block-content-page-header__page-icon--${coverSize}`
|
||||||
}), hasCustomImage && !imageUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.MediaPlaceholder, {
|
}), hasCustomImage && !imageUrl && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_block_editor__WEBPACK_IMPORTED_MODULE_4__.MediaPlaceholder, {
|
||||||
accept: "image/*",
|
accept: "image/*",
|
||||||
allowedTypes: ["image"],
|
allowedTypes: ["image"],
|
||||||
|
|
@ -434,7 +455,7 @@ module.exports = window["wp"]["primitives"];
|
||||||
\************************/
|
\************************/
|
||||||
/***/ ((module) => {
|
/***/ ((module) => {
|
||||||
|
|
||||||
module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/content-page-header","version":"0.1.0","title":"Content page header","category":"homegrade-blocks","icon":"smiley","description":"Bloc bannière/header de contenu de premier niveau pour les pages de contenu","supports":{"html":false,"anchor":true},"textdomain":"homegrade-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"hasCustomTitle":{"type":"boolean","default":false},"blockCustomTitle":{"type":"string"},"pageHeaderTitle":{"type":"string"},"hasCta":{"type":"boolean","default":false},"cta":{"type":"object"},"hasCustomImage":{"type":"boolean","default":false},"imageUrl":{"type":"string"},"imageAlt":{"type":"string"},"imageId":{"type":"number"},"imageProportion":{"type":"string","default":"original"},"anchor":{"type":"string"}}}');
|
module.exports = JSON.parse('{"$schema":"https://schemas.wp.org/trunk/block.json","apiVersion":2,"name":"homegrade-content-blocks/content-page-header","version":"0.1.0","title":"Content page header","category":"homegrade-blocks","icon":"smiley","description":"Bloc bannière/header de contenu de premier niveau pour les pages de contenu","supports":{"html":false,"anchor":true},"textdomain":"homegrade-blocks","editorScript":"file:./index.js","editorStyle":"file:./index.css","style":"file:./style-index.css","render":"file:./render.php","attributes":{"hasCustomTitle":{"type":"boolean","default":false},"blockCustomTitle":{"type":"string"},"pageHeaderTitle":{"type":"string"},"hasCta":{"type":"boolean","default":false},"cta":{"type":"object"},"hasCustomImage":{"type":"boolean","default":false},"imageUrl":{"type":"string"},"imageAlt":{"type":"string"},"imageId":{"type":"number"},"imageProportion":{"type":"string","default":"original"},"anchor":{"type":"string"},"coverSize":{"type":"string","default":"medium"}}}');
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -7,6 +7,7 @@ $pageIllustration = get_field('page_illustration');
|
||||||
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
|
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
|
||||||
$customImageUrl = $attributes['imageUrl'] ?? null;
|
$customImageUrl = $attributes['imageUrl'] ?? null;
|
||||||
$customImageAlt = $attributes['imageAlt'] ?? null;
|
$customImageAlt = $attributes['imageAlt'] ?? null;
|
||||||
|
$coverSize = $attributes['coverSize'] ?? null;
|
||||||
|
|
||||||
$customTitle = $attributes['blockCustomTitle'] ?? null;
|
$customTitle = $attributes['blockCustomTitle'] ?? null;
|
||||||
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
||||||
|
|
@ -32,10 +33,10 @@ $anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($pageIllustration && !$hasCustomImage) : ?>
|
<?php if ($pageIllustration && !$hasCustomImage) : ?>
|
||||||
<img class="block-content-page-header__page-icon" src="<?php echo $pageIllustration['url'] ?>" alt="">
|
<img class="block-content-page-header__page-icon <?php echo $coverSize ? "block-content-page-header__page-icon--" . $coverSize : "" ?> " src="<?php echo $pageIllustration['url'] ?>" alt="">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
||||||
<img class="block-content-page-header__page-icon" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
<img class="block-content-page-header__page-icon <?php echo $coverSize ? "block-content-page-header__page-icon--" . $coverSize : "" ?>" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
/*!***************************************************************************************************************************************************************************************************************************************!*\
|
|
||||||
!*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[4].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[4].use[2]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[4].use[3]!./src/style.scss ***!
|
|
||||||
\***************************************************************************************************************************************************************************************************************************************/
|
|
||||||
.block-content-page-header p {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.block-content-page-header .innerblocks p {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*# sourceMappingURL=style-index.css.map*/
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"./style-index.css","mappings":";;;AAEC;EACC;AADF;AAGC;EACC;AADF,C","sources":["webpack://multiblocks/./src/style.scss"],"sourcesContent":["// Styled by the theme\r\n.block-content-page-header {\r\n\tp {\r\n\t\tdisplay: none;\r\n\t}\r\n\t.innerblocks p {\r\n\t\tdisplay: block;\r\n\t}\r\n}\r\n"],"names":[],"sourceRoot":""}
|
|
||||||
|
|
@ -53,6 +53,10 @@
|
||||||
},
|
},
|
||||||
"anchor": {
|
"anchor": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"coverSize": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "medium"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -14,9 +14,11 @@ import {
|
||||||
import {
|
import {
|
||||||
PanelBody,
|
PanelBody,
|
||||||
TextControl,
|
TextControl,
|
||||||
ToggleControl,
|
|
||||||
Button,
|
Button,
|
||||||
Tip,
|
Tip,
|
||||||
|
ToggleControl,
|
||||||
|
__experimentalToggleGroupControl as ToggleGroupControl,
|
||||||
|
__experimentalToggleGroupControlOption as ToggleGroupControlOption,
|
||||||
} from "@wordpress/components";
|
} from "@wordpress/components";
|
||||||
|
|
||||||
import { trash } from "@wordpress/icons";
|
import { trash } from "@wordpress/icons";
|
||||||
|
|
@ -33,6 +35,7 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
imageId,
|
imageId,
|
||||||
imageAlt,
|
imageAlt,
|
||||||
imageUrl,
|
imageUrl,
|
||||||
|
coverSize,
|
||||||
} = attributes;
|
} = attributes;
|
||||||
|
|
||||||
const pageTitle = useSelect((select) => {
|
const pageTitle = useSelect((select) => {
|
||||||
|
|
@ -105,6 +108,9 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function onCoverSizeChange(coverSize) {
|
||||||
|
setAttributes({ coverSize });
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<InspectorControls>
|
<InspectorControls>
|
||||||
|
|
@ -171,6 +177,17 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<ToggleGroupControl
|
||||||
|
className="homegrade-blocks-highlight__variant"
|
||||||
|
isBlock
|
||||||
|
label="Taille de la couverture"
|
||||||
|
onChange={onCoverSizeChange}
|
||||||
|
value={coverSize}
|
||||||
|
>
|
||||||
|
<ToggleGroupControlOption label="S" value="small" />
|
||||||
|
<ToggleGroupControlOption label="M" value="medium" />
|
||||||
|
<ToggleGroupControlOption label="L" value="large" />
|
||||||
|
</ToggleGroupControl>
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
|
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
|
@ -262,7 +279,7 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
<img
|
<img
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
alt={imageAlt}
|
alt={imageAlt}
|
||||||
className="block-content-page-header__page-icon"
|
className={`block-content-page-header__page-icon block-content-page-header__page-icon--${coverSize}`}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{hasCustomImage && !imageUrl && (
|
{hasCustomImage && !imageUrl && (
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ $pageIllustration = get_field('page_illustration');
|
||||||
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
|
$hasCustomImage = $attributes['hasCustomImage'] ?? null;
|
||||||
$customImageUrl = $attributes['imageUrl'] ?? null;
|
$customImageUrl = $attributes['imageUrl'] ?? null;
|
||||||
$customImageAlt = $attributes['imageAlt'] ?? null;
|
$customImageAlt = $attributes['imageAlt'] ?? null;
|
||||||
|
$coverSize = $attributes['coverSize'] ?? null;
|
||||||
|
|
||||||
$customTitle = $attributes['blockCustomTitle'] ?? null;
|
$customTitle = $attributes['blockCustomTitle'] ?? null;
|
||||||
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
$anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
||||||
|
|
@ -32,10 +33,10 @@ $anchor = isset($attributes['anchor']) ? esc_html($attributes['anchor']) : null;
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php if ($pageIllustration && !$hasCustomImage) : ?>
|
<?php if ($pageIllustration && !$hasCustomImage) : ?>
|
||||||
<img class="block-content-page-header__page-icon" src="<?php echo $pageIllustration['url'] ?>" alt="">
|
<img class="block-content-page-header__page-icon <?php echo $coverSize ? "block-content-page-header__page-icon--" . $coverSize : "" ?> " src="<?php echo $pageIllustration['url'] ?>" alt="">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
<?php if ($hasCustomImage && $customImageUrl) : ?>
|
||||||
<img class="block-content-page-header__page-icon" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
<img class="block-content-page-header__page-icon <?php echo $coverSize ? "block-content-page-header__page-icon--" . $coverSize : "" ?>" src="<?php echo $customImageUrl ?>" alt="<?php echo $customImageAlt ?>">
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
Loading…
Reference in New Issue
Block a user