Skip to content

Use System Default for Initial Theme? #47299

Closed

Description

@naomi-lgbt

Describe the Issue

I had an issue with another website that was fixed by clearing my browser cache. As a result, I had to log in to all of my sites again. I ended up on Reddit which defaulted to light mode for unauthenticated users, and realised that freeCodeCamp does the same.

Affected Page

https://freecodecamp.org

Steps to Reproduce

  1. Log out.
  2. See light mode?

Expected behavior

I'm wondering if we should leverage the user's system setting to determine if we should default to light or dark mode.

Screenshots

No response

System

The only relevant thing here is that I'm on Windows, I think.

Additional context

No response

Activity

  1. added
    status: waiting triage
    on Aug 15, 2022
  2. moT01 commented on Aug 16, 2022

    @moT01
    Member

    Yes, we default to light mode.

    ... we should leverage the user's system setting ...

    I'm not against this - although, I think the bigger issue is that you can only switch the theme if you are logged in. Seems like you should be able to switch regardless. I don't recall if there was any reason that we don't allow that.

  3. added
    status: discussing
    and removed
    status: waiting triage
    on Aug 17, 2022
  4. iarmankhan commented on Aug 21, 2022

    @iarmankhan

    @moT01 Wouldn't it be more helpful to have night-mode for non-logged in user as well, and also it defaults to system's theme?

  5. ahmaxed commented on Aug 31, 2022

    @ahmaxed
    Member

    So the logic should be the followings:
    // if user has a set a preference, set the theme
    // else if system setting has a theme, set the theme,
    // else set the theme as default.

    We could set the theme in the localstorage and pull it up on the upcoming sessions.
    Reference: https://github.com/gaearon/overreacted.io/blob/master/src/html.js#L21-L48

  6. moT01 commented on Sep 21, 2022

    @moT01
    Member

    Do we want to allow non-authed users to switch to night mode using the menu? I feel like we should. If so, we may not need some of this logic (or, may need more).

  7. ahmaxed commented on Sep 23, 2022

    @ahmaxed
    Member

    I think we should allow non-auth users to switch theme.
    If users have not set a preference in the localhost and have a theme preference on their record, we could pull that data and set it accordingly if possible. Moving forward we would not want to use the user records for theme switching.

  8. added
    help wanted
    and removed
    status: discussing
    on Nov 9, 2022
  9. naomi-lgbt commented on Nov 9, 2022

    @naomi-lgbt
    MemberAuthor

    To resolve this issue in the short term:

    • If the camper has set the theme to night: We should display night mode (the current behaviour)
    • If the camper has set the theme to default: We should respect the system settings for the theme.
  10. 2 remaining items

  11. removed
    help wanted
    on Dec 14, 2022
  12. self-assigned this
    on Dec 14, 2022
  13. Sboonny commented on Dec 19, 2022

    @Sboonny
    Member

    @ahmadabdolsaheb, @ojeytonwilliams, @raisedadead. I want to bring back the discussion to the issue, and finalize the solution before the implementation.

    image

    I have a looked into different implementation, and the one from Mozilla foundation seems the most fitting to me and want to discuss it with you.

    What do you think of 3rd option for OS system? So people can have an opt-in system option, when the ability to store data hinder the camper experience, because they want to have different themes in different devices.

  14. ojeytonwilliams commented on Dec 19, 2022

    @ojeytonwilliams
    Contributor

    Sure, that sounds good.

  15. Sboonny commented on Jan 6, 2023

    @Sboonny
    Member

    @ahmadabdolsaheb, I lost the notes because of the holiday so I am not sure, we didn't want the themes to be a dropdown, but just buttons for now.

    Was that about the menu or the setting picker? I am not sure.

    image

  16. ahmaxed commented on Jan 6, 2023

    @ahmaxed
    Member

    We can keep them as buttons. Also, we could remove the theme switching from the navigation entirely.

  17. raisedadead commented on Jan 6, 2023

    @raisedadead
    Member

    My two cents:

    • They should be a drop-down on the settings page. Dropdowns make it very nice and clear of the selection and not to mention easiest to maintain (a11y and UX wise, etc.).
    • There was a very strong argument to keep the theme in the nav and was a very common request. I wonder if the toggle can be converted into a similar UX as the language selector, then we would be set.
  18. Sboonny commented on Jan 6, 2023

    @Sboonny
    Member

    They should be a drop-down on the settings page. Dropdowns make it very nice and clear of the selection and not to mention easiest to maintain (a11y and UX wise, etc.).

    We can come back to the dropdown, when we add new themes. Maybe we create a different component that display part of the page in different themes instead, like GitHub. So let's not spend our effort on this yet, while the one we're currently having something that is working. 👍

    They should be a drop-down on the settings page. Dropdowns make it very nice and clear of the selection and not to mention easiest to maintain (a11y and UX wise, etc.).

    I am worried that we will run into the issue of it being obscure, like what we have in the language selector.

  19. raisedadead commented on Jan 6, 2023

    @raisedadead
    Member

    We can come back to the dropdown, when we add new themes.

    A wise man (Quincy) once said, you should avoid introducing big changes to UI. If you have to, then delay and introduce them all at once, because you WILL get called out for doing something radical. Might as well do it fewer times.

    Point being, if you are building something that you are going to throw away (and you know it), you are doing it wrong. 🤷🏽

  20. ahmaxed commented on Jan 6, 2023

    @ahmaxed
    Member

    Themes switchers seems to be the convention in blog/documentation website navigations. As the app gets more complicated, the theme switcher gets relocated to the settings.

    The language selector is moving to the top navigation. If we rely on the settings page's theme switcher, we could remove related section from the dropdown navigation entirely. That being said, if there is a lot of demand for it, we should keep it around in the nav.

    If we keep the theme switcher in the nav, it makes sense to use a component that looks good on mobile such as a dropdown so we could reuse it in the settings page as well.

  21. Sboonny commented on Jan 26, 2023

    @Sboonny
    Member

    Based on discussion with @ojeytonwilliams:

    • it's possible to add the theme values to local storage and set the default theme of the pages based on them.
    • it's possible to have system theme if the local storage store third value
    • it's possible to clear the flash with the usage of local storage
  22. ahmaxed commented on Jan 27, 2023

    @ahmaxed
    Member

    If the logic seem convoluted, feel free to lay it down in pseudo code.
    Once everyone is in agreement, we can proceed with the implementation.

  23. removed their assignment
    on Oct 19, 2023
  24. moT01 commented on Jun 6, 2024

    @moT01
    Member

    Closing as stale. Thanks and happy coding 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions