Skip to content
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

Add the UI toggle for changing theme #4840

Merged
merged 21 commits into from
Sep 5, 2024
Merged

Add the UI toggle for changing theme #4840

merged 21 commits into from
Sep 5, 2024

Conversation

dhruvkb
Copy link
Member

@dhruvkb dhruvkb commented Aug 30, 2024

Fixes

Fixes #4309 by @zackkrida
Fixes #4155 by @fcoveram

Description

This PR

  • adds icon assets and i18n strings for theme switching
  • updates the VSelectField component to hide the active choice
  • creates the UI component for switching between color modes
    • wires the component to functionality implemented in Add color mode to ui store #4810
    • adds the UI component to the footer based on whether the "dark_mode_ui_toggle" feature flag is enabled
  • deletes the "force_dark_mode" feature flag as it is redundant
    • deletes usage and tests for the feature flag

Testing Instructions

  1. Check out the PR and run the dev server.
  2. Enable the "dark_mode_ui_toggle" feature flag. You should see the theme selector in the footer.
  3. Switch between light and dark theme. The site should update to show the your chosen color theme (regardless of the system theme). The icon in the footer should also update.
  4. Switch between the OS light and dark theme. The text for the "System" choice in the theme selector should update.
  5. Switch to the "System" theme.
  6. Switch between the OS light and dark theme. The text for the "System" choice in the theme selector should update. The actual dark/light theme should also update. The icon in the footer should also update.

Checklist

  • My pull request has a descriptive title (not a vague title likeUpdate index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.
  • I ran the DAG documentation generator (ov just catalog/generate-docs for catalog
    PRs) or the media properties generator (ov just catalog/generate-docs media-props
    for the catalog or ov just api/generate-docs for the API) where applicable.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@dhruvkb dhruvkb added the ⛔ status: blocked Blocked & therefore, not ready for work label Aug 30, 2024
@openverse-bot openverse-bot added 🧱 stack: frontend Related to the Nuxt frontend 🏷 status: label work required Needs proper labelling before it can be worked on labels Aug 30, 2024
@dhruvkb
Copy link
Member Author

dhruvkb commented Aug 30, 2024

This PR is drafted till #4810 is merged and labelled as "⛔️ status: blocked" (to prevent accidentally merging it). Once that is merged, it will be rebased and undrafted. Feel free to review in the meantime, I do not anticipate UI/functionality changes.

@dhruvkb dhruvkb added 🟨 priority: medium Not blocking but should be addressed soon 🌟 goal: addition Addition of new feature 💻 aspect: code Concerns the software code in the repository 🕹 aspect: interface Concerns end-users' experience with the software 🔧 tech: vue Involves Vue.js and removed 🏷 status: label work required Needs proper labelling before it can be worked on labels Aug 30, 2024
@dhruvkb dhruvkb changed the title Add assets for the sun and moon icon Add the UI toggle for changing theme Aug 30, 2024
@dhruvkb dhruvkb mentioned this pull request Aug 30, 2024
8 tasks
@dhruvkb dhruvkb force-pushed the dark_mode_toggle_impl branch from 2d5fea3 to a3f775f Compare August 30, 2024 16:38
Base automatically changed from feat-4308-frontend-color-mode-ui-state to main August 30, 2024 17:12
Copy link
Member

@zackkrida zackkrida left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely! There are a few small issues I'm noticing:

  • The "system" mode icon doesn't reflect the user's preference on SSR, it is always light.
  • There's an icon sizing/spacing issue:
    image
  • For the first issue, perhaps making the component clientonly would fix it

I really like how you're displaying the parenthetical of what the actual system value is, nice touch!

@dhruvkb dhruvkb force-pushed the dark_mode_toggle_impl branch from 90c1b9a to a4efc3a Compare August 30, 2024 17:42
@dhruvkb
Copy link
Member Author

dhruvkb commented Aug 30, 2024

@zackkrida that is so weird, I'm not seeing the select field sizing issue on any major browser! This is Safari, Arc (Chromium) and Firefox:

image

Safari has some wildly different problems going on, though.

@dhruvkb dhruvkb removed the ⛔ status: blocked Blocked & therefore, not ready for work label Aug 30, 2024
@dhruvkb dhruvkb marked this pull request as ready for review August 30, 2024 18:13
@dhruvkb dhruvkb requested a review from a team as a code owner August 30, 2024 18:13
@dhruvkb dhruvkb requested review from zackkrida and obulat August 30, 2024 18:13
@zackkrida
Copy link
Member

@dhruvkb it looks like removing overflow-hidden from the VSelectField wrapper div fixes the collapsing issue. The problem makes sense to me: a flex child with overflow-hidden and two absolutely-positioned children would collapse, as I understand.

I'm seeing it in Chrome and Firefox on Fedora. In any case, I think we can safely remove the overflow hiding.

Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to be able to change the theme from the UI!

I have 2 blocking requests:

  1. The VThemeSelect should not detect the user's color scheme. It should only use the value from the UI store, and update it.
    app.vue (and error.vue) as the entrypoints to the application would be the best place for the detection of the user's color scheme. We update the UI store layout properties (breakpoint and width) there.

  2. The select inside the VSelectField component does not set the outline style or width on focus-visible, but we do set its color. So with the default values, the focus ring has a white outline. Adding a focus-visible:outline-none to the select element could fix this white ring around the pink one:

Screenshot 2024-09-03 at 9 07 58 AM

@dhruvkb
Copy link
Member Author

dhruvkb commented Sep 3, 2024

  1. I need some more information here.

    The UI store only holds the user's choice of color theme, which can be dark/light/system. The first two correspond to actual themes but system can map to either of these. The component detects the user's theme to determine the icon to show. For the user's preference, it still reads from and writes to the UI store.

  2. I cannot see the white outline.

    Firefox:
    Screenshot 2024-09-03 at 12 34 19 PM

    Chrome:
    Screenshot 2024-09-03 at 12 34 33 PM

@dhruvkb dhruvkb marked this pull request as draft September 3, 2024 07:05
@dhruvkb dhruvkb force-pushed the dark_mode_toggle_impl branch from a0f7587 to 6dc18b5 Compare September 3, 2024 16:59
@dhruvkb dhruvkb marked this pull request as ready for review September 3, 2024 17:29
@dhruvkb dhruvkb requested a review from obulat September 3, 2024 17:29
Copy link
Contributor

@obulat obulat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality is perfect ✨ It's nice that the composable encapsulates handling of the color mode and we don't have to update the pages.

In dark mode, I can see a ring around the select field focus border in Arc, Chrome and Safari. Firefox is the only browser that displays the focus border correctly. I'm not blocking on this because this is a problem that existed with the language select, and should have a separate issue.

@dhruvkb dhruvkb dismissed zackkrida’s stale review September 5, 2024 12:00

Feedback implemented

@dhruvkb dhruvkb merged commit 3711b60 into main Sep 5, 2024
52 checks passed
@dhruvkb dhruvkb deleted the dark_mode_toggle_impl branch September 5, 2024 12:00
@dhruvkb dhruvkb linked an issue Sep 5, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻 aspect: code Concerns the software code in the repository 🕹 aspect: interface Concerns end-users' experience with the software 🌟 goal: addition Addition of new feature 🟨 priority: medium Not blocking but should be addressed soon 🧱 stack: frontend Related to the Nuxt frontend 🔧 tech: vue Involves Vue.js
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add UI toggle for dark mode Component: Theme switcher Site theme switcher (dark mode toggle)
4 participants