-
Notifications
You must be signed in to change notification settings - Fork 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
Dynamically change color scheme from color_scheme query param #96557
Dynamically change color scheme from color_scheme query param #96557
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~36 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~10 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
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.
Tested well! 👍 I have some comments on the code.
client/layout/color-scheme/index.jsx
Outdated
export function getColorSchemeFromCurrentQuery( currentQuery ) { | ||
return currentQuery?.color_scheme | ||
? currentQuery?.color_scheme | ||
: new URLSearchParams( currentQuery?.redirect_to ).get( 'color_scheme' ); |
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.
If redirect_to is null, undefined, or an invalid URL, URLSearchParams will throw an error. Should we add a fallback for cases where redirect_to is not a valid URL?
client/layout/index.jsx
Outdated
let colorScheme = null; | ||
|
||
// Try to get the color scheme from `color_scheme` query param if we're in the WooCommerce Passwordless JPC flow. | ||
if ( isWooPasswordlessJPC ) { |
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.
How about using the ternary operator here to simplify the logic?
let colorScheme =
isWooPasswordlessJPC
? getColorSchemeFromCurrentQuery(currentQuery)
: getColorScheme({
state,
isGlobalSidebarVisible,
sectionName,
});
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 was tempted to use ternary at first.
When color_scheme
query param is missing for some reason, I think we should call getColorScheme
to get the user's preference instead.
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.
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.
@adrianduffell Good catch! Let's use the default color scheme in that case.
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.
@chihsuan @adrianduffell Fixed it in Return 'default' color scheme
client/layout/logged-out.jsx
Outdated
@@ -153,6 +156,10 @@ const LayoutLoggedOut = ( { | |||
|
|||
let masterbar = null; | |||
|
|||
useEffect( () => { | |||
refreshColorScheme( 'default', colorScheme ); |
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.
Should we check if isWooPasswordlessJPC
before calling the function? If it's only needed for Woo.
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.
@@ -185,7 +185,7 @@ $breakpoint-mobile: 660px; | |||
|
|||
.progress-bar__progress { | |||
border-radius: 0; | |||
background-color: var(--wp-admin-theme-color); | |||
background-color: var(--color-primary); |
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.
Nice fix!
client/layout/masterbar/woo.scss
Outdated
// Color scheme 'blue' fix | ||
// The 'blue' theme color from wp-calypso does not match the 'blue' color from the local WordPress admin color scheme. | ||
// Fix the color scheme 'blue' to match the local WordPress admin color scheme on the new JPC page. | ||
body.is-blue { |
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.
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.
@adrianduffell Good catch. I think the core profiler has incorrect color. We've been using --wp-admin-theme-color
for the button color, but it should be --color-pirmary
. I'll double check and open a PR in WC repo.
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.
Good catch. I think the core profiler has incorrect color.
I take it back 😄
Without this change, wp-calypso renders the exact same color as the core profiler.
I've removed it in Remove blue color fix change -- no longer needed
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.
Thanks @moon0326, it is testing nice and smooth! Pre-approving once the comments are resolved 🚀
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
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.
Thanks, LGTM!
* Change color theme by color_scheme query param * Use --color-primary for the primary button and the progress bar * Fix blue theme color to match the local WordPress * Apply color_scheme from query * Refresh color scheme when if it is woo passwordless JPC * Return 'default' color scheme * Remove blue color fix change -- no longer needed * Fix error with isWooPasswordlessJPC access
Related to woocommerce/woocommerce#52875
Proposed Changes
color_scheme
query parameter when the user is using the new passwordless Jetpack connectionTesting Instructions
yarn start
sunrise
color_scheme
Supported color schemes:
Pre-merge Checklist