Skip to content

Commit 4b7a0ed

Browse files
dpradapre-commit-ci[bot]bsipocz
authored
ENH: Adding scroll bars with proper cell tags (#454)
* Adding support to tags 'output_scroll', 'scroll-output' and 'scroll-input' * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Scrollbar width, height, border radius and colors added as variables. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Brigitta Sipőcz <bsipocz@gmail.com>
1 parent c4acf78 commit 4b7a0ed

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

myst_nb/static/mystnb.css

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
--mystnb-hide-prompt-opacity: 70%;
1313
--mystnb-source-border-radius: .4em;
1414
--mystnb-source-border-width: 1px;
15+
--mystnb-scrollbar-width: 0.3rem;
16+
--mystnb-scrollbar-height: 0.3rem;
17+
--mystnb-scrollbar-thumb-color: #c1c1c1;
18+
--mystnb-scrollbar-thumb-hover-color: #a0a0a0;
19+
--mystnb-scrollbar-thumb-border-radius: 0.25rem;
1520
}
1621

1722
/* Whole cell */
@@ -217,6 +222,73 @@ tbody span.pasted-inline img {
217222
max-height: none;
218223
}
219224

225+
226+
/* Adding scroll bars if tags: output_scroll, scroll-output, and scroll-input
227+
* On screens, we want to scroll, but on print show all
228+
*
229+
* It was before in https://github.com/executablebooks/sphinx-book-theme/blob/eb1b6baf098b27605e8f2b7b2979b17ebf1b9540/src/sphinx_book_theme/assets/styles/extensions/_myst-nb.scss
230+
*/
231+
232+
div.cell.tag_output_scroll div.cell_output, div.cell.tag_scroll-output div.cell_output {
233+
max-height: 24em;
234+
overflow-y: auto;
235+
max-width: 100%;
236+
overflow-x: auto;
237+
}
238+
239+
div.cell.tag_output_scroll div.cell_output::-webkit-scrollbar, div.cell.tag_scroll-output div.cell_output::-webkit-scrollbar {
240+
width: var(--mystnb-scrollbar-width);
241+
height: var(--mystnb-scrollbar-height);
242+
}
243+
244+
div.cell.tag_output_scroll div.cell_output::-webkit-scrollbar-thumb, div.cell.tag_scroll-output div.cell_output::-webkit-scrollbar-thumb {
245+
background: var(--mystnb-scrollbar-thumb-color);
246+
border-radius: var(--mystnb-scrollbar-thumb-border-radius);
247+
}
248+
249+
div.cell.tag_output_scroll div.cell_output::-webkit-scrollbar-thumb:hover, div.cell.tag_scroll-output div.cell_output::-webkit-scrollbar-thumb:hover {
250+
background: var(--mystnb-scrollbar-thumb-hover-color);
251+
}
252+
253+
@media print {
254+
div.cell.tag_output_scroll div.cell_output, div.cell.tag_scroll-output div.cell_output {
255+
max-height: unset;
256+
overflow-y: visible;
257+
max-width: unset;
258+
overflow-x: visible;
259+
}
260+
}
261+
262+
div.cell.tag_scroll-input div.cell_input {
263+
max-height: 24em;
264+
overflow-y: auto;
265+
max-width: 100%;
266+
overflow-x: auto;
267+
}
268+
269+
div.cell.tag_scroll-input div.cell_input::-webkit-scrollbar {
270+
width: var(--mystnb-scrollbar-width);
271+
height: var(--mystnb-scrollbar-height);
272+
}
273+
274+
div.cell.tag_scroll-input div.cell_input::-webkit-scrollbar-thumb {
275+
background: var(--mystnb-scrollbar-thumb-color);
276+
border-radius: var(--mystnb-scrollbar-thumb-border-radius);
277+
}
278+
279+
div.cell.tag_scroll-input div.cell_input::-webkit-scrollbar-thumb:hover {
280+
background: var(--mystnb-scrollbar-thumb-hover-color);
281+
}
282+
283+
@media print {
284+
div.cell.tag_scroll-input div.cell_input {
285+
max-height: unset;
286+
overflow-y: visible;
287+
max-width: unset;
288+
overflow-x: visible;
289+
}
290+
}
291+
220292
/* Font colors for translated ANSI escape sequences
221293
Color values are copied from Jupyter Notebook
222294
https://github.com/jupyter/notebook/blob/52581f8eda9b319eb0390ac77fe5903c38f81e3e/notebook/static/notebook/less/ansicolors.less#L14-L21

0 commit comments

Comments
 (0)