Repository navigation
feat: add system style - #48757
feat: add system style#48757Sboonny wants to merge 40 commits into
Conversation
|
👀 Review this PR in a CodeSee Review Map |
|
Thanks for putting together this pull request. |
We are using a system, that stops respecting the preferred camper color scheme when they are logged in (although improvement from previous system, it still an issue and bad UX). To respect the camper choices, I had to add variables that change based on the camper system, but stop applying when the Camper changes to dark or light mode. That's caused the creation of After creating the system variables, I need a way to make campers opt in the system (like setting the theme value to
Maybe I have no idea, I have to look into this after I am done refactor the theme and introducing a system button. Edit: BTW, I have no idea how big this will be or how to make it cleaner yet. |
|
Just to make sure I understand the objective. This PR should allow the user to switch between three theme states: light, dark and system settings? |
|
yeab, no local storage stuff and no changing theme while logged out |
|
Reading through the original discussion, I thought the consensus was to move away from storing this in the database in favour of local storage. Before anything is implemented, there needs to be a clear goal.
Finally, irrespective of what we chose, there are only two palettes (dark and light), so we don't need more variables. |
We have discussed this in issue triage, and Naomi put valid points about storing it in the database, so it gets carried between devices. if someone prefer dark mode and pick dark mode once, they don't have to pick dark mode in every device that camper use. I am in favor of local storage as I use multiple devices at different times of day at different environment, so I want the system to be respected always, but the issue triage meeting ended with keeping the database as is. |
Do you guys know something, I don't? well of course you do, but that not what I mean. I have actually no idea how to do |
#48568 already had that behaviour for logged out users. That can be reused. Anyways, all I was trying to say is that we need to be clear about what we actually want before writing code. If there was a consensus reached in the meeting, that's great, but it doesn't seem to have been documented. From memory, Mrugesh proposed something similar to GitHub's approach i.e. have three settings
By default (and when the user is logged out) we want 1. Otherwise we want whatever the user chooses via the settings or menu. That seems fine to me, and builds on #47299 (comment) but I'm curious what @raisedadead, @ahmadabdolsaheb and @naomi-lgbt think. |
|
Whatever Oliver said is accurate and should be the flow. In addition, and only for signed-in users, the theme value should be stored/replicated in their DB record and local storage. Any theme change in the settings should happen in this order: User changes setting --> Update DB --> Update the Local Storage. The CSS should then use the local storage value as the source of truth for the signed-in user. This will avoid any "flash" of theme change during page navigation and reloads because the CSS would avoid reading the DB values directly. For non-signed-in users, all the above can go down the drain, and only a simple preference hierarchy can be followed (assuming we let them do this in the menu or something):
Which can get dropped in the local storage (preferably a different key than the signed-in user) for revisits and reloads etc. In both cases the CSS should always check the local storage for it's rendering. |
|
Thanks for clarifying the spec @raisedadead. That seems solid. |
|
@Sboonny This is getting very close. Just a few things that need to be addressed.
Also, I'm not sure the |
Co-authored-by: Bruce B <[email protected]>
|
Blocked until #48974 is in. Also, per #48974 (comment), we want to add tests to make sure that the editor's theme is in sync with the rest of the site. |
|
@Sboonny Concerning Ideally, we would do testing with screen reader users to determine whether If I had to pick, I would choose to remove
But really, without testing we can't know for sure which would be preferred (and there is a possibility that testing could give us ambiguous results). So if we want to leave |
|
I haven't abandoned this, there is too much part that require changes and I am planning to open issues gradually that reduce the needs for that much change. |

Checklist:
Update index.md)mainbranch of freeCodeCamp.Ref #47299
This aims to add the ability to opt in default system mode. by allowing the theme to be null, so it will move to system.
This won't close the issue, because I know at least, that I won't create the local storage logic in the PR.