Skip to content

[dashboard] Update theme preference selector #4021

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 1 commit into from
Apr 21, 2021
Merged

Conversation

jankeromnes
Copy link
Contributor

@jankeromnes jankeromnes commented Apr 20, 2021

Fixes #3984

  • 1. Update the theme selector style
  • 2. Default to light theme to be less surprising to the user (do we really want this?)
  • 3. Update the section design description to something more descriptive
  • 4. Consider introducing a secondary option to sync theme between dashboard and editor (unsure about this)

@jankeromnes jankeromnes force-pushed the jx/new-theme-selector branch 3 times, most recently from c08e587 to b1807d9 Compare April 20, 2021 17:32
@jankeromnes jankeromnes force-pushed the jx/new-theme-selector branch from b1807d9 to ccff686 Compare April 20, 2021 17:34
@jankeromnes jankeromnes marked this pull request as ready for review April 20, 2021 17:46
@jankeromnes jankeromnes requested a review from gtsiolis April 20, 2021 17:48
@jankeromnes
Copy link
Contributor Author

jankeromnes commented Apr 20, 2021

Great design! 💯 Currently looks like this:

Screenshot 2021-04-20 at 19 45 04

Screenshot 2021-04-20 at 19 45 15

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Apr 20, 2021

Thought: Maybe the IDE cards and Theme cards could be squares?

Screenshot 2021-04-20 at 20 00 22

Or IDE cards could have the same height / aspect ratio as Theme cards?

Screenshot 2021-04-20 at 19 57 12

Copy link
Contributor

@gtsiolis gtsiolis left a comment

Choose a reason for hiding this comment

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

This looks so good. Thanks for picking this up @jankeromnes! 🌟 🌟 🌟

Regarding the pending tasks:

Default to light theme to be less surprising to the user

No strong feelings for this one. We could keep defaulting to system theme, as the current setup. The two primary reasons for that suggestion are a) to avoid surprising the user, especially given that we can't sync back and forth with the editor (see #3982 (comment)) and b) to make the dark and system setting opt-in in #3956 instead of a fallback.

Consider introducing a secondary option to sync

We could keep this out of this iteration or wait to reach some consensus in #3982. I'd vote for getting this in as soon as possible.

Maybe the IDE cards and Theme cards could be squares?

Also thought about this while designing the theme preference selector. Two reasons why I kept these as they are. First, a) to differentiate these options and make them distinct options from the editor preference[1] and second b) to evolve the card component by trying a new design[2].

[1] For example, we should separate tab index between editor and theme cards. Currently, you can cycle between every option when using the right or left arrows. You should able to jump between Editor and Theme options (cards) only using Tab.

[2] Our component system will naturally evolve and new designs will pop-up on the way as the system matures. Aligning the rest of the components by making them square here is also fine. Your call! 📞

56ggq6

<label><input type="radio" name="theme" value="system" checked={theme === 'system'} onChange={() => actuallySetTheme('system')}></input> System</label>
<label><input type="radio" name="theme" value="dark" checked={theme === 'dark'} onChange={() => actuallySetTheme('dark')}></input> Dark</label>
<label><input type="radio" name="theme" value="light" checked={theme === 'light'} onChange={() => actuallySetTheme('light')}></input> Light</label>
<SelectableCard className="w-36 h-32" title="Light" selected={theme === 'light'} onClick={() => actuallySetTheme('light')}>
Copy link
Contributor

Choose a reason for hiding this comment

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

praise: Go re-usable components! 🎉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

More coming 🔜! 😇

<img className="w-16 dark:filter-invert" src={theia}/>
</div>
</SelectableCard>
</div>
<h3 className="mt-12">Theme</h3>
<p className="text-base text-gray-500">Light or dark?</p>
<p className="text-base text-gray-500">Early bird or night owl? Choose your side.</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: Suggested text can be taken lightly here. If anyone has a better alternative, feel free to update! In any case, looks great for this iteration. 🦉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Your text is perfect! 🌟🎯

<svg className="h-16" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 108 64"><rect width="68" height="40" x="40" fill="#C4C4C4" rx="8"/><rect width="32" height="16" fill="#C4C4C4" rx="8"/><rect width="32" height="16" y="24" fill="#C4C4C4" rx="8"/><rect width="32" height="16" y="48" fill="#C4C4C4" rx="8"/></svg>
</div>
</SelectableCard>
<SelectableCard className="w-36 h-32" title="Dark" selected={theme === 'dark'} onClick={() => actuallySetTheme('dark')}>
Copy link
Contributor

Choose a reason for hiding this comment

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

question: Curious why we named this actuallySetTheme? Isn't setTheme a sufficient alternative? Do we use setTheme elsewhere? 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Haha 😂 nice catch! If you look above in the code, there is a theme React state (a string), with already a setTheme(value) function.

But if we just call setTheme(value) from the selector component, we'll just switch the React state / selected card, but not the actual web app theme itself.

That's where actuallySetTheme(value) comes in: it calls setTheme(value), but then it also toggles the dark class on the body, and it also updates local storage so that the value is remembered across reloads.

If you see better names for these functions, please share. 😇

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for explaining @jankeromnes! Sounds good! Let's keep this as is. DOES. THE. JOB. 💯

@jankeromnes
Copy link
Contributor Author

jankeromnes commented Apr 21, 2021

Many thanks for the quick review! 🙏

Default to light theme to be less surprising to the user

No strong feelings for this one. We could keep defaulting to system theme, as the current setup. The two primary reasons for that suggestion are a) to avoid surprising the user, especially given that we can't sync back and forth with the editor (see #3982 (comment)) and b) to make the dark and system setting opt-in in #3956 instead of a fallback.

That's a good point. In this light, I think the default theme should be the same for the dashboard and the IDE (i.e. "System" default in both, or "Light" default in both, but maybe we don't need to sync beyond the default value). Added my thoughts to the issue.

Consider introducing a secondary option to sync

We could keep this out of this iteration or wait to reach some consensus in #3982. I'd vote for getting this in as soon as possible.

Agreed, thanks! 🚀

@jankeromnes jankeromnes merged commit e0c1791 into main Apr 21, 2021
@jankeromnes jankeromnes deleted the jx/new-theme-selector branch April 21, 2021 06:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[dashboard] Update theme preference selector
2 participants