Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2af4fa8

Browse files
committed
docs(site): document critical frontend pattern migrations
Add comprehensive documentation for active frontend pattern migrationsdiscovered through analysis of 100 recent PRs:- Emotion → Tailwind CSS (strict 'no new emotion' policy)- MUI → Custom/Radix components (especially Tooltips)- spyOn → queries parameter for GET endpoint mocks in Storybook- localStorage → user_configs table for user preferences- Chromatic testing best practices (prefer snapshots over assertions)Includes concrete examples and migration patterns to guide developersaway from deprecated approaches and toward current best practices.---🤖 This change was written by Claude Sonnet 4.5 Thinking using mux and reviewed by a human 🏂
1 parentb7d8918 commit2af4fa8

File tree

1 file changed

+104
-5
lines changed

1 file changed

+104
-5
lines changed

‎site/CLAUDE.md‎

Lines changed: 104 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
#Frontend Development Guidelines
22

3+
##🚨 Critical Pattern Migrations (MUST FOLLOW)
4+
5+
The following patterns are actively being migrated and have**STRICT policies**:
6+
7+
1.**Emotion → Tailwind**: "No new emotion styles, full stop" - Always use Tailwind CSS
8+
2.**MUI → Custom/Radix Components**: Replace MUI components with custom equivalents (especially Tooltips)
9+
3.**spyOn → queries parameter**: Use`queries` in story parameters for GET endpoint mocks
10+
4.**localStorage → user_configs**: Store user preferences in backend, not browser storage
11+
12+
When touching existing code,**"leave the campsite better than you found it"** - refactor old patterns to new ones even if not directly related to your changes.
13+
314
##TypeScript LSP Navigation (USE FIRST)
415

516
When investigating or editing TypeScript/React code, always use the TypeScript language server tools for accurate navigation:
@@ -26,20 +37,48 @@ When investigating or editing TypeScript/React code, always use the TypeScript l
2637

2738
##Components
2839

29-
- MUI components are deprecated - migrate away from these when encountered
30-
- Use shadcn/ui components first - check`site/src/components` for existing implementations.
40+
-**MUI components are deprecated** - migrate away from these when encountered
41+
- Replace`@mui/material/Tooltip` with custom`Tooltip` component (Radix-based)
42+
- Default 100ms delay via global tooltip provider
43+
- Use`delayDuration={0}` when immediate tooltip needed
44+
- Systematically replace MUI components with custom/shadcn equivalents
45+
- Use shadcn/ui components first - check`site/src/components` for existing implementations
3146
- Do not use shadcn CLI - manually add components to maintain consistency
32-
- The modules folder should contain components with business logic specific to the codebase.
47+
- The modules folder should contain components with business logic specific to the codebase
3348
- Create custom components only when shadcn alternatives don't exist
3449

3550
##Styling
3651

37-
- Emotion CSS is deprecated. Use Tailwind CSS instead.
38-
- Use custom Tailwind classes in tailwind.config.js.
52+
-**Emotion CSS is STRICTLY DEPRECATED: "no new emotion styles, full stop"**
53+
- Never use`@emotion/react`,`css` prop,`useTheme()`, or emotion styled components
54+
- Always use Tailwind CSS utility classes instead
55+
- When touching code with emotion styles, refactor to Tailwind ("leave the campsite better than you found it")
56+
- Use custom Tailwind classes in tailwind.config.js
3957
- Tailwind CSS reset is currently not used to maintain compatibility with MUI
4058
- Responsive design - use Tailwind's responsive prefixes (sm:, md:, lg:, xl:)
4159
- Do not use`dark:` prefix for dark mode
4260

61+
###Common Emotion → Tailwind Migrations
62+
63+
```tsx
64+
// OLD - Emotion (DO NOT USE)
65+
import {typeInterpolation,typeTheme,useTheme }from"@emotion/react";
66+
<divcss={styles.container}>
67+
<Stackdirection="row"spacing={3}>
68+
<spancss={{ fontWeight:500, color:theme.experimental.l1.text }}>
69+
70+
// NEW - Tailwind
71+
<divclassName="flex flex-col gap-2">
72+
<divclassName="flex items-center gap-6">
73+
<spanclassName="font-medium text-content-primary">
74+
```
75+
76+
**Common replacements:**
77+
- `css={visuallyHidden}` → `className="sr-only"`
78+
- `Stack` component → flex with Tailwind classes (`flex`, `flex-col`, `flex-row`, `gap-*`)
79+
- Theme colors → Tailwind semantic tokens (`text-content-primary`, `bg-surface-secondary`, `border-border-default`)
80+
- Icons: use lucide-react with `size-icon-sm`, `size-icon-xs` classes
81+
4382
## Tailwind Best Practices
4483

4584
- Group related classes
@@ -53,6 +92,66 @@ When investigating or editing TypeScript/React code, always use the TypeScript l
5392
- Prefer `for...of` over `forEach` for iteration
5493
- **Biome** handles both linting and formatting (not ESLint/Prettier)
5594

95+
## Testing Patterns
96+
97+
### Storybook: spyOn → queries parameter (for GET endpoint mocks)
98+
99+
**PREFERRED PATTERN**: Use `queries` parameter in story parameters instead of `spyOn` for GET endpoint mocks.
100+
101+
```tsx
102+
// OLD - spyOn pattern (AVOID for GET mocks)
103+
beforeEach: () =>{
104+
spyOn(API,"getUsers").mockResolvedValue({
105+
users:MockUsers,
106+
count:MockUsers.length,
107+
});
108+
spyOn(API,"getTemplates").mockResolvedValue([MockTemplate]);
109+
}
110+
111+
// NEW - queries parameter pattern (PREFERRED)
112+
parameters:{
113+
queries: [
114+
{
115+
key:usersKey({ q:"" }),
116+
data: {
117+
users:MockUsers,
118+
count:MockUsers.length,
119+
},
120+
},
121+
{
122+
key:getTemplatesQueryKey({ q:"has-ai-task:true" }),
123+
data: [MockTemplate],
124+
},
125+
],
126+
}
127+
```
128+
129+
**Important notes:**
130+
- This applies specifically to GET endpoint mocks in Storybook stories
131+
- `spyOn` is still used for other mock types (POST, PUT, DELETE, non-GET endpoints)
132+
- Must import the correct query key functions (e.g., `usersKey`, `getTemplatesQueryKey`)
133+
134+
### Chromatic/Storybook Testing Best Practices
135+
136+
- **Prefer visual validation through snapshots** over programmatic assertions
137+
- Chromatic snapshots catch visual changes during review
138+
- Avoid programmatic assertions in stories that duplicate what snapshots show
139+
- Programmatic assertions can introduce flakiness - remove when redundant
140+
- Stories are snapshot tests - rely on the screenshot to verify correctness
141+
142+
## State Storage
143+
144+
### localStorage vs user_configs table
145+
146+
**IMPORTANT**: For user preferences that should persist across devices and browsers, use the `user_configs` table in the backend, NOT `localStorage`.
147+
148+
- **localStorage is browser-specific**, not user-specific
149+
- **User preferences should persist** across devices/browsers
150+
- Follow the plumbing for `theme_preference` as a reference example
151+
- localStorage may be acceptable only for truly transient UI state that doesn't need to follow the user
152+
153+
**Key principle**: If a user dismisses something or sets a preference, it should be tied to their account, not their browser.
154+
56155
## Workflow
57156

58157
- Be sure to typecheck when you're done making a series of code changes

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp