name: 'step-08d-add-variant' description: 'Add a new variant to an existing component in the design system'
Add a new variant to an existing component: extract variant-specific info, determine name, update component file, track usage, validate addition.
{communication_language}Read existing component file:
Example:
Component: Button [btn-001]
Current Variants:
- primary (submit actions)
- secondary (cancel actions)
```
📖 Loaded Button [btn-001]
Current variants: 2 (primary, secondary)
Adding new variant: navigation
````
From new component specification, extract:
Example:
Shared with existing:
- Size: medium
- Shape: rounded
- Base states: default, hover, active, disabled
Different from existing:
- Has icon (arrow-right)
- Has loading state
- Icon animation on hover
- Purpose: navigation vs submission
````
---
## Step 3: Determine Variant Name
<action>
Generate descriptive variant name:
- Based on purpose or visual distinction
- Consistent with existing variant naming
- Clear and semantic
</action>
**Examples:**
Purpose-based:
Visual-based:
Context-based:
inline (used inline with text)
<ask>
Suggested variant name: "navigation"
This variant is for navigation actions (continue, next, proceed).
Is this name clear and appropriate? (y/n) Or suggest alternative name:
</ask>
---
## Step 4: Update Component File
<action>
Add variant to component definition:
</action>
### Update Variants Section
**Before:**
```markdown
## Variants
- **primary** - Main call-to-action (submit, save, continue)
- **secondary** - Secondary actions (cancel, back)
After:
## Variants
- **primary** - Main call-to-action (submit, save, continue)
- **secondary** - Secondary actions (cancel, back)
- **navigation** - Navigation actions (next, proceed, continue) ← Added
Add section:
### Variant-Specific Styling
**Primary:**
- Background: blue-600
- Icon: none
- Loading: spinner only
**Secondary:**
- Background: gray-200
- Text: gray-900
- Icon: none
**Navigation:** ← Added
- Background: blue-600
- Icon: arrow-right
- Loading: spinner + icon
- Hover: icon shifts right
If navigation variant has loading state but others don't:
## States
**Shared States (all variants):**
- default
- hover
- active
- disabled
**Variant-Specific States:**
**Navigation:**
- loading (shows spinner, disables interaction)
Track new variant usage:
Add to component file:
## Variant Usage
**Primary:** 5 pages
**Secondary:** 3 pages
**Navigation:** 1 page ← Added
**Navigation variant used in:**
- Onboarding page (continue button)
Add note about variant count:
If this is 3rd+ variant:
## Notes
This component now has 3 variants. Consider:
- Are all variants necessary?
- Should any variants be separate components?
- Is the component becoming too complex?
Review component organization when reaching 5+ variants.
Check for potential issues:
Variant Explosion Check:
⚠️ Variant Count: 3
This is manageable. Monitor for variant explosion as more are added.
Recommended maximum: 5 variants per component
Consistency Check:
✓ New variant consistent with existing variants
✓ Naming convention followed
✓ Shared attributes maintained
Complexity Check:
⚠️ Navigation variant adds loading state not present in other variants.
This increases component complexity. Consider:
- Should loading state be shared across all variants?
- Or is it truly navigation-specific?
Current approach: Variant-specific (acceptable)
Track component changes:
Update version history:
## Version History
**Created:** 2024-12-01
**Last Updated:** 2024-12-09
**Changes:**
- 2024-12-01: Created component with primary and secondary variants
- 2024-12-09: Added navigation variant ← Added
Generate reference for page spec:
Output:
component_reference:
id: btn-001
name: Button
variant: navigation ← New variant
file: D-Design-System/components/button.md
Validate variant addition:
If variant name conflicts:
⚠️ Variant "navigation" already exists in Button [btn-001].
This might mean:
1. You're trying to add a duplicate
2. The existing variant should be updated
3. A different variant name is needed
Current navigation variant:
[Show existing variant details]
Options:
1. Update existing variant
2. Choose different name
3. Cancel
Your choice:
If component file not found:
❌ Error: Component file not found.
Component ID: btn-001
Expected file: D-Design-System/components/button.md
This shouldn't happen. Possible causes:
- File was deleted
- Component ID is incorrect
- Design system structure corrupted
Would you like to:
1. Create component as new
2. Specify correct component ID
3. Cancel
Your choice:
If variant too different:
⚠️ Warning: High Divergence Detected
The new variant is very different from existing variants:
- Different core purpose
- Different visual structure
- Different behavioral patterns
Similarity to existing variants: 35%
This might be better as a separate component.
Options:
1. Add as variant anyway
2. Create as new component instead
3. Review differences in detail
Your choice:
After adding variant, check component health:
Component Health Check:
📊 Component Health: Button [btn-001]
Variants: 3
Complexity: Medium
Consistency: High
Usage: 9 pages
Health Status: ✅ Healthy
Recommendations:
- Document variant selection guidelines
- Consider adding variant usage examples
- Monitor for variant explosion
This operation adds a variant. Return to Phase 4 with component reference. ```
Display: "Select an Option: [C] Continue to Generate Catalog or [M] Return to Activity Menu"
ONLY WHEN [variant is added, component file updated, and usage tracked], will you then load and read fully {nextStepFile} to execute the next step.
Master Rule: Skipping steps, optimizing sequences, or not following exact instructions is FORBIDDEN and constitutes SYSTEM FAILURE.