put reflexGlobalStyles before everything and add style to radix theme root#5763
put reflexGlobalStyles before everything and add style to radix theme root#5763adhami3310 merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR fixes a critical styling regression in Reflex 0.8.x production builds where wrapped component styles (like table borders) were being lost when running with --env prod. The fix involves three key changes to ensure proper CSS loading order and theme application:
-
Global styles relocation: The global Reflex styles (
reflexGlobalStyles) are moved from the app root level to the document head incompiler/utils.py. A newLinkcomponent is added that imports the global CSS file early in the document head, ensuring base styles load before component-specific styles. -
App root template cleanup: The
app_root_templateincompiler/templates.pyis simplified by removing the global styles import and thelinksexport function, as global styles are now handled at the document level rather than the component level. -
Radix theme synchronization: A
useEffecthook is added to theRadixThemesColorModeProvidercomponent that directly manipulates the DOM to ensure Radix theme root classes are properly applied. This addresses theme class application issues in production builds by manually syncing the resolved theme with the Radix root element's CSS classes.
These changes address CSS cascade order issues that occur in production builds where the bundling process affects stylesheet loading sequence. By establishing global styles early and ensuring theme classes are correctly applied, the fix maintains styling consistency across development and production environments while preserving the existing component architecture.
Confidence score: 4/5
- This PR addresses a well-documented production styling issue with a targeted approach that maintains backwards compatibility
- Score reflects thorough understanding of CSS loading order issues and appropriate technical solutions for each affected component
- Pay close attention to the DOM manipulation in the color mode provider as it bypasses React's normal rendering flow
3 files reviewed, no comments
CodSpeed Performance ReportMerging #5763 will not alter performanceComparing Summary
|
fixes #5757