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

Global: Implement Dark Mode 🌙 #669

Merged
merged 20 commits into from
Jun 24, 2024
Merged

Conversation

Samk13
Copy link
Member

@Samk13 Samk13 commented Jun 17, 2024

❤️ Thank you for your contribution!

Description

This pull request includes the following changes:

  • Set up dark mode 🌙
  • Remove outdated overrides
  • Auto pick prefers-color-scheme from system settings
  • Resolves the asset URL problem failing CI by removing the base override.

These changes enhance the user experience by providing an alternative color scheme that is easier on the eyes in low-light environments.

Screenshots:

image

127 0 0 1_8000_ (2)

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@Samk13 Samk13 changed the title global: Implement dark mode and update theme palette global: Implement dark mode 🌙 Jun 18, 2024
@Samk13 Samk13 changed the title global: Implement dark mode 🌙 global: Implement Dark Mode 🌙 Jun 18, 2024
@Samk13 Samk13 changed the title global: Implement Dark Mode 🌙 Global: Implement Dark Mode 🌙 Jun 18, 2024
@Samk13 Samk13 force-pushed the dark-mode branch 2 times, most recently from 3b0e340 to 0fa0744 Compare June 18, 2024 14:44
@Samk13 Samk13 marked this pull request as ready for review June 18, 2024 21:18
@Samk13 Samk13 requested a review from fenekku June 18, 2024 21:18
@Samk13 Samk13 added the documentation Improvements or additions to documentation label Jun 18, 2024
@fenekku
Copy link
Collaborator

fenekku commented Jun 20, 2024

Thanks for that.

When I run it here is what I get on the frontpage by default:

frontpage_default_light

... where the dark mode toggle is missing. Let's have it there too. It's also missing on the Features page.

Then when I click on the "Install" tab, it switches to dark mode automatically:

install_default_dark

And then when I click on the home logo to go back to the frontpage:

frontpage_default_dark

...it switches to dark mode.

I suspect the frontpage starts with a value unset. The pages that have the dark mode toggle set that value, and so when visiting the frontpage after, the value is now set and the dark theme kicks in. My slightly quirky setup may be revealing that issue: Ubuntu 22.04 light mode + Firefox automatic mode + Mozilla dark theme addon enabled. (For comparison this didn't happen on Brave (Chromium based) browser on the same platform).

Getting dark mode setting for front+feature page should provide a consistent experience.

Comment on lines +6 to +7
--color-black: #000000;
--color-white: #ffffff;
Copy link
Collaborator

@fenekku fenekku Jun 20, 2024

Choose a reason for hiding this comment

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

We can just use white and black directly in places where these are used. If the idea is to abstract the references to have a single point of control, then a different name would be best e.g., --main-light / --main-dark, or --white-like / --black-like or smtg else ... (what concept is abstracted here is a bit hard to tell which I suspect was why just values were used before. Using values seems fine by me.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I've thought about it, but using --main-light and --main-dark suggests a relation to the main theme, which isn't the case here. The purpose, as you mentioned, is to have a single point of control for easy color management. Custom changes can still be made directly when needed.

Another point is that much of the extra.css is redundant and can be minimized even more. I'd prefer to keep it as is for now, and in a future PR, we could remove more of the custom rules altogether.

@Samk13
Copy link
Member Author

Samk13 commented Jun 20, 2024

I suspect the frontpage starts with a value unset. The pages that have the dark mode toggle set that value, and so when visiting the frontpage after, the value is now set and the dark theme kicks in. My slightly quirky setup may be revealing that issue: Ubuntu 22.04 light mode + Firefox automatic mode + Mozilla dark theme addon enabled. (For comparison this didn't happen on Brave (Chromium based) browser on the same platform).

Getting dark mode setting for front+feature page should provide a consistent experience.

As we discussed in the DMs, the reason the toggle is not showing is that the current inheritance doesn't support displaying the toggle and search input on the front page without routing in the docs. You can simply replace one line {% extends "main.html" %} here, but then we need to refactor these pages and rewrite the CSS again.

@Samk13
Copy link
Member Author

Samk13 commented Jun 20, 2024

Update: I fixed it now, there is still the CSS color cut left to fix.

Samk13 added 4 commits June 21, 2024 04:27
* Remove frontpage_base.html override as we are extending from main
* Still need to fix gradient color cut and style diffrence between dark and light mode
* Fix homepage gradients without the need to override base.html
@Samk13
Copy link
Member Author

Samk13 commented Jun 22, 2024

Update:

  • Adapting the style without overriding base.html which in result resolves the asset URL problem we have experienced for a while now.
  • Fix the CSS color cut in the gradient
  • Fix the toggle not showing on the front page and features page.
  • Show Github stats
  • Remove outdated CSS styles to reduce future maintenance costs.

Screenshot from 2024-06-22 04-45-37

Screenshot from 2024-06-22 04-28-00

@Samk13 Samk13 requested a review from fenekku June 24, 2024 11:28
Copy link
Collaborator

@fenekku fenekku left a comment

Choose a reason for hiding this comment

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

Awesome! So glad we got

  • dark mode
  • search on frontpage
  • break from replacing base.html completely and therefore URL of assets problem fixed

Thanks for all the effort on this one!

@fenekku
Copy link
Collaborator

fenekku commented Jun 24, 2024

Final look:

image

@fenekku fenekku merged commit 5a7ef8b into inveniosoftware:master Jun 24, 2024
1 check passed
@Samk13 Samk13 deleted the dark-mode branch June 24, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants