supporting anchors

This commit is contained in:
Antoine M 2023-11-24 18:41:02 +01:00
parent 45f02d4758
commit 6795dfaf2e
8 changed files with 19 additions and 10 deletions

View File

@ -8,7 +8,8 @@
"icon": "smiley", "icon": "smiley",
"description": "Bloc bannière/header de contenu de premier niveau pour les pages de contenu", "description": "Bloc bannière/header de contenu de premier niveau pour les pages de contenu",
"supports": { "supports": {
"html": false "html": false,
"anchor": true
}, },
"textdomain": "homegrade-blocks", "textdomain": "homegrade-blocks",
"editorScript": "file:./index.js", "editorScript": "file:./index.js",
@ -52,6 +53,9 @@
"imageProportion": { "imageProportion": {
"type": "string", "type": "string",
"default": "original" "default": "original"
},
"anchor": {
"type": "string"
} }
} }
} }

View File

@ -1 +1 @@
<?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'fb46f6506f140d571d0c'); <?php return array('dependencies' => array('wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '585c32b2534a1b8eeb09');

View File

@ -36,6 +36,7 @@ function Edit({
setAttributes setAttributes
}) { }) {
const { const {
anchor,
blockCustomTitle, blockCustomTitle,
hasCustomTitle, hasCustomTitle,
pageHeaderTitle, pageHeaderTitle,
@ -136,6 +137,7 @@ function Edit({
} }
}); });
} }
console.log("attributes", attributes);
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")
@ -443,7 +445,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},"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"},"pageHeaderDescription":{"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"}}}'); 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"},"pageHeaderDescription":{"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"}}}');
/***/ }) /***/ })

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,4 @@
<?php <?php
$pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null; $pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null;
$pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null; $pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null;
$cta = $attributes['cta'] ?? null; $cta = $attributes['cta'] ?? null;
@ -13,7 +12,7 @@ $customTitle = $attributes['blockCustomTitle'] ?? null;
?> ?>
<section <?php echo get_block_wrapper_attributes(['class' => 'block-content-page-header']) ?>> <section id="<?php echo esc_html($attributes['anchor']) ?>" <?php echo get_block_wrapper_attributes(['class' => 'block-content-page-header']) ?>>
<div class="block-content-page-header__content"> <div class="block-content-page-header__content">
<div className="section_titling"> <div className="section_titling">
<?php if (!$attributes['hasCustomTitle']) : ?> <?php if (!$attributes['hasCustomTitle']) : ?>

View File

@ -8,7 +8,8 @@
"icon": "smiley", "icon": "smiley",
"description": "Bloc bannière/header de contenu de premier niveau pour les pages de contenu", "description": "Bloc bannière/header de contenu de premier niveau pour les pages de contenu",
"supports": { "supports": {
"html": false "html": false,
"anchor": true
}, },
"textdomain": "homegrade-blocks", "textdomain": "homegrade-blocks",
"editorScript": "file:./index.js", "editorScript": "file:./index.js",
@ -52,6 +53,9 @@
"imageProportion": { "imageProportion": {
"type": "string", "type": "string",
"default": "original" "default": "original"
},
"anchor": {
"type": "string"
} }
} }
} }

View File

@ -23,6 +23,7 @@ import { trash } from "@wordpress/icons";
export default function Edit({ attributes, setAttributes }) { export default function Edit({ attributes, setAttributes }) {
const { const {
anchor,
blockCustomTitle, blockCustomTitle,
hasCustomTitle, hasCustomTitle,
pageHeaderTitle, pageHeaderTitle,
@ -108,7 +109,7 @@ export default function Edit({ attributes, setAttributes }) {
}, },
}); });
} }
console.log("attributes", attributes);
return ( return (
<> <>
<InspectorControls> <InspectorControls>

View File

@ -1,5 +1,4 @@
<?php <?php
$pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null; $pageHeaderTitle = $attributes['pageHeaderTitle'] ?? null;
$pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null; $pageHeaderDescription = $attributes['pageHeaderDescription'] ?? null;
$cta = $attributes['cta'] ?? null; $cta = $attributes['cta'] ?? null;
@ -13,7 +12,7 @@ $customTitle = $attributes['blockCustomTitle'] ?? null;
?> ?>
<section <?php echo get_block_wrapper_attributes(['class' => 'block-content-page-header']) ?>> <section id="<?php echo esc_html($attributes['anchor']) ?>" <?php echo get_block_wrapper_attributes(['class' => 'block-content-page-header']) ?>>
<div class="block-content-page-header__content"> <div class="block-content-page-header__content">
<div className="section_titling"> <div className="section_titling">
<?php if (!$attributes['hasCustomTitle']) : ?> <?php if (!$attributes['hasCustomTitle']) : ?>