Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global styles: add background to global styles changes output #60229

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const translationMap = {
'settings.typography': __( 'Typography' ),
'styles.color': __( 'Colors' ),
'styles.spacing': __( 'Spacing' ),
'styles.background': __( 'Background' ),
'styles.typography': __( 'Typography' ),
};
const getBlockNames = memoize( () =>
Expand Down Expand Up @@ -126,6 +127,7 @@ export function getGlobalStylesChangelist( next, previous ) {
const changedValueTree = deepCompare(
{
styles: {
background: next?.styles?.background,
color: next?.styles?.color,
typography: next?.styles?.typography,
spacing: next?.styles?.spacing,
Expand All @@ -136,6 +138,7 @@ export function getGlobalStylesChangelist( next, previous ) {
},
{
styles: {
background: previous?.styles?.background,
color: previous?.styles?.color,
typography: previous?.styles?.typography,
spacing: previous?.styles?.spacing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ import {
describe( 'getGlobalStylesChanges and utils', () => {
const next = {
styles: {
background: {
backgroundImage: {
url: 'https://example.com/image.jpg',
source: 'file',
},
backgroundSize: 'contain',
backgroundPosition: '30% 30%',
backgroundRepeat: 'no-repeat',
},
typography: {
fontSize: 'var(--wp--preset--font-size--potato)',
fontStyle: 'normal',
Expand Down Expand Up @@ -84,6 +93,15 @@ describe( 'getGlobalStylesChanges and utils', () => {
};
const previous = {
styles: {
background: {
backgroundImage: {
url: 'https://example.com/image_new.jpg',
source: 'file',
},
backgroundSize: 'contain',
backgroundPosition: '40% 77%',
backgroundRepeat: 'repeat',
},
typography: {
fontSize: 'var(--wp--preset--font-size--fungus)',
fontStyle: 'normal',
Expand Down Expand Up @@ -195,7 +213,7 @@ describe( 'getGlobalStylesChanges and utils', () => {
it( 'returns a list of changes', () => {
const result = getGlobalStylesChanges( next, previous );
expect( result ).toEqual( [
'Colors, Typography styles.',
'Background, Colors, Typography styles.',
'Test pumpkin flowers block.',
'H3, Caption, H6, Link elements.',
'Color, Typography settings.',
Expand All @@ -204,10 +222,10 @@ describe( 'getGlobalStylesChanges and utils', () => {

it( 'returns a list of truncated changes', () => {
const resultA = getGlobalStylesChanges( next, previous, {
maxResults: 3,
maxResults: 4,
} );
expect( resultA ).toEqual( [
'Colors, Typography styles.',
'Background, Colors, Typography styles.',
'Test pumpkin flowers block.',
] );
} );
Expand Down Expand Up @@ -254,6 +272,7 @@ describe( 'getGlobalStylesChanges and utils', () => {
const resultA = getGlobalStylesChangelist( next, previous );

expect( resultA ).toEqual( [
[ 'styles', 'Background' ],
[ 'styles', 'Colors' ],
[ 'styles', 'Typography' ],
[ 'blocks', 'Test pumpkin flowers' ],
Expand Down
Loading