-
Notifications
You must be signed in to change notification settings - Fork 132
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
Support dark mode #635
base: master
Are you sure you want to change the base?
Support dark mode #635
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -656,26 +656,18 @@ | |
} | ||
|
||
/* Some additional styling taken form the Jupyter notebook CSS */ | ||
.jp-RenderedHTMLCommon table, | ||
div.rendered_html table { | ||
:is(.jp-RenderedHTMLCommon, div.rendered_html) table { | ||
border: none; | ||
border-collapse: collapse; | ||
border-spacing: 0; | ||
color: black; | ||
font-size: 12px; | ||
table-layout: fixed; | ||
} | ||
.jp-RenderedHTMLCommon thead, | ||
div.rendered_html thead { | ||
:is(.jp-RenderedHTMLCommon, div.rendered_html) thead { | ||
border-bottom: 1px solid black; | ||
vertical-align: bottom; | ||
} | ||
.jp-RenderedHTMLCommon tr, | ||
.jp-RenderedHTMLCommon th, | ||
.jp-RenderedHTMLCommon td, | ||
div.rendered_html tr, | ||
div.rendered_html th, | ||
div.rendered_html td { | ||
:is(.jp-RenderedHTMLCommon, div.rendered_html) :is(tr, th, td) { | ||
text-align: right; | ||
vertical-align: middle; | ||
padding: 0.5em 0.5em; | ||
|
@@ -684,16 +676,29 @@ | |
max-width: none; | ||
border: none; | ||
} | ||
.jp-RenderedHTMLCommon th, | ||
div.rendered_html th { | ||
:is(.jp-RenderedHTMLCommon, div.rendered_html) th { | ||
font-weight: bold; | ||
} | ||
.jp-RenderedHTMLCommon tbody tr:nth-child(odd), | ||
div.rendered_html tbody tr:nth-child(odd) { | ||
background: #f5f5f5; | ||
@media (prefers-color-scheme: light) { | ||
body:not([data-theme="dark"]) { | ||
--nbsphinx-table-row-odd-bg: #f5f5f5; | ||
} | ||
} | ||
.jp-RenderedHTMLCommon tbody tr:hover, | ||
div.rendered_html tbody tr:hover { | ||
@media (prefers-color-scheme: dark) { | ||
body:not([data-theme="light"]) { | ||
--nbsphinx-table-row-odd-bg: rgba(255, 255, 255, .1); | ||
} | ||
} | ||
body[data-theme="light"]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The sphinx-immaterial is a port of the mkdocs-material theme, and the attribute similar to furo's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Furthermore, I think |
||
--nbsphinx-table-row-odd-bg: #f5f5f5; | ||
} | ||
body[data-theme="dark"] { | ||
--nbsphinx-table-row-odd-bg: rgba(255, 255, 255, .1); | ||
} | ||
:is(.jp-RenderedHTMLCommon, div.rendered_html) tbody tr:nth-child(odd) { | ||
background: var(--nbsphinx-table-row-odd-bg); | ||
} | ||
:is(.jp-RenderedHTMLCommon, div.rendered_html) tbody tr:hover { | ||
background: rgba(66, 165, 245, 0.2); | ||
} | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This color (
rgba(255, 255, 255, .1)
) is essentially a shade of grey in dark mode. It might make more sense to usergba(127, 127, 127, 0.25)
for both light and dark modes. That way the foreground color doesn't also need compensation. Font colors are usually more absolutely white or black, but colored text will depend more on the saturation of the color used in text; this discrepancy doesn't arise often.I tested my color suggestion in furo, and the text is still legible.
The suggested alpha value could be adjusted (maybe lesser) to reduce the subtlety though.
While this comment is focused on the CSS selector
tr.row-odd
(or something more specifically used by nbsphinx), it could also be applied to the input code-block's added border. I have listed all the problematic hard-coded colors in #734 (comment)