New components in @cuicui/ui follow a specific directory and file structure. They consist of a base component implementation and one or more variants.
1. Directory Structure
Components are organized by [section], then [category], then [component_name]. The path follows this pattern:
packages/ui/cuicui/[section]/[category]/[component_name]/
2. Implementation Steps
- Base Component: Create a
component.ts file containing the core logic and a ComponentProps interface. - Variants: Create
.variant.tsx files (e.g., primary.variant.tsx) that wrap the BaseComponent with specific styles or props. - Export Generation: After creating your files, you must run the
pre-build script to generate the necessary component exports.
3. Example Structure
📁 [component_name]
├── 📄 [variant1_name].variant.tsx
├── 📄 [variant2_name].variant.tsx
└── 📄 component.ts
# 1. Create the directory
mkdir -p packages/ui/cuicui/[section]/[category]/YourComponentName
# 2. (After writing component.ts and *.variant.tsx)
# 3. Generate exports
pnpm pre-build