Skip to content

Commit ccffe9a

Browse files
stevepiercydrammockgabalafoutrallard
authored
Reposition the admonition title icon to the top of the paragraph in m… (#2100)
…ulti-line titles Fixes #2099 --------- Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: gabalafou <[email protected]> Co-authored-by: Tania Allard <[email protected]>
1 parent 1865b19 commit ccffe9a

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

docs/examples/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ See the sections in the primary sidebar and below to explore.
2828
:numbered:
2929
:caption: Reference and test section. Mostly meant for developers to check that things look OK.
3030

31+
regressions
3132
no-sidebar
3233
persistent-search-field
3334
in-page-toc

docs/examples/regressions.rst

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
===========
2+
Regressions
3+
===========
4+
5+
Whenever a corner case is reported and fixed that the theme got wrong, it should
6+
be added to this page. That way it can be inspected against current and upcoming
7+
versions of the theme to help prevent the bug from reappearing in a release.
8+
9+
Admonition with multi-line title
10+
================================
11+
12+
Issue `#2099 <https://github.com/pydata/pydata-sphinx-theme/issues/2099>`_
13+
14+
In the following example, the admonition title should span multiple lines and
15+
the icon should be aligned with the top line of the admonition title text.
16+
17+
.. admonition:: Warning! This feature is experimental and only applies to registering routes for React Router 7 applications. Click to accept the risks and read details.
18+
:class: warning, toggle
19+
20+
Uh-oh, now you're in trouble!

src/pydata_sphinx_theme/assets/styles/content/_admonitions.scss

+9-3
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ div.admonition,
4040

4141
// Defaults for all admonitions
4242
> .admonition-title {
43+
$padding-top: 0.4rem;
44+
$icon-width: 1rem;
45+
$icon-margin-x: 0.5rem;
46+
4347
margin: 0 -0.6rem;
44-
padding: 0.4rem 0.6rem 0.4rem 2rem;
48+
padding: 0.4rem 0.6rem $padding-top calc($icon-width + 2 * $icon-margin-x);
4549
font-weight: var(--pst-admonition-font-weight-heading);
4650
position: relative;
4751

@@ -54,8 +58,10 @@ div.admonition,
5458

5559
&::after {
5660
position: absolute;
57-
left: 0.5rem;
58-
width: 1rem;
61+
top: $padding-top; // align icon with title text
62+
left: 0;
63+
margin: 0 $icon-margin-x;
64+
width: $icon-width;
5965
height: 1rem;
6066
color: var(--pst-color-info);
6167
font: var(--fa-font-solid);

0 commit comments

Comments
 (0)