Skip to content

Commit 21a924c

Browse files
committed
adopt new workflow for style.css
1 parent 3e0468b commit 21a924c

File tree

3 files changed

+141
-1
lines changed

3 files changed

+141
-1
lines changed

notebooks/Makefile.style

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919
# file if needed, to avoid errors in the build process)
2020

2121

22-
style: _static/style.html
22+
style: _static/style.css _static/style.html
2323

24+
_static/style.css: _static/style_common.css _static/style_local.css
25+
(echo '/* autogenerated, DO NOT EDIT ME ! - edit style_common.css or style_local.css instead */'; \
26+
cat $^ ) > $@
27+
28+
# need to remove css comments (one one line only please) from html file
2429
_static/style.html: _static/style_common.css _static/style_local.css
2530
(echo '<!-- autogenerated, DO NOT EDIT ME ! - edit style_common.css or style_local.css instead -->'; \
2631
echo '<style>'; \

notebooks/_static/style.css

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/* autogenerated, DO NOT EDIT ME ! - edit style_common.css or style_local.css instead */
2+
/*
3+
* trying to improve the rendering of jupyter notebooks
4+
* particularly wrt spacing around lists and paragraphs
5+
* as well as other miscellanous tweaks
6+
*
7+
* .bd-container targets jupyter-book output
8+
* .myst targets jupyter-lab rendering
9+
*/
10+
11+
/* use more horizontal space when available
12+
* this is otherwise arbitrarily set to 88rem
13+
*/
14+
15+
@media (min-width: 960px) {
16+
.bd-page-width {
17+
max-width: initial !important;
18+
}
19+
20+
/* but keep the upper-left logo to grow too much */
21+
.navbar-brand.logo>img {
22+
max-width: 250px;
23+
max-height: 170px;
24+
}
25+
}
26+
27+
/* make the right-hand-side index background transparent */
28+
#bd-toc-nav {
29+
background-color: rgb(0 0 0 / 0);
30+
}
31+
32+
33+
/* not too much space between paragraphs */
34+
:is(.bd-container, .myst) :is(p, ul) {
35+
margin-bottom: 0.5em !important;
36+
margin-top: 0.5em !important;
37+
}
38+
39+
.myst :where(:is(p, ul)):not(:where([class~=not-prose], [class~=not-prose] *)) {
40+
margin-bottom: 0.5em !important;
41+
margin-top: 0.5em !important;
42+
}
43+
44+
45+
/* not too much space around lists */
46+
:is(.bd-container, .myst) *+ :is(ol, ul),
47+
/* a paragraph that is just above a list should not have a bottom margin
48+
* thanks SO
49+
* https://stackoverflow.com/questions/1817792/is-there-a-previous-sibling-selector
50+
*/
51+
:is(.bd-container, .myst) p:has(+ :is(ol, ul)) {
52+
margin-bottom: initial !important;
53+
}
54+
55+
:is(.bd-container, .myst) li>ul {
56+
margin-top: 0.1em !important;
57+
}
58+
59+
60+
/* execution output cells */
61+
div.cell div.cell_output .output pre {
62+
background-color: #f8fff8 !important;
63+
border: 0.3px solid blue !important;
64+
}
65+
66+
html[data-theme='dark'] div.cell div.cell_output .output pre {
67+
background-color: #064b06 !important;
68+
}
69+
70+
div.prompt.input_prompt, div.prompt.output_prompt {
71+
opacity: 0.6;
72+
}
73+
74+
/* jupyterlab-myst and tables */
75+
:is(.bd-container, .myst) table td {
76+
padding: initial !important;
77+
}
78+
79+
:is(.bd-container, .myst) table tbody tr:nth-child(odd) {
80+
background-color: #fdfdfd;
81+
}
82+
83+
:is(.bd-container, .myst) table tbody tr:nth-child(even) {
84+
background-color: #fbfbfb;
85+
}
86+
87+
:is(.bd-container, .myst) table :is(thead, tfoot) tr {
88+
background-color: #f8f8f8;
89+
}
90+
91+
html[data-theme='dark'] {
92+
& :is(.bd-container, .myst) table tbody tr:nth-child(odd) {
93+
background-color: #020202;
94+
}
95+
96+
& :is(.bd-container, .myst) table tbody tr:nth-child(even) {
97+
background-color: #040404;
98+
}
99+
100+
& :is(.bd-container, .myst) table :is(thead, tfoot) tr {
101+
background-color: #080808;
102+
}
103+
}
104+
105+
/* space before admonitions */
106+
:is(.bd-container, .myst) div.admonition>.admonition-title+* {
107+
margin-top: 0px !important;
108+
}
109+
110+
/* standard admonition classes */
111+
.admonition-smaller {
112+
font-size: smaller;
113+
line-height: 1.2;
114+
}
115+
116+
.admonition-small {
117+
font-size: small;
118+
line-height: 1.2;
119+
}
120+
121+
.admonition-x-small {
122+
font-size: x-small;
123+
line-height: 1.2;
124+
}
125+
126+
/* slight gradient for corriges */
127+
.corrige {
128+
background-image: radial-gradient(circle at top left, #d1effa, #e2f9cd);
129+
}
130+
131+
html[data-theme='dark'] .corrige {
132+
background-image: radial-gradient(circle at top left, #0e3852, #0c5517);
133+
}
134+
/* no longer need a local style */

notebooks/_static/style.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,5 @@
107107

108108
html[data-theme='dark'] .corrige {
109109
background-image: radial-gradient(circle at top left, #0e3852, #0c5517);
110+
}
110111
</style>

0 commit comments

Comments
 (0)