-
Notifications
You must be signed in to change notification settings - Fork 215
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
Dark Mode Frontend Implementation Plan #3963
Conversation
Full-stack documentation: https://docs.openverse.org/_preview/3963 Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again. You can check the GitHub pages deployment action list to see the current status of the deployments. New files ➕: |
Do you have a deadline in mind for this document @zackkrida? If helpful, I found the following Figma documentation/post that could ease moving the design to frontend. |
@fcoveram I'm going to finish this today. I will look at these resources. Thanks! |
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
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.
Looking great so far! I think there are some potential complications with the selector that need to be ironed out, and some other minor clarifications. I don't anticipate any blockers during the decision phase.
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Show resolved
Hide resolved
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
Here are pretend, simplified examples of this setup. | ||
|
||
In our primary CSS file, we setup two lists of CSS variables with different | ||
values when the `.dark-mode` class is present: |
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.
To make Tailwind respect this for the dark:
prefix, we'll need to update the config for manual toggling, right? https://tailwindcss.com/docs/dark-mode#toggling-dark-mode-manually
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 totally forgot to document this, yes. I'll update, and make sure the documentation is clear that this is only relevant for the "escape hatch" of dark:
and not the core color changing mechanism.
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Show resolved
Hide resolved
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
@sarayourfriend and @obulat any objection to me drafting the PR and moving on to the following updates?
|
Yes, sounds good to me. |
@obulat and @sarayourfriend this proposal has been updated, and is ready for final review in the Decision round. |
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.
LGTM!
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Show resolved
Hide resolved
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Show resolved
Hide resolved
2. Update our Cloudflare static page caching rule for the frontend in with | ||
a Cookie bypass rule (in pseudocode, something like `and not | ||
http.cookie contains "openverse_color_scheme")) |
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 wish there were a way to cache each colour scheme, rather than bypassing all caching entirely. I think Cloudflare actually might support something like this with custom cache keys, but those are only for Cloudflare enterprise customers: https://developers.cloudflare.com/cache/how-to/cache-keys/#availability
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.
Would this make all of the users who select the dark mode bypass cache?
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.
@obulat yes, it would, but crucially only on the pages which are being cached: the homepage and all static pages. Also, due to SPA routing these, static pages are only served from the cache on the user's initial page load. Therefore, cached homepage and static page visits mark an overall small percentage of Openverse traffic.
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.
Just wanted to add more 'flavour' to the issue, but even if we were worried about the caching issue, we could solve it by caching and segmenting the cache at the nginx level (or replace it with varnish, something more suitable for complex caching rules). We'd already be doing that if we moved those routes "statically" out of the app or cached them at all, and we could segment on as many relevant cookies as needed (hopefully not too many!).
Just say, there are solutions to this if it ever became a problem.
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
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.
LGTM!
Thank you for mentioning the cache rules, too.
documentation/projects/proposals/dark_mode/20240325-implementation_plan_dark_mode.md
Outdated
Show resolved
Hide resolved
2. Update our Cloudflare static page caching rule for the frontend in with | ||
a Cookie bypass rule (in pseudocode, something like `and not | ||
http.cookie contains "openverse_color_scheme")) |
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.
Would this make all of the users who select the dark mode bypass cache?
Co-authored-by: Olga Bulat <[email protected]> Co-authored-by: sarayourfriend <[email protected]>
Fixes
Fixes #3958 by @zackkrida
Description
This is an implementation plan for adding a dark mode to the Openverse frontend as part of the #3592 project.
I have chosen @obulat and @sarayourfriend as reviewers for their expertise in implementing frontend features, TypeScript generally, and familiarity with the testing-related code in the frontend.
Testing Instructions
Please read the IP using the decision-making process described below.
Decision-making process
This discussion is following the Openverse decision-making process. Information about this process can be found on the Openverse documentation site. Requested reviewers or participants will be following this process. If you are being asked to give input on a specific detail, you do not need to familiarise yourself with the process and follow it.
Current round
This discussion is currently in the Decision round. The deadline for this round is Friday, May 3rd.
Checklist
Update index.md
).main
) or a parent feature branch.Developer Certificate of Origin
Developer Certificate of Origin