| 1 |
/** |
| 2 |
* Styles for various Sphinx execution libraries to display pre-executed notebooks. |
| 3 |
* For now, where these define output sections, we simply revert their background |
| 4 |
* to be a "light theme" background. This ensures that inputs/outputs behave similarly, |
| 5 |
* because the CSS is often controlled by each package. |
| 6 |
* In the future, we might add dark theme support for specific packages. |
| 7 |
*/ |
| 8 |
|
| 9 |
/******************************************************************************* |
| 10 |
* nbsphinx |
| 11 |
*/ |
| 12 |
html div.rendered_html, |
| 13 |
// NBsphinx ipywidgets output selector |
| 14 |
html .jp-RenderedHTMLCommon { |
| 15 |
// Add some margin around the element box for the focus ring. Otherwise the |
| 16 |
// focus ring gets clipped because the containing elements have `overflow: |
| 17 |
// hidden` applied to them (via the `.lm-Widget` selector) |
| 18 |
margin: $focus-ring-width; |
| 19 |
|
| 20 |
table { |
| 21 |
table-layout: auto; |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
.bd-content .nboutput { |
| 26 |
.output_area { |
| 27 |
&.rendered_html, |
| 28 |
.jp-RenderedHTMLCommon { |
| 29 |
// pandas |
| 30 |
table.dataframe { |
| 31 |
@include table-colors; |
| 32 |
|
| 33 |
tbody { |
| 34 |
tr:hover { |
| 35 |
background-color: var(--pst-color-table-row-hover-bg); |
| 36 |
} |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
// Dark theme special-cases |
| 42 |
html[data-theme="dark"] & { |
| 43 |
&.rendered_html:not(:has(table.dataframe)), |
| 44 |
// ipywidgets |
| 45 |
.widget-subarea { |
| 46 |
@include cell-output-background; |
| 47 |
} |
| 48 |
|
| 49 |
&.stderr { |
| 50 |
background-color: var(--pst-color-danger); |
| 51 |
} |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
// Add extra padding to the final item in an nbsphinx container |
| 57 |
div.nblast.container { |
| 58 |
margin-bottom: 1rem; |
| 59 |
} |
| 60 |
|
| 61 |
// Override nbsphinx's colors for notebook cell prompts because they do not have |
| 62 |
// sufficient contrast. Colors chosen from accessible-pygments |
| 63 |
// a11y-high-contrast-{light,dark} themes. |
| 64 |
|
| 65 |
// Notebook cell input line number. Replace nbsphinx's low contrast blue with |
| 66 |
// higher contrast blues. |
| 67 |
.nbinput.container .prompt pre { |
| 68 |
html[data-theme="light"] & { |
| 69 |
// Copied from accessible-pygments [a11y-high-contrast-light](https://github.com/Quansight-Labs/accessible-pygments/tree/main/a11y_pygments/a11y_high_contrast_light) |
| 70 |
color: #005b82; |
| 71 |
} |
| 72 |
|
| 73 |
html[data-theme="dark"] & { |
| 74 |
// Copied from accessible-pygments [a11y-high-contrast-dark](https://github.com/Quansight-Labs/accessible-pygments/tree/main/a11y_pygments/a11y_high_contrast_dark) |
| 75 |
color: #00e0e0; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
// Notebook cell output line number. Replace nbsphinx's low contrast red with |
| 80 |
// higher contrast red / orange. |
| 81 |
.nboutput.container .prompt pre { |
| 82 |
html[data-theme="light"] & { |
| 83 |
// Copied from accessible-pygments [a11y-high-contrast-light](https://github.com/Quansight-Labs/accessible-pygments/tree/main/a11y_pygments/a11y_high_contrast_light) |
| 84 |
color: #a12236; |
| 85 |
} |
| 86 |
|
| 87 |
html[data-theme="dark"] & { |
| 88 |
// Copied from accessible-pygments [a11y-high-contrast-dark](https://github.com/Quansight-Labs/accessible-pygments/tree/main/a11y_pygments/a11y_high_contrast_dark) |
| 89 |
color: #ffa07a; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
/******************************************************************************* |
| 94 |
* myst NB |
| 95 |
*/ |
| 96 |
|
| 97 |
div.cell_output .output { |
| 98 |
max-width: 100%; |
| 99 |
overflow-x: auto; |
| 100 |
} |
| 101 |
|
| 102 |
.bd-content div.cell_output { |
| 103 |
// pandas |
| 104 |
table.dataframe { |
| 105 |
@include table-colors; |
| 106 |
|
| 107 |
tbody { |
| 108 |
tr:hover { |
| 109 |
background-color: var(--pst-color-table-row-hover-bg); |
| 110 |
} |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
html[data-theme="dark"] & { |
| 115 |
img, |
| 116 |
.text_html:not(:has(table.dataframe)), |
| 117 |
// ipywidgets |
| 118 |
.widget-subarea { |
| 119 |
@include cell-output-background; |
| 120 |
} |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
// Prevent tables from scrunching together |
| 125 |
.bd-content { |
| 126 |
div.cell_input { |
| 127 |
display: flex; |
| 128 |
flex-direction: column; |
| 129 |
justify-content: stretch; |
| 130 |
} |
| 131 |
|
| 132 |
div.cell_input, |
| 133 |
div.output { |
| 134 |
border-radius: $admonition-border-radius; |
| 135 |
} |
| 136 |
|
| 137 |
div.output { |
| 138 |
table { |
| 139 |
table-layout: auto; |
| 140 |
} |
| 141 |
} |
| 142 |
} |