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

Custom primary and accent color option #122

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions sphinx_material/sphinx_material/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@
{% if theme_touch_icon %}
<link rel="apple-touch-icon" href="{{ pathto('_static/' ~ theme_touch_icon, 1) }}"/>
{% endif %}
<style>
:root {
--custom-color-primary: #{{ theme_custom_color_primary }};
--custom-color-accent: #{{ theme_custom_color_accent }};
}
</style>
{{ super() }}
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ table.longtable.docutils.align-default {
}
}

[data-md-color-primary=custom] .md-nav__extra_link:active {
color: var(--custom-color-primary)
}

[data-md-color-primary=custom] .md-nav__item--nested > .md-nav__extra_link {
color: inherit
}

[data-md-color-primary=red] .md-nav__extra_link:active {
color: #ef5350
}
Expand Down Expand Up @@ -327,6 +335,10 @@ table.longtable.docutils.align-default {
color: inherit
}

[data-md-color-accent=custom] .md-nav__extra_link:focus, [data-md-color-accent=custom] .md-nav__extra_link:hover {
color: var(--custom-color-accent)
}

[data-md-color-accent=red] .md-nav__extra_link:focus, [data-md-color-accent=red] .md-nav__extra_link:hover {
color: #ff1744
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,28 @@ button[data-md-color-primary]:hover {
opacity: .75
}

button[data-md-color-primary=custom] {
background-color: var(--custom-color-primary)
}

[data-md-color-primary=custom] .md-typeset a {
color: var(--custom-color-primary)
}

[data-md-color-primary=custom] .md-header,
[data-md-color-primary=custom] .md-hero {
background-color: var(--custom-color-primary)
}

[data-md-color-primary=custom] .md-nav__link--active,
[data-md-color-primary=custom] .md-nav__link:active {
color: var(--custom-color-primary)
}

[data-md-color-primary=custom] .md-nav__item--nested>.md-nav__link {
color: inherit
}

button[data-md-color-primary=red] {
background-color: #ef5350
}
Expand Down Expand Up @@ -1138,6 +1160,10 @@ button[data-md-color-accent=deep-orange] {
}

@media only screen and (max-width:59.9375em) {
[data-md-color-primary=custom] .md-nav__source {
background-color: var(--custom-color-primary);
opacity: 0.0325;
}
[data-md-color-primary=red] .md-nav__source {
background-color: rgba(190, 66, 64, .9675)
}
Expand Down Expand Up @@ -1202,6 +1228,9 @@ button[data-md-color-accent=deep-orange] {
}

@media only screen and (max-width:76.1875em) {
html [data-md-color-primary=custom] .md-nav--primary .md-nav__title--site {
background-color: var(--custom-color-primary)
}
html [data-md-color-primary=red] .md-nav--primary .md-nav__title--site {
background-color: #ef5350
}
Expand Down Expand Up @@ -1269,6 +1298,9 @@ button[data-md-color-accent=deep-orange] {
}

@media only screen and (min-width:76.25em) {
[data-md-color-primary=custom] .md-tabs {
background-color: var(--custom-color-primary)
}
[data-md-color-primary=red] .md-tabs {
background-color: #ef5350
}
Expand Down
8 changes: 6 additions & 2 deletions sphinx_material/sphinx_material/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ theme_color = #3f51b5
# Primary colors:
# red, pink, purple, deep-purple, indigo, blue, light-blue, cyan,
# teal, green, light-green, lime, yellow, amber, orange, deep-orange,
# brown, grey, blue-grey, white
# brown, grey, blue-grey, white, custom
color_primary = blue-grey

# Accent colors:
# red, pink, purple, deep-purple, indigo, blue, light-blue, cyan,
# teal, green, light-green, lime, yellow, amber, orange, deep-orange
# teal, green, light-green, lime, yellow, amber, orange, deep-orange, custom
color_accent = blue

# Custom colors:
custom_color_primary = 546e7a
custom_color_accent = 448aff

# Content Minification
# Minify pages after creation using htmlmin
html_minify = False
Expand Down