Skip to content

Commit f222ef5

Browse files
authored
ENH: Add dark mode to website (#10523)
1 parent df2a581 commit f222ef5

15 files changed

+1887
-281
lines changed

doc/_static/mne_logo.svg

Lines changed: 864 additions & 174 deletions
Loading

doc/_static/mne_logo_dark.svg

Lines changed: 866 additions & 0 deletions
Loading

doc/_static/mne_logo_small.svg

Lines changed: 82 additions & 80 deletions
Loading

doc/_static/style.css

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88

99
}
1010

11+
html[data-theme="light"] {
12+
--mne-color-github: #000;
13+
--mne-color-discourse: #231e20;
14+
--pst-color-border-rgba: rgba(0, 0, 0, 0.125);
15+
--pst-color-background-rgba: rgba(0, 0, 0, 0.03);
16+
}
17+
html[data-theme="dark"] {
18+
--mne-color-github: #fff;
19+
--mne-color-discourse: #d1c498;
20+
--pst-color-border-rgba: rgba(201, 201, 201, 0.25);
21+
--pst-color-background-rgba: rgba(255, 255, 255, 0.08);
22+
}
23+
1124
/* ************************************************************ Sphinx fixes */
1225
dl.field-list {
1326
grid-template-columns: auto 1fr;
@@ -156,17 +169,28 @@ div.frontpage-gallery:hover .fadeout {
156169
opacity: 0.0;
157170
transition: 200ms linear;
158171
}
172+
div.card img.institution {
173+
background-color: #fffe;
174+
}
175+
div.card {
176+
border: 1px solid var(--pst-color-border-rgba);
177+
background-color: rgb(var(--pst-color-background));
178+
}
179+
.card-header {
180+
border-bottom-color: var(--pst-color-border-rgba);
181+
background-color: var(--pst-color-background-rgba);
182+
}
159183

160184
/* ****************************************************** navbar quick links */
161185

162186
i.fa-github-square:before {
163-
color: #000;
187+
color: rgb(var(--mne-color-github));
164188
}
165189
i.fa-twitter-square:before {
166190
color: #55acee;
167191
}
168192
i.fa-discourse:before {
169-
color: #231e20;
193+
color: rgb(var(--mne-color-discourse));
170194
}
171195
i.fa-discord:before {
172196
color: #7289da; /* 99aab5 is also in-brand for discord */

doc/_templates/homepage.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="col-12 col-sm-6 col-lg-4 my-2">
66
<div class="card frontpage-gallery">
77
<a href="{{ item.url }}">
8-
<img class="card-img" src="{{ item.img if item.img.startswith('http') else pathto('_images/' + item.img, 1) }}" alt="{{ item.alt }}">
8+
<img class="card-img institution" src="{{ item.img if item.img.startswith('http') else pathto('_images/' + item.img, 1) }}" alt="{{ item.alt }}">
99
<div class="card-img-overlay px-3 py-1">
1010
<p class="lead mb-1 fadeout">{{ item.title }}</p>
1111
<p class="card-text fadeout">{{ item.text }}</p>
@@ -23,7 +23,7 @@
2323
{% for item in funders -%}
2424
<div class="card my-1 mx-2 border-light" style="{{ 'width: ' + item.size + 'rem;' }}">
2525
<a href="{{ pathto('funding.html', 1) }}">
26-
<img class="card-img" src="{{ pathto('_static/funding/' + item.img, 1) }}" title="{{ item.title }}" alt="{{ item.title }}">
26+
<img class="card-img institution" src="{{ pathto('_static/funding/' + item.img, 1) }}" title="{{ item.title }}" alt="{{ item.title }}">
2727
</a>
2828
</div>
2929
{% endfor %}
@@ -36,7 +36,7 @@
3636
{% for inst in institutions -%}
3737
<div class="card my-1 mx-2 border-light" style="{{ 'width: ' + inst.size + 'rem;' }}">
3838
<a href="{{ inst.url }}">
39-
<img class="card-img" src="{{ pathto('_static/institution_logos/' + inst.img, 1) }}" title="{{ inst.name }}" alt="{{ inst.name }}"/>
39+
<img class="card-img institution" src="{{ pathto('_static/institution_logos/' + inst.img, 1) }}" title="{{ inst.name }}" alt="{{ inst.name }}"/>
4040
</a>
4141
</div>
4242
{% endfor %}

doc/conf.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ def append_attr_meth_examples(app, what, name, obj, options, lines):
575575
'use_edit_page_button': False,
576576
'navigation_with_keys': False,
577577
'show_toc_level': 1,
578-
'navbar_end': ['version-switcher', 'navbar-icon-links'],
578+
'navbar_end': ['theme-switcher', 'version-switcher', 'navbar-icon-links'],
579579
'footer_items': ['copyright'],
580580
'google_analytics_id': 'UA-37225609-1',
581581
'switcher': {
@@ -635,6 +635,9 @@ def append_attr_meth_examples(app, what, name, obj, options, lines):
635635
# variables to pass to HTML templating engine
636636
html_context = {
637637
'build_dev_html': bool(int(os.environ.get('BUILD_DEV_HTML', False))),
638+
'default_mode': 'auto',
639+
'pygment_light_style': 'tango',
640+
'pygment_dark_style': 'native',
638641
'funders': [
639642
dict(img='nih.png', size='3', title='National Institutes of Health'),
640643
dict(img='nsf.png', size='3.5',

doc/index.rst

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,22 @@ MNE-Python Homepage
1212

1313
.. LOGO
1414
15+
.. raw:: html
16+
17+
<script type="text/javascript">
18+
var observer = new MutationObserver(function(mutations) {
19+
const dark = document.documentElement.dataset.theme == 'dark';
20+
document.getElementsByClassName('mainlogo')[0].src = dark ? '_static/mne_logo_dark.svg' : "_static/mne_logo.svg";
21+
})
22+
observer.observe(document.documentElement, {attributes: true, attributeFilter: ['data-theme']});
23+
</script>
24+
<link rel="preload" href="_static/mne_logo_dark.svg" as="image">
25+
1526
.. image:: _static/mne_logo.svg
1627
:alt: MNE-Python
17-
:class: logo
28+
:class: logo, mainlogo
1829
:align: center
1930

20-
2131
.. rst-class:: h4 text-center font-weight-light my-4
2232

2333
Open-source Python package for exploring, visualizing, and analyzing

doc/install/install_type_selector.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h6 class="card-subtitle mb-2 mt-2 text-muted">For Beginners</h6>
1212
everything to get you started!
1313
</p>
1414
</div>
15-
<div class="card-footer bg-white border-white"">
15+
<div class="card-footer"">
1616
<a class="btn btn-primary font-weight-bold shadow-sm mb-3" role="button" href="installers.html">
1717
<i class="fa fa-cloud-download-alt"></i>&ensp;Download Installers
1818
</a>
@@ -31,7 +31,7 @@ <h6 class="card-subtitle mb-2 mt-2 text-muted">For Advanced Users</h6>
3131
<code>conda</code>!
3232
</p>
3333
</div>
34-
<div class="card-footer bg-white border-white"">
34+
<div class="card-footer">
3535
<a class="btn btn-primary font-weight-bold shadow-sm mb-3" role="button" href="manual_install.html">
3636
<i class="fa fa-wrench"></i>&ensp;Setup Instructions
3737
</a>

0 commit comments

Comments
 (0)