11/* Variables */
22: root {
3- --mystnb-source-bg-color : # f7f7f7 ;
4- --mystnb-stdout-bg-color : # fcfcfc ;
5- --mystnb-stderr-bg-color : # fdd ;
6- --mystnb-traceback-bg-color : # fcfcfc ;
7- --mystnb-source-border-color : # ccc ;
3+ /*
4+ Following palettes are generated by using https://m2.material.io/design/color/the-color-system.html#tools-for-picking-colors
5+ - neutral palette with #fcfcfc and danger palette with #ffdddd as base colors.
6+ 50 means lightest, 900 means darkest; less used intermediate shades are omitted
7+ but can be added when needed by accessing full palette from the above link.
8+ */
9+ --mystnb-neutral-palette-50 : # fcfcfc ;
10+ --mystnb-neutral-palette-100 : # f7f7f7 ;
11+ --mystnb-neutral-palette-400 : # cccccc ;
12+ --mystnb-neutral-palette-500 : # afafaf ;
13+ --mystnb-neutral-palette-800 : # 505050 ;
14+ --mystnb-neutral-palette-900 : # 2d2d2d ;
15+
16+ --mystnb-danger-palette-50 : # ffdddd ;
17+ --mystnb-danger-palette-100 : # f5acad ;
18+ --mystnb-danger-palette-400 : # c42029 ;
19+ --mystnb-danger-palette-500 : # b40008 ;
20+ --mystnb-danger-palette-800 : # 850010 ;
21+ --mystnb-danger-palette-900 : # 680010 ;
22+
23+ /* MyST-NB specific variables; colors should be logically picked from palettes */
24+ --mystnb-source-bg-color : var (--mystnb-neutral-palette-100 );
25+ --mystnb-stdout-bg-color : var (--mystnb-neutral-palette-50 );
26+ --mystnb-stderr-bg-color : var (--mystnb-danger-palette-50 );
27+ --mystnb-traceback-bg-color : var (--mystnb-neutral-palette-50 );
28+ --mystnb-source-border-color : var (--mystnb-neutral-palette-400 );
829 --mystnb-source-margin-color : green;
9- --mystnb-stdout-border-color : # f7f7f7 ;
10- --mystnb-stderr-border-color : # f7f7f7 ;
11- --mystnb-traceback-border-color : # ffd6d6 ;
30+ --mystnb-stdout-border-color : var ( --mystnb-neutral-palette-100 ) ;
31+ --mystnb-stderr-border-color : var ( --mystnb-neutral-palette-100 ) ;
32+ --mystnb-traceback-border-color : var ( --mystnb-danger-palette-100 ) ;
1233 --mystnb-hide-prompt-opacity : 70% ;
1334 --mystnb-source-border-radius : .4em ;
1435 --mystnb-source-border-width : 1px ;
36+ --mystnb-scrollbar-width : 0.3rem ;
37+ --mystnb-scrollbar-height : 0.3rem ;
38+ --mystnb-scrollbar-thumb-color : var (--mystnb-neutral-palette-400 );
39+ --mystnb-scrollbar-thumb-hover-color : var (--mystnb-neutral-palette-500 );
40+ --mystnb-scrollbar-thumb-border-radius : 0.25rem ;
1541}
1642
43+ /* Override colors in dark theme */
44+ html [data-theme = "dark" ] {
45+ --mystnb-source-bg-color : var (--mystnb-neutral-palette-800 );
46+ --mystnb-stdout-bg-color : var (--mystnb-neutral-palette-900 );
47+ --mystnb-stderr-bg-color : var (--mystnb-danger-palette-900 );
48+ --mystnb-traceback-bg-color : var (--mystnb-neutral-palette-900 );
49+ --mystnb-source-border-color : var (--mystnb-neutral-palette-500 );
50+ --mystnb-stdout-border-color : var (--mystnb-neutral-palette-800 );
51+ --mystnb-stderr-border-color : var (--mystnb-neutral-palette-800 );
52+ --mystnb-traceback-border-color : var (--mystnb-danger-palette-800 );
53+ --mystnb-scrollbar-thumb-color : var (--mystnb-neutral-palette-500 );
54+ --mystnb-scrollbar-thumb-hover-color : var (--mystnb-neutral-palette-400 );
55+ }
56+
57+
1758/* Whole cell */
1859div .container .cell {
1960 padding-left : 0 ;
@@ -35,8 +76,7 @@ div.container.cell {
3576}
3677
3778/* Input cells */
38- div .cell div .cell_input ,
39- div .cell details .above-input > summary {
79+ div .cell > div .cell_input {
4080 padding-left : 0em ;
4181 padding-right : 0em ;
4282 border : var (--mystnb-source-border-width ) var (--mystnb-source-border-color ) solid;
@@ -69,8 +109,9 @@ div.cell_output div.output>div.highlight {
69109 box-shadow : none;
70110}
71111
72- .cell_output .output .text_plain ,
73- .cell_output .output .stream {
112+ .cell_output .output .text_plain : not (: has (.highlight )),
113+ .cell_output .output .stream : not (: has (.highlight )) {
114+ /* plain (or stream of) output, not containing a pygments-highlighted block */
74115 background : var (--mystnb-stdout-bg-color );
75116 border : 1px solid var (--mystnb-stdout-border-color );
76117}
@@ -85,57 +126,69 @@ div.cell_output div.output>div.highlight {
85126 border : 1px solid var (--mystnb-traceback-border-color );
86127}
87128
88- /* Collapsible cell content */
89- div .cell details .above-input div .cell_input {
90- border-top-left-radius : 0 ;
91- border-top-right-radius : 0 ;
92- border-top : var (--mystnb-source-border-width ) var (--mystnb-source-border-color ) dashed;
129+ /* --- Collapsible cell content --- */
130+
131+ /*
132+ encourage summary container to blend in with its parent.
133+ p.admonition-title should hold the title styles.
134+ */
135+ div .cell details .hide summary {
136+ border-left : unset;
137+ padding : inherit;
138+ margin : inherit;
139+ background-color : inherit;
93140}
94141
95- div .cell div .cell_input .above-output-prompt {
96- border-bottom-left-radius : 0 ;
97- border-bottom-right-radius : 0 ;
142+ /* Neighboring input/output elements - spacing, borders */
143+ div .cell details .hide .above-input + details .below-input ,
144+ div .cell div .cell_input + details .below-input
145+ {
146+ margin-top : 0 ;
98147}
99148
100- div .cell details .above-input > summary {
149+ div .cell details .hide .above-input : has (+ details .below-input ),
150+ div .cell div .cell_input : has (+ details .below-input )
151+ {
152+ margin-bottom : 0 ;
153+ }
154+
155+ div .cell : has (> * : nth-child (2 )) div .cell_input : first-child ,
156+ div .cell : has (> * : nth-child (2 )) details : first-child
157+ {
101158 border-bottom-left-radius : 0 ;
102159 border-bottom-right-radius : 0 ;
103- border-bottom : var (--mystnb-source-border-width ) var (--mystnb-source-border-color ) dashed;
104- padding-left : 1em ;
105- margin-bottom : 0 ;
106160}
107161
108- div .cell details .above-output > summary {
109- background-color : var (--mystnb-source-bg-color );
110- padding-left : 1em ;
111- padding-right : 0em ;
112- border : var (--mystnb-source-border-width ) var (--mystnb-source-border-color ) solid;
113- border-radius : var (--mystnb-source-border-radius );
114- border-left-color : var (--mystnb-source-margin-color );
115- border-left-width : medium;
162+ div .cell : has (> * : nth-child (2 )) div .cell_input : last-child ,
163+ div .cell : has (> * : nth-child (2 )) details : last-child
164+ {
165+ border-top-left-radius : 0 ;
166+ border-top-right-radius : 0 ;
116167}
117168
118- div .cell details .below-input > summary {
119- background-color : var (--mystnb-source-bg-color );
120- padding-left : 1em ;
121- padding-right : 0em ;
122- border : var (--mystnb-source-border-width ) var (--mystnb-source-border-color ) solid;
123- border-top : none;
124- border-bottom-left-radius : var (--mystnb-source-border-radius );
125- border-bottom-right-radius : var (--mystnb-source-border-radius );
126- border-left-color : var (--mystnb-source-margin-color );
127- border-left-width : medium;
169+ /* intra-label styles for collapsibles */
170+ div .cell .container details .hide .above-input > summary ,
171+ div .cell .container details .hide .below-input > summary ,
172+ div .cell .container details .hide .above-output > summary
173+ {
174+ display : block;
175+ border-left : none;
128176}
129177
130- div .cell details .hide > summary > span {
131- opacity : var (--mystnb-hide-prompt-opacity );
178+ div .cell details .hide > summary > p .admonition-title {
179+ display : list-item;
180+ margin-bottom : 0 ;
181+ }
182+
183+ div .cell details .hide : not ([open ]) {
184+ padding-bottom : 0 ;
132185}
133186
134- div .cell details .hide [open ]> summary > span .collapsed {
187+ div .cell details .hide [open ]> summary > p .collapsed {
135188 display : none;
136189}
137190
138- div .cell details .hide : not ([open ])> summary > span .expanded {
191+ div .cell details .hide : not ([open ])> summary > p .expanded {
139192 display : none;
140193}
141194
@@ -154,6 +207,11 @@ div.cell details.hide[open]>summary~* {
154207 animation : collapsed-fade-in 0.3s ease-in-out;
155208}
156209
210+ /* Clear conflicting styles for details and admonitions set by some themes */
211+ div .cell details .admonition summary ::before {
212+ content : unset;
213+ }
214+
157215/* Math align to the left */
158216.cell_output .MathJax_Display {
159217 text-align : left !important ;
@@ -217,6 +275,80 @@ tbody span.pasted-inline img {
217275 max-height : none;
218276}
219277
278+
279+ /* Adding scroll bars if tags: output_scroll, scroll-output, and scroll-input
280+ * On screens, we want to scroll, but on print show all
281+ *
282+ * It was before in https://github.com/executablebooks/sphinx-book-theme/blob/eb1b6baf098b27605e8f2b7b2979b17ebf1b9540/src/sphinx_book_theme/assets/styles/extensions/_myst-nb.scss
283+ */
284+ div .cell : is (
285+ .tag_output_scroll ,
286+ .tag_scroll-output ,
287+ .config_scroll_outputs
288+ )
289+ div .cell_output ,
290+ div .cell .tag_scroll-input div .cell_input {
291+ max-height : 24em ;
292+ overflow-y : auto;
293+ max-width : 100% ;
294+ overflow-x : auto;
295+ }
296+
297+ div .cell .config_scroll_outputs div .cell_output : has (img ) {
298+ /* If the output cell has image(s), allow it to take 90% of viewport height
299+ but still bounded between 24em and 60em */
300+ max-height : clamp (24em , 90vh , 60em );
301+ }
302+
303+ /* Custom scrollbars */
304+ div .cell : is (
305+ .tag_output_scroll ,
306+ .tag_scroll-output ,
307+ .config_scroll_outputs
308+ )
309+ div .cell_output ::-webkit-scrollbar ,
310+ div .cell .tag_scroll-input div .cell_input ::-webkit-scrollbar {
311+ width : var (--mystnb-scrollbar-width );
312+ height : var (--mystnb-scrollbar-height );
313+ }
314+
315+ div .cell : is (
316+ .tag_output_scroll ,
317+ .tag_scroll-output ,
318+ .config_scroll_outputs
319+ )
320+ div .cell_output ::-webkit-scrollbar-thumb ,
321+ div .cell .tag_scroll-input div .cell_input ::-webkit-scrollbar-thumb {
322+ background : var (--mystnb-scrollbar-thumb-color );
323+ border-radius : var (--mystnb-scrollbar-thumb-border-radius );
324+ }
325+
326+ div .cell : is (
327+ .tag_output_scroll ,
328+ .tag_scroll-output ,
329+ .config_scroll_outputs
330+ )
331+ div .cell_output ::-webkit-scrollbar-thumb : hover ,
332+ div .cell .tag_scroll-input div .cell_input ::-webkit-scrollbar-thumb : hover {
333+ background : var (--mystnb-scrollbar-thumb-hover-color );
334+ }
335+
336+ /* In print mode, unset scroll styles */
337+ @media print {
338+ div .cell : is (
339+ .tag_output_scroll ,
340+ .tag_scroll-output ,
341+ .config_scroll_outputs
342+ )
343+ div .cell_output ,
344+ div .cell .tag_scroll-input div .cell_input {
345+ max-height : unset;
346+ overflow-y : visible;
347+ max-width : unset;
348+ overflow-x : visible;
349+ }
350+ }
351+
220352/* Font colors for translated ANSI escape sequences
221353Color values are copied from Jupyter Notebook
222354https://github.com/jupyter/notebook/blob/52581f8eda9b319eb0390ac77fe5903c38f81e3e/notebook/static/notebook/less/ansicolors.less#L14-L21
0 commit comments