forked from WordPress/gutenberg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Section Styles: Resolve ref values in variations data (WordPress#63172)
Co-authored-by: aaronrobertshaw <[email protected]> Co-authored-by: andrewserong <[email protected]> Co-authored-by: ramonjd <[email protected]> Co-authored-by: daviedR <[email protected]>
- Loading branch information
1 parent
6d3282e
commit 0aa455b
Showing
5 changed files
with
286 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
https://github.com/WordPress/wordpress-develop/pull/6989 | ||
|
||
* https://github.com/WordPress/gutenberg/pull/63172 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
packages/block-editor/src/hooks/test/get-variation-styles-with-ref-values.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { getVariationStylesWithRefValues } from '../block-style-variation'; | ||
|
||
describe( 'getVariationStylesWithRefValues', () => { | ||
it( 'should resolve ref values correctly', () => { | ||
const globalStyles = { | ||
styles: { | ||
color: { background: 'red' }, | ||
blocks: { | ||
'core/heading': { | ||
color: { text: 'blue' }, | ||
}, | ||
'core/group': { | ||
variations: { | ||
custom: { | ||
color: { | ||
text: { ref: 'styles.does-not-exist' }, | ||
background: { | ||
ref: 'styles.color.background', | ||
}, | ||
}, | ||
blocks: { | ||
'core/heading': { | ||
color: { | ||
text: { | ||
ref: 'styles.blocks.core/heading.color.text', | ||
}, | ||
background: { ref: '' }, | ||
}, | ||
}, | ||
}, | ||
elements: { | ||
link: { | ||
color: { | ||
text: { | ||
ref: 'styles.elements.link.color.text', | ||
}, | ||
background: { ref: undefined }, | ||
}, | ||
':hover': { | ||
color: { | ||
text: { | ||
ref: 'styles.elements.link.:hover.color.text', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
elements: { | ||
link: { | ||
color: { text: 'green' }, | ||
':hover': { | ||
color: { text: 'yellow' }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
expect( | ||
getVariationStylesWithRefValues( | ||
globalStyles, | ||
'core/group', | ||
'custom' | ||
) | ||
).toEqual( { | ||
color: { background: 'red' }, | ||
blocks: { | ||
'core/heading': { | ||
color: { text: 'blue' }, | ||
}, | ||
}, | ||
elements: { | ||
link: { | ||
color: { | ||
text: 'green', | ||
}, | ||
':hover': { | ||
color: { text: 'yellow' }, | ||
}, | ||
}, | ||
}, | ||
} ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters