Skip to content

Commit afbe8fa

Browse files
justin808claude
andcommitted
Fix FOUC in Pro spec/dummy app with critical CSS
Inline critical CSS styles in the <head> to prevent Flash of Unstyled Content (FOUC) on initial page load. This ensures the two-column layout renders correctly before the main CSS loads. Changes: - Add inlined critical CSS for flex layout, sidebar dimensions, colors, spacing, and overflow handling - Add preload hint for client-bundle.css for faster loading This matches Tailwind class definitions used in the layout structure so the page has proper layout even before full CSS loads. Fixes #2100 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 16b3908 commit afbe8fa

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

react_on_rails_pro/spec/dummy/app/views/layouts/application.html.erb

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,39 @@
1616
<% end %>
1717
<%= yield :head %>
1818
<style>
19+
/* Critical CSS inlined to prevent FOUC (Flash of Unstyled Content)
20+
These styles ensure the layout renders correctly before the main CSS loads.
21+
See: https://github.com/shakacode/react_on_rails/issues/2100 */
1922
html {
2023
font-size: 16px !important;
2124
}
25+
/* Base layout styles */
26+
.flex { display: flex; }
27+
.flex-row { flex-direction: row; }
28+
.flex-col { flex-direction: column; }
29+
.flex-1 { flex: 1 1 0%; }
30+
.h-screen { height: 100vh; }
31+
.w-screen { width: 100vw; }
32+
/* Sidebar styles */
33+
.min-w-\[400px\] { min-width: 400px; }
34+
.max-w-\[400px\] { max-width: 400px; }
35+
.bg-slate-100 { background-color: #f1f5f9; }
36+
.bg-white { background-color: #ffffff; }
37+
.border-solid { border-style: solid; }
38+
.border-r-2 { border-right-width: 2px; }
39+
.border-slate-700 { border-color: #334155; }
40+
/* Spacing */
41+
.p-5 { padding: 1.25rem; }
42+
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
43+
/* Overflow handling */
44+
.overflow-y-auto { overflow-y: auto; }
45+
.overflow-x-hidden { overflow-x: hidden; }
46+
/* Typography (minimal for initial render) */
47+
.text-red-700 { color: #b91c1c; }
48+
.underline { text-decoration: underline; }
2249
</style>
50+
<!-- Preload CSS for faster loading -->
51+
<%= preload_pack_asset('client-bundle.css', as: 'style') %>
2352
<%= stylesheet_pack_tag('client-bundle',
2453
media: 'all',
2554
'data-turbo-track': 'reload') %>

0 commit comments

Comments
 (0)