You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2c30572
Browse filesBrowse the repository at this point in the historyBrowse files
Do not add `"use client"` to layouts, pages, or wrapper components just because a child needs it — push `"use client"` down to the smallest possible component.
23
30
24
-
## File placement
31
+
## Directory structure
25
32
```
26
-
app/ # route files only (page.tsx, layout.tsx, loading.tsx, error.tsx)
utils.ts — cn() utility and other non-React helpers
41
+
types/ — shared TypeScript type definitions
32
42
```
33
43
34
-
## Component file structure
44
+
Route files (`page.tsx`, `layout.tsx`, `loading.tsx`, `error.tsx`) live in `app/` only.
45
+
46
+
## `cn()` utility
47
+
All conditional class merging uses `cn()` from `lib/utils.ts`:
48
+
```ts
49
+
// lib/utils.ts
50
+
import { clsx, typeClassValue } from"clsx"
51
+
import { twMerge } from"tailwind-merge"
52
+
53
+
exportfunction cn(...inputs:ClassValue[]) {
54
+
returntwMerge(clsx(inputs))
55
+
}
56
+
```
57
+
Import it as `import { cn } from "@/lib/utils"` in every component that merges classes.
58
+
59
+
## `components/ui/` — shadcn primitives
60
+
Generated by shadcn/ui. Use `class-variance-authority` (`cva`) for variant logic and `Slot` from `radix-ui` for the `asChild` pattern. Do not hand-edit these files directly; re-run the shadcn CLI to update them.
`H1`, `H2`, `H3` — semantic heading wrappers that forward a `className` prop through `cn()`. `H2` makes `className` optional; `H1` and `H3` require it.
112
+
113
+
`Loader` — accepts a required `className` prop and renders a `div` with those classes applied via `cn()`.
114
+
115
+
## `components/home/` — feature-scoped components
116
+
Components specific to the home feature. Scoped to avoid polluting `common/`.
117
+
55
118
## TypeScript rules
56
119
- No `any`. Use proper interfaces or `unknown`.
57
-
- Extend native HTML element types (`ButtonHTMLAttributes`, `InputHTMLAttributes`) for wrapper components.
58
-
- Keep component prop types in the same file as the component unless shared across multiple files.
59
-
- Shared types → `types/` directory.
120
+
- For shadcn primitives, extend `React.ComponentProps<"element">` (not `ButtonHTMLAttributes`) and combine with `VariantProps<typeof variantsFn>`.
121
+
- For common/feature components, inline prop types in the same file unless the type is shared across multiple files — then move it to `types/`.
122
+
- Import types with `import type` to keep runtime bundles clean.
123
+
- React 19: JSX transform is automatic — no `import React from "react"` needed unless you reference `React.*` directly.
60
124
61
125
## Imports
62
-
- Use TypeScript path aliases from `tsconfig.json` — check it before writing relative import chains.
63
-
- Import React only when needed (React 19 — JSX transform is automatic, no `import React` needed).
64
-
- Import types with `import type` to keep runtime bundles clean.
126
+
Use TypeScript path aliases (`@/`) from `tsconfig.json`. Do not write deep relative import chains.
0 commit comments