block settings: toggle for text contrast and fix colour/tint
This commit is contained in:
@@ -150,16 +150,21 @@ export default function BlockSettings({ attributes, setAttributes }) {
|
|||||||
slug = selected.slug;
|
slug = selected.slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
setAttributes( {
|
let colourAttributes = {
|
||||||
background_colour: slug,
|
background_colour: slug,
|
||||||
background_hex: hex,
|
background_hex: hex,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if(!slug || [0, '0', 'white', 'black'].includes(slug)) {
|
||||||
|
colourAttributes.background_tint = '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
setAttributes( colourAttributes );
|
||||||
|
|
||||||
} }
|
} }
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{ 'background_colour' in attributes && attributes.background_colour && ![0, '0', 'white', 'black'].includes(attributes.background_colour) ? (
|
{ 'background_colour' in attributes && attributes.background_colour && ![0, '0', 'white', 'black'].includes(attributes.background_colour) ? (
|
||||||
<>
|
|
||||||
<SelectControl
|
<SelectControl
|
||||||
label={ __("Tint", "badegg") }
|
label={ __("Tint", "badegg") }
|
||||||
value={ background_tint }
|
value={ background_tint }
|
||||||
@@ -168,14 +173,14 @@ export default function BlockSettings({ attributes, setAttributes }) {
|
|||||||
__next40pxDefaultSize={ true }
|
__next40pxDefaultSize={ true }
|
||||||
__nextHasNoMarginBottom={ true }
|
__nextHasNoMarginBottom={ true }
|
||||||
/>
|
/>
|
||||||
|
) : null }
|
||||||
|
|
||||||
<ToggleControl
|
<ToggleControl
|
||||||
label={ __('Text Contrast', 'badegg') }
|
label={ __('Text Contrast', 'badegg') }
|
||||||
checked={ background_contrast }
|
checked={ background_contrast }
|
||||||
onChange={(value) => setAttributes({ background_contrast: value }) }
|
onChange={(value) => setAttributes({ background_contrast: value }) }
|
||||||
__nextHasNoMarginBottom
|
__nextHasNoMarginBottom
|
||||||
/>
|
/>
|
||||||
</>
|
|
||||||
) : null }
|
|
||||||
|
|
||||||
{ background_image != 0 && (
|
{ background_image != 0 && (
|
||||||
<>
|
<>
|
||||||
|
|||||||
Reference in New Issue
Block a user