| 1 |
/** |
| 2 |
* Admonitions and blocks of styled content. |
| 3 |
* Admonitions CSS originally inspired by https://squidfunk.github.io/mkdocs-material/getting-started/ |
| 4 |
*/ |
| 5 |
$admonition-border-radius: 0.25rem; |
| 6 |
$admonition-left-border-width: 0.2rem; |
| 7 |
|
| 8 |
div.admonition, |
| 9 |
.admonition { |
| 10 |
margin: 1.5625em auto; |
| 11 |
padding: 0 0.6rem 0.8rem; |
| 12 |
overflow: hidden; |
| 13 |
|
| 14 |
/* break-inside has replaced page-break-inside and is widely usable since 2019 */ |
| 15 |
break-inside: avoid; |
| 16 |
border-left: $admonition-left-border-width solid; |
| 17 |
border-color: var(--pst-color-info); |
| 18 |
border-radius: $admonition-border-radius; |
| 19 |
background-color: var(--pst-color-on-background); |
| 20 |
|
| 21 |
@include box-shadow; |
| 22 |
|
| 23 |
// Last item should have no spacing since we'll control that w/ padding |
| 24 |
*:last-child { |
| 25 |
margin-bottom: 0; |
| 26 |
} |
| 27 |
|
| 28 |
// Items after the title should be indented |
| 29 |
p.admonition-title ~ * { |
| 30 |
margin-left: 1.4rem; |
| 31 |
margin-right: 1.4rem; |
| 32 |
} |
| 33 |
|
| 34 |
// Lists need to have left margin so they don't spill into it |
| 35 |
> ol, |
| 36 |
> ul { |
| 37 |
margin-left: 1em; |
| 38 |
} |
| 39 |
|
| 40 |
// Defaults for all admonitions |
| 41 |
> .admonition-title { |
| 42 |
$padding-top: 0.4rem; |
| 43 |
$icon-width: 1rem; |
| 44 |
$icon-margin-x: 0.5rem; |
| 45 |
|
| 46 |
margin: 0 -0.6rem; |
| 47 |
padding: 0.4rem 0.6rem $padding-top calc($icon-width + 2 * $icon-margin-x); |
| 48 |
font-weight: var(--pst-admonition-font-weight-heading); |
| 49 |
position: relative; |
| 50 |
|
| 51 |
@include legacy-backdrop-placeholder; |
| 52 |
|
| 53 |
background-color: var(--pst-color-info-bg); |
| 54 |
|
| 55 |
// now that we use solid colors we want the title on top |
| 56 |
z-index: 1; |
| 57 |
|
| 58 |
&::after { |
| 59 |
position: absolute; |
| 60 |
top: $padding-top; // align icon with title text |
| 61 |
left: 0; |
| 62 |
margin: 0 $icon-margin-x; |
| 63 |
width: $icon-width; |
| 64 |
height: 1rem; |
| 65 |
color: var(--pst-color-info); |
| 66 |
font: var(--fa-font-solid); |
| 67 |
line-height: inherit; |
| 68 |
content: var(--pst-icon-admonition-default); |
| 69 |
opacity: 1; |
| 70 |
} |
| 71 |
|
| 72 |
// Next element after title needs some extra upper-space |
| 73 |
+ * { |
| 74 |
margin-top: 0.4em; |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
&.attention { |
| 79 |
border-color: var(--pst-color-attention); |
| 80 |
|
| 81 |
> .admonition-title { |
| 82 |
background-color: var(--pst-color-attention-bg); |
| 83 |
|
| 84 |
&::after { |
| 85 |
color: var(--pst-color-attention); |
| 86 |
content: var(--pst-icon-admonition-attention); |
| 87 |
} |
| 88 |
} |
| 89 |
} |
| 90 |
|
| 91 |
&.caution { |
| 92 |
border-color: var(--pst-color-warning); |
| 93 |
|
| 94 |
> .admonition-title { |
| 95 |
background-color: var(--pst-color-warning-bg); |
| 96 |
|
| 97 |
&::after { |
| 98 |
color: var(--pst-color-warning); |
| 99 |
content: var(--pst-icon-admonition-caution); |
| 100 |
} |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
&.warning { |
| 105 |
border-color: var(--pst-color-warning); |
| 106 |
|
| 107 |
> .admonition-title { |
| 108 |
background-color: var(--pst-color-warning-bg); |
| 109 |
|
| 110 |
&::after { |
| 111 |
color: var(--pst-color-warning); |
| 112 |
content: var(--pst-icon-admonition-warning); |
| 113 |
} |
| 114 |
} |
| 115 |
} |
| 116 |
|
| 117 |
&.danger { |
| 118 |
border-color: var(--pst-color-danger); |
| 119 |
|
| 120 |
> .admonition-title { |
| 121 |
background-color: var(--pst-color-danger-bg); |
| 122 |
|
| 123 |
&::after { |
| 124 |
color: var(--pst-color-danger); |
| 125 |
content: var(--pst-icon-admonition-danger); |
| 126 |
} |
| 127 |
} |
| 128 |
} |
| 129 |
|
| 130 |
&.error { |
| 131 |
border-color: var(--pst-color-danger); |
| 132 |
|
| 133 |
> .admonition-title { |
| 134 |
background-color: var(--pst-color-danger-bg); |
| 135 |
|
| 136 |
&::after { |
| 137 |
color: var(--pst-color-danger); |
| 138 |
content: var(--pst-icon-admonition-error); |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
&.hint { |
| 144 |
border-color: var(--pst-color-success); |
| 145 |
|
| 146 |
> .admonition-title { |
| 147 |
background-color: var(--pst-color-success-bg); |
| 148 |
|
| 149 |
&::after { |
| 150 |
color: var(--pst-color-success); |
| 151 |
content: var(--pst-icon-admonition-hint); |
| 152 |
} |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
&.tip { |
| 157 |
border-color: var(--pst-color-success); |
| 158 |
|
| 159 |
> .admonition-title { |
| 160 |
background-color: var(--pst-color-success-bg); |
| 161 |
|
| 162 |
&::after { |
| 163 |
color: var(--pst-color-success); |
| 164 |
content: var(--pst-icon-admonition-tip); |
| 165 |
} |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
&.important { |
| 170 |
border-color: var(--pst-color-attention); |
| 171 |
|
| 172 |
> .admonition-title { |
| 173 |
background-color: var(--pst-color-attention-bg); |
| 174 |
|
| 175 |
&::after { |
| 176 |
color: var(--pst-color-attention); |
| 177 |
content: var(--pst-icon-admonition-important); |
| 178 |
} |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
&.note { |
| 183 |
border-color: var(--pst-color-info); |
| 184 |
|
| 185 |
> .admonition-title { |
| 186 |
background-color: var(--pst-color-info-bg); |
| 187 |
|
| 188 |
&::after { |
| 189 |
color: var(--pst-color-info); |
| 190 |
content: var(--pst-icon-admonition-note); |
| 191 |
} |
| 192 |
} |
| 193 |
} |
| 194 |
|
| 195 |
&.seealso { |
| 196 |
border-color: var(--pst-color-success); |
| 197 |
|
| 198 |
> .admonition-title { |
| 199 |
background-color: var(--pst-color-success-bg); |
| 200 |
|
| 201 |
&::after { |
| 202 |
color: var(--pst-color-success); |
| 203 |
content: var(--pst-icon-admonition-seealso); |
| 204 |
} |
| 205 |
} |
| 206 |
} |
| 207 |
|
| 208 |
&.admonition-todo { |
| 209 |
border-color: var(--pst-color-secondary); |
| 210 |
|
| 211 |
> .admonition-title { |
| 212 |
background-color: var(--pst-color-secondary-bg); |
| 213 |
|
| 214 |
&::after { |
| 215 |
color: var(--pst-color-secondary); |
| 216 |
content: var(--pst-icon-admonition-todo); |
| 217 |
} |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
/** |
| 222 |
* Special-case for a `sidebar` class that makes the admonition float to |
| 223 |
* the right like the {sidebar} directive. |
| 224 |
*/ |
| 225 |
&.sidebar { |
| 226 |
max-width: 40%; |
| 227 |
float: right; |
| 228 |
clear: both; |
| 229 |
margin-left: 0.5rem; |
| 230 |
margin-top: 0; |
| 231 |
|
| 232 |
// Undo the .sidebar directive border |
| 233 |
border-width: 0 0 0 $admonition-left-border-width; |
| 234 |
|
| 235 |
// TODO: these semantic-color-names border-color rules might no longer be |
| 236 |
// needed when we drop support for Sphinx 4 / docutils 0.17 |
| 237 |
&.attention, |
| 238 |
&.important { |
| 239 |
border-color: var(--pst-color-attention); |
| 240 |
} |
| 241 |
|
| 242 |
&.caution, |
| 243 |
&.warning { |
| 244 |
border-color: var(--pst-color-warning); |
| 245 |
} |
| 246 |
|
| 247 |
&.danger, |
| 248 |
&.error { |
| 249 |
border-color: var(--pst-color-danger); |
| 250 |
} |
| 251 |
|
| 252 |
&.hint, |
| 253 |
&.tip, |
| 254 |
&.seealso { |
| 255 |
border-color: var(--pst-color-success); |
| 256 |
} |
| 257 |
|
| 258 |
&.note, |
| 259 |
&.todo { |
| 260 |
border-color: var(--pst-color-info); |
| 261 |
} |
| 262 |
|
| 263 |
// No inner margin since we have less horizontal space w/ the sidebar |
| 264 |
p.admonition-title ~ * { |
| 265 |
margin-left: 0; |
| 266 |
margin-right: 0; |
| 267 |
} |
| 268 |
} |
| 269 |
} |
| 270 |
|
| 271 |
/************************************************************** |
| 272 |
* Similar content blocks that are not technically admonitions. |
| 273 |
*/ |
| 274 |
|
| 275 |
/** |
| 276 |
* Topics and the {contents} directive |
| 277 |
*/ |
| 278 |
// Docutils <= 0.17 |
| 279 |
div.topic, |
| 280 |
div.topic.contents, |
| 281 |
// Docutils >= 0.18 |
| 282 |
nav.contents, |
| 283 |
aside.topic { |
| 284 |
display: flex; |
| 285 |
flex-direction: column; |
| 286 |
background-color: var(--pst-color-surface); |
| 287 |
border-color: var(--pst-color-border); |
| 288 |
border-radius: $admonition-border-radius; |
| 289 |
padding: 1rem 1.25rem; |
| 290 |
|
| 291 |
@include box-shadow; |
| 292 |
|
| 293 |
.topic-title { |
| 294 |
margin: 0 0 0.5rem; |
| 295 |
} |
| 296 |
|
| 297 |
// Over-ride text color to ensure enough contrast |
| 298 |
p { |
| 299 |
color: var(--pst-color-on-surface) !important; |
| 300 |
} |
| 301 |
|
| 302 |
a { |
| 303 |
color: var(--pst-color-link-higher-contrast); |
| 304 |
} |
| 305 |
|
| 306 |
// Over-ride large default padding |
| 307 |
ul.simple { |
| 308 |
padding-left: 1rem; |
| 309 |
|
| 310 |
ul { |
| 311 |
// So that sub-lists will have a bit less padding |
| 312 |
padding-left: 2em; |
| 313 |
} |
| 314 |
} |
| 315 |
} |
| 316 |
|
| 317 |
/** |
| 318 |
* Sidebar directive |
| 319 |
*/ |
| 320 |
aside.sidebar { |
| 321 |
border: 1px solid var(--pst-color-border); |
| 322 |
background-color: var(--pst-color-surface); |
| 323 |
border-radius: $admonition-border-radius; |
| 324 |
|
| 325 |
// to match the admonition-styled sidebars: |
| 326 |
margin-left: 0.5rem; |
| 327 |
padding: 0; |
| 328 |
|
| 329 |
> *:last-child { |
| 330 |
padding-bottom: 1rem; |
| 331 |
} |
| 332 |
|
| 333 |
p.sidebar-title { |
| 334 |
position: relative; |
| 335 |
margin-bottom: 0; |
| 336 |
padding-top: 0.5rem; |
| 337 |
padding-bottom: 0.5rem; |
| 338 |
border-bottom: 1px solid var(--pst-color-border); |
| 339 |
font-family: var(--pst-font-family-heading); |
| 340 |
font-weight: var(--pst-admonition-font-weight-heading); |
| 341 |
} |
| 342 |
|
| 343 |
// Add margin to the first non-`.sidebar-title` item |
| 344 |
> *:not(.sidebar-title):first-child, |
| 345 |
> p.sidebar-title + * { |
| 346 |
margin-top: 1rem; |
| 347 |
} |
| 348 |
|
| 349 |
> * { |
| 350 |
padding-left: 1rem; |
| 351 |
padding-right: 1rem; |
| 352 |
} |
| 353 |
} |
| 354 |
|
| 355 |
/** |
| 356 |
* Rubrics look kind of like section headers |
| 357 |
*/ |
| 358 |
p.rubric { |
| 359 |
display: flex; |
| 360 |
flex-direction: column; |
| 361 |
} |
| 362 |
|
| 363 |
/** |
| 364 |
* Seealso is kind of like a vertically-collapsed admonition |
| 365 |
*/ |
| 366 |
.seealso dd { |
| 367 |
margin-top: 0; |
| 368 |
margin-bottom: 0; |
| 369 |
} |