-
Notifications
You must be signed in to change notification settings - Fork 593
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 Theme Support 🎨 #10391
Add Theme Support 🎨 #10391
Conversation
…d a new pxtrcdeps (pxt react common dependencies) min.js file which includes (for now) just the DOMPurify code. Then I added a reference to it in skillmap.
Awesome to see this. Ok to assign copilot to review this change (I am curious what it will do) ? |
Sure, I'll assign it |
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.
Copilot reviewed 106 out of 120 changed files in this pull request and generated 1 comment.
Files not reviewed (14)
- react-common/styles/controls/Button.less: Language not supported
- react-common/styles/controls/Card.less: Language not supported
- react-common/styles/controls/DraggableGraph.less: Language not supported
- react-common/styles/controls/Dropdown.less: Language not supported
- react-common/styles/controls/EditorToggle.less: Language not supported
- react-common/components/controls/TeachingBubble.tsx: Evaluated as low risk
- react-common/components/controls/Modal.tsx: Evaluated as low risk
- react-common/components/profile/SignInModal.tsx: Evaluated as low risk
- react-common/components/Notification.tsx: Evaluated as low risk
- pxtlib/auth.ts: Evaluated as low risk
- react-common/components/share/ShareInfo.tsx: Evaluated as low risk
- pxteditor/editorcontroller.ts: Evaluated as low risk
- pxtservices/editorDriver.ts: Evaluated as low risk
- gulpfile.js: Evaluated as low risk
Comments suppressed due to low confidence (1)
react-common/components/theming/themeManager.ts:115
- The use of DOMPurify.sanitize on the programmatically generated CSS string is unnecessary and might strip out necessary CSS rules. Consider removing this sanitization step.
css = DOMPurify.sanitize(css);
…vars were used previously, but put back all the hardcoded values.
… but the little numbers on the right aren't themed to contrast in dark theme, and I was struggling to get them working. So just hard-code for now.
This adds light, legacy, and dark themes for arcade, based on changes in microsoft/pxt#10391 It also bumps pxt-core to get those changes.
The new theming changes in pxt (microsoft/pxt#10391) removed some less variables and set others to css variables, which cannot be used in less color-manipulation functions (like lighten, darken, etc...). As a result, the build for microbit broke when referencing newer versions of pxt (or local). In this change, I fix those css build errors, add a default theme, and update themepack variables to reference new theme variables. In time, we may want to fully swap over from themepack to this, but this is a stop-gap until we're focused on micro:bit again. This isn't meant to look perfect. I mostly want to make sure everything can still build. Making it look nice is secondary, and more likely something we'll focus on when it comes time for our next micro:bit release.
Overview
This is a first pass at adding color theme support for arcade (and other targets in the future).
See the theme README.md file (
theme\color-themes\README.md
) for details on what each theme variable is for. They are loosely based on fluentUI, though of course, we have a much smaller set to deal with.Upload Target: https://arcade.makecode.com/app/8ff7826fe1b820f3793c301c11dabf0ce5bcfdc0-0927214d31
Key Areas
Most of this change is just updating colors, but here are a few spots that deserve special attention:
react-common\components\theming\themeManager.ts
- this is what handles actual theme-related operationscli\cli.ts
- this is where theme json is added to the target bundlewebapp\src\app.tsx
&pxtlib\auth.ts
-> loading / saving themesreact-common\components\theming\ThemePickerModal.tsx
& related elementsHow It Works
In short, when a user changes themes, we swap out the variable definitions and apply any override css directly on a
theme-override
style element in the document head (we create it if it does not exist). See theThemeManager
for implementation.A Few Shortcuts I Took
Additional Notes
react-common\styles\semantic-ui-overrides.less
file. I think this was still less work than removing semantic UI altogether. But it certainly isn't tidy. I didn't want to use!important
all over the place, so I've opted for using weirdly specific css selectors instead.Remaining Work (after PR)