8000 [DT-2854] move dark mode button from side nav to top nav by andrewzamojc · Pull Request #2720 · temporalio/ui · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[DT-2854] move dark mode button from side nav to top nav #2720

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

Merged
merged 14 commits into from
May 28, 2025

Conversation

andrewzamojc
Copy link
Contributor
@andrewzamojc andrewzamojc commented May 12, 2025

Description & motivation 💭

This PR enhances the app's dark mode functionality by adding a "System Default" option. This allows users to set their app's light/dark mode to defer to their system setting.

  • There is a new store to hold the user's dark mode preference (light/dark/system).
  • The existing useDarkMode store is now derived from the preference, and continues to always return true/false. It resolves the system case to a boolean. This way existing code keeps working.
  • Two new components, the DarkModeIconButton and DarkModeNavigationButton capture the interaction.
  • Top nav gets an icon button (the moon in the first screen shot, top right)
  • Bottom (mobile) nav get a navigation button
  • Side nav has its dark mode button removed

Screenshots (if applicable) 📸

Screenshot 2025-05-13 at 2 43 56 PM Screenshot 2025-05-13 at 2 43 35 PM Screenshot 2025-05-13 at 2 43 41 PM Screenshot 2025-05-28 at 1 22 49 PM Screenshot 2025-05-13 at 4 23 07 PM Screenshot 2025-05-13 at 4 07 48 PM Screenshot 2025-05-28 at 1 18 00 PM

Design Considerations 🎨

  • Minor wording: the words "System Default" (e.g. in the tooltip) doesn't mention dark mode.
  • Cycle order light/dark/system is easy to alter if there's a better order.

Testing 🧪

How was this tested 👻

Manual testing, plus added a unit test.

Made preview PR on cloud-ui and manually tested there as well, https://github.com/temporalio/cloud-ui/pull/1460.

  • Manual testing
  • E2E tests added
  • Unit tests added

Steps for others to test: 🚶🏽‍♂️🚶🏽‍♀️

To see the change:

  • run the branch
  • notice there is no light/dark mode button in the side nav
  • notice there is a light/dark mode button in the top nav
  • notice there is a light/dark mode button in the bottom-right nav when you squish the screen to mobile size
  • notice clicking the button cycles between system-default / dark / light.

Checklists

Draft Checklist

Merge Checklist

Issue(s) closed

Docs

Any docs updates needed?

Copy link
vercel bot commented May 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
holocene ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 28, 2025 6:25pm

@CLAassistant
Copy link
CLAassistant commented May 12, 2025

CLA assistant check
All committers have signed the CLA.

useDarkModePreference,
} from './dark-mode';

describe('dark-mode utilities', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Annotation: Thanks AI.

@andrewzamojc andrewzamojc marked this pull request as ready for review May 13, 2025 21:00
@andrewzamojc andrewzamojc requested review from rossedfort and a team as code owners May 13, 2025 21:00
@andrewzamojc andrewzamojc changed the title move dark mode button from side nav to top nav [DT-2854] move dark mode button from side nav to top nav May 13, 2025
<IconButton
variant="ghost"
label={buttonText}
icon={$useDarkMode ? 'moon' : 'sun'}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll want a third icon here, right?
Screenshot 2025-05-15 at 8 55 13 AM

Same for dark-mode-navigation-button.svelte

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aha. Could you link me to that node in Figma? I didn't see this part....

I'll also loop in @bilal-karim on the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member
@bilal-karim bilal-karim May 15, 2025

Choose a reason for hiding this comment

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

Thanks for the 8000 catch @rossedfort.

Hey @andrewzamojc — sorry, I didn't make it clear in the designs or the ticket. The icon placement is correct in the top nav, but the icons should be:

system-window

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done. Dark mode buttons now use system-window icon.

/>
<slot name="bottom" />
</svelte:fragment>
<slot name="bottom" />
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we'll need the below. This is definitely tricky and will help when we move to Svelte5 (don't need that for this PR). Basically there's multiple slots that we need to pass down through.

<svelte:fragment slot="bottom" name="bottom" >

or

<svelte:fragment slot="bottom">
  <slot name="bottom">
</svelte:fragment>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

useDarkModePreference,
} from '$lib/utilities/dark-mode';

let buttonText = $derived(
Copy link
Contributor

Choose a reason for hiding this comment

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

Tiniest of nits, but usually if you are using $derived it should be a const. You can update $derived but it's only its for optimistic updates or some other edge case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I don't know why I used let here. I'll update it before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@andrewzamojc andrewzamojc merged commit d831ccc into main May 28, 2025
20 checks passed
@andrewzamojc andrewzamojc deleted the DT-2854-dark-mode-system-setting branch May 28, 2025 18:40
@andrewzamojc andrewzamojc mentioned this pull request May 29, 2025
3 tasks
Alex-Tideman pushed a commit that referenced this pull request May 30, 2025
* add useDarkModePreference store, make existing useDarkMode derived

* add dark mode button component

* add dark mode button to top nav

* add DarkModeButton to bottom nav

* remove dark mode button from side nav

* enhance dark mode utilities with preference type and next preference function

* separate icon button and nav button for bottom nav

* add some tests for the dark-mode file

* use original default value from .env

* use svelte5, tidy up

* add system-window icon

* use system-window icon for dark mode buttons

* tweak side nav slot "bottom" to be more like original

* change let to const in dark-mode buttons
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0