# Operation: Update Component
**Purpose:** Update an existing component definition (not adding variant, but modifying existing).
**When:** Component needs changes (new state, styling update, behavior change)
**Input:** Component ID + update specification
**Output:** Updated component file
---
## When to Use This Operation
**Use this operation when:**
- Adding new state to all variants (e.g., adding "loading" state)
- Updating shared styling (e.g., changing border-radius)
- Modifying behavior (e.g., adding keyboard shortcut)
- Updating accessibility attributes
- Refining documentation
- Fixing errors in component definition
**Don't use this operation for:**
- Adding new variant → Use `add-variant.md`
- Creating new component → Use `create-new-component.md`
- Reusing component → Handled by assessment flow
---
## Step 1: Identify Update Type
Determine what's being updated:
**Update Types:**
### Type A: Add New State
Adding state to all variants (e.g., loading, error, success)
### Type B: Update Styling
Changing visual properties (colors, sizing, spacing)
### Type C: Update Behavior
Changing interactions, animations, or keyboard support
### Type D: Update Accessibility
Adding/modifying ARIA attributes or screen reader support
### Type E: Update Documentation
Clarifying usage, adding examples, fixing errors
### Type F: Refactor
Reorganizing component structure, splitting/merging variants
```
What type of update is this?
[A] Add new state
[B] Update styling
[C] Update behavior
[D] Update accessibility
[E] Update documentation
[F] Refactor component
Your choice:
```
---
## Step 2: Load Current Component
Read existing component file:
- Current definition
- All variants
- Current states
- Current styling
- Usage tracking
---
## Step 3: Analyze Impact
Determine impact of update:
**Impact Assessment:**
### Scope
- All variants affected?
- Specific variant only?
- All instances affected?
- Specific usage only?
### Breaking Changes
- Does this change existing behavior?
- Will existing pages need updates?
- Does this affect developers?
### Compatibility
- Compatible with current usage?
- Requires page spec updates?
- Requires code changes?
---
## Step 4: Confirm Update
```
Ready to update Button [btn-001]
Update: Add "loading" state
Impact: 9 pages (no breaking changes)
This will:
✓ Add loading state to component definition
✓ Update all variant documentation
✓ Maintain backward compatibility
Proceed with update? (y/n)
````
---
## Step 5: Apply Update
Update component file based on type:
### Type A: Add New State
**Update States Section:**
**Before:**
```markdown
## States
**Shared States:**
- default
- hover
- active
- disabled
````
**After:**
```markdown
## States
**Shared States:**
- default
- hover
- active
- disabled
- loading ← Added
**State Descriptions:**
**Loading:**
- Disabled interaction
- Shows spinner icon
- Maintains button size
- Reduced opacity (0.7)
```
**Update Variant-Specific Sections (if needed):**
```markdown
### Variant-Specific Styling
**Navigation (loading state):**
- Spinner + arrow icon
- Arrow fades out during loading
```
### Type B: Update Styling
**Update Styling Section:**
**Before:**
```markdown
### Visual Properties
**Border Radius:** 0.375rem (md)
```
**After:**
```markdown
### Visual Properties
**Border Radius:** 0.5rem (lg) ← Updated
**Change Reason:** Increased for better visual consistency with other components
```
### Type C: Update Behavior
**Update Behavior Section:**
**Before:**
```markdown
### Keyboard
- Enter/Space: Triggers button action
- Tab: Moves focus to/from button
```
**After:**
```markdown
### Keyboard
- Enter/Space: Triggers button action
- Tab: Moves focus to/from button
- Escape: Cancels action (if in progress) ← Added
```
### Type D: Update Accessibility
**Update Accessibility Section:**
**Before:**
```markdown
**ARIA Attributes:**
- role: button
- aria-disabled: true [when disabled]
```
**After:**
```markdown
**ARIA Attributes:**
- role: button
- aria-disabled: true [when disabled]
- aria-busy: true [when loading] ← Added
- aria-live: polite [for status updates] ← Added
```
### Type E: Update Documentation
**Update Usage Section:**
**Before:**
```markdown
### When to Use
- Primary actions
- Secondary actions
```
**After:**
```markdown
### When to Use
- Primary actions (submit forms, save data, proceed to next step)
- Secondary actions (cancel, go back, dismiss)
- Triggering modals or dialogs ← Added
- Navigation to new pages/sections ← Added
### When Not to Use
- For navigation that looks like text (use Link component) ← Added
- For toggling states (use Toggle or Checkbox) ← Added
```
### Type F: Refactor
**Example: Split variant into separate component**
```markdown
## Refactoring Note
**Date:** 2024-12-09
**Change:** Moved "icon-only" variant to separate Icon Button component
**Reason:** Icon-only buttons have significantly different:
- Visual structure (no text)
- Accessibility requirements (requires aria-label)
- Usage patterns (toolbars, compact spaces)
**Migration:**
- Old: Button.icon-only [btn-001]
- New: Icon Button [btn-002]
**Affected Pages:** 5 pages
**Migration Status:** Complete
```
---
## Step 6: Update Version History
Track update in version history:
**Update:**
```markdown
## Version History
**Created:** 2024-12-01
**Last Updated:** 2024-12-09
**Changes:**
- 2024-12-01: Created component
- 2024-12-05: Added navigation variant
- 2024-12-09: Added loading state to all variants ← Added
```
---
## Step 7: Notify Affected Pages
If update affects existing usage, create notification:
---
## Step 8: Update Design System Stats
Update design system metadata:
**Update:** `D-Design-System/README.md`
```markdown
**Last Updated:** 2024-12-09
**Recent Changes:**
- Button [btn-001]: Added loading state
````
---
## Step 9: Complete
---
## Validation
Validate update:
- ✓ Component file updated
- ✓ Changes documented
- ✓ Version history updated
- ✓ Impact assessed
- ✓ Notifications sent (if needed)
- ✓ Backward compatibility maintained
---
## Error Handling
**If update creates breaking change:**
```
⚠️ Breaking Change Detected
This update will break existing usage:
- [List of breaking changes]
- Affected pages: [count]
Breaking changes require:
1. Designer confirmation
2. Migration plan
3. Page spec updates
Proceed with breaking change? (y/n)
If yes, I'll create a migration checklist.
```
**If component file locked:**
```
⚠️ Component file is being edited elsewhere.
Component: Button [btn-001]
Status: Locked by [user/process]
Options:
1. Wait and retry
2. Force update (may cause conflicts)
3. Cancel update
Your choice:
```
**If update conflicts with variants:**
```
⚠️ Update Conflict Detected
You're trying to add "loading" state to all variants,
but "navigation" variant already has a different loading implementation.
Current navigation loading: Spinner + icon animation
Proposed loading: Spinner only
Options:
1. Override navigation variant (make consistent)
2. Keep navigation variant different (document exception)
3. Cancel update
Your choice:
````
---
## Post-Update Actions
### If Breaking Change
Create migration checklist:
**Output:**
```markdown
# Migration Checklist: Button [btn-001] Update
**Update:** [Description]
**Breaking Changes:** [List]
**Affected Pages:** [Count]
## Migration Steps
- [ ] Review all affected pages
- [ ] Update page specifications
- [ ] Test updated pages
- [ ] Update documentation
- [ ] Deploy changes
## Affected Pages
- [ ] Login page - [Specific changes needed]
- [ ] Signup page - [Specific changes needed]
- [ ] Dashboard - [Specific changes needed]
[... more pages]
## Rollback Plan
If issues arise:
1. Revert component file to previous version
2. Restore page specifications
3. Document issues encountered
````
### If Major Update
Suggest design system review:
---
**This operation updates a component. Changes apply to all future usage automatically.**
```