feat: modernize float classes to Bootstrap 5 with deprecation handling#4
feat: modernize float classes to Bootstrap 5 with deprecation handling#4
Conversation
Summary of ChangesHello @CybotTM, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request modernizes the TYPO3 documentation theme by updating its handling of floating elements to align with Bootstrap 5's logical properties. It introduces a robust system for backward compatibility, automatically rewriting deprecated Bootstrap 4 float classes while providing clear warnings. The changes ensure that the documentation rendering remains consistent and adaptable to future web development practices, improving maintainability and user experience. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
Modernizes float/alignment handling in the TYPO3 docs theme for Bootstrap 5 by mapping :align: to float-start/float-end and adding backward-compatible rewriting + warnings for legacy float-left/float-right usage across figures and images.
Changes:
- Add shared legacy-float rewrite logic, apply it to
FigureDirective, and introduce a composition-basedImageDirectivewrapper that rewrites legacy float classes and logs deprecations. - Update Twig templates and theme styles (SCSS + compiled CSS) to use Bootstrap 5 float class names and support
align-center, including class deduplication. - Add an integration test fixture covering align mapping, legacy rewrite behavior, mixed classes, and deprecation warnings.
Reviewed changes
Copilot reviewed 18 out of 21 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/typo3-docs-theme/src/Directives/RewritesLegacyFloatClasses.php | New shared trait to detect/rewrite float-left/right to float-start/end. |
| packages/typo3-docs-theme/src/Directives/FigureDirective.php | Rewrites legacy float classes with warnings; shifts float behavior to the <figure> wrapper. |
| packages/typo3-docs-theme/src/Directives/ImageDirective.php | Wraps upstream final directive via composition to rewrite legacy float classes + warn. |
| packages/typo3-docs-theme/src/DependencyInjection/Typo3DocsThemeExtension.php | Removes upstream Figure/Image directive service definitions so theme directives take over. |
| packages/typo3-docs-theme/resources/template/body/figure.html.twig | Maps :align: to BS5 float classes and deduplicates CSS classes. |
| packages/typo3-docs-theme/resources/template/body/image.html.twig | Same :align: mapping/dedup; removes legacy HTML align attribute output. |
| packages/typo3-docs-theme/assets/sass/components/_images.scss | Adds BS5 float styling for figures + legacy class compatibility during migration. |
| packages/typo3-docs-theme/assets/sass/components/_rst.scss | Adds BS5 float styling and align-center for images/objects + responsive behavior. |
| packages/typo3-docs-theme/assets/sass/_utilities.scss | Adds .clear-both alias next to .cc. |
| packages/typo3-docs-theme/resources/public/css/theme.css | Compiled CSS updates corresponding to SCSS changes. |
| packages/typo3-docs-theme/resources/config/typo3-docs-theme.php | Registers the new ImageDirective service. |
| tests/Integration/tests/images/Float/** | New integration test fixture (input + expected HTML + expected warnings). |
| Documentation-rendertest/ImagesAndFigures/*.rst | Restructures rendertest docs and adds a dedicated float/alignment page using BS5 classes. |
| composer.json / composer.lock | Bumps friendsofphp/php-cs-fixer to ^3.94 and updates lockfile. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request is a well-executed modernization of Bootstrap float classes, complete with backward compatibility and deprecation warnings. The use of a shared trait for rewriting legacy classes and the composition-based decorator for the ImageDirective are excellent design choices that demonstrate a strong understanding of software engineering principles. The addition of comprehensive integration tests further enhances the quality of this contribution. My feedback includes a few suggestions to reduce code duplication in the SCSS and Twig templates, which should improve long-term maintainability.
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
Summary
Modernizes Bootstrap float classes from v4 (
float-left/float-right) to v5 (float-start/float-end) in the TYPO3 docs theme, with backward-compatible deprecation handling.:align:to Bootstrap 5 classes, with deduplication to prevent duplicate CSS classes:class: float-left/right, emit deprecation warnings, extract sharedRewritesLegacyFloatClassestraitfinalclass — intercepts legacy float classes without forkingCommits
refactor: modernize float classes to Bootstrap 5 naming— Twig dedup + cross-refs + SCSS deprecation commentsfeat: detect and rewrite deprecated float classes in FigureDirective— FigureDirective + traitfeat: add ImageDirective decorator for float class deprecation— composition-based decoratortest: add integration tests for float class modernization— comprehensive test coverageKey design decisions
final, so we wrap it via manual instantiation rather than Symfony->decorate()(which caused PHP 8.1 issues with tagged service collections)RewritesLegacyFloatClasseseliminates DRY violation between Figure and Image directivesfloat-start float-startwhen both:align:and rewritten:class:produce the same classUpstream context
Test plan