-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 custom gradient component #17603
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d62b902
Post rebases fixes (+6 squashed commits)
jorgefilipecosta 4a51675
Refactor to state based
jorgefilipecosta 09a6ceb
Add tests to the gradient serializer
jorgefilipecosta c6d2ae7
Update packages/components/src/custom-gradient-picker/control-points.js
jorgefilipecosta e6e40ed
Update packages/components/src/custom-gradient-picker/control-points.js
jorgefilipecosta 7c6c5c0
Clean up listeners on unmout
jorgefilipecosta dbb5f8b
Revert include custom gradient picker on gradient picker component
jorgefilipecosta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
packages/block-editor/src/components/color-palette/control.scss
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 0 additions & 4 deletions
4
packages/block-editor/src/components/gradient-picker/control.scss
This file was deleted.
Oops, something went wrong.
18 changes: 14 additions & 4 deletions
18
packages/block-editor/src/components/gradient-picker/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
packages/components/src/custom-gradient-picker/constants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const INSERT_POINT_WIDTH = 23; | ||
export const GRADIENT_MARKERS_WIDTH = 18; | ||
export const MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_MARKER = ( INSERT_POINT_WIDTH + GRADIENT_MARKERS_WIDTH ) / 2; | ||
export const MINIMUM_ABSOLUTE_LEFT_POSITION = 5; | ||
export const MINIMUM_DISTANCE_BETWEEN_POINTS = 9; | ||
export const MINIMUM_SIGNIFICANT_MOVE = 5; | ||
export const DEFAULT_GRADIENT = 'linear-gradient(135deg, rgba(6, 147, 227, 1) 0%, rgb(155, 81, 224) 100%)'; | ||
export const COLOR_POPOVER_PROPS = { | ||
className: 'components-custom-gradient-picker__color-picker-popover', | ||
position: 'top', | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't this be an or not an and
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.
It is supposed to be an "and". Users can not choose a gradient if there are no presets and they can not use the custom gradient picker. If there are presets, or custom gradients are enabled the component should render something.
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.
I think that
disableCustomGradient
is set, then it should ignore defined gradients. ATMdisableCustomColors
has to set to true and the list of gradients has to be empty.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.
Sorry, I'm not managing the clarify this logic. If there are gradients available, the gradient picker should render even if custom gradients are disabled to allow the user to choose a preset gradient. If disableCustomGradients is false, the gradient picker should render even if the gradients list is empty to allow the user to create a custom gradient.
The only case where the gradient picker should not render is if the gradients list is empty and custom gradients are disabled because, in that case, the user cannot select a preset gradient or create a custom gradient.