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

CssModulesContent.tsx

56 lines1.9 KB

1/// <reference types="vite/client" />
2/// <reference types="@vitejs/plugin-rsc/types" />
3import styles from './serverComponent.module.css'
4​
5export function CssModulesContent({ data }: { data: { title?: string } }) {
6 const serverTimestamp = Date.now()
7​
8 const features = [
9 { id: 1, icon: 'βœ“', text: 'Scoped class names prevent conflicts' },
10 { id: 2, icon: 'βœ“', text: 'Works seamlessly in server components' },
11 { id: 3, icon: 'βœ“', text: 'CSS is extracted and optimized' },
12 { id: 4, icon: 'βœ“', text: 'Full IDE support with TypeScript' },
13 ]
14​
15 return (
16 <div className={styles.container} data-testid="rsc-css-modules-content">
17 <div className={styles.header}>
18 <span className={styles.badge} data-testid="rsc-css-modules-badge">
19 SERVER RENDERED
20 </span>
21 <span
22 className={styles.timestamp}
23 data-testid="rsc-css-modules-timestamp"
24 >
25 Fetched: {new Date(serverTimestamp).toLocaleTimeString()}
26 </span>
27 </div>
28​
29 <h2 className={styles.title} data-testid="rsc-css-modules-title">
30 {data.title || 'CSS Modules in RSC'}
31 </h2>
32​
33 <p className={styles.description}>
34 This server component uses CSS Modules for styling. The class names are
35 automatically scoped to prevent conflicts with other styles.
36 </p>
37​
38 <ul className={styles.featureList} data-testid="rsc-css-modules-features">
39 {features.map((feature) => (
40 <li
41 key={feature.id}
42 className={styles.featureItem}
43 data-testid={`rsc-css-modules-feature-${feature.id}`}
44 >
45 <span className={styles.featureIcon}>{feature.icon}</span>
46 <span>{feature.text}</span>
47 </li>
48 ))}
49 </ul>
50​
51 <div className={styles.footer}>
52 Component ID: css-mod-{Math.random().toString(36).slice(2, 8)}
53 </div>
54 </div>
55 )