FEATURE Add iconId and iconUrl attributes to tab block; update edit and save components for new attributes
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e159cb4ba0
commit
f81fddf450
|
|
@ -25,6 +25,14 @@
|
||||||
"title": {
|
"title": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
|
},
|
||||||
|
"iconId": {
|
||||||
|
"type": "number",
|
||||||
|
"default": 0
|
||||||
|
},
|
||||||
|
"iconUrl": {
|
||||||
|
"type": "string",
|
||||||
|
"default": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -17,6 +17,7 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
className: "block-chapo",
|
className: "block-chapo",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(attributes);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<InspectorControls>
|
<InspectorControls>
|
||||||
|
|
@ -42,9 +43,17 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
<>
|
<>
|
||||||
{iconUrl ? (
|
{iconUrl ? (
|
||||||
<div className="tab__icon-preview">
|
<div className="tab__icon-preview">
|
||||||
<img src={iconUrl} alt="" style={{ maxWidth: 48, height: "auto" }} />
|
<img
|
||||||
|
src={iconUrl}
|
||||||
|
alt=""
|
||||||
|
style={{ maxWidth: 48, height: "auto" }}
|
||||||
|
/>
|
||||||
<div style={{ marginTop: 8 }}>
|
<div style={{ marginTop: 8 }}>
|
||||||
<Button variant="secondary" onClick={open} style={{ marginRight: 8 }}>
|
<Button
|
||||||
|
variant="secondary"
|
||||||
|
onClick={open}
|
||||||
|
style={{ marginRight: 8 }}
|
||||||
|
>
|
||||||
{__("Remplacer", "carhop-blocks")}
|
{__("Remplacer", "carhop-blocks")}
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
|
|
@ -70,13 +79,6 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
</InspectorControls>
|
</InspectorControls>
|
||||||
<div {...blockProps}>
|
<div {...blockProps}>
|
||||||
<RichText
|
|
||||||
tagName="h2"
|
|
||||||
className="tab__title"
|
|
||||||
placeholder="Titre"
|
|
||||||
value={title}
|
|
||||||
onChange={(value) => setAttributes({ title: value })}
|
|
||||||
/>
|
|
||||||
<InnerBlocks
|
<InnerBlocks
|
||||||
allowedBlocks={[
|
allowedBlocks={[
|
||||||
"core/heading",
|
"core/heading",
|
||||||
|
|
@ -98,10 +100,14 @@ export default function Edit({ attributes, setAttributes }) {
|
||||||
"carhop-blocks/cta-group",
|
"carhop-blocks/cta-group",
|
||||||
"carhop-blocks/audio-player",
|
"carhop-blocks/audio-player",
|
||||||
"carhop-blocks/content-box",
|
"carhop-blocks/content-box",
|
||||||
|
"carhop-blocks/content-card",
|
||||||
"carhop-blocks/notice-panel",
|
"carhop-blocks/notice-panel",
|
||||||
"shortcode",
|
"shortcode",
|
||||||
]}
|
]}
|
||||||
template={[["core/paragraph", { content: "Contenu" }]]}
|
template={[
|
||||||
|
["core/heading", { content: "Titre", level: 3 }],
|
||||||
|
["core/paragraph", { content: "Contenu" }],
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,10 @@ registerBlockType(metadata.name, {
|
||||||
</svg>
|
</svg>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
__experimentalLabel: (attributes) => {
|
||||||
|
const label = attributes?.title?.trim();
|
||||||
|
return label || metadata.title;
|
||||||
|
},
|
||||||
edit: Edit,
|
edit: Edit,
|
||||||
save,
|
save,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ export default function save({ attributes }) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<RichText.Content value={title} tagName="h2" className="tab__title" />
|
|
||||||
<InnerBlocks.Content />
|
<InnerBlocks.Content />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user