Skip to content

Commit 37125e2

Browse files
authored
refactor: simplify background handling (#38913)
## **Description** Simplify handling of dark/light theme background using the light-dark function Also fixes #38827 where the document needs to match the main container background [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/38913?quickstart=1) ## **Changelog** <!-- If this PR is not End-User-Facing and should not show up in the CHANGELOG, you can choose to either: 1. Write `CHANGELOG entry: null` 2. Label with `no-changelog` If this PR is End-User-Facing, please write a short User-Facing description in the past tense like: `CHANGELOG entry: Added a new tab for users to see their NFTs` `CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker` (This helps the Release Engineer do their job more quickly and accurately) --> CHANGELOG entry: null ## **Related issues** Fixes: #38827 ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <!-- [screenshots/recordings] --> ### **After** <!-- [screenshots/recordings] --> ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Simplifies global dark/light theming by using CSS light-dark and consolidating document/background color handling in `ui/css/base-styles.scss`. > > - **Global CSS/Theming** (`ui/css/base-styles.scss`): > - Use `color-scheme: dark light` and `light-dark(...)` in `:root` to set default text and background colors. > - Replace complex `prefers-color-scheme` and non-`data-theme` conditionals with a single `html[data-theme]` rule for theme overrides. > - Remove background styling coupling from `#app-content` so the document and main container backgrounds align. > - Keep base element resets; no structural layout changes beyond background/color handling. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit de2fc83. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent c306c13 commit 37125e2

File tree

1 file changed

+7
-27
lines changed

1 file changed

+7
-27
lines changed

ui/css/base-styles.scss

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
--width-max: 798px;
1010
--width-max-sidepanel: 490px;
1111
--header-height: 68px;
12+
13+
color-scheme: dark light;
14+
color: light-dark(var(--brand-colors-grey-grey1000), var(--brand-colors-grey-grey050));
15+
background-color: light-dark(var(--brand-colors-grey-grey050), var(--brand-colors-grey-grey1000));
1216
}
1317

1418
html,
1519
body {
16-
color: var(--color-text-default);
1720
width: 100%;
1821
height: 100%;
1922
margin: 0;
@@ -25,28 +28,9 @@ body {
2528
text-rendering: optimizeLegibility;
2629
}
2730

28-
html {
29-
@include design-system.screen-sm-max {
30-
&:not([data-theme]) {
31-
background-color: var(--color-background-default);
32-
}
33-
}
34-
35-
/*
36-
Until we get the user's preference from React state,
37-
assume the user is in dark mode, because the default
38-
theme is system preference
39-
*/
40-
@media (prefers-color-scheme: dark) {
41-
&:not([data-theme]) {
42-
color: var(--brand-colors-white);
43-
background-color: var(--brand-colors-grey-grey900);
44-
45-
body {
46-
color: var(--brand-colors-white);
47-
}
48-
}
49-
}
31+
html[data-theme] {
32+
color: var(--color-text-default);
33+
background-color: var(--color-background-alternative);
5034
}
5135

5236
/* stylelint-disable */
@@ -55,10 +39,6 @@ html {
5539
height: 100%;
5640
display: flex;
5741
flex-direction: column;
58-
59-
html[data-theme] & {
60-
background: var(--color-background-alternative);
61-
}
6242
}
6343
/* stylelint-enable */
6444

0 commit comments

Comments
 (0)