Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7716adc
Mobile - Read global styles and set color palette and gradients
Apr 9, 2021
f670aec
Mobile - Enable colors for blocks that support it
Apr 13, 2021
3f18835
Parse all color variables
Apr 13, 2021
fa6b94d
Merge branch 'rnmobile/feature/global-styles-base' into rnmobile/feat…
Apr 13, 2021
007e862
Mobile - Set background, title, text and link colors
Apr 13, 2021
6561363
Fix gradients
Apr 13, 2021
69881e5
Merge branch 'rnmobile/feature/global-styles-base' into rnmobile/feat…
Apr 13, 2021
ac1ac60
Add placeholder color
Apr 20, 2021
6e67b40
Add support to block styles
Apr 20, 2021
0fc97af
Add reset button in color picker
Apr 20, 2021
e0af895
Fix placeholder colors
Apr 20, 2021
1b74f6c
Fix paddings and remove Columns placeholder solid background
Apr 20, 2021
05ed7b6
Don't reset paddings for inner blocks that have paddings already
Apr 20, 2021
5417603
Mobile - Block styles support
Apr 26, 2021
d38dc7e
Add fallback text color to blocks
Apr 26, 2021
7102a51
Adds new Prop for Global Styles Settings
antonis Apr 6, 2021
906a9f6
Rename updateTheme to be more generic for update settings include GSS…
chipsnyder May 6, 2021
226780b
Fix wrong naming of subscribeUpdateEditorSettings
May 7, 2021
8ad3a37
Update Gutenberg demo
May 7, 2021
0132134
Updates new props to rawStyles and rawFeatures
antonis May 13, 2021
0f4fffc
Merge branch 'trunk' into rnmobile/3163-GSS
chipsnyder May 14, 2021
bf75be1
Update iOS Bridge for new values
chipsnyder May 14, 2021
aeaf65f
Mobile - Global styles: Pass settings and set color palette and gradi…
May 18, 2021
ee936cb
Merge branch 'trunk' into rnmobile/3163-GSS
May 21, 2021
4058908
Merge branch 'trunk' into rnmobile/3163-GSS
antonis May 26, 2021
32a2b3a
Removes Android rawFeatures prop
antonis May 27, 2021
9741f39
Mobile - Remove usage of rawFeatures
May 27, 2021
9a404b4
Remove rawFeatures
chipsnyder May 27, 2021
792ab77
Adds raw Styles in React Native Bridge
antonis May 28, 2021
954d337
Mobile - Pass rawStyles on initial props and fix colors and gradients
May 28, 2021
eae36b0
Merge branch 'rnmobile/3163-GSS' of github.com:WordPress/gutenberg in…
May 28, 2021
d2ba74f
Merge remote-tracking branch 'origin/trunk' into rnmobile/3163-GSS
chipsnyder Jun 16, 2021
2e12d2c
Add Raw Features back
chipsnyder Jun 16, 2021
1bbda52
Revert "Removes Android rawFeatures prop"
antonis Jun 17, 2021
1f34a27
Add rawFeatures in the mobile editor
Jun 17, 2021
3d780d3
Mobile - Global styles: Set theme's background and text color (#30810)
Jun 18, 2021
4ddbe5c
Merge branch 'rnmobile/3163-GSS' into rnmobile/feature/global-styles-…
Jun 18, 2021
853acac
Remove old usage of useEditorFeature
Jun 18, 2021
0548227
Remove old mock data
Jun 18, 2021
f8e2fa7
Merge branch 'trunk' into rnmobile/3163-GSS
Jun 22, 2021
e7f32bc
Merge branch 'rnmobile/3163-GSS' into rnmobile/feature/global-styles-…
Jun 22, 2021
0b9b34b
Add support for block styles of the Verse block in mobile
Jun 22, 2021
a0e9a1d
Merge branch 'trunk' into rnmobile/3163-GSS
antonis Jun 23, 2021
0e9e6c2
Merge branch 'rnmobile/3163-GSS' into rnmobile/feature/global-styles-…
Jun 24, 2021
e625af8
Merge with trunk
Jun 29, 2021
7b15beb
Merge branch 'trunk' into rnmobile/feature/global-styles-block-styles
Jul 1, 2021
bb32cd8
Merge branch 'trunk' into rnmobile/feature/global-styles-block-styles
Jul 6, 2021
ed6e9d2
Rename mergedStyle to style
Jul 6, 2021
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 @@ -68,33 +68,27 @@ export function getBlockColors( blockStyleAttributes, defaultColors ) {
}

// To-do add tests
export function parseGradientsColorVariables( colorPalette, gradients ) {
export function parseColorVariables( styles, colorPalette ) {
const stylesBase = JSON.stringify( styles );
const colorPrefixRegex = /var\(--wp--preset--color--(.*?)\)/g;
Object.keys( gradients ).forEach( ( key ) => {
const value = gradients[ key ]?.gradient;
const colorValue = value?.replace( colorPrefixRegex, ( _$1, $2 ) => {
const mappedColor = find( colorPalette, {
slug: $2,
} );
return mappedColor?.color;
} );
gradients[ key ].gradient = colorValue;
} );

return gradients;
return stylesBase
? JSON.parse(
stylesBase?.replace( colorPrefixRegex, ( _$1, $2 ) => {
const mappedColor = find( colorPalette, {
slug: $2,
} );
return mappedColor?.color;
} )
)
: styles;
}

export function getGlobalStyles( baseStyles ) {
const globalStyles = {
...baseStyles,
};
const colorSettings = globalStyles?.settings?.color;
const colorSettings = baseStyles?.settings?.color;
const palette = colorSettings?.palette;
const gradients = colorSettings?.gradients;

if ( gradients ) {
parseGradientsColorVariables( palette, gradients );
}
const globalStyles = parseColorVariables( baseStyles, palette );

return {
...( palette || gradients
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default {
elements: {
link: {
color: {
text: 'green',
text: 'var(--wp--preset--color--dark-gray)',
},
},
},
Expand Down