2.1 KiB
2.1 KiB
Generate Component (gc)
Generate an FSD component using the project's generator script.
Usage
/gc <layer> <ComponentName>
Arguments:
$ARGUMENTS— expects<layer> <ComponentName>, e.g.shared Button,entity ProjectCard,feature CreateProjectModal
Layers
| Alias | Path |
|---|---|
shared |
src/shared/ui/ |
entity / entities |
src/entities/ |
feature / features |
src/features/ |
widget / widgets |
src/widgets/ |
page / pages |
src/pages/ |
Instructions
-
Parse
$ARGUMENTSto extract<layer>and<ComponentName>. If arguments are missing or unclear, ask the user. -
Run the generator:
bun run gc <layer> <ComponentName> -
This creates 4 files:
index.ts— re-exports the component<ComponentName>.tsx— component implementation withFunctionComponent,JSX.Element, SCSS module import,data-testid<ComponentName>.d.ts— props interfaceI<ComponentName>PropswithclassName?: string<ComponentName>.module.scss— empty.root {}class
-
After generation, report the created files and the full path.
-
If the user provides additional context about what the component should do or look like, modify the generated files accordingly:
- Add props to the
.d.tsfile - Implement the component logic in
.tsx - Add styles to
.module.scss - Use existing project patterns:
classnamesascs, typography/mixin includes from auto-injected SCSS partials, Radix UI primitives or Themes where appropriate,lucide-reacticons
- Add props to the
Project Conventions
- Props interface:
I<ComponentName>Propsin a.d.tsfile - Import types with
import type { ... } - Import order: types → react/libs → path aliases (
@shared/,@entities/, etc.) → local - Use
cs()fromclassnamesfor combining classes - Root element gets
className={styles.root}anddata-testid="<ComponentName>" - SCSS auto-injected namespaces:
variables,breakpoints,typography,mixins - Use
"use client"directive only when component uses hooks or browser APIs