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

Add PHP API for registering custom gradient presents #17774

Closed
spacedmonkey opened this issue Oct 4, 2019 · 5 comments · Fixed by #17841
Closed

Add PHP API for registering custom gradient presents #17774

spacedmonkey opened this issue Oct 4, 2019 · 5 comments · Fixed by #17841
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Package] Block editor /packages/block-editor [Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.

Comments

@spacedmonkey
Copy link
Member

As originally discussed in #17169 (comment) and with work continue #17603 .

In #17169 gradient presents were added to buttons. This function similar to the present colors already found in gutenberg. The present colours allow for register of list of colours in PHP using theme supports. Example.

add_theme_support( 'editor-color-palette',
			array(
				array(
					'name'  => __( 'Primary', 'twentynineteen' ),
					'slug'  => 'primary',
					'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 33 ),
				),
				array(
					'name'  => __( 'Secondary', 'twentynineteen' ),
					'slug'  => 'secondary',
					'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 23 ),
				),
				array(
					'name'  => __( 'Dark Gray', 'twentynineteen' ),
					'slug'  => 'dark-gray',
					'color' => '#111',
				),
				array(
					'name'  => __( 'Light Gray', 'twentynineteen' ),
					'slug'  => 'light-gray',
					'color' => '#767676',
				),
				array(
					'name'  => __( 'White', 'twentynineteen' ),
					'slug'  => 'white',
					'color' => '#FFF',
				),
			)
);

A similar api should be added for gradient presents. I would recommend the name editor-gradient-presets.

@spacedmonkey
Copy link
Member Author

I have a WIP PR #17841

While working on this PR, I am starting to believe that another theme_supports should be added called disableCustomGradients to bring it inline with colors.

@swissspidy swissspidy added [Package] Block editor /packages/block-editor [Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement. [Feature] Themes Questions or issues with incorporating or styling blocks in a theme. labels Oct 8, 2019
@spacedmonkey
Copy link
Member Author

I think we should add add_theme_support('disable-gradient-presets'). See #18213

@bbertucc
Copy link

bbertucc commented Nov 7, 2019

@spacedmonkey - I'm working on a site now with brand guidelines that specifically discourage using gradients, so yes- would love add_theme_support('disable-gradient-presets')

@spacedmonkey
Copy link
Member Author

@bbertucc
Copy link

bbertucc commented Nov 8, 2019

Thanks @spacedmonkey - That's an awesome experimental fix. Should I be worried about the __experimental part of the variable? Once its mature, will there be a fallback, or should I just keep tabs on #18213 for updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Themes Questions or issues with incorporating or styling blocks in a theme. [Package] Block editor /packages/block-editor [Package] Components /packages/components [Status] In Progress Tracking issues with work in progress [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants