Page MenuHomePhabricator

[web] introduce AppThemeWrapper
ClosedPublic

Authored by ginsu on Oct 24 2023, 12:12 PM.
Tags
None
Referenced Files
F2202420: D9580.diff
Sat, Jul 6, 7:27 AM
Unknown Object (File)
Thu, Jul 4, 6:38 PM
Unknown Object (File)
Wed, Jul 3, 5:19 AM
Unknown Object (File)
Tue, Jul 2, 1:58 AM
Unknown Object (File)
Thu, Jun 27, 1:04 PM
Unknown Object (File)
Fri, Jun 14, 2:58 AM
Unknown Object (File)
Wed, Jun 12, 10:41 AM
Unknown Object (File)
Mon, Jun 10, 7:27 PM

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