Skip to content

Commit 2dddc8b

Browse files
authored
feat: add CSS float and alignment support for images and figures (#1174)
Resolves: #1172 ## Summary - Add missing `float: left`/`float: right` CSS properties to `img.float-left`/`img.float-right` rules (Bootstrap 5 removed these) - Add figure float rules (`figure.float-left`, `figure.float-right`) with `max-width: 50%` and responsive breakpoint (<576px disables float) - Add `img.align-center` / `figure.align-center` CSS for centered alignment - Replace deprecated HTML `align` attribute in `image.html.twig` with CSS class mapping (`:align: left` → `float-left`, `:align: right` → `float-right`, `:align: center` → `align-center`) - Add `:align:` CSS class support in `figure.html.twig` - Preserve `:align:` option on FigureNode (was being stripped) so `.. figure:: :align: left` works - Strip `float-left`/`float-right` from inner `<img>` inside `<figure>` to prevent caption wrapping issues - Add `.clear-both` CSS utility alias (alongside existing `.cc`) - Split `ImagesAndFigures` rendertest into separate pages: Index (styling), Zoom, FloatAndAlignment ## Files changed | File | Change | |------|--------| | `assets/sass/components/_rst.scss` | Add `float` property + `align-center` to img rules | | `assets/sass/components/_images.scss` | Add figure float/align rules + responsive | | `assets/sass/_utilities.scss` | Add `.clear-both` alias | | `resources/template/body/image.html.twig` | Replace HTML `align` attr with CSS classes | | `resources/template/body/figure.html.twig` | Add `:align:` CSS class support | | `src/Directives/FigureDirective.php` | Keep `:align:` on FigureNode, strip float from inner img | | `resources/public/css/theme.css` | Regenerated | | `Documentation-rendertest/ImagesAndFigures/` | Split into Index + Zoom + FloatAndAlignment | ## Test plan - [x] All 195 PHPUnit tests pass - [x] PHPStan reports 0 errors - [x] Rendered docs verified: image/figure float left/right with text wrapping - [x] `:align: left`/`:align: right` on figures works correctly - [x] `.clear-both` clears floats as expected - [x] Responsive: floats disable on small screens (<576px) - [x] Visual review of rendered ImagesAndFigures pages ### Related - Follow-up PR: #1179 (modernize to `float-start`/`float-end`) - Upstream issue: [phpDocumentor/guides#1303](phpDocumentor/guides#1303) — proposes removing `final` from upstream directives to avoid forking
1 parent c753119 commit 2dddc8b

14 files changed

Lines changed: 759 additions & 257 deletions

File tree

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
.. include:: /Includes.rst.txt
2+
3+
.. _images-float-and-alignment:
4+
5+
===================
6+
Float and alignment
7+
===================
8+
9+
.. contents:: This page
10+
:backlinks: top
11+
:class: compact-list
12+
:depth: 99
13+
:local:
14+
15+
16+
.. _images-float-image-left:
17+
18+
Image float left
19+
================
20+
21+
.. |example-teaser-left| image:: ../images/q150_cccccc.png
22+
:alt: Left floating image
23+
:class: float-left with-shadow
24+
25+
|example-teaser-left|
26+
Typesetting is the composition of text by means of arranging physical
27+
types[1] or the digital equivalents. Stored letters and other symbols
28+
(called sorts in mechanical systems and glyphs in digital systems)
29+
are retrieved and ordered according to a language's orthography for
30+
visual display.
31+
32+
.. rst-class:: clear-both
33+
34+
Floating cleared. Below the image.
35+
36+
37+
.. _images-float-image-right:
38+
39+
Image float right
40+
=================
41+
42+
.. |example-teaser-right| image:: ../images/q150_cccccc.png
43+
:alt: Right floating image
44+
:class: float-right with-shadow
45+
46+
|example-teaser-right|
47+
Typesetting is the composition of text by means of arranging physical
48+
types[1] or the digital equivalents. Stored letters and other symbols
49+
(called sorts in mechanical systems and glyphs in digital systems)
50+
are retrieved and ordered according to a language's orthography for
51+
visual display.
52+
53+
.. rst-class:: clear-both
54+
55+
Floating cleared. Below the image.
56+
57+
58+
.. _images-float-figure-left:
59+
60+
Figure float left
61+
=================
62+
63+
.. figure:: ../images/q150_cccccc.png
64+
:alt: Left floating figure
65+
:class: float-left with-shadow
66+
67+
A figure floated to the left
68+
69+
Typesetting is the composition of text by means of arranging physical
70+
types[1] or the digital equivalents. Stored letters and other symbols
71+
(called sorts in mechanical systems and glyphs in digital systems)
72+
are retrieved and ordered according to a language's orthography for
73+
visual display. Typesetting requires one or more fonts. The source
74+
could be a manuscript, a previously composed version, or a plain text.
75+
76+
.. rst-class:: clear-both
77+
78+
Floating cleared. Below the figure.
79+
80+
81+
.. _images-float-figure-right:
82+
83+
Figure float right
84+
==================
85+
86+
.. figure:: ../images/q150_cccccc.png
87+
:alt: Right floating figure
88+
:class: float-right with-shadow
89+
90+
A figure floated to the right
91+
92+
Typesetting is the composition of text by means of arranging physical
93+
types[1] or the digital equivalents. Stored letters and other symbols
94+
(called sorts in mechanical systems and glyphs in digital systems)
95+
are retrieved and ordered according to a language's orthography for
96+
visual display. Typesetting requires one or more fonts. The source
97+
could be a manuscript, a previously composed version, or a plain text.
98+
99+
.. rst-class:: clear-both
100+
101+
Floating cleared. Below the figure.
102+
103+
104+
.. _images-float-align-left:
105+
106+
Figure align left
107+
=================
108+
109+
.. figure:: ../images/q150_cccccc.png
110+
:alt: Left aligned figure
111+
:align: left
112+
113+
A figure aligned left via :align:
114+
115+
Typesetting is the composition of text by means of arranging physical
116+
types[1] or the digital equivalents. Stored letters and other symbols
117+
(called sorts in mechanical systems and glyphs in digital systems)
118+
are retrieved and ordered according to a language's orthography for
119+
visual display. Typesetting requires one or more fonts. The source
120+
could be a manuscript, a previously composed version, or a plain text.
121+
122+
.. rst-class:: clear-both
123+
124+
Floating cleared. Below the figure.
125+
126+
127+
.. _images-float-align-right:
128+
129+
Figure align right
130+
==================
131+
132+
.. figure:: ../images/q150_cccccc.png
133+
:alt: Right aligned figure
134+
:align: right
135+
136+
A figure aligned right via :align:
137+
138+
Typesetting is the composition of text by means of arranging physical
139+
types[1] or the digital equivalents. Stored letters and other symbols
140+
(called sorts in mechanical systems and glyphs in digital systems)
141+
are retrieved and ordered according to a language's orthography for
142+
visual display. Typesetting requires one or more fonts. The source
143+
could be a manuscript, a previously composed version, or a plain text.
144+
145+
.. rst-class:: clear-both
146+
147+
Floating cleared. Below the figure.

0 commit comments

Comments
 (0)