Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

styles.ts

222 lines4.7 KB

1/**
2 * Shared styles for RSC E2E tests.
3 * Blue = Server Rendered (RSC)
4 * Green = Client Interactive
5 */
6​
7// Server-rendered content styles (blue theme)
8export const serverStyles = {
9 container: {
10 backgroundColor: '#e0f2fe',
11 border: '2px solid #0284c7',
12 borderRadius: '8px',
13 padding: '16px',
14 marginBottom: '16px',
15 },
16 badge: {
17 display: 'inline-block',
18 backgroundColor: '#0284c7',
19 color: 'white',
20 padding: '2px 8px',
21 borderRadius: '4px',
22 fontSize: '11px',
23 fontWeight: 'bold' as const,
24 letterSpacing: '0.5px',
25 },
26 header: {
27 display: 'flex',
28 justifyContent: 'space-between',
29 alignItems: 'center',
30 marginBottom: '12px',
31 },
32 timestamp: {
33 fontSize: '11px',
34 color: '#64748b',
35 fontFamily: 'monospace',
36 },
37 label: {
38 color: '#0369a1',
39 fontSize: '11px',
40 fontWeight: 'bold' as const,
41 textTransform: 'uppercase' as const,
42 letterSpacing: '0.5px',
43 marginBottom: '4px',
44 },
45 text: {
46 color: '#0c4a6e',
47 },
48 muted: {
49 color: '#64748b',
50 },
51 divider: {
52 borderTop: '1px solid #bae6fd',
53 margin: '12px 0',
54 },
56​
57// Client interactive content styles (green theme)
58export const clientStyles = {
59 container: {
60 backgroundColor: '#dcfce7',
61 border: '2px solid #16a34a',
62 borderRadius: '8px',
63 padding: '16px',
64 marginBottom: '16px',
65 },
66 badge: {
67 display: 'inline-block',
68 backgroundColor: '#16a34a',
69 color: 'white',
70 padding: '2px 8px',
71 borderRadius: '4px',
72 fontSize: '11px',
73 fontWeight: 'bold' as const,
74 letterSpacing: '0.5px',
75 },
76 header: {
77 display: 'flex',
78 justifyContent: 'space-between',
79 alignItems: 'center',
80 marginBottom: '12px',
81 },
82 label: {
83 color: '#166534',
84 fontSize: '11px',
85 fontWeight: 'bold' as const,
86 textTransform: 'uppercase' as const,
87 letterSpacing: '0.5px',
88 marginBottom: '4px',
89 },
90 text: {
91 color: '#14532d',
92 },
93 divider: {
94 borderTop: '1px solid #bbf7d0',
95 margin: '12px 0',
96 },
97 button: {
98 padding: '8px 16px',
99 borderRadius: '6px',
100 border: 'none',
101 fontWeight: 'bold' as const,
102 cursor: 'pointer',
103 fontSize: '13px',
104 transition: 'opacity 0.2s',
105 },
106 primaryButton: {
107 backgroundColor: '#16a34a',
108 color: 'white',
109 },
110 secondaryButton: {
111 backgroundColor: '#e2e8f0',
112 color: '#334155',
113 },
115​
116// Async/Loading content styles (amber theme for pending states)
117export const asyncStyles = {
118 container: {
119 backgroundColor: '#fef3c7',
120 border: '2px dashed #f59e0b',
121 borderRadius: '8px',
122 padding: '16px',
123 marginBottom: '16px',
124 },
125 badge: {
126 display: 'inline-block',
127 backgroundColor: '#f59e0b',
128 color: 'white',
129 padding: '2px 8px',
130 borderRadius: '4px',
131 fontSize: '11px',
132 fontWeight: 'bold' as const,
133 letterSpacing: '0.5px',
134 },
135 loadingBar: {
136 height: '4px',
137 backgroundColor: '#fde68a',
138 borderRadius: '2px',
139 overflow: 'hidden',
140 marginTop: '8px',
141 },
142 loadingProgress: {
143 height: '100%',
144 backgroundColor: '#f59e0b',
145 animation: 'loading 1.5s ease-in-out infinite',
146 },
148​
149// Page layout styles
150export const pageStyles = {
151 container: {
152 padding: '20px',
153 maxWidth: '800px',
154 fontFamily:
155 '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
156 },
157 title: {
158 margin: '0 0 8px 0',
159 fontSize: '24px',
160 color: '#1e293b',
161 },
162 description: {
163 color: '#64748b',
164 marginBottom: '20px',
165 lineHeight: '1.5',
166 },
167 legend: {
168 display: 'flex',
169 gap: '16px',
170 marginBottom: '20px',
171 padding: '12px',
172 backgroundColor: '#f8fafc',
173 borderRadius: '8px',
174 flexWrap: 'wrap' as const,
175 },
176 legendItem: {
177 display: 'flex',
178 alignItems: 'center',
179 gap: '6px',
180 },
181 legendColor: (color: string) => ({
182 width: '16px',
183 height: '16px',
184 backgroundColor: color,
185 borderRadius: '4px',
186 }),
187 legendText: {
188 fontSize: '13px',
189 color: '#475569',
190 },
191 section: {
192 marginBottom: '24px',
193 },
194 sectionTitle: {
195 fontSize: '16px',
196 fontWeight: 'bold' as const,
197 color: '#334155',
198 marginBottom: '12px',
199 },
201​
202// Color constants for easy reference
203export const colors = {
204 server: '#0284c7',
205 serverLight: '#e0f2fe',
206 client: '#16a34a',
207 clientLight: '#dcfce7',
208 async: '#f59e0b',
209 asyncLight: '#fef3c7',
211​
212/**
213 * Format a timestamp for display.
214 * Uses a fixed UTC format to avoid hydration mismatch between server and client.
215 */
216export function formatTime(timestamp: number): string {
217 const d = new Date(timestamp)
218 const hh = String(d.getUTCHours()).padStart(2, '0')
219 const mm = String(d.getUTCMinutes()).padStart(2, '0')
220 const ss = String(d.getUTCSeconds()).padStart(2, '0')
221 return `${hh}:${mm}:${ss} UTC`