Add missing rx.el.figure HTML element#5575
Conversation
- Add Figure class to typography.py following existing pattern - Add figure to element mapping in __init__.py - Create convenience function figure = Figure.create - Fixes issue #5573 where rx.el.figure was not available The figure element is a standard HTML semantic element used to represent self-contained content, often with a caption using figcaption.
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Greptile Summary
This PR adds support for the HTML <figure> element to Reflex's typography components. The implementation includes:
- Adding the
figureelement to the_MAPPINGdictionary in__init__.py - Creating a new
Figureclass intypography.pythat extendsBaseHTML - Adding a corresponding
figurefactory function - Updating type definitions in pyi files
This addition complements the existing figcaption element support, allowing developers to create semantically correct markup for self-contained content like images, diagrams, or code snippets with captions.
PR Description Notes:
- The PR description is currently a placeholder and should be updated with actual implementation details
Confidence score: 5/5
- This PR is extremely safe to merge as it follows established patterns and adds standard HTML functionality
- The implementation is straightforward, follows existing patterns perfectly, and cannot introduce regressions
- No files need special attention as the changes are minimal and well-structured
3 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
CodSpeed Performance ReportMerging #5575 will not alter performanceComparing Summary
|
- Regenerated .pyi files locally to match CI expectations - Fixes pre-commit hook failure in CI
|
run |
- Used 'uv run python -m reflex.utils.pyi_generator' as requested by @adhami3310 - Fixes CI pre-commit failure by updating pyi_hashes.json with correct values - All 119 .pyi files regenerated successfully
Add missing rx.el.figure HTML element
Summary
This PR implements the missing
rx.el.figureHTML element that was reported in issue #5573. Users were getting anAttributeErrorwhen trying to userx.el.figurebecause the element wasn't implemented in the framework.The implementation follows the established pattern for HTML elements in Reflex:
Figureclass toreflex/components/el/elements/typography.py(alongside the existingFigcaptionclass)figureto the element mapping inreflex/components/el/elements/__init__.pyfigure = Figure.createThe HTML
figureelement is a standard semantic element used to represent self-contained content, often with a caption usingfigcaption. Sincefigcaptionwas already implemented in the typography module, placingfigurethere maintains logical grouping.Review & Testing Checklist for Human
rx.el.figureactually works: Test thatimport reflex as rx; rx.el.figure("content")works without errorsrx.el.figure(rx.el.img(...), rx.el.figcaption("caption"))works as expectedRecommended test plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TD Issue5573["GitHub Issue #5573<br/>rx.el.figure missing"] TypographyPy["reflex/components/el/elements/<br/>typography.py"]:::major-edit InitPy["reflex/components/el/elements/<br/>__init__.py"]:::major-edit ElInit["reflex/components/el/<br/>__init__.py"]:::context HtmlConstants["reflex/components/el/constants/<br/>html.py"]:::context Issue5573 --> TypographyPy Issue5573 --> InitPy TypographyPy --> |"exports figure"| ElInit InitPy --> |"maps 'figure' to typography"| ElInit HtmlConstants --> |"figure already in ELEMENTS"| TypographyPy TypographyPy --> |"Figure class + convenience function"| FigureAPI["rx.el.figure API"] InitPy --> |"element mapping"| FigureAPI subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
figureelement was already present inreflex/components/el/constants/html.py, so no additional registration was needed thereFigcaption,Div,Hr, etc.Figure.createmethodfigureandfigcaptionare related HTML elements and belong together in the typography moduleLink to Devin run: https://app.devin.ai/sessions/bb621b3b81da48149fbe7e18b7176433
Requested by: @adhami3310