Skip to content

Commit

Permalink
Style theme variations: add property extraction and merge utils (#58803)
Browse files Browse the repository at this point in the history
* First commit

Pulling out the utils from #56622 so we test separately

* Adding failing tests :)

* Adds working tests
Removes extra functions - now internal to the hook

* Adds more tests

* Adds filterObjectByProperty tests

* Update packages/edit-site/src/hooks/use-theme-style-variations/use-theme-style-variations-by-property.js

Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>

* Merge map callbacks

* More tests, adding a `null` check too

* Update comment to reflect functionality

* Update test to ensure we don't reference original object

---------

Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: scruffian <scruffian@git.wordpress.org>
  • Loading branch information
4 people authored Feb 13, 2024
1 parent 60fc52d commit 1a63093
Show file tree
Hide file tree
Showing 4 changed files with 1,065 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { store as coreStore } from '@wordpress/core-data';
*/
import { useSupportedStyles } from '../../components/global-styles/hooks';
import { unlock } from '../../lock-unlock';
import cloneDeep from '../../utils/clone-deep';

const { cleanEmptyObject, GlobalStylesContext } = unlock(
blockEditorPrivateApis
Expand Down Expand Up @@ -275,10 +276,6 @@ function setNestedValue( object, path, value ) {
return object;
}

function cloneDeep( object ) {
return ! object ? {} : JSON.parse( JSON.stringify( object ) );
}

function PushChangesToGlobalStylesControl( {
name,
attributes,
Expand Down
Loading

0 comments on commit 1a63093

Please sign in to comment.