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

Refactor out CSS gradient from custom-gradient-bar #27936

Merged
merged 19 commits into from
Jan 14, 2021

Conversation

ajlende
Copy link
Contributor

@ajlende ajlende commented Dec 30, 2020

Description

While working on #26361 I wanted to reuse components from the gradient picker so they can share the same style and markup.

The old gradient bar worked directly with a CSS gradient string. This refactoring introduces an intermediate color-stop array to be used in the CustomGradientBar instead of that string. Then, at the CustomGradientPicker level, the color-stop array can finally be converted back to the gradient string. This means that the gradientAST doesn't need to be passed all the way down too. The logic remains fairly similar otherwise—I didn't want to make this a complete rewrite.

How has this been tested?

  • Add control points (and update the color at the same time)
  • Remove control points
  • Update control points
  • Select gradient presets on web and mobile

Screenshots

No visual changes made. Markup generated should be identical.

Types of changes

Bug fix

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@ajlende ajlende added [Type] Code Quality Issues or PRs that relate to code quality [Package] Components /packages/components labels Dec 30, 2020
@mkaz
Copy link
Member

mkaz commented Jan 13, 2021

I got an error when trying out this PR, when clicking a preset gradient.
See attached screencast:

gradient-error

@ajlende
Copy link
Contributor Author

ajlende commented Jan 13, 2021

@mkaz Thanks for the catch! The theme I was using only provided colors as rgb so I didn't see it. All cases should be covered now.

Copy link
Member

@mkaz mkaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated changes tested well, thanks for the quick fix.
Looks good 👍

@ajlende ajlende merged commit a20e005 into WordPress:master Jan 14, 2021
@ajlende ajlende deleted the fix/refactor-gradient-bar branch January 14, 2021 21:55
@github-actions github-actions bot added this to the Gutenberg 9.9 milestone Jan 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants