Skip to content

Commit

Permalink
Merge pull request #67 from infinum/release/1.4.7
Browse files Browse the repository at this point in the history
1.4.7
  • Loading branch information
piqusy authored Dec 18, 2024
2 parents 3a516d0 + 867456e commit aea9580
Show file tree
Hide file tree
Showing 9 changed files with 10,220 additions and 26 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

---

## [1.4.7]

### Changed
- Fixed Image component "image" part tailwind class output if not set.
- Fix Image component responsive output Co-authored-by: [email protected]
- Add "Auto" width to wrapperContent and set is as defaults
- Add a buttonType attribute to Button component
- Implement a11y for Icon component either by setting aria-hidden to true (default) or using the existing iconName label from manifest options key
- Updated dependencies.

## [1.4.6]

### Changed
Expand Down Expand Up @@ -159,6 +169,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
- Initial release.

[Unreleased]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/master...HEAD
[1.4.7]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.6...1.4.7
[1.4.6]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.5...1.4.6
[1.4.5]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.4...1.4.5
[1.4.4]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.4.3...1.4.4
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
3 changes: 3 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,9 @@
"buttonId": {
"type": "string"
},
"buttonType": {
"type": "string"
},
"buttonColor": {
"type": "string",
"default": "navy-500"
Expand Down
19 changes: 18 additions & 1 deletion blocks/init/src/Blocks/components/icon/icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
$additionalClass = $attributes['additionalClass'] ?? '';

$iconName = Helpers::checkAttr('iconName', $attributes, $manifest);
$iconAriaHidden = Helpers::checkAttr('iconAriaHidden', $attributes, $manifest);

if (!isset($manifest['icons'][$iconName])) {
return;
Expand All @@ -29,7 +30,23 @@
$className = Helpers::tailwindClasses('base', $attributes, $manifest, $additionalClass);

if (!empty($className)) {
$icon = str_replace('<svg ', '<svg class="' . htmlspecialchars($className) . '" ', $icon);
$icon = str_replace('<svg ', '<svg class="' . esc_attr($className) . '" ', $icon);
}

if ($iconAriaHidden) {
$icon = str_replace('<svg ', '<svg aria-hidden="true" ', $icon);
} else {
$iconTitle = '';
$iconOption = array_filter($manifest['options']['iconName'], fn($option) => $option['value'] === $iconName);

if (!empty($iconOption)) {
$iconTitle = reset($iconOption)['label'];
}

if (!empty($iconTitle)) {
$titleTag = '<title>' . esc_html($iconTitle) . '</title>';
$icon = str_replace('</svg>', $titleTag . '</svg>', $icon);
}
}

// phpcs:ignore Eightshift.Security.HelpersEscape.OutputNotEscaped
Expand Down
4 changes: 4 additions & 0 deletions blocks/init/src/Blocks/components/icon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"iconUse": {
"type": "boolean",
"default": true
},
"iconAriaHidden": {
"type": "boolean",
"default": true
}
},
"options": {
Expand Down
13 changes: 9 additions & 4 deletions blocks/init/src/Blocks/components/image/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,20 @@
$isDesktopFirst = $imageData['_desktopFirst'] ?? false;

$breakpointData = Helpers::getSettingsGlobalVariablesBreakpoints();
$breakpoints = Helpers::getTwBreakpoints();
$breakpoints = Helpers::getTwBreakpoints($isDesktopFirst);

if (!$isDesktopFirst) {
$breakpoints = array_reverse($breakpoints);
}
?>

<picture
<?php if (!empty($additionalClass['picture'])) { ?>
class="<?php echo esc_attr($additionalClass['picture']); ?>"
<?php } ?>
>
<?php foreach ($breakpoints as $breakpoint) { ?>
<?php
foreach ($breakpoints as $breakpoint) { ?>
<?php
if (!isset($imageData[$breakpoint])) {
continue;
Expand All @@ -45,7 +50,7 @@ class="<?php echo esc_attr($additionalClass['picture']); ?>"
continue;
}

$breakpointWidth = $breakpointData[$breakpoint];
$breakpointWidth = $breakpointData[str_replace('max-', '', $breakpoint)];

$widthMode = $isDesktopFirst ? 'max-width' : 'min-width';

Expand All @@ -57,7 +62,7 @@ class="<?php echo esc_attr($additionalClass['picture']); ?>"
<img
src="<?php echo esc_url($imageData['_default']['url'] ?? ''); ?>"
alt="<?php echo esc_attr($imageAlt); ?>"
class="<?php echo esc_attr(Helpers::tailwindClasses('base', $attributes, $manifest, $additionalClass['image'] ?? $additionalClass)); ?>"
class="<?php echo esc_attr(Helpers::tailwindClasses('base', $attributes, $manifest, $additionalClass['image'] ?? '')); ?>"
/>
</picture>

8 changes: 7 additions & 1 deletion blocks/init/src/Blocks/wrapper/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"wrapperContentWidth": {
"type": "object",
"default": {
"_default": "full",
"_default": "auto",
"_desktopFirst": true
}
},
Expand Down Expand Up @@ -289,6 +289,11 @@
}
],
"wrapperContentWidth": [
{
"label": "Auto",
"value": "auto",
"separator": "below"
},
{
"label": "Full",
"value": "full",
Expand Down Expand Up @@ -439,6 +444,7 @@
"wrapperContentWidth": {
"responsive": true,
"twClasses": {
"auto": "w-auto",
"full": "w-full",
"half": "w-1/2",
"one-third": "w-1/3",
Expand Down
Loading

0 comments on commit aea9580

Please sign in to comment.