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 dark mode #1554

Merged
merged 35 commits into from
May 24, 2022
Merged

Add dark mode #1554

merged 35 commits into from
May 24, 2022

Conversation

matt852
Copy link
Contributor

@matt852 matt852 commented Mar 25, 2022

Closes: #729

What's Changed

I added dark mode to Nautobot. This makes minimal changes to the existing CSS configurations and continues using Bootstrap 3.

I added a small toggle feature using Javascript to the footer that allows toggling between light and dark mode.

The setting is saved client side on the client computer, and will remain set unless the user clears the browser session data (or uses something like incognito mode).
This does not make and database changes or store any theme-related data server-side.

Screen Shot 2022-03-25 at 4 20 59 PM

Screen Shot 2022-03-25 at 4 20 22 PM

Screen Shot 2022-03-25 at 4 20 49 PM

@bryanculver bryanculver self-requested a review March 28, 2022 08:27
Copy link
Member

@bryanculver bryanculver 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 like a great start @matt852!

I'd like to see this go just a bit further, referencing a guide like this: https://css-tricks.com/a-complete-guide-to-dark-mode-on-the-web/

  • Using browser preference settings (I'm a day-time light mode, night-time dark mode user)

  • Handling the buttons which look weird IMHO with black text.

@matt852
Copy link
Contributor Author

matt852 commented Mar 28, 2022

@bryanculver I've updated the buttons, the status backgrounds, etc to always use white text.
I updated the JS to detect the current system theme, and set Nautobot's theme to match it. It will also change if the system theme changes.
I left in the ability for the user to select a theme from the footer button. This enables the user to force the theme for Nautobot, and will no longer update based on the system theme (unless they use a new browser, incognito mode, etc).

Screen Shot 2022-03-28 at 8 31 21 AM

Copy link
Contributor

@glennmatthews glennmatthews left a comment

Choose a reason for hiding this comment

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

Pretty cool! A few thoughts:

nautobot/project-static/css/base.css Outdated Show resolved Hide resolved
@bryanculver bryanculver linked an issue Apr 14, 2022 that may be closed by this pull request
@bryanculver bryanculver changed the base branch from next to develop April 19, 2022 01:42
@matt852
Copy link
Contributor Author

matt852 commented Apr 21, 2022

I added in support for 3 options: light mode, dark mode, and system settings. With adding a third, the toggle idea with the "light/dark" text in the footer wasn't as viable, so I created a modal that pops up. Upon selecting a theme, the page refreshes and the modal closes, or you can simply cancel out of it.
Screen Shot 2022-04-20 at 8 52 19 PM
Screen Shot 2022-04-20 at 8 56 00 PM

@matt852
Copy link
Contributor Author

matt852 commented Apr 21, 2022

Screen Shot 2022-04-20 at 9 16 29 PM
Screen Shot 2022-04-20 at 9 15 42 PM

@matt852
Copy link
Contributor Author

matt852 commented Apr 21, 2022

Screen Shot 2022-04-20 at 9 22 05 PM
Screen Shot 2022-04-20 at 9 21 54 PM

@matt852
Copy link
Contributor Author

matt852 commented Apr 21, 2022

Screen Shot 2022-04-20 at 9 25 50 PM
Screen Shot 2022-04-20 at 9 25 39 PM

@matt852
Copy link
Contributor Author

matt852 commented Apr 21, 2022

@glennmatthews @bryanculver I've addressed all of your feedback, and included screenshots for the various areas of concern.
I believe the Rack Elevations, API docs, and GraphiQL pages are all working properly now (they weren't previously...good catch!)

From my earlier comment: I added in support for 3 options: light mode, dark mode, and system settings. With adding a third, the toggle idea with the "light/dark" text in the footer wasn't as viable, so I created a modal that pops up. Upon selecting a theme, the page refreshes and the modal closes, or you can simply cancel out of it.

"System" theme is set by default right now. I can change this if desired.

Please let me know your thoughts or concerns. I know it's slightly different without using a fully separate light/dark stylesheet, but I believe it will work well until there's a broader UI overhaul and push towards Bootstrap 5 (or some other update).

EDIT: I'm just looking for overall feedback at the moment. I want to figure out some integration tests first and check a few more things. I'll let you know when it's ready for approval/merging.

@matt852 matt852 marked this pull request as draft April 21, 2022 11:57
@smk4664 smk4664 mentioned this pull request May 17, 2022
12 tasks
nautobot/core/templates/base.html Outdated Show resolved Hide resolved
nautobot/core/templates/base.html Show resolved Hide resolved
nautobot/core/tests/integration/test_theme.py Show resolved Hide resolved
nautobot/core/urls.py Outdated Show resolved Hide resolved
nautobot/project-static/css/base.css Outdated Show resolved Hide resolved
@matt852
Copy link
Contributor Author

matt852 commented May 20, 2022

I've confirmed the Rack elevation is dark, but when selecting "Save SVG", the SVG is rendered in light mode (as requested).

@bryanculver bryanculver changed the base branch from develop to next May 20, 2022 17:03
@bryanculver
Copy link
Member

Retargeted at next as this is a new feature not addressing a bug.

@matt852 matt852 marked this pull request as ready for review May 20, 2022 19:04
@matt852 matt852 requested a review from bryanculver May 20, 2022 20:57
@bryanculver bryanculver changed the title [WIP] Add dark mode Add dark mode May 24, 2022
Copy link
Member

@bryanculver bryanculver left a comment

Choose a reason for hiding this comment

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

😎

Screen.Recording.2022-05-24.at.14.15.07-small2.mov

@bryanculver bryanculver merged commit 61d43f9 into nautobot:next May 24, 2022
@bryanculver bryanculver mentioned this pull request May 24, 2022
@matt852 matt852 deleted the dark-mode branch June 15, 2022 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Dark mode theme
3 participants