feat: modernize float classes to Bootstrap 5 with deprecation handling#1179
feat: modernize float classes to Bootstrap 5 with deprecation handling#1179CybotTM wants to merge 7 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. |
157a004 to
1c51cde
Compare
Add missing float and alignment CSS for images and figures, replacing the deprecated HTML align attribute with CSS class mapping. - Add float-left/float-right CSS rules for img and figure elements with max-width: 50% and responsive breakpoint at 575.98px - Add align-center CSS for centered images and figures - Map :align: left/right/center to CSS classes in Twig templates, replacing the deprecated HTML align attribute on <img> - Preserve :align: option on FigureNode (was being stripped) - Strip float classes from inner <img> inside <figure> to prevent caption wrapping issues - Add .clear-both CSS utility alias alongside existing .cc - Split ImagesAndFigures rendertest into Index, Zoom, and FloatAndAlignment pages
Cover all float/alignment scenarios: - Figure :align: left/right/center maps to CSS classes - Image :align: left/right/center maps to CSS classes - Figure :class: float-left/right (float stripped from inner img) - Mixed :class: float-left with-shadow (extra classes preserved) - Image :class: float-right - Combined :align: + :class: (both applied to figure element)
- 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.
1c51cde to
301f6b1
Compare
|
ok, I now added all stuff from #1174 also into this PR, dunno if this what you meant. |
Summary
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