Allow setting different primary color for dark mode (fixes #35)

This commit is contained in:
daudix
2024-07-20 22:07:29 +03:00
parent 8b200e577d
commit 9a2b0aca95
3 changed files with 31 additions and 7 deletions

View File

@ -56,6 +56,10 @@ taxonomies = [{ name = "tags", feed = true }]
primary_color = "#ff7800" primary_color = "#ff7800"
# Same as primary_color, but with 20% opacity # Same as primary_color, but with 20% opacity
primary_color_alpha = "rgba(255, 120, 0, 0.2)" primary_color_alpha = "rgba(255, 120, 0, 0.2)"
# Ditto but for the dark mode.
# If not set regular variant will be used.
primary_color_dark = "#ffa348"
primary_color_dark_alpha = "rgba(255, 163, 72, 0.2)"
# Use emoji as a favicon. # Use emoji as a favicon.
# Only one emoji is being rendered, everything else is truncated. # Only one emoji is being rendered, everything else is truncated.
# emoji_favicon = "🦆🪶" # emoji_favicon = "🦆🪶"

View File

@ -94,7 +94,8 @@ To add your own or override existing styles, create a custom stylesheet and add
```toml ```toml
[extra] [extra]
stylesheets = [ stylesheets = [
"YOUR_STYLE.css" "YOUR_STYLE.css",
"ALSO_YOUR_STYLE.css"
] ]
``` ```
@ -111,19 +112,26 @@ You can also load stylesheets per page/section by setting them inside page's fro
```toml ```toml
[extra] [extra]
stylesheets = [ stylesheets = [
"YOUR_STYLE.css", "YOUR_PAGE_STYLE.css"
"ALSO_YOUR_STYLE.css"
] ]
``` ```
### Primary Color ### Primary Color
Duckquill respects chosen primary color everywhere, simply change the primary color in `config.toml`: Duckquill respects chosen primary color everywhere. To use your own, simply change the primary color in `config.toml`:
```toml ```toml
[extra] [extra]
primary_color = "COLOR_CODE" primary_color = "#3584e4"
primary_color_alpha = "COLOR_CODE" primary_color_alpha = "rgba(53, 132, 228, 0.2)"
```
Additionally, you can set a separate color for dark mode:
```toml
[extra]
primary_color_dark = "#ff7800"
primary_color_dark_alpha = "rgba(255, 120, 0, 0.2)"
``` ```
### Favicon ### Favicon

View File

@ -4,6 +4,9 @@
<meta name="description" content="{{ config.description }}" /> <meta name="description" content="{{ config.description }}" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="{{ config.extra.primary_color | default(value='#9a9996') }}" /> <meta name="theme-color" content="{{ config.extra.primary_color | default(value='#9a9996') }}" />
{%- if config.extra.primary_color_dark %}
<meta name="theme-color" content="{{ config.extra.primary_color_dark }}" media="(prefers-color-scheme:dark)" />
{%- endif %}
<link rel="canonical" href="{{ current_url | default(value='/') | safe }}" /> <link rel="canonical" href="{{ current_url | default(value='/') | safe }}" />
<title>{% include "partials/title.html" %}</title> <title>{% include "partials/title.html" %}</title>
@ -37,6 +40,15 @@
--primary-color: {{ config.extra.primary_color | default(value="#9a9996") }}; --primary-color: {{ config.extra.primary_color | default(value="#9a9996") }};
--primary-color-alpha: {{ config.extra.primary_color_alpha | default(value="rgba(154, 153, 150, 0.2)") }}; --primary-color-alpha: {{ config.extra.primary_color_alpha | default(value="rgba(154, 153, 150, 0.2)") }};
} }
{%- if config.extra.primary_color_dark %}
@media (prefers-color-scheme: dark) {
:root {
--primary-color: {{ config.extra.primary_color_dark }};
--primary-color-alpha: {{ config.extra.primary_color_dark_alpha }};
}
}
{%- endif %}
</style> </style>
{%- if config.extra.goatcounter %} {%- if config.extra.goatcounter %}