[FEATURE] Modernize float classes to Bootstrap 5 with deprecation handling#1179
[FEATURE] Modernize float classes to Bootstrap 5 with deprecation handling#1179CybotTM wants to merge 5 commits intoTYPO3-Documentation:mainfrom
Conversation
|
Did you want to rewrite the deprecated float-left/right to float-start/end or just log their usage? |
Both. |
f70bc2c to
c1c6b52
Compare
f9da026 to
66a89af
Compare
66a89af to
f6ca36e
Compare
f6ca36e to
157a004
Compare
|
yeah, finally, I think it is ready now. |
|
Hi @ineswillenbrock ,
Dunno what exact test you mean, but will have a look. |
|
oh, do you talk about e20a1b7 ? This is not part of PR #1179 but #1174. The plan was #1174 needs to be merged first - this is the real float fix. As stated in the #1179 description this PR depends on #1174. |
1c51cde to
301f6b1
Compare
|
ok, I now added all stuff from #1174 also into this PR, dunno if this what you meant. |
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
|
@CybotTM it seems like we have conflicts now |
301f6b1 to
a403c91
Compare
|
rebased |
- Map RST :align: left/right/center to Bootstrap 5 CSS classes (float-start, float-end, align-center) in Twig templates - Add class deduplication to prevent duplicate CSS classes when both :align: and :class: produce the same float class - Group modern and legacy float selectors in SCSS to reduce duplication - Add deprecation timeline comments to legacy CSS rules - Cross-reference comments between figure/image templates
- Extract RewritesLegacyFloatClasses trait for shared detection/rewrite logic - Detect :class: float-left/float-right and rewrite to float-start/float-end - Emit deprecation warning guiding authors to use :align: instead - Strip float classes from inner <img> using array_filter for clarity
- Wrap upstream final ImageDirective via composition pattern - Intercept :class: float-left/float-right, rewrite to float-start/float-end - Emit deprecation warning with substitution-image-aware message - Uses RewritesLegacyFloatClasses trait shared with FigureDirective - Register in DI config, remove upstream definition via compiler pass
- Test :align: left/right/center on figures and images - Test legacy :class: float-left/float-right rewriting on figures, images - Test mixed :class: with extra classes (e.g. with-shadow) - Test combined :align: + legacy :class: (deduplication) - Test modern float-start/float-end pass through without warnings - Test substitution image with legacy float class - Verify deprecation warnings with correct line numbers
Cover RewritesLegacyFloatClasses trait, ImageDirective decorator, and FigureDirective with 40 unit tests for 100% patch code coverage.
a403c91 to
ba580a5
Compare
Summary
Builds on #1174 (merged). Modernizes legacy float CSS classes to Bootstrap 5 logical properties with backward-compatible deprecation handling.
float-start/float-end), keeping backward-compatible aliases with grouped selectors to reduce duplicationalignMapto translate RST:align:values to CSS classes, with deduplication to prevent duplicate classes when both:align:and:class:resolve to the same value:class: float-left/:class: float-rightin both FigureDirective and ImageDirective, emitting deprecation warningsRewritesLegacyFloatClassestrait for detection/rewrite logic (DRY)finalclass — zero code duplication, upstream changes are inherited automaticallyImplementation notes
finalclass via composition. Interceptsprocess()to rewrite float classes, then delegates to$this->inner->process(). No need to duplicateprocessNode()orresolveLinkTarget().array_filter/explodeto strip float classes from the inner<img>while preserving non-float classes (e.g.with-shadow). A future PR will explore refactoring this to use decoration as well.hasLegacyFloatClass) and rewrite (rewriteLegacyFloatClasses) used by both directives.finalremoval: Allow themes to extend ImageDirective and FigureDirective (currently final) phpDocumentor/guides#1303Test plan