Page MenuHomePhabricator

[web] introduce AppThemeWrapper
ClosedPublic

Authored by ginsu on Oct 24 2023, 12:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 20, 2:09 AM
Unknown Object (File)
Sat, Nov 16, 8:58 AM
Unknown Object (File)
Wed, Nov 13, 1:23 PM
Unknown Object (File)
Wed, Nov 13, 1:23 PM
Unknown Object (File)
Wed, Nov 13, 1:23 PM
Unknown Object (File)
Wed, Nov 13, 1:23 PM
Unknown Object (File)
Wed, Nov 13, 1:20 PM
Unknown Object (File)
Oct 12 2024, 7:56 AM

Details

Summary

This diff introduces a new component that wraps the contents of the App component, and the job of this component is to update the data attribute based on what the activeTheme of the app is. The subsequent diff will introduce the css variable list that will use this data attribute to show dark or light mode color values

Sources I used to help me with this implementation:
https://css-tricks.com/easy-dark-mode-and-multiple-color-themes-in-react/
https://stackoverflow.com/questions/56300132/how-to-override-css-prefers-color-scheme-setting

Test Plan

Please see the demo video below where the theme of the app changes based on the activeTheme redux state

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

ginsu edited the test plan for this revision. (Show Details)
ginsu added reviewers: atul, inka, rohan.
ginsu edited the test plan for this revision. (Show Details)
web/style.css
49 ↗(On Diff #32352)

We need to add this here to prevent this from happening:

Screenshot 2023-10-24 at 3.30.23 PM.png (2×3 px, 719 KB)

atul added a subscriber: ted.

Looks good, small question inline about defaulting to light

web/app-theme-wrapper.react.js
16 ↗(On Diff #32352)

Does this mean we're defaulting to light mode? Personally prefer light mode, but figure we'd be defaulting to dark mode?

CC @ashoat, @ted

This revision is now accepted and ready to land.Oct 24 2023, 3:20 PM
web/app-theme-wrapper.react.js
16 ↗(On Diff #32352)

probably something I should have called out... but on native we default to light mode as well if activeTheme is not defined.

https://github.com/CommE2E/comm/blob/master/native/themes/colors.js#L254

Kept it the same here to be consistent across both platforms, but happy to change this if we think this is not the best option

ginsu edited the summary of this revision. (Show Details)

rebase before landing

This revision was automatically updated to reflect the committed changes.

We definitely should not be defaulting to a half-baked light mode implementation, but I assume this has been considered

probably something I should have called out... but on native we default to light mode as well if activeTheme is not defined.

https://github.com/CommE2E/comm/blob/master/native/themes/colors.js#L254

Kept it the same here to be consistent across both platforms, but happy to change this if we think this is not the best option

While this is true, defaultGlobalThemeInfo defaults to dark mode, which means the app defaults to dark mode. I assume we're doing the same on web?

While this is true, defaultGlobalThemeInfo defaults to dark mode, which means the app defaults to dark mode. I assume we're doing the same on web?

Yes that is correct https://github.com/CommE2E/comm/blob/master/lib/types/theme-types.js#L12-L19