- This topic has 20 replies, 5 voices, and was last updated 2 months ago by
Leo.
-
AuthorPosts
-
March 19, 2020 at 8:43 pm #1200123
Bodie
I love the ability to customize the GeneratePress color palette and I was wondering if there was a way to do the same with the GenerateBlocks color palette? Assuming you could do something the same as here:
add_filter( 'generate_default_color_palettes', 'tu_custom_color_palettes' ); function tu_custom_color_palettes( $palettes ) { $palettes = array( '#000000', '#FFFFFF', '#F1C40F', '#E74C3C', '#1ABC9C', '#1e72bd', '#8E44AD', '#00CC77', ); return $palettes; }
Not sure what hooks exist in GenerateBlocks yet, so thought I would check here first.
Thanks!
March 20, 2020 at 9:27 am #1200829Tom
Lead DeveloperLead DeveloperHi there,
Gutenberg itself has a way to define the colors:
add_action( 'after_setup_theme', function() { add_theme_support( 'editor-color-palette', array( array( 'name' => __( 'Blue' ), 'slug' => 'blue', 'color' => '#59BACC', ), array( 'name' => __( 'Green' ), 'slug' => 'green', 'color' => '#58AD69', ), array( 'name' => __( 'Orange' ), 'slug' => 'orange', 'color' => '#FFBC49', ), array( 'name' => __( 'Red' ), 'slug' => 'red', 'color' => '#E2574C', ), ) ); } );
Let me know if you need more info π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 20, 2020 at 10:23 am #1200880Bodie
Great! Thanks Tom for the quick response. Is there a limit to how many colors can be added?
March 20, 2020 at 4:29 pm #1201105Tom
Lead DeveloperLead DeveloperI don’t think so π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMarch 23, 2020 at 12:24 am #1207017Mark
Brilliant, exactly what i was looking for. Is there a way to disable custom color in Gutenberg. So that clients can’t pick outrageous colors, they can just choose from the color palette that i give them.
March 23, 2020 at 8:19 am #1207611Tom
Lead DeveloperLead DeveloperIn GenerateBlocks, or in general?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 1, 2020 at 3:27 am #1221872Mark
I will be using Generateblocks mainly.
April 1, 2020 at 10:04 am #1222436Tom
Lead DeveloperLead DeveloperAs of right now it’s not possible, but I’ll see what I can do π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 1, 2020 at 10:19 am #1222445Mark
Thanks Tom π
April 1, 2020 at 4:38 pm #1222854Tom
Lead DeveloperLead DeveloperNo problem, thanks for the feedback! π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentApril 23, 2020 at 11:01 am #1251895Mike
Actually, you can disable custom colors in the gutenberg palette, add this just before the other add_theme_support:
add_theme_support( 'disable-custom-colors' );
May 22, 2020 at 11:35 pm #1297565Matthias
thx all.
Was just asking myself this – and here we already got a solution π
But i am a bit confused now if those two solutions can be merged into one? So you dont have to add each color twice.
May 23, 2020 at 11:07 am #1298369Tom
Lead DeveloperLead DeveloperNot too sure what you mean – can you explain a bit more? π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentMay 23, 2020 at 3:22 pm #1298557Matthias
i mean if it is possible to combine the two code blocks – so you only need to enter the palette one time in your css – and it shows in back (gutenberg) and frontend (customizer).
not really sure where to place mikes code best also.
May 24, 2020 at 10:45 am #1299531Tom
Lead DeveloperLead DeveloperThe above code (https://generatepress.com/forums/topic/customizing-generateblocks-color-palette/#post-1200829) just makes it so the color palette options you have when using the color picker match what you’ve set. Can be useful if you’re always selecting the same colors.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.