Skip to content

Commit

Permalink
Merge pull request #45 from infinum/feature/new-helper
Browse files Browse the repository at this point in the history
Release 1.3.1
  • Loading branch information
iruzevic authored Sep 13, 2024
2 parents 2b3b1c1 + fd1b26c commit 82bcb8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ 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.3.1] - 2024-09-13
- Helper `getFilteredAttributes` used on SSR components to filter out unwanted attributes and optimize the output.

## [1.3.0] - 2024-08-08
- `twClasses` and `twClassesEditor` can now be passed as an array
- Updated schemas to account for the `twClasses`/`twClassesEditor` changes.
Expand Down Expand Up @@ -40,6 +43,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.3.1]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.3.0...1.3.1
[1.3.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.2.0...1.3.0
[1.2.0]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.1.1...1.2.0
[1.1.1]: https://github.com/infinum/eightshift-frontend-libs-tailwind/compare/1.1.0...1.1.1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eightshift/frontend-libs-tailwind",
"version": "1.3.0",
"version": "1.3.1",
"description": "A framework for creating modern Gutenberg themes with styling provided by Tailwind CSS.",
"author": {
"name": "Eightshift team",
Expand Down
25 changes: 25 additions & 0 deletions scripts/editor/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,28 @@ export const props = (newName, attributes, manual = {}) => {
// Return the original attribute for optimization purposes.
return output;
};


/**
* Filter attributes by array of keys. Used to provide alternative attributes to server side render component to prevent unnecessary rerender.
*
* @param {object} attributes Attributes data source.
* @param {array} filterAttributes Array of attributes to filter.
* @param {object} appendItems Append additional attributes.
*
* @returns {object}
*/
export const getFilteredAttributes = (attributes, filterAttributes, appendItems = {}) => {
const output = {};

for (const [key, value] of Object.entries(attributes)) {
if (filterAttributes.includes(key)) {
output[key] = value;
}
}

return {
...output,
...appendItems,
};
};

0 comments on commit 82bcb8c

Please sign in to comment.