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

Home page enable dark mode #45535

Closed
49 changes: 49 additions & 0 deletions assets/scss/_base.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//Enabled partial dark mode support only in the main page.

@import "reset";

// header
Expand Down Expand Up @@ -34,6 +36,13 @@ $vendor-strip-font-size: 16px;
// video
$video-section-height: 200px;

//Dark mode

$dark-bg-color-1: #040505;
$dark-bg-color-2: #151818;
$dark-text-color-1: #FFF;
$dark-text-color-2: #3371e3;

@import "size";

////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -918,3 +927,43 @@ section#cncf {
border-top-left-radius: 0;
}
}

//Home page dark-mode
@media (prefers-color-scheme: dark) {
.cid-home main {
background-color: $dark-bg-color-2;
color:$dark-text-color-1;
}

.cid-home main section:not(#video):not(#cncf) {
background-color: $dark-bg-color-1;
color:$dark-text-color-1;
}

.cid-home .feature-box div {
background-color: $dark-bg-color-2;
color:$dark-text-color-1;
}

.cid-home main section:is(#video) #desktopShowVideoButton {
background-color: $dark-bg-color-1;
}

.cid-home main section:is(#video) #desktopShowVideoButton:hover {
color: $dark-text-color-2;
}

.cid-home main section:is(#video) #desktopKCButton:hover {
background-color: $dark-bg-color-1;
}

.cid-home main section:is(#talkToUs) img {
filter: invert(100%);
-webkit-filter: invert(100%);
}

.cid-home main section:is(#cncf) {
background-color: $dark-bg-color-2;
background-image: url(/images/cncf-white.png);
Copy link
Member

Choose a reason for hiding this comment

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

Inverting image colors or adjusting background image according to prefers-color-scheme: dark is nice addition for the homepage. However, extending this functionality to the entire docs and all its different images would be a challenge. It would be nice if this could be achieved through a Hugo shortcode, dynamically altering image source based on prefers-color-scheme: dark or light. I notice the issue description(here) also hints at employing shortcode for image switching, which aligns well with this suggestion.

For guidance on shortcode, refer to the tips provided at https://gohugo.io/templates/shortcode-templates/

}
}
2 changes: 2 additions & 0 deletions assets/scss/_custom.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//Enabled partial dark mode support only in the main page.

$announcement-size-adjustment: 8px;

/* GLOBAL */
Expand Down
Binary file added static/images/cncf-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.