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 theme to website #3981

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

thesuperzapper
Copy link
Member

@thesuperzapper thesuperzapper commented Jan 31, 2025

This PR adds a new dark-theme to the Kubeflow website.

resolves #3692
resolves #3954

How does this work?

Because we use docsy, which has its own themes in addition to bootstrap, we now render two themes into our CSS based on the [data-theme] attribute on the root <html> element, see assets/scss/main.scss for more context.

This approach allows us to retain our custom docsy changes while adding a nice dark theme.

What changed?

NOTE: this PR does NOT change any of the docs content. However, some images/diagrams have been updated to look better when viewed on a dark background.

Theme-specific styling

To make theme-specific styling possible, we have added the following:

  • CSS classes:
    • show_light-only (only show element in light mode)
    • show_dark-only (only show element in dark mode)
  • Theme-specific SCSS variables:
    • assets/scss/dark/_variables.scss
    • assets/scss/light/_variables.scss
  • Theme-specific SCSS styles:
    • assets/scss/dark/_styles.scss
    • assets/scss/light/_styles.scss

NOTE: the existing assets/scss/_styles_project.scss is still used for global styles. It is used by both themes, usually with theme-specific variables to set colors.

Theme Switcher

We have added a theme switcher to the top right of the website, which allows users to switch between the light and dark themes. By default, we match the theme set on the user's OS.

theme_switcher

Images

We have not created new images for the dark theme, as most looked OK on the dark background. In the future, we can use the show_light-only and show_dark-only classes to show different images based on the theme.

We have updated the following images to look better on the dark theme:

  • Getting Started / Introduction
  • Getting Started / Architecture

Iframes / Swagger

There were two cases where I used a color inversion filter to create a fake "dark mode":

  1. For the Google calendar embed in the community page
  2. For the Swagger UI API reference pages

They seem to work well enough, but we can revisit this in the future if those components get official dark mode support.

Screenshots

Home Page (preview)

home

Getting Started (preview)

getting_started

Code Blocks (preview)

code_blocks

@google-oss-prow google-oss-prow bot requested a review from alfsuse January 31, 2025 22:55
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zijianjoy for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@thesuperzapper
Copy link
Member Author

@varodrig @ederign @milinddethe15 could you take a first look at this PR, that adds a dark mode?

Once we are happy, we can share it around the community for wider feedback.

See: preview site

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade hugo and docsy version (add dark theme) Implement Dark/Light Mode Compatibility for Website
1 participant