Changes to lcp-button
This commit is contained in:
@ -6,17 +6,10 @@
|
||||
"title": "Button",
|
||||
"category": "widgets",
|
||||
"icon": "smiley",
|
||||
"description": "Example block scaffolded with Create Block tool.",
|
||||
"description": "A button for various functions or custom urls",
|
||||
"example": {},
|
||||
"supports": {
|
||||
"html": false,
|
||||
"color": {
|
||||
"background": true,
|
||||
"link": true,
|
||||
"text": true,
|
||||
"gradients": true,
|
||||
"button": true
|
||||
}
|
||||
"html": false
|
||||
},
|
||||
"attributes": {
|
||||
"buttonAction": {
|
||||
@ -32,14 +25,16 @@
|
||||
"default": "Button Text"
|
||||
},
|
||||
"displayIcon": {
|
||||
"type": "boolean"
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"iconSource": {
|
||||
"type": "string",
|
||||
"default": "manualSvgPath"
|
||||
},
|
||||
"iconSvgPath": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"iconSvgId": {
|
||||
"type": "string",
|
||||
@ -53,10 +48,12 @@
|
||||
"type": "number"
|
||||
},
|
||||
"manualIconSvgPath":{
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"buttonHeight":{
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"buttonPadding":{
|
||||
"type": "object",
|
||||
@ -88,10 +85,12 @@
|
||||
}
|
||||
},
|
||||
"iconHeight": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"iconWidth": {
|
||||
"type": "string"
|
||||
"type": "string",
|
||||
"default": ""
|
||||
}
|
||||
},
|
||||
"textdomain": "lcp",
|
||||
|
||||
@ -2,7 +2,7 @@ import { useBlockProps } from '@wordpress/block-editor';
|
||||
|
||||
export default function save(props) {
|
||||
const { attributes } = props;
|
||||
const { buttonText, buttonPadding,iconHeight,iconSvgPath, iconSvgViewbox, buttonAction, customUrl } = attributes; // Destructure buttonText, iconSvgPath, and iconSvgViewbox
|
||||
const {displayIcon, buttonText, buttonPadding,iconHeight,iconSvgPath, iconSvgViewbox, buttonAction, customUrl } = attributes; // Destructure buttonText, iconSvgPath, and iconSvgViewbox
|
||||
|
||||
// Get the block props for the button
|
||||
const blockProps = useBlockProps.save();
|
||||
@ -10,7 +10,7 @@ export default function save(props) {
|
||||
// Conditionally render the link or button based on buttonAction
|
||||
return (
|
||||
|
||||
<div {...useBlockProps()}>
|
||||
<div {...blockProps}>
|
||||
{buttonAction === 'customUrl' ? (
|
||||
<a href={customUrl} className="lcp-button" style={{ padding: buttonPadding || '10px' }}>
|
||||
{displayIcon && iconSvgPath && (
|
||||
|
||||
Reference in New Issue
Block a user