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