From 3d15e4f5daab86731eeb79085c071d96a3e7eb5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 14:06:47 +0200 Subject: [PATCH 1/9] update packages in default package json --- src/InitSetup/tailwind/plugin/package.json | 8 ++++---- src/InitSetup/tailwind/theme/package.json | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/InitSetup/tailwind/plugin/package.json b/src/InitSetup/tailwind/plugin/package.json index a41b89e8..af3933d0 100644 --- a/src/InitSetup/tailwind/plugin/package.json +++ b/src/InitSetup/tailwind/plugin/package.json @@ -12,13 +12,13 @@ }, "devDependencies": { "husky": "^9.0.11", - "webpack": "^5.91.0", + "webpack": "^5.93.0", "webpack-cli": "^5.1.4" }, "dependencies": { - "@eightshift/ui-components": "^1.2.2", - "fluid-tailwind": "^1.0.2", - "tailwindcss": "^3.4.4", + "@eightshift/ui-components": "^1.4.7", + "fluid-tailwind": "^1.0.3", + "tailwindcss": "^3.4.10", "tailwindcss-animate": "^1.0.7" }, "husky": { diff --git a/src/InitSetup/tailwind/theme/package.json b/src/InitSetup/tailwind/theme/package.json index 6328b7a2..edd6f46d 100644 --- a/src/InitSetup/tailwind/theme/package.json +++ b/src/InitSetup/tailwind/theme/package.json @@ -11,14 +11,14 @@ "build": "webpack --mode production" }, "devDependencies": { - "husky": "^9.0.11", - "webpack": "^5.91.0", + "husky": "^9.1.5", + "webpack": "^5.93.0", "webpack-cli": "^5.1.4" }, "dependencies": { - "@eightshift/ui-components": "^1.2.2", - "fluid-tailwind": "^1.0.2", - "tailwindcss": "^3.4.4", + "@eightshift/ui-components": "^1.4.7", + "fluid-tailwind": "^1.0.3", + "tailwindcss": "^3.4.10", "tailwindcss-animate": "^1.0.7", "micromodal": "^0.4.10" }, From 62f9a982d013a96f1e357d594724223adc8b6e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 15:04:18 +0200 Subject: [PATCH 2/9] allow array classes in tw manfiest --- src/Helpers/TailwindTrait.php | 36 +++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/Helpers/TailwindTrait.php b/src/Helpers/TailwindTrait.php index b69f4175..6223f1f8 100644 --- a/src/Helpers/TailwindTrait.php +++ b/src/Helpers/TailwindTrait.php @@ -58,6 +58,10 @@ public static function getTwPart($part, $manifest, ...$custom) $partClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; + if (is_array($partClasses)) { + $partClasses = implode(' ', $partClasses); + } + return Helpers::classnames([$partClasses, ...$custom]); } @@ -81,6 +85,10 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo $baseClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; + if (is_array($baseClasses)) { + $baseClasses = implode(' ', $baseClasses); + } + $mainClasses = []; if (isset($manifest['tailwind']['options'])) { @@ -111,7 +119,13 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo } if (!$responsive) { - $mainClasses = [...$mainClasses, $twClasses[$value]]; + $output = $twClasses[$value] ?? ''; + + if (is_array($output)) { + $output = implode(' ', $output); + } + + $mainClasses = [...$mainClasses, $output]; continue; } @@ -124,6 +138,10 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo $currentClasses = $twClasses[$value[$breakpoint]] ?? ''; + if (is_array($currentClasses)) { + $currentClasses = implode(' ', $currentClasses); + } + if (!$currentClasses) { return $curr; } @@ -162,6 +180,10 @@ public static function getTwClasses($attributes, $manifest, ...$custom) $baseClasses = $manifest['tailwind']['base']['twClasses'] ?? ''; + if (is_array($baseClasses)) { + $baseClasses = implode(' ', $baseClasses); + } + $mainClasses = []; if (isset($manifest['tailwind']['options'])) { @@ -192,7 +214,13 @@ public static function getTwClasses($attributes, $manifest, ...$custom) } if (!$responsive) { - $mainClasses = [...$mainClasses, $twClasses[$value]]; + $output = $twClasses[$value] ?? ''; + + if (is_array($output)) { + $output = implode(' ', $output); + } + + $mainClasses = [...$mainClasses, $output]; continue; } @@ -230,6 +258,10 @@ public static function getTwClasses($attributes, $manifest, ...$custom) $conditions = $value['attributes']; $twClasses = $value['twClasses']; + if (is_array($twClasses)) { + $twClasses = implode(' ', $twClasses); + } + $matches = true; foreach ($conditions as $key => $attrConditions) { From 24a69a697805ed272529ece500c966b767e268f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 16:50:18 +0200 Subject: [PATCH 3/9] fix issue with dynamic part taking global classnames --- src/Helpers/TailwindTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Helpers/TailwindTrait.php b/src/Helpers/TailwindTrait.php index 6223f1f8..b87bc59b 100644 --- a/src/Helpers/TailwindTrait.php +++ b/src/Helpers/TailwindTrait.php @@ -93,7 +93,7 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo if (isset($manifest['tailwind']['options'])) { foreach ($manifest['tailwind']['options'] as $attributeName => $value) { - if (isset($value['part']) && $value['part'] !== $part) { + if (!isset($value['part']) || $value['part'] !== $part) { continue; } From 0993fc4022a6edc1256a5b8fcca9ae3cd8c4335a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:10:24 +0200 Subject: [PATCH 4/9] output tw classes if no tw classes are output --- src/Helpers/TailwindTrait.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helpers/TailwindTrait.php b/src/Helpers/TailwindTrait.php index b87bc59b..32b2b9ad 100644 --- a/src/Helpers/TailwindTrait.php +++ b/src/Helpers/TailwindTrait.php @@ -53,7 +53,7 @@ public static function getTwBreakpoints($desktopFirst = false) public static function getTwPart($part, $manifest, ...$custom) { if (!$part || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return ''; + return Helpers::classnames($custom); } $partClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; @@ -80,7 +80,7 @@ public static function getTwPart($part, $manifest, ...$custom) public static function getTwDynamicPart($part, $attributes, $manifest, ...$custom) { if (!$part || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return ''; + return Helpers::classnames($custom); } $baseClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; @@ -175,7 +175,7 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo public static function getTwClasses($attributes, $manifest, ...$custom) { if (!$attributes || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return ''; + return Helpers::classnames($custom); } $baseClasses = $manifest['tailwind']['base']['twClasses'] ?? ''; From 9b1567fb574b46e2b62689bcb2c09889f1e1b34f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 17:22:05 +0200 Subject: [PATCH 5/9] update changelog --- CHANGELOG.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 941966fc..fd5aef98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/). +## [9.1.0] + +### Fixed +- Default Tailwind config - PHP files are watched now only in the root folder and anything within `src/` +- Fixed Tailwind outputs not working properly with booleans. +- `twClasses` and `twClassesEditor` can now be passed as an array +- Fixed a couple of bugs related to Tailwind class output. + ## [9.0.2] ### Changed @@ -177,7 +185,7 @@ This is a major release that includes PHP8+ support. We tested it on the PHP 8.2 - Missing type hinting. - New command to change version number. - Better copy for `checkAttr`` helper if key is missing. -- Every enqueue script now has `is<>Used` method that is by default true. +- Every enqueue script now has `is<>Used` method that is by default true. ### Removed - Blocks "old" version functions. @@ -453,7 +461,7 @@ MAYOR BREAKING CHANGES ## [2.2.2] - 2020-05-15 -### Added +### Added - New helper method for making responsive selectors. ## [2.2.1] - 2020-05-13 @@ -461,13 +469,13 @@ MAYOR BREAKING CHANGES ### Removed - PHP version 7.0 from Travis build. -### Added +### Added - Check for block manifest validation. ## [2.2.0] - 2020-05-06 ### Changed -* Removed config dependency from the Asset classes and exposed config through Manifest. +* Removed config dependency from the Asset classes and exposed config through Manifest. * `editor-color-palette` - Add theme support for editor color palette built from global manifest.json. ## [2.1.1] - 2020-03-05 @@ -624,6 +632,7 @@ Init setup [Unreleased]: https://github.com/infinum/eightshift-libs/compare/main...HEAD +[9.1.0]: https://github.com/infinum/eightshift-libs/compare/9.0.2...9.1.0 [9.0.2]: https://github.com/infinum/eightshift-libs/compare/9.0.1...9.0.2 [9.0.1]: https://github.com/infinum/eightshift-libs/compare/9.0.0...9.0.1 [9.0.0]: https://github.com/infinum/eightshift-libs/compare/8.0.7...9.0.0 From bd266e31e0d2776da1bc44ef681d1743515e5ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:45:37 +0200 Subject: [PATCH 6/9] fix phpstan issues --- src/Helpers/TailwindTrait.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helpers/TailwindTrait.php b/src/Helpers/TailwindTrait.php index 32b2b9ad..0bbf6d71 100644 --- a/src/Helpers/TailwindTrait.php +++ b/src/Helpers/TailwindTrait.php @@ -53,7 +53,7 @@ public static function getTwBreakpoints($desktopFirst = false) public static function getTwPart($part, $manifest, ...$custom) { if (!$part || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return Helpers::classnames($custom); + return $custom ? Helpers::classnames($custom) : ''; } $partClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; @@ -80,7 +80,7 @@ public static function getTwPart($part, $manifest, ...$custom) public static function getTwDynamicPart($part, $attributes, $manifest, ...$custom) { if (!$part || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return Helpers::classnames($custom); + return $custom ? Helpers::classnames($custom) : ''; } $baseClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; @@ -175,7 +175,7 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo public static function getTwClasses($attributes, $manifest, ...$custom) { if (!$attributes || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return Helpers::classnames($custom); + return $custom ? Helpers::classnames($custom) : ''; } $baseClasses = $manifest['tailwind']['base']['twClasses'] ?? ''; From 38af87517a226b8e44ae118082f5efbb600707ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:46:46 +0200 Subject: [PATCH 7/9] fix phpcs issues --- src/Helpers/TailwindTrait.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Helpers/TailwindTrait.php b/src/Helpers/TailwindTrait.php index 0bbf6d71..eb83473c 100644 --- a/src/Helpers/TailwindTrait.php +++ b/src/Helpers/TailwindTrait.php @@ -58,8 +58,8 @@ public static function getTwPart($part, $manifest, ...$custom) $partClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; - if (is_array($partClasses)) { - $partClasses = implode(' ', $partClasses); + if (\is_array($partClasses)) { + $partClasses = \implode(' ', $partClasses); } return Helpers::classnames([$partClasses, ...$custom]); @@ -85,8 +85,8 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo $baseClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; - if (is_array($baseClasses)) { - $baseClasses = implode(' ', $baseClasses); + if (\is_array($baseClasses)) { + $baseClasses = \implode(' ', $baseClasses); } $mainClasses = []; @@ -121,8 +121,8 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo if (!$responsive) { $output = $twClasses[$value] ?? ''; - if (is_array($output)) { - $output = implode(' ', $output); + if (\is_array($output)) { + $output = \implode(' ', $output); } $mainClasses = [...$mainClasses, $output]; @@ -138,8 +138,8 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo $currentClasses = $twClasses[$value[$breakpoint]] ?? ''; - if (is_array($currentClasses)) { - $currentClasses = implode(' ', $currentClasses); + if (\is_array($currentClasses)) { + $currentClasses = \implode(' ', $currentClasses); } if (!$currentClasses) { @@ -180,8 +180,8 @@ public static function getTwClasses($attributes, $manifest, ...$custom) $baseClasses = $manifest['tailwind']['base']['twClasses'] ?? ''; - if (is_array($baseClasses)) { - $baseClasses = implode(' ', $baseClasses); + if (\is_array($baseClasses)) { + $baseClasses = \implode(' ', $baseClasses); } $mainClasses = []; @@ -216,8 +216,8 @@ public static function getTwClasses($attributes, $manifest, ...$custom) if (!$responsive) { $output = $twClasses[$value] ?? ''; - if (is_array($output)) { - $output = implode(' ', $output); + if (\is_array($output)) { + $output = \implode(' ', $output); } $mainClasses = [...$mainClasses, $output]; @@ -258,8 +258,8 @@ public static function getTwClasses($attributes, $manifest, ...$custom) $conditions = $value['attributes']; $twClasses = $value['twClasses']; - if (is_array($twClasses)) { - $twClasses = implode(' ', $twClasses); + if (\is_array($twClasses)) { + $twClasses = \implode(' ', $twClasses); } $matches = true; From 8f82487ea335863641ea3bdc7a1f4c48ad841313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:49:12 +0200 Subject: [PATCH 8/9] add phpstan ignores --- src/Helpers/TailwindTrait.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Helpers/TailwindTrait.php b/src/Helpers/TailwindTrait.php index eb83473c..16b9c7b0 100644 --- a/src/Helpers/TailwindTrait.php +++ b/src/Helpers/TailwindTrait.php @@ -53,7 +53,7 @@ public static function getTwBreakpoints($desktopFirst = false) public static function getTwPart($part, $manifest, ...$custom) { if (!$part || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return $custom ? Helpers::classnames($custom) : ''; + return $custom ? Helpers::classnames($custom) : ''; // @phpstan-ignore-line } $partClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; @@ -80,7 +80,7 @@ public static function getTwPart($part, $manifest, ...$custom) public static function getTwDynamicPart($part, $attributes, $manifest, ...$custom) { if (!$part || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return $custom ? Helpers::classnames($custom) : ''; + return $custom ? Helpers::classnames($custom) : ''; // @phpstan-ignore-line } $baseClasses = $manifest['tailwind']['parts'][$part]['twClasses'] ?? ''; @@ -175,7 +175,7 @@ public static function getTwDynamicPart($part, $attributes, $manifest, ...$custo public static function getTwClasses($attributes, $manifest, ...$custom) { if (!$attributes || !$manifest || !isset($manifest['tailwind']) || \array_keys($manifest['tailwind']) === []) { - return $custom ? Helpers::classnames($custom) : ''; + return $custom ? Helpers::classnames($custom) : ''; // @phpstan-ignore-line } $baseClasses = $manifest['tailwind']['base']['twClasses'] ?? ''; From ff8f1db4e6d57d9475b7659724cb6d6bc086c181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Goran=20Alkovi=C4=87?= <77000136+goranalkovic-infinum@users.noreply.github.com> Date: Wed, 21 Aug 2024 20:51:29 +0200 Subject: [PATCH 9/9] tweak prettier config --- CHANGELOG.md | 1 + src/InitSetup/tailwind/plugin/.prettierrc | 6 +++++- src/InitSetup/tailwind/theme/.prettierrc | 6 +++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd5aef98..610a4d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - Fixed Tailwind outputs not working properly with booleans. - `twClasses` and `twClassesEditor` can now be passed as an array - Fixed a couple of bugs related to Tailwind class output. +- Tweaked default Prettier config for new projects. ## [9.0.2] diff --git a/src/InitSetup/tailwind/plugin/.prettierrc b/src/InitSetup/tailwind/plugin/.prettierrc index 2c8e79ab..9cfeaf23 100644 --- a/src/InitSetup/tailwind/plugin/.prettierrc +++ b/src/InitSetup/tailwind/plugin/.prettierrc @@ -6,5 +6,9 @@ "jsxSingleQuote": true, "singleQuote": true, "singleAttributePerLine": true, - "printWidth": 120 + "printWidth": 120, + "arrowParens": "always", + "bracketSpacing": true, + "semi": true, + "trailingComma": "all" } diff --git a/src/InitSetup/tailwind/theme/.prettierrc b/src/InitSetup/tailwind/theme/.prettierrc index 2c8e79ab..9cfeaf23 100644 --- a/src/InitSetup/tailwind/theme/.prettierrc +++ b/src/InitSetup/tailwind/theme/.prettierrc @@ -6,5 +6,9 @@ "jsxSingleQuote": true, "singleQuote": true, "singleAttributePerLine": true, - "printWidth": 120 + "printWidth": 120, + "arrowParens": "always", + "bracketSpacing": true, + "semi": true, + "trailingComma": "all" }