Skip to content

Commit

Permalink
Merge pull request #71 from infinum/feature/button-type
Browse files Browse the repository at this point in the history
Feature - button type
  • Loading branch information
piqusy authored Dec 5, 2024
2 parents 3407b33 + cb36884 commit 1a56577
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
- Fixed Image component "image" part tailwind class output if not set.
- Fix Image component responsive output Co-authored-by: goran.alkovic@infinum.com
- Add "Auto" width to wrapperContent and set is as defaults
- Add a buttonType attribute to Button component
- Updated dependencies.

## [1.4.6]
Expand Down
5 changes: 5 additions & 0 deletions blocks/init/src/Blocks/components/button/button.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$additionalClass = $attributes['additionalClass'] ?? '';
$additionalAttributes = $attributes['additionalAttributes'] ?? [];
$buttonId = Helpers::checkAttr('buttonId', $attributes, $manifest);
$buttonType = Helpers::checkAttr('buttonType', $attributes, $manifest);

$buttonUrl = Helpers::checkAttr('buttonUrl', $attributes, $manifest);
$buttonIsNewTab = Helpers::checkAttr('buttonIsNewTab', $attributes, $manifest);
Expand Down Expand Up @@ -59,6 +60,10 @@
$buttonAttrs['class'] = Helpers::tailwindClasses('base', $attributes, $manifest, 'button', $additionalClass);

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

if (empty($buttonUrl) && !empty($buttonType)) {
$buttonAttrs['type'] = $buttonType;
}
?>

<<?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": ""
},
"buttonColor": {
"type": "string",
"default": "navy-500"
Expand Down

0 comments on commit 1a56577

Please sign in to comment.