-
Notifications
You must be signed in to change notification settings - Fork 179
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
Editor: Add support for applying gradient to text #13590
Conversation
… `handleSetColor` on changing the color
Generate and apply textColor styles to `FillElement`
…m/GoogleForCreators/web-stories-wp into feat/12143-apply-gradient-to-text
Hi @swissspidy I have currently used regex to convert the CSS property of a gradient color to the The web-stories-wp/packages/patterns/src/getColorFromGradientStyle.ts Lines 63 to 91 in 5a6aa48
This function is then used in the web-stories-wp/packages/rich-text/src/formatters/gradientColor.ts Lines 41 to 42 in 5a6aa48
I was wondering if there is a more intuitive way to do the parsing, instead of using regex? Thanks! |
Great question! Agreed that it would be good to find a more intuitive solution if possible, especially given the CodeQL warning above for one of the regex. At first glance it looks like third-party packages such as https://www.npmjs.com/package/webskit-gradient-parser or https://www.npmjs.com/package/gradient-parser could be used for this. In my quick testing only the former seemed to be able to parse the Both haven't been updated in a while, but since our use case is limited to just linear & radial gradients, it might be good enough for us. Question is whether such a package will significantly increase our bundle size or not. |
Size Change: +1 kB (0%) Total Size: 2.77 MB
ℹ️ View Unchanged
|
Plugin builds for 413b47d are ready 🛎️!
|
@Swanand01 I take it there was no suitable existing package for parsing gradients so we keep the regex? |
Yes, I tried both packages, but they weren't reliable enough, especially while parsing radial gradients. |
…m/GoogleForCreators/web-stories-wp into feat/12143-apply-gradient-to-text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be working well! 🎉 🚀
Let's see how the users like it :)
Summary
This PR adds support for applying gradient colors to text.
User-facing changes
The user can now select gradient based colors from the color picker in the
Text
style panel.text-gradient-updated.mov
Testing Instructions
This PR can be tested by following these steps:
Style
panelText
section🐛 Bugs
The color does not update on selecting a default color for a pre-existing text element.The editor crashes on changing the color of a part of text.🚧 WIP
Add similar support to color picker in Design options toolbarRender output with text color.Reviews
Does this PR have a security-related impact?
No.
Does this PR change what data or activity we track or use?
No.
Does this PR have a legal-related impact?
No.
Checklist
Type: XYZ
label to the PRFixes #12143