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

Color mode #984

Merged
merged 13 commits into from
Oct 27, 2023
Merged

Color mode #984

merged 13 commits into from
Oct 27, 2023

Conversation

AnnMarieW
Copy link
Contributor

@AnnMarieW AnnMarieW commented Oct 16, 2023

Added light-dark color mode switch to the docs. This new feature is available in Bootstrap>=5.3.0

For more info see this forum post: https://community.plotly.com/t/light-and-dark-color-modes-with-dash-bootstrap-components-1-5-0/78810

To do:

  • Add info to the Theme section with an example of how to add a light/dark color mode switch component to a Dash app.
  • Update the Forms section with info on how to style dcc components in dark mode
  • Refactor the way the theme switch component was added to the docs



dbc-color-mode

@tcbegley tcbegley self-requested a review October 20, 2023 07:05
Copy link
Collaborator

@tcbegley tcbegley left a comment

Choose a reason for hiding this comment

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

This is amazing work! Thank you so much.

Some things I noticed:

  • The border doesn't look quite right on the code snippets
    image
  • The examples apps don't look all that great. Let's just have them always be light mode, which I think we can do by setting data-bs-theme on the wrapper component for the app itself. The navbar, source code etc. is fine to be toggleable.

docs/components_page/components/form.md Outdated Show resolved Hide resolved
docs/components_page/components/layout/horizontal_stack.py Outdated Show resolved Hide resolved
docs/components_page/components/layout/horizontal_stack.py Outdated Show resolved Hide resolved
docs/static/docs.css Outdated Show resolved Hide resolved
docs/static/js/docs-theme-change.js Outdated Show resolved Hide resolved
docs/templates/index.html Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we right-align this one in the navbar? Just to create some distinction with the navigation links

Copy link
Contributor Author

@AnnMarieW AnnMarieW Oct 23, 2023

Choose a reason for hiding this comment

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

Yes, but the icon looked so lonely over there 🙂 . I changed the style to make it more visible, but it might be too much now.

image

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting, let's try adding a GitHub link to make it less lonely in a follow-up PR.

@AnnMarieW
Copy link
Contributor Author

The examples apps don't look all that great. Let's just have them always be light mode, which I think we can do by setting data-bs-theme on the wrapper component for the app itself. The navbar, source code etc. is fine to be toggleable.

Are you referring the the apps on https://dash-bootstrap-components.opensource.faculty.ai/examples/, or do you mean all the code snippets examples on every page?

@tcbegley
Copy link
Collaborator

The former. I think it's fine to have light themed app embedded in a possibly dark themed website.

I just thought, I didn't check the theme explorer, does that look ok?

@AnnMarieW
Copy link
Contributor Author

AnnMarieW commented Oct 20, 2023

Just to double confirm... you want to have all the code snippets light even when the app is in dark mode? I think that would be confusing. The idea is to demonstrate what the Bootstrap components look like in either the dark or light color modes. If they were all light in the dark themed docs app, then it would look like the dbc components do not respond to the color mode.

The goal was for it to work like the upstream Bootstrap docs when in dark mode https://getbootstrap.com/docs/5.3/components/buttons/ Do those docs look ok? Or do you have any ideas on how to make the dark mode code examples look better in the docs app?

If you prefer all the code snippet examples in light mode, then I think we should re-think this PR. Instead of having a global light/dark theme, we should just add a page on the color modes and show some examples of what the components look like in dark mode, and how to change the color mode either globally and/or by component.

@tcbegley
Copy link
Collaborator

No, I think there's been a misunderstanding. Code snippets are fine, no changes.

On the examples page where we embed examples in the docs app (like the iris k-means example), the examples apps are being rendered in dark mode even though they are not designed to look good in dark mode. Eg the graph background is all white.

I'm saying let's disable dark mode on the embedded example apps. That's all, no changes outside of /examples

@AnnMarieW
Copy link
Contributor Author

Ok, got it 😅
The example page should be easy to fix.

Copy link
Collaborator

@tcbegley tcbegley left a comment

Choose a reason for hiding this comment

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

Fantastic work, thanks so much for this!

I think I'm happy to merge this, push through a few PRs I have on the backlog, make a few final tweaks, and then go live alongside the next release. wdyt?

@AnnMarieW
Copy link
Contributor Author

Thanks for your kind words 😁
This was a fun project -- the dark mode available in 5.3 is pretty cool.

The open issues are fairly minor, so I think it would be great to merge this and do the final tweaks in separate PRs. I'm looking forward to seeing it live!

@tcbegley tcbegley merged commit 9bb7785 into facultyai:main Oct 27, 2023
7 checks passed
@AnnMarieW AnnMarieW deleted the color-mode branch October 27, 2023 19:39
This was referenced Apr 14, 2024
tcbegley added a commit that referenced this pull request Apr 14, 2024
* css and className changes for color mode

* docs color mode theme switch

* lint

* Added more info on themes

* Update docs/components_page/components/form.md

Co-authored-by: Tom Begley <tomcbegley@gmail.com>

* fixed stack style

* align theme toggle to right & format as btn

* lint

* fixed stack examples

* make examples pages always a light theme

---------

Co-authored-by: Tom Begley <tomcbegley@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants