diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e05620..f272dd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ 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/). +## [1.4.0] - 2024-09-30 +- Introduced new, more flexible, and simpler to use `tailwindClasses` function. Replaces `getTwPart`, `getTwDynamicPart`, and `getTwClasses`. + - **Potentially breaking**: `twClassesEditor` is now appended to `twClasses`. If you need editor-only classes, you can now use the `twClassesEditorOnly` key. Editor-only classes replace `twClasses`, but will also have classes from `twClassesEditor`. + - **Potentially breaking**: `parts` key in manifest now supports specifying multiple parts just with a comma-separated string. + - You can now apply classes to multiple parts within one option or combination! Also work with responsive options. + - There are now (basic) warnings for misconfigurations of parts and options. +- Updated block and component schemas with new Tailwind functionalities. +- Updated dependencies. +- Updated default blocks with new Tailwind functions. +- Default Stylelint config will no longer report `@tailwind` rules. + ## [1.3.3] - 2024-09-24 - Updating schema. @@ -49,6 +60,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a [Unreleased]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/master...HEAD +[1.4.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.3.3...1.4.0 [1.3.3]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.3.2...1.3.3 [1.3.2]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.3.1...1.3.2 [1.3.1]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.3.0...1.3.1 diff --git a/blocks/init/src/Blocks/components/button/button.php b/blocks/init/src/Blocks/components/button/button.php index b51fb8d..ec6d35f 100644 --- a/blocks/init/src/Blocks/components/button/button.php +++ b/blocks/init/src/Blocks/components/button/button.php @@ -56,7 +56,7 @@ $buttonAttrs['aria-label'] = $buttonAriaLabel; } -$buttonAttrs['class'] = Helpers::getTwClasses($attributes, $manifest, 'button', $additionalClass); +$buttonAttrs['class'] = Helpers::tailwindClasses('base', $attributes, $manifest, 'button', $additionalClass); $buttonTag = !empty($buttonUrl) ? 'a' : 'button'; ?> diff --git a/blocks/init/src/Blocks/components/button/components/button-editor.js b/blocks/init/src/Blocks/components/button/components/button-editor.js index 17f9daa..0be8d43 100644 --- a/blocks/init/src/Blocks/components/button/components/button-editor.js +++ b/blocks/init/src/Blocks/components/button/components/button-editor.js @@ -1,6 +1,6 @@ import { __ } from '@wordpress/i18n'; import { RichText } from '@wordpress/block-editor'; -import { checkAttr, getAttrKey, getTwClasses, props } from '@eightshift/frontend-libs-tailwind/scripts'; +import { checkAttr, getAttrKey, tailwindClasses, props } from '@eightshift/frontend-libs-tailwind/scripts'; import { IconEditor } from '../../icon/components/icon-editor'; import manifest from './../manifest.json'; @@ -17,7 +17,7 @@ export const ButtonEditor = (attributes) => { } return ( -
+
-
+
[ - 'image' => Helpers::getTwPart('image', $manifest), - 'picture' => Helpers::getTwPart('imagePicture', $manifest), + 'image' => Helpers::tailwindClasses('image', $attributes, $manifest), + 'picture' => Helpers::tailwindClasses('imagePicture', $attributes, $manifest), ] ])); ?> -
+
Helpers::getTwPart('intro', $manifest), + 'additionalClass' => Helpers::tailwindClasses('intro', $attributes, $manifest), ])), Helpers::render('heading', Helpers::props('heading', $attributes)), Helpers::render('paragraph', Helpers::props('paragraph', $attributes, [ - 'additionalClass' => Helpers::getTwPart('text', $manifest), + 'additionalClass' => Helpers::tailwindClasses('text', $attributes, $manifest), ])), Helpers::render('button', Helpers::props('button', $attributes, [ - 'additionalClass' => Helpers::getTwPart('button', $manifest), + 'additionalClass' => Helpers::tailwindClasses('button', $attributes, $manifest), ])); ?>
diff --git a/blocks/init/src/Blocks/components/card/components/card-editor.js b/blocks/init/src/Blocks/components/card/components/card-editor.js index e9e7ade..09e2bb4 100644 --- a/blocks/init/src/Blocks/components/card/components/card-editor.js +++ b/blocks/init/src/Blocks/components/card/components/card-editor.js @@ -1,4 +1,4 @@ -import { props, getTwClasses, getTwPart } from '@eightshift/frontend-libs-tailwind/scripts'; +import { props, tailwindClasses } from '@eightshift/frontend-libs-tailwind/scripts'; import { ImageEditor } from '../../image/components/image-editor'; import { HeadingEditor } from '../../heading/components/heading-editor'; import { ParagraphEditor } from '../../paragraph/components/paragraph-editor'; @@ -9,30 +9,34 @@ export const CardEditor = (attributes) => { const { additionalClass } = attributes; return ( -
+
-
+
- + - +
); diff --git a/blocks/init/src/Blocks/components/heading/components/heading-editor.js b/blocks/init/src/Blocks/components/heading/components/heading-editor.js index 4a84d07..eb0cd75 100644 --- a/blocks/init/src/Blocks/components/heading/components/heading-editor.js +++ b/blocks/init/src/Blocks/components/heading/components/heading-editor.js @@ -1,6 +1,6 @@ import { __ } from '@wordpress/i18n'; import { RichText } from '@wordpress/block-editor'; -import { checkAttr, getAttrKey, getTwClasses } from '@eightshift/frontend-libs-tailwind/scripts'; +import { checkAttr, getAttrKey, tailwindClasses } from '@eightshift/frontend-libs-tailwind/scripts'; import manifest from './../manifest.json'; export const HeadingEditor = (attributes) => { @@ -16,7 +16,7 @@ export const HeadingEditor = (attributes) => { return ( setAttributes({ [getAttrKey('headingContent', attributes, manifest)]: value })} diff --git a/blocks/init/src/Blocks/components/heading/components/heading-options.js b/blocks/init/src/Blocks/components/heading/components/heading-options.js index 6649657..9042765 100644 --- a/blocks/init/src/Blocks/components/heading/components/heading-options.js +++ b/blocks/init/src/Blocks/components/heading/components/heading-options.js @@ -49,10 +49,10 @@ export const HeadingOptions = (attributes) => { type='menu' wrapperProps={{ triggerIcon: {headingTag}, - tooltip: __('Heading level', '%g_textdomain%'), }} hidden={hiddenOptions?.headingLevel} noTriggerLabel + tooltip /> {additionalControls} diff --git a/blocks/init/src/Blocks/components/heading/heading.php b/blocks/init/src/Blocks/components/heading/heading.php index b452736..f4224f8 100644 --- a/blocks/init/src/Blocks/components/heading/heading.php +++ b/blocks/init/src/Blocks/components/heading/heading.php @@ -36,7 +36,7 @@ < data-slug="" - class="" + class="" > { } return ( -
+
diff --git a/blocks/init/src/Blocks/components/hero/hero.php b/blocks/init/src/Blocks/components/hero/hero.php index 6fb8ca1..99a10b7 100644 --- a/blocks/init/src/Blocks/components/hero/hero.php +++ b/blocks/init/src/Blocks/components/hero/hero.php @@ -19,12 +19,12 @@ $additionalClass = $attributes['additionalClass'] ?? ''; ?> -
+
[ 'image' => 'size-full grayscale', - 'picture' => Helpers::getTwPart('imagePicture', $manifest), + 'picture' => Helpers::tailwindClasses('imagePicture', $attributes, $manifest), ], ])); ?> diff --git a/blocks/init/src/Blocks/components/icon/components/icon-editor.js b/blocks/init/src/Blocks/components/icon/components/icon-editor.js index a4b51c0..c10728c 100644 --- a/blocks/init/src/Blocks/components/icon/components/icon-editor.js +++ b/blocks/init/src/Blocks/components/icon/components/icon-editor.js @@ -1,4 +1,4 @@ -import { checkAttr, getTwClasses } from '@eightshift/frontend-libs-tailwind/scripts'; +import { checkAttr, tailwindClasses } from '@eightshift/frontend-libs-tailwind/scripts'; import { JsxSvg } from '@eightshift/ui-components/icons'; import manifest from './../manifest.json'; @@ -17,7 +17,7 @@ export const IconEditor = (attributes) => { return ( ); }; diff --git a/blocks/init/src/Blocks/components/icon/icon.php b/blocks/init/src/Blocks/components/icon/icon.php index ad25288..edce2b1 100644 --- a/blocks/init/src/Blocks/components/icon/icon.php +++ b/blocks/init/src/Blocks/components/icon/icon.php @@ -26,7 +26,7 @@ $icon = $manifest['icons'][$iconName]; -$className = Helpers::getTwClasses($attributes, $manifest, $additionalClass); +$className = Helpers::tailwindClasses('base', $attributes, $manifest, $additionalClass); if (!empty($className)) { $icon = str_replace(' { ); })} diff --git a/blocks/init/src/Blocks/components/image/image.php b/blocks/init/src/Blocks/components/image/image.php index 2308df2..215e047 100644 --- a/blocks/init/src/Blocks/components/image/image.php +++ b/blocks/init/src/Blocks/components/image/image.php @@ -57,6 +57,6 @@ class="" <?php echo esc_attr($imageAlt); ?> diff --git a/blocks/init/src/Blocks/components/list/components/list-editor.js b/blocks/init/src/Blocks/components/list/components/list-editor.js index 0b1d818..7bdfd9b 100644 --- a/blocks/init/src/Blocks/components/list/components/list-editor.js +++ b/blocks/init/src/Blocks/components/list/components/list-editor.js @@ -1,6 +1,6 @@ import { __ } from '@wordpress/i18n'; import { RichText } from '@wordpress/block-editor'; -import { checkAttr, getAttrKey, getTwClasses } from '@eightshift/frontend-libs-tailwind/scripts'; +import { checkAttr, getAttrKey, tailwindClasses } from '@eightshift/frontend-libs-tailwind/scripts'; import manifest from '../manifest.json'; export const ListEditor = (attributes) => { @@ -16,7 +16,7 @@ export const ListEditor = (attributes) => { const listType = checkAttr('listType', attributes, manifest); return ( -
+
< - class="" + class="" > a]:underline font-synthesis-none" + "twClassesEditorOnly": "font-sans [&>a]:underline font-synthesis-none" }, "options": { "listSize": { @@ -115,7 +115,7 @@ "decimal": "list-decimal ml-[1.125em]", "checks": "list-['✓_'] ml-[1em]" }, - "twClassesEditor": { + "twClassesEditorOnly": { "none": "*:list-none", "disc": "*:list-disc *:ml-[1.125em]", "decimal": "*:list-decimal *:ml-[1.125em]", diff --git a/blocks/init/src/Blocks/components/modal/modal.php b/blocks/init/src/Blocks/components/modal/modal.php index d4c0102..c5e608c 100644 --- a/blocks/init/src/Blocks/components/modal/modal.php +++ b/blocks/init/src/Blocks/components/modal/modal.php @@ -18,17 +18,17 @@ $modalContent = Helpers::checkAttr('modalContent', $attributes, $manifest); ?> -