-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Global Styles: Move Randomize colors
button to Edit Palette panel
#70128
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
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
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.
d6355f1
to
69a283b
Compare
Hey @t-hamano, Thanks for the review. I have adjusted the button as suggested. Please let me know if it looks good to you whenever you have time. |
@himanshupathak95 Thanks for the update! Sorry, my explanation was insufficient. When defining styles, it's important to note the following:
I think you can achieve this without using CSS using the following approach: Detailsdiff --git a/packages/edit-site/src/components/global-styles/color-palette-panel.js b/packages/edit-site/src/components/global-styles/color-palette-panel.js
index 5aa45c7ca2..17750bf9d6 100644
--- a/packages/edit-site/src/components/global-styles/color-palette-panel.js
+++ b/packages/edit-site/src/components/global-styles/color-palette-panel.js
@@ -59,41 +59,43 @@ export default function ColorPalettePanel( { name } ) {
className="edit-site-global-styles-color-palette-panel"
spacing={ 8 }
>
- { !! themeColors && !! themeColors.length && (
- <PaletteEdit
- canReset={ themeColors !== baseThemeColors }
- canOnlyChangeValues
- colors={ themeColors }
- onChange={ setThemeColors }
- paletteLabel={ __( 'Theme' ) }
- paletteLabelHeadingLevel={ 3 }
- popoverProps={ popoverProps }
- />
- ) }
- { !! defaultColors &&
- !! defaultColors.length &&
- !! defaultPaletteEnabled && (
+ <VStack spacing={ 4 }>
+ { !! themeColors && !! themeColors.length && (
<PaletteEdit
- canReset={ defaultColors !== baseDefaultColors }
+ canReset={ themeColors !== baseThemeColors }
canOnlyChangeValues
- colors={ defaultColors }
- onChange={ setDefaultColors }
- paletteLabel={ __( 'Default' ) }
+ colors={ themeColors }
+ onChange={ setThemeColors }
+ paletteLabel={ __( 'Theme' ) }
paletteLabelHeadingLevel={ 3 }
popoverProps={ popoverProps }
+ __next40pxDefaultSize
+ variant="secondary"
+ icon={ shuffle }
+ onClick={ randomizeThemeColors }
+ >
+ { __( 'Randomize colors' ) }
+ </Button>
+ ) }
+ </VStack>
<PaletteEdit
colors={ customColors }
onChange={ setCustomColors }
diff --git a/packages/edit-site/src/components/global-styles/style.scss b/packages/edit-site/src/components/global-styles/style.scss
index ac98e6f2f7..bd6b0dec5d 100644
--- a/packages/edit-site/src/components/global-styles/style.scss
+++ b/packages/edit-site/src/components/global-styles/style.scss
@@ -259,10 +259,3 @@
border-radius: $radius-small;
}
}
-
-.edit-site-global-styles-color-palette-panel {
- // Reduce spacing between Color palette and Randomize colors button
- .components-button.is-secondary.has-icon.has-text {
- margin-top: -16px;
- }
-} In other words, all we need to do is wrap the color palette and the randomize button in a |
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.
LGTM!
Just found out that the
Gradient
panel is getting squashed in the Twenty Twenty-Five theme because of the newly occupied vertical space -
Do you mind submitting a new issue regarding the problem above?
Thanks @t-hamano for the review. I will soon open an issue for that problem. |
…ordPress#70128) * Global Styles: Move 'Randomize colors' button to Edit Palette panel * Global Styles: Reduce spacing between Custom palette and Randomize colors button to `16px` * Remove custom styles added * Wrap the Theme colors palette and randomize colors button in VStack Co-authored-by: himanshupathak95 <abcd95@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org> Co-authored-by: richtabor <richtabor@git.wordpress.org> Co-authored-by: afercia <afercia@git.wordpress.org>
What?
Closes #66169
This PR relocates the
Randomize colors
button from the main color palette overview to within the 'Edit Palette' panel in the Site Editor's Global Styles.Why?
Introduced in #52315. Currently, the
Randomize colors
button is positioned outside the palette editing interface. These previews are limited to the first 5 colors, providing an incomplete view of the actual changes across the entire palette.Moving the button inside the 'Edit Palette' panel allows users to see the randomization effect applied to the entire theme color palette displayed within that panel. This offers a clearer, more accurate, and more useful user experience for this feature.
Testing Instructions
Screenshots or screencast