-
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
Color Schemes: Add color schemes via CSS custom properties #17366
Color Schemes: Add color schemes via CSS custom properties #17366
Conversation
Referencing issues #457, #16699 & https://github.com/Automattic/wp-desktop/issues/320 for the sake of continuity. |
"browsers": "last 2 versions, > 1%, Safari >= 8, iOS >= 8, Firefox ESR, Opera 12.1" | ||
}, | ||
"postcss-custom-properties": { | ||
"preserve": "true", |
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.
Can we add a comment regarding the need of preserve
?
Excellent. Can we add a short version of that explanation to the file comments – so people are aware in the future that we are walking around that edge? :) |
@@ -166,14 +167,15 @@ | |||
"preanalyze-bundles": "cross-env WEBPACK_OUTPUT_JSON=1 CALYPSO_ENV=production NODE_ARGS=\"--max_old_space_size=8192\" npm run -s build", | |||
"analyze-bundles": "webpack-bundle-analyzer stats.json public -p 9898", | |||
"autoprefixer": "postcss -r --use autoprefixer --autoprefixer.browsers \"last 2 versions, > 1%, Safari >= 8, iOS >= 8, Firefox ESR, Opera 12.1\"", |
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.
Do we need this now?
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 left it in there in case one of the CSS steps e.g. editor wants to back out of using any further postcss plugins apart from autoprefixer. So it's more left as an option, it's not a necessity for the current build. Want me to remove it? :)
@@ -106,6 +106,7 @@ | |||
"phone": "git+https://github.com/Automattic/node-phone.git#1.0.8", | |||
"photon": "2.0.0", | |||
"postcss-cli": "2.5.1", | |||
"postcss-custom-properties": "6.1.0", |
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 we need to regen shrinkwrap here? npm run update-deps
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.
Done and pushed 👌
I'm wondering though if npm run update-deps
hasn't been run in a while. It updated quite a bit more than just the postcss-custom-properties
:
https://github.com/Automattic/wp-calypso/pull/17366/files#diff-36018a6a9e1de1798516799b84841318
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.
Looks like the initial install with --save
should've updated the shrinkwrap. I'm going to investigate why that did not happen in this 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.
OK, I reverted back to a state prior to this PR and ran npm install --save
for postcss-custom-properties
again. This time it triggered the shrinkwrap update automagically like it should as per the docs. Not sure why that didn't happen the first time around, wondering if it has to do with me editing the css build steps in the package.json at the same time.
Either way this time it only added the dependencies it actually should. So I decided to do an interactive rebase, delete the old shrinkwrap commit and add the new one. Issue should be resolved now 👍
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.
Awesome work - this looks much more reasonable, thanks for looking in to this! :)
7556e32
to
45b0b4d
Compare
Hey, @kwight 👋 Thanks for letting me know 👍 |
93b569d
to
3d195d3
Compare
@frontdevde This PR needs a rebase |
Commenting for continuity: The issue where the selection couldn't be persisted was solved in one of the preceding PRs. Once those are merged into master, this one will be pointed at master so we can confirm the fix is working. |
Closing this PR in favor of newer PRs (see references above). |
This PR is part of a series of PRs aiming to provide support for Color Schemes in Calypso.
This PR focuses on adding color scheme support via CSS custom properties.
General
Notable additions in this PR:
postcss-custom-properties
to the postcss build stepautoprefixer
andpostcss-custom-properties
are combined in a dedicatedpostcss.config.json
config file in the project rootstylesheets/shared/_color-schemes.scss
that contains the color schemesdark
andlight
color scheme are added and demonstrated on the MasterbarConsiderations
For a more detailed description of the feature, the chosen approach and its advantages feel free to check out my post on the subject:
p4TIVU-75d-p2
(internal reference).Hat tip to @folletto for a good idea that resulted in the solution presented here, which offers an even better developer experience than the initially suggested one. :)
How to test
Accounts Settings
page and scroll down to theAdmin Color Scheme
section.Suggestions as to what to test
Notes
This PR currently compares its changes to PR #17307. This is so the changes can be easily identified. The following PRs (in chronological order) need to be merged prior to this PR:
PR #17157:
Color Schemes: Add new form components as basis for color scheme switcher
PR #17200:
Color Schemes: Add Color Scheme Picker
PR #17259:
Color Schemes: Add Color Scheme Picker to Account Settings
PR #17307:
Color Schemes: Add selected Color Scheme to Layout
PR #17310:
Color Schemes: Add Feature Detection
This PR will be pointed at
master
once all of the above have been merged.Design Review
I'd like to use this PR to also get some design review on the visual elements introduced in this and the PRs mentioned above. I'm thus also posting some additional screenshots here of the visual elements that are being introduced by the Color Scheme PRs.
Form Components: Form Radio with Thumbnail & Form Radios Bar
devdocs/design/form-fields
– first introduced in PR #17157Using several
FormRadioWithThumbnail
components will list them vertically. For a nicer visual appearance, they can be wrapped in theFormRadiosBar
which will display them in a horizontal grid. TheFormRadiosBar
also provides a nicer developer experience for both normal and thumbnail radios as they can now be passed in as an object.Blocks: Color Scheme Picker
devdocs/blocks/color-scheme-picker
– first introduced in PR #17200This is added as a block with its potential future of becoming a per-person per-site selection in mind. That would involve adding more components like e.g. a site selector.
Note: I created the theme previews in Photoshop, that's why they are currently PNGs. I've already noted down converting them to SVG as a future todo. Or if you'd like to help with that... :)
Thanks for reading! 🚀