Site logo

Archived topic

Custom colour palette

10 replies · Started by Rachel on February 16, 2021

Viewing posts 1–11 of 11

Hi,

are you implementing a custom color palette to the theme, Gutenberg and Generateblocks, too?

I am using two code snippets now but in the customiser I am missing the
a) transparency and
b) if I click inside Gutenberg to change the color of a single word of a paragraph it does change the whole sentence instead of only one word.
c) I prefer to use in posts the normal Gutenberg editor instead of Generateblocks (I use it only in pages and with the block element.

Hi there,

We're working on a global color feature in GP and GB.

What code snippets are you using, currently?

How are you adding the color? I believe you need to use the block toolbar to color individual words - not the features in the sidebar.

Hi,

Thanks Tom. Really great to hear that you are working on it.

Watched Leo’s video today with the dynamic stuff.

Really good- I love your way of thinking.

I am using code snippets and I posted the code in from one of your posts. I run it only in the Admin area.

I was trying to use the generateblocks colour selection but that didn’t work so I used the Gutenberg one that works but it would be cool to use it in generateblocks...

Thank you

Strange, it should work in GenerateBlocks, but it depends on the exact snippet. Feel free to link me to it and I'll take a look.

Thanks for the kind words! Lots of cool things on the way :)

Hi, this is the code I have put in the snippets plugin.

This for the customizer:

add_filter( 'generate_default_color_palettes', 'tu_custom_color_palettes' );
function tu_custom_color_palettes( $palettes ) {
$palettes = array(
'#666666',
'#FFFFFF',
'#000000',
'#CCABC1',
'#F2E3E3',
'#D09100',
);

return $palettes;
}

and this one

add_action( 'after_setup_theme', function() {
add_theme_support( 'editor-color-palette', array(
array(
'name' => __( 'Dove Gray' ),
'slug' => 'dove gray',
'color' => '#666666',
),
array(
'name' => __( 'White' ),
'slug' => 'white',
'color' => '#FFFFFF',
),
array(
'name' => __( 'Lily' ),
'slug' => 'lily',
'color' => '#CCABC1',
),
array(
'name' => __( 'Dawn Pink' ),
'slug' => 'Dawn Pink',
'color' => '#F2E3E3',
),
array(
'name' => __( 'Buddha Gold' ),
'slug' => 'Buddha Gold',
'color' => '#D09100',
),
array(
'name' => __( 'Strikemaster' ),
'slug' => 'Strikemaster',
'color' => '#8E6480',
),
array(
'name' => __( 'Bermuda' ),
'slug' => 'Bermuda',
'color' => '#7DBBC3',
),
) );
} );

Oh, it works to select it but it doesnt take the color - I need to go to custom color and it is selected but I need to press return - than it works.

And that makes it work on the front-end as well?

One thing I'm noticing is the capital letters/spaces in your slug values. Make sure to keep it lowercase with dashes instead of spaces. So Dawn Pink becomes dawn-pink.

Thank you I just wait when it is finished in Generateblocks and Generatepress.

Do you have a rough idea when to release it?

Thank you.

Since you're using this with a core paragraph block, it's not likely something that will be fixed in GP/GB - it should just work out of the box.

Thank you Tom

No problem!

This archived topic is closed to new replies.