FEATURE Handling content-card border
This commit is contained in:
parent
e12ccb8581
commit
7bb9b66b5f
|
|
@ -17,6 +17,10 @@
|
||||||
"style": "file:./style-index.css",
|
"style": "file:./style-index.css",
|
||||||
"viewScript": "file:./view.js",
|
"viewScript": "file:./view.js",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
|
"hasBorder": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": true
|
||||||
|
},
|
||||||
"hasBackgroundColor": {
|
"hasBackgroundColor": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,13 @@ import {
|
||||||
|
|
||||||
export default function Edit({ attributes, setAttributes, ...props }) {
|
export default function Edit({ attributes, setAttributes, ...props }) {
|
||||||
const colors = useSetting("color.palette.theme");
|
const colors = useSetting("color.palette.theme");
|
||||||
const { hasBackgroundColor, backgroundColor, textColor, hasLightBackground } =
|
const {
|
||||||
attributes;
|
hasBackgroundColor,
|
||||||
|
backgroundColor,
|
||||||
|
textColor,
|
||||||
|
hasLightBackground,
|
||||||
|
hasBorder,
|
||||||
|
} = attributes;
|
||||||
|
|
||||||
function onBackgroundColorChange(value) {
|
function onBackgroundColorChange(value) {
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
|
|
@ -47,6 +52,16 @@ export default function Edit({ attributes, setAttributes, ...props }) {
|
||||||
<>
|
<>
|
||||||
<InspectorControls>
|
<InspectorControls>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
className="deligraph-blocks-components-image__panel-body"
|
||||||
|
title={__("Options", "carhop-blocks")}
|
||||||
|
>
|
||||||
|
<CheckboxControl
|
||||||
|
label="Bordure"
|
||||||
|
checked={hasBorder}
|
||||||
|
onChange={(value) => setAttributes({ hasBorder: value })}
|
||||||
|
/>
|
||||||
|
</PanelBody>
|
||||||
|
{/* <PanelBody
|
||||||
className="deligraph-blocks-components-image__panel-body"
|
className="deligraph-blocks-components-image__panel-body"
|
||||||
title={__("Arrière plan", "deligraph-blocks")}
|
title={__("Arrière plan", "deligraph-blocks")}
|
||||||
>
|
>
|
||||||
|
|
@ -78,7 +93,7 @@ export default function Edit({ attributes, setAttributes, ...props }) {
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</PanelBody>
|
</PanelBody> */}
|
||||||
</InspectorControls>
|
</InspectorControls>
|
||||||
<div
|
<div
|
||||||
{...useBlockProps({
|
{...useBlockProps({
|
||||||
|
|
@ -86,7 +101,7 @@ export default function Edit({ attributes, setAttributes, ...props }) {
|
||||||
hasLightBackground
|
hasLightBackground
|
||||||
? "content-card--bg-light"
|
? "content-card--bg-light"
|
||||||
: "content-card--bg-dark"
|
: "content-card--bg-dark"
|
||||||
}`,
|
} ${hasBorder ? "content-card--has-border" : ""}`,
|
||||||
style: {
|
style: {
|
||||||
"--content-card-text-color": textColor ?? "inherit",
|
"--content-card-text-color": textColor ?? "inherit",
|
||||||
"--content-card-background-color": hasBackgroundColor
|
"--content-card-background-color": hasBackgroundColor
|
||||||
|
|
@ -109,6 +124,7 @@ export default function Edit({ attributes, setAttributes, ...props }) {
|
||||||
"core/buttons",
|
"core/buttons",
|
||||||
"carhop-blocks/heading",
|
"carhop-blocks/heading",
|
||||||
"carhop-blocks/cta-group",
|
"carhop-blocks/cta-group",
|
||||||
|
"carhop-blocks/cta",
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,13 @@ import { useBlockProps, InnerBlocks } from "@wordpress/block-editor";
|
||||||
import { isColorLight } from "../../_utilities/utilities";
|
import { isColorLight } from "../../_utilities/utilities";
|
||||||
|
|
||||||
export default function save({ attributes }) {
|
export default function save({ attributes }) {
|
||||||
const { backgroundColor, textColor, hasLightBackground, hasBackgroundColor } =
|
const {
|
||||||
attributes;
|
backgroundColor,
|
||||||
|
textColor,
|
||||||
|
hasLightBackground,
|
||||||
|
hasBackgroundColor,
|
||||||
|
hasBorder,
|
||||||
|
} = attributes;
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
{...useBlockProps.save({
|
{...useBlockProps.save({
|
||||||
|
|
@ -11,7 +16,7 @@ export default function save({ attributes }) {
|
||||||
hasLightBackground
|
hasLightBackground
|
||||||
? "content-card--bg-light"
|
? "content-card--bg-light"
|
||||||
: "content-card--bg-dark"
|
: "content-card--bg-dark"
|
||||||
}`,
|
} ${hasBorder ? "content-card--has-border" : ""}`,
|
||||||
style: {
|
style: {
|
||||||
"--content-card-text-color": textColor ?? "inherit",
|
"--content-card-text-color": textColor ?? "inherit",
|
||||||
"--content-card-background-color": hasBackgroundColor
|
"--content-card-background-color": hasBackgroundColor
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user