Skip to content

Commit

Permalink
Add a buttonType attribute to Button component
Browse files Browse the repository at this point in the history
Enables setting a button type as 'submit', any other viable option or a
default 'button' if the Button is not a link
  • Loading branch information
piqusy committed Dec 5, 2024
1 parent ba5a429 commit c39c725
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions blocks/init/src/Blocks/components/button/button.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
$buttonAttrs['class'] = Helpers::tailwindClasses('base', $attributes, $manifest, 'button', $additionalClass);

$buttonTag = !empty($buttonUrl) ? 'a' : 'button';

if (empty($buttonUrl)) {
$buttonAttrs['type'] = Helpers::checkAttr('buttonType', $attributes, $manifest);
}
?>

<<?php echo $buttonTag; // phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped ?>
Expand Down
4 changes: 4 additions & 0 deletions blocks/init/src/Blocks/components/button/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"buttonId": {
"type": "string"
},
"buttonType": {
"type": "string",
"default": "button"
},
"buttonColor": {
"type": "string",
"default": "navy-500"
Expand Down

0 comments on commit c39c725

Please sign in to comment.