FEATURE Adding the ability to show hide icon
This commit is contained in:
parent
0296b12d4c
commit
74604c0a19
|
|
@ -15,5 +15,11 @@
|
|||
"editorScript": "file:./index.js",
|
||||
"editorStyle": "file:./index.css",
|
||||
"style": "file:./style-index.css",
|
||||
"viewScript": "file:./view.js"
|
||||
"viewScript": "file:./view.js",
|
||||
"attributes": {
|
||||
"hasIcon": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +1,33 @@
|
|||
import { __ } from "@wordpress/i18n";
|
||||
import { useBlockProps, RichText, InnerBlocks } from "@wordpress/block-editor";
|
||||
import {
|
||||
useBlockProps,
|
||||
RichText,
|
||||
InnerBlocks,
|
||||
InspectorControls,
|
||||
} from "@wordpress/block-editor";
|
||||
import "./editor.scss";
|
||||
import { PanelBody, CheckboxControl } from "@wordpress/components";
|
||||
|
||||
export default function Edit({ attributes, setAttributes }) {
|
||||
const { hasIcon } = attributes;
|
||||
return (
|
||||
<>
|
||||
<InspectorControls>
|
||||
<PanelBody title={__("Icone", "carhop-blocks")}>
|
||||
<CheckboxControl
|
||||
label={__("Afficher une icône", "carhop-blocks")}
|
||||
checked={hasIcon}
|
||||
onChange={(value) => setAttributes({ hasIcon: value })}
|
||||
/>
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<div
|
||||
{...useBlockProps({
|
||||
className: "notice-panel",
|
||||
})}
|
||||
>
|
||||
<div className="notice-panel__content">
|
||||
<div className="icon"></div>
|
||||
<div className={`notice-panel__content has-icon-${hasIcon}`}>
|
||||
{hasIcon && <div className="icon"></div>}
|
||||
<div className="innerblocks">
|
||||
<InnerBlocks
|
||||
template={[
|
||||
|
|
|
|||
|
|
@ -3,14 +3,15 @@ import { RichText } from "@wordpress/block-editor";
|
|||
import { InnerBlocks } from "@wordpress/block-editor";
|
||||
|
||||
export default function save({ attributes }) {
|
||||
const { hasIcon } = attributes;
|
||||
return (
|
||||
<div
|
||||
{...useBlockProps.save({
|
||||
className: "notice-panel",
|
||||
})}
|
||||
>
|
||||
<div className="notice-panel__content">
|
||||
<div className="icon"></div>
|
||||
<div className={`notice-panel__content has-icon-${hasIcon}`}>
|
||||
{hasIcon && <div className="icon"></div>}
|
||||
|
||||
<div className="innerblocks">
|
||||
<InnerBlocks.Content />
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user