diff --git a/gulpfile.js b/gulpfile.js index b7e671c..c8e2d42 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,10 @@ var gulp = require('gulp'), minify = require('gulp-cssnano'); gulp.task('less', function () { - return gulp.src('./static/stylesheet/style.less') + return gulp.src([ + './static/stylesheet/style.less', + './static/stylesheet/dark-theme.less', + ]) .pipe(less()) .pipe(minify()) .pipe(rename({ diff --git a/static/stylesheet/dark-theme.less b/static/stylesheet/dark-theme.less index ae16b4f..e5d852e 100644 --- a/static/stylesheet/dark-theme.less +++ b/static/stylesheet/dark-theme.less @@ -1,114 +1,144 @@ -// This stylesheet contains style overrides for the dark theme. +// +// Dark Theme CSS. +// +// If you want to always use the dark theme, then you can use a like the +// following: +// +// +// +// If you want to enable only when the prefers-color-scheme is set to dark (and +// potentially no-preference), make sure that you add the appropriate media +// query to the . For example: +// +// +// +// or +// +// +// +// depending on whether you want to default to dark mode or not when the user +// hasn't set a preference. +// + @import "variables.less"; -body { - background-color: @body-bg-dark-theme; - color: @text-color-dark-theme; -} - -hr { - color: @solid-dark-grey; - background-color: @solid-dark-grey; -} - -aside { - background-color: @sidebar-bg-dark-theme; - color: @sidebar-text-color; - -} - -main { - nav { - border-bottom-color: @nav-border-color-dark-theme; +html:not(.light-theme), html.dark-theme { + body { + background-color: @body-bg-dark-theme; + color: @text-color-dark-theme; } - nav, .translations { - a { - border-color: @nav-border-color-dark-theme; + hr { + color: @solid-dark-grey; + background-color: @solid-dark-grey; + } + + aside { + background-color: @sidebar-bg-dark-theme; + color: @sidebar-text-color; + + } + + main { + nav { + border-bottom-color: @nav-border-color-dark-theme; + } + + nav, .translations { + a { + border-color: @nav-border-color-dark-theme; + } + } + + article { + kbd { + background-color: #080808; + color: @light-grey; + } + + *:not(pre) > code { + background-color: #080808; + border-color: #000; + } + } + + footer { + border-top-color: @footer-border-color-dark-theme; } } - article { - kbd { - background-color: #080808; - color: @light-grey; - } + div.related-posts { + border-color: @rel-post-border-color-dark-theme; + } - *:not(pre) > code { - background-color: #080808; - border-color: #000; + // Admonition + div.admonition.attention { + p, div { + color: @admonition-attention-color-dark-theme; + background-color: @admonition-attention-bg-color-dark-theme; } } - footer { - border-top-color: @footer-border-color-dark-theme; - } -} - -div.related-posts { - border-color: @rel-post-border-color-dark-theme; -} - -// Admonition -div.admonition.attention { - p, div { - color: @admonition-attention-color-dark-theme; - background-color: @admonition-attention-bg-color-dark-theme; - } -} - -div.admonition.caution { - p, div { - color: @admonition-caution-color-dark-theme; - background-color: @admonition-caution-bg-color-dark-theme; - } -} - -div.admonition.danger { - p, div { - color: @admonition-danger-color-dark-theme; - background-color: @admonition-danger-bg-color-dark-theme; - } -} - -div.admonition.error { - p, div { - color: @admonition-error-color-dark-theme; - background-color: @admonition-error-bg-color-dark-theme; - } -} - -div.admonition.hint { - p, div { - color: @admonition-hint-color-dark-theme; - background-color: @admonition-hint-bg-color-dark-theme; - } -} - -div.admonition.important { - p, div { - color: @admonition-important-color-dark-theme; - background-color: @admonition-important-bg-color-dark-theme; - } -} - -div.admonition.note { - p, div { - color: @admonition-note-color-dark-theme; - background-color: @admonition-note-bg-color-dark-theme; - } -} - -div.admonition.tip { - p, div { - color: @admonition-tip-color-dark-theme; - background-color: @admonition-tip-bg-color-dark-theme; - } -} - -div.admonition.warning { - p, div { - color: @admonition-warning-color-dark-theme; - background-color: @admonition-warning-bg-color-dark-theme; + div.admonition.caution { + p, div { + color: @admonition-caution-color-dark-theme; + background-color: @admonition-caution-bg-color-dark-theme; + } + } + + div.admonition.danger { + p, div { + color: @admonition-danger-color-dark-theme; + background-color: @admonition-danger-bg-color-dark-theme; + } + } + + div.admonition.error { + p, div { + color: @admonition-error-color-dark-theme; + background-color: @admonition-error-bg-color-dark-theme; + } + } + + div.admonition.hint { + p, div { + color: @admonition-hint-color-dark-theme; + background-color: @admonition-hint-bg-color-dark-theme; + } + } + + div.admonition.important { + p, div { + color: @admonition-important-color-dark-theme; + background-color: @admonition-important-bg-color-dark-theme; + } + } + + div.admonition.note { + p, div { + color: @admonition-note-color-dark-theme; + background-color: @admonition-note-bg-color-dark-theme; + } + } + + div.admonition.tip { + p, div { + color: @admonition-tip-color-dark-theme; + background-color: @admonition-tip-bg-color-dark-theme; + } + } + + div.admonition.warning { + p, div { + color: @admonition-warning-color-dark-theme; + background-color: @admonition-warning-bg-color-dark-theme; + } } } diff --git a/templates/base.html b/templates/base.html index 37c4c5b..a93d8ca 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,7 +5,11 @@ {% endif %} - + @@ -28,6 +32,50 @@ {% endif %} + + + + + {% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE or THEME_COLOR == "dark" %} + + {% endif %} + {% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE or not THEME_COLOR or THEME_COLOR == "light" %} + + {% endif %} + {% if USE_TIPUE_SEARCH %} @@ -36,12 +84,6 @@ {% endif %} - - diff --git a/templates/partial/flex.html b/templates/partial/flex.html index c881e3b..c43198c 100644 --- a/templates/partial/flex.html +++ b/templates/partial/flex.html @@ -1,53 +1,70 @@ -

{{ _('Built with %(pelican_url)s using %(flex_url)s theme', - pelican_url='Pelican', - flex_url='Flex'|safe) }} +

+{{ + _('Built with %(pelican_url)s using %(flex_url)s theme', + pelican_url='Pelican', + flex_url='Flex'|safe) +}} +{% if THEME_COLOR_ENABLE_USER_OVERRIDE %} | Switch to the dark | light - | - browser + {% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE %} + | + browser + + {% endif %} theme +{% endif %}

- + {% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE %} + darkSchemeWatch.addListener(detectThemeAndSwitchStyle); + {% endif %} + +{% endif %}