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

feat: dark theme #605

Merged
merged 30 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6473160
add dark mode switch
atsuyaw Oct 20, 2023
d2899e5
add a script for switch
atsuyaw Oct 20, 2023
5c10d9c
add dark color scheme
atsuyaw Oct 20, 2023
f31192f
mod switch logo and its behavier
atsuyaw Oct 22, 2023
26023de
mod color scheme for dark mode
atsuyaw Oct 22, 2023
bde4fac
mod css
atsuyaw Oct 22, 2023
b5c4679
describe the configration of dark theme
atsuyaw Oct 22, 2023
488e60e
del excess
atsuyaw Oct 22, 2023
7151139
fix: mod readme
atsuyaw Oct 30, 2023
77731a4
fix: rename the classes
atsuyaw Oct 30, 2023
8a6d61a
fix: fetching scripts for dark mode in theme.js
atsuyaw Oct 30, 2023
4bed796
fix: migrate _dk-*.scss to dark-theme.scss
atsuyaw Oct 31, 2023
7b69701
fix: update css.html
atsuyaw Oct 31, 2023
c67505f
fix(v4) update i18n/ja (#593)
atsuyaw Sep 29, 2023
ededde1
fix(v4): adjust margins in title container (#595)
atsuyaw Sep 29, 2023
86ce9dc
updates to avoid duplication in CSS
igor-baiborodine Nov 2, 2023
47fd080
fix: polish colors
atsuyaw Nov 3, 2023
96d2780
feat: store dark mode preference
atsuyaw Nov 11, 2023
2f604ca
fix: revise the color scheme
atsuyaw Nov 12, 2023
66a6d7c
style: change the color name
atsuyaw Nov 14, 2023
cfd0fe8
perf: inhibit flickering during rendering on dark mode
atsuyaw Nov 14, 2023
8513726
fix: disable light/dark switcher even if enableLightDarkMode is false
atsuyaw Nov 19, 2023
d027fb6
feat: dynamic giscus theme switching
atsuyaw Nov 19, 2023
1b8d08f
Revert "perf: inhibit flickering during rendering on dark mode"
atsuyaw Nov 25, 2023
e1093f4
perf: modify the theme switching mechanism to prevent flicking on ren…
atsuyaw Nov 26, 2023
001e61b
fix description in readme.md
atsuyaw Nov 26, 2023
bed1a1c
fix connection line color
atsuyaw Nov 26, 2023
4b31067
fix the parameter name
atsuyaw Nov 26, 2023
201d709
fix: keep prefered theme
atsuyaw Dec 1, 2023
fb5d63a
fix: incorrect text output "check-theme-prefer.js"
atsuyaw Dec 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions v4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,17 @@ $base-color: {{ .Param "baseColor" | default "#1d1f38" }};
baseColor = "#ff8080"
```

Switching light/dark theme is supported.
atsuyaw marked this conversation as resolved.
Show resolved Hide resolved

Colors for dark theme with a prefix `dk-` are stored in [`assets/sass/dk-theme.scss`](assets/sass/dk-theme.scss).
You can customize them via the same way with light (default) colors.

*Note* that the dark theme can be disabled:
```toml
[params]
darkmode = false
```

### CSS and JS modules

This theme supports hot-swappable CSS and JavaScript extensions, which can be specified using the `css_modules`
Expand Down
35 changes: 35 additions & 0 deletions v4/assets/js/dark-toggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const dkToggle = document.getElementById("darkToggleLogo");
const darkTheme = document.getElementById("darkTheme");
const PCS = window.matchMedia("(prefers-color-scheme: dark)");
atsuyaw marked this conversation as resolved.
Show resolved Hide resolved

dkToggle.addEventListener("click", () => {
if (dkToggle.className === "fa fa-sun") {
setTheme("dark");
}
else {
atsuyaw marked this conversation as resolved.
Show resolved Hide resolved
setTheme("light");
}
});

function setTheme(mode) {
atsuyaw marked this conversation as resolved.
Show resolved Hide resolved
if (mode === "dark") {
darkTheme.disabled = false;
dkToggle.className = "fa fa-moon";
} else {
darkTheme.disabled = true;
dkToggle.className = "fa fa-sun";
}
}

const listener = (event) => {
if (event.matches) {
setTheme("dark");
}
atsuyaw marked this conversation as resolved.
Show resolved Hide resolved
else {
setTheme("light");
}
};

// PCS.addEventListerner("change", listener);
atsuyaw marked this conversation as resolved.
Show resolved Hide resolved
listener(PCS);

148 changes: 148 additions & 0 deletions v4/assets/sass/_dk-articles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
article {
background-color: $dk-article-background-color;
// :before and :after to generate the < pointer
&:before {
border-right-color: #ddd;
}

&:after {
border-right-color: #fff;
}

.content {
h1 {
a {
&:hover {
color: $dk-highlight-color;
}
}
}

.meta {
color: $dk-meta-text-color;
border-bottom: 3px double $dk-meta-border-color;

a {
color: inherit;
font-style: normal;

&:hover {
color: $dk-highlight-color;
}
}

}

a {
color: $dk-highlight-color;
}

a.more {
color: $dk-highlight-color;
}

.archive-list {
ul {
li {
border-bottom: 1px solid #eee;
}
a {
color: $dk-highlight-color;

span {
color: $dk-meta-text-color;
}

&:hover {
color: $dk-base-color;
}
}
}
}

blockquote {
background-color: lighten($dk-article-background-color,8);
border-left: 0.5em solid #ededed;
}

#TableOfContents {
li {
color: $dk-text-color;
a {
&:hover {
color: $dk-highlight-color;
}
}
}
}
}

.footer {
// background: transparentize($dk-base-color, 0.2);
background: transparentize($base-color, 0.2);

.tags {
.links {
a:not(:last-child):after {
color: $dk-text-color !important;
}
}
}

.languages {
.links {
a:not(:last-child):after {
color: $dk-text-color !important;
}
}
}
}

// Quotes
&.quote {
background-color: $dk-special-color;
&:after {
border-right-color: $dk-special-color;
}
blockquote {
color: $dk-text-color;
}
}

// Gallery
&.gallery {
.flexslider {
.flex-direction-nav a {
&:before {
color: rgba(255, 255, 255, 0.9);
text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);
}
}
}
}

// Link
&.link {
background-color: $dk-special-color;
&:after {
border-right-color: $dk-special-color;
}
&:hover {
background-color: $dk-highlight-color;
color: #fff;
a {
color: $dk-bubble-background-color;
}

&:after {
border-right-color: $dk-highlight-color;
}
}

// @include featuredImage();

a {
color: $dk-text-color;
}
}
}
38 changes: 38 additions & 0 deletions v4/assets/sass/_dk-bilberry-hugo-theme.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@import "_dk-no-js";
.bilberry-hugo-theme {
background-color: $dk-page-background-color;
color: $dk-text-color;
a {
color: inherit;

&:hover {
color: $dk-highlight-color;
}
}

.highlight {
pre {
code {
background-color: inherit;
}
.copy-button {
background: $dk-page-background-color;
}
}
}

#back-to-top-button {
color: $dk-base-color;
background-color: $dk-bubble-color;
}

#back-to-top-button:hover {
background-color: $dk-highlight-color;
}
@import "dk-topnav";
@import "dk-header";
@import "dk-main";
@import "dk-articles";
@import "dk-pagination";
@import "dk-footer";
}
49 changes: 49 additions & 0 deletions v4/assets/sass/_dk-footer.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
footer {
border-top: 3px solid $dk-footer-border-color;
border-bottom: 3px solid $dk-footer-border-color;
background-color: $dk-footer-background-color;

.container {
strong {
color: $dk-footer-headline-color;
}
ul {
a {
color: $dk-highlight-color;
&:hover {
// color: lighten($dk-base-color, 70);
color: lighten($dk-page-background-color, 70);
}
}
}

.right {
.external-profiles {
a {
color: $dk-footer-headline-color;
&:hover {
color: $dk-highlight-color;
}
}
}

.languages {
a {
color: $dk-highlight-color;
&:hover {
color: $dk-text-color;
}
&:not(:last-child):after {
color: $dk-text-color !important;
}
}
}
}
}
}

.credits {
.container {
color: $dk-bubble-color;
}
}
37 changes: 37 additions & 0 deletions v4/assets/sass/_dk-header.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
header {
background-color: $dk-base-color;
color: $dk-header-text-color;
.container {
&:after {
background: rgba(255, 255, 255, 0.1);
}
}

.logo {
background-color: $dk-logo-color;
border: 5px $dk-logo-color solid;
color: $dk-logo-color;
.overlay {
background-color: $dk-bubble-hover-color;
}
}

.switchbox {
.darkToggleBox {
background-color: $dk-special-color;
button {
color: $dk-header-text-color;
}
}
.languages {
background-color: $dk-special-color;
a {
color: $dk-header-text-color;
}
}
}

.toggler {
background: $dk-special-color;
}
}
21 changes: 21 additions & 0 deletions v4/assets/sass/_dk-main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.main {
&:before {
background: $dk-bubble-color;
}

&:after {
background: $dk-bubble-color;
}

.article-wrapper {
.bubble {
background-color: $dk-bubble-background-color;
border: 3px solid $dk-bubble-color;
color: $dk-bubble-color;
&:hover {
background-color: $dk-highlight-color;
color: $dk-bubble-background-color;
}
}
}
}
47 changes: 47 additions & 0 deletions v4/assets/sass/_dk-no-js.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
.js {
.no-js-message {
display: none;
}
}

.no-js {

.no-js-hidden {
display: none;
}

.no-js-message {
display: block;
padding: 2em;
background-color: $dk-base-color;
color: $dk-header-text-color;
font-size: 0.9em;
font-style: italic;
text-align: center;

&:first-line {
font-weight: bold;
}
}

nav {
display: block !important;
}

.search,
.toggler {
display: none !important;
}

pre code {
background: inherit;
color: inherit;
}

.responsive-video {
&.youtube, &.vimeo, &.peertube {
height: auto !important;
padding: 0 !important;
}
}
}
Loading