summaryrefslogtreecommitdiffstats
path: root/WEEK4-PLAN.md
blob: 755aa485af15117ab5c12a9416091e990744d5b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
# Week 4 Plan: Forms & Interactions
**Date Started:** 2026-04-16 | **Branch:** `week-4-forms` | **Estimated Duration:** 6–8 hours

---

## 🎯 Week 4 Objectives

### 1. Form Component System
Build a reusable form component library with accessibility and styling.

#### Components to Create:
- **Input Fields** (`.form-input`)
  - Text input, email, password, number
  - States: default, focus, invalid, disabled
  - Placeholder and label styling
  - Error message display
  - Character count support (optional)

- **Textareas** (`.form-textarea`)
  - Resizable or fixed height
  - Auto-expanding variant
  - Character limit indicator
  - Syntax highlighting placeholder (optional)

- **Select Dropdowns** (`.form-select`)
  - Native `<select>` styling
  - Multi-select support
  - Custom styled variant (Alpine.js powered)
  - Accessible keyboard navigation

- **Checkboxes & Radio Buttons** (`.form-checkbox`, `.form-radio`)
  - Custom styled (not browser defaults)
  - Grouped layouts (inline, stacked)
  - Label association (proper `<label for="">`)
  - Accessible keyboard navigation

- **Form Groups** (`.form-group`)
  - Label + input + error message layout
  - Spacing consistency
  - Validation state indicators
  - Help text support

#### Styling Requirements:
- ✅ Dark mode support (all components)
- ✅ Light mode support (all components)
- ✅ Focus indicators (2px ring, visible)
- ✅ Error states (red outline, error message)
- ✅ Disabled states (opacity, cursor)
- ✅ WCAG AA contrast verified
- ✅ Touch targets ≥44px (mobile)
- ✅ Consistent spacing (8px grid)

---

### 2. Form Layouts & Patterns
Implement common form patterns using the component library.

#### Layouts:
- **Single Column**
  - Contact form (name, email, message)
  - Newsletter signup (email, subscribe button)
  - Search form (input, submit)

- **Multi Column**
  - Registration form (2–3 columns on desktop, 1 on mobile)
  - Filter/search form (label + input grids)

- **Inline Forms**
  - Search bar (icon + input + button)
  - Newsletter widget (email + button)

#### Validation Patterns:
- **Client-side** (Alpine.js)
  - Required field checking
  - Email format validation
  - Password strength indicator
  - Conditional field visibility (show/hide based on selection)

- **Server-side Integration**
  - PHP contact form endpoint (`contact.php`)
  - Error message display
  - Success/confirmation messaging
  - CSRF token handling (if applicable)

#### Form States:
- Empty (pristine)
- Focused (active field)
- Filled (has value)
- Invalid (validation error)
- Submitting (loading spinner)
- Submitted (success message)

---

### 3. Modals & Overlays
Build reusable modal components for alerts, confirmations, and content.

#### Modal Variants:
- **Alert Modal** (`.modal-alert`)
  - Single action button (OK, Close)
  - Message display
  - Optional icon

- **Confirmation Modal** (`.modal-confirm`)
  - Two action buttons (Confirm, Cancel)
  - Title + message
  - Danger state (red button for destructive actions)

- **Content Modal** (`.modal-content`)
  - Close button (X)
  - Title + body + footer
  - Large, medium, small sizes
  - Scrollable content

#### Modal Features:
- ✅ Backdrop (semi-transparent overlay)
- ✅ Keyboard handling (Escape to close, Tab trap)
- ✅ Focus management (focus inside modal, restore on close)
- ✅ Animation (fade in/out, slide up)
- ✅ Responsive (full-screen on mobile, centered on desktop)
- ✅ WCAG compliant (role="dialog", aria-labelledby)

#### Alpine.js Integration:
- `x-data="{ open: false }"`
- `@click.outside="open = false"` (close on background click)
- `@keydown.escape="open = false"` (close on Escape)
- Smooth transitions with `x-transition`

---

### 4. Interactive Patterns
Enhance user interactions with feedback and validation.

#### Patterns:
- **Form Submission Feedback**
  - Loading spinner during submission
  - Success toast/notification
  - Error notification with retry
  - Progress indicator (for long forms)

- **Inline Validation**
  - Real-time feedback as user types
  - Email format validation
  - Password strength meter
  - Character count display

- **Loading States**
  - Spinner component (animated SVG or CSS)
  - Button disabled state during submission
  - Loading overlay (for full-page actions)

- **Toast Notifications**
  - Success (green)
  - Error (red)
  - Info (blue)
  - Warning (amber)
  - Auto-dismiss (5 seconds)
  - Manual close button

- **Tooltips**
  - Hover to show/hide
  - Fixed positioning (stays visible)
  - Arrow pointing to target
  - Dark/light mode support

---

## 📊 Implementation Roadmap

| Task | Description | Est. Time | Dependencies |
|------|-------------|-----------|--------------|
| **1. Input Fields** | Text, email, password inputs | 1.5h | Week 3 (CSS vars) |
| **2. Textareas** | Resizable, auto-expand variants | 0.75h | Input fields |
| **3. Selects** | Native + custom styled dropdowns | 1h | Input fields |
| **4. Checkboxes/Radios** | Custom styled with groups | 1h | Input fields |
| **5. Form Groups** | Label + input + error layout | 0.5h | All inputs |
| **6. Form Layouts** | Single/multi-column patterns | 1h | Form groups |
| **7. Validation** | Client-side Alpine.js validation | 1h | Form layouts |
| **8. Modals** | Alert/confirm/content modals | 1.5h | Alpine.js |
| **9. Loading States** | Spinners, disabled buttons | 0.75h | Modals |
| **10. Notifications** | Toast system, tooltips | 1h | Loading states |
| **11. Testing** | Dark/light, mobile, a11y | 1.5h | All components |
| **12. Integration** | Update existing forms/templates | 1h | Testing |

**Total Estimated Time:** 6–8 hours

---

## 🛠 Technical Specifications

### CSS Structure
```
main.css
├── Forms
│   ├── Input fields
│   ├── Textareas
│   ├── Selects
│   ├── Checkboxes/Radios
│   ├── Form groups
│   └── Form layouts
├── Modals
│   ├── Backdrop
│   ├── Dialog containers
│   └── Modal animations
├── States
│   ├── Loading spinners
│   ├── Toast notifications
│   └── Tooltips
└── Utilities
    ├── Z-index management
    ├── Focus management
    └── Responsive overrides
```

### Alpine.js Patterns
```javascript
// Form validation
x-data="{ email: '', error: null }"
@input="validateEmail(email)"

// Modal control
x-data="{ open: false }"
@click.outside="open = false"
@keydown.escape="open = false"

// Loading state
x-data="{ loading: false }"
@click="submitForm()"

// Toast notification
x-data="{ visible: true }"
x-init="setTimeout(() => visible = false, 5000)"
```

### Tailwind CSS Classes
- Form inputs: `.form-input`, `.form-input:focus`, `.form-input:invalid`
- Textareas: `.form-textarea`, `.form-textarea:focus`
- Selects: `.form-select`, `.form-select:focus`
- Checkboxes: `.form-checkbox`, `.form-checkbox:checked`
- Radio buttons: `.form-radio`, `.form-radio:checked`
- Form groups: `.form-group`, `.form-group.error`
- Modals: `.modal`, `.modal-backdrop`, `.modal-content`
- Loading: `.spinner`, `.spinner-sm`, `.spinner-lg`
- Toast: `.toast`, `.toast-success`, `.toast-error`, `.toast-info`, `.toast-warning`
- Tooltips: `.tooltip`, `.tooltip-top`, `.tooltip-bottom`, `.tooltip-left`, `.tooltip-right`

---

## ✅ Testing Strategy

### Functional Testing
- ✅ Form input focus/blur behavior
- ✅ Validation (valid/invalid states)
- ✅ Character count/limits
- ✅ Modal open/close (click button, click outside, press Escape)
- ✅ Toast auto-dismiss
- ✅ Spinner animation
- ✅ Tooltip show/hide

### Responsive Testing
- ✅ Mobile (320px): Single column, full-width inputs
- ✅ Tablet (768px): Multi-column layouts work
- ✅ Desktop (1060px+): Full layout visible

### Accessibility Testing
- ✅ Keyboard navigation (Tab, Shift+Tab, Enter, Space, Escape)
- ✅ Focus indicators (visible on all interactive elements)
- ✅ ARIA labels (form labels, modal title, button text)
- ✅ Focus trap (modal keeps focus inside)
- ✅ Screen reader (semantic HTML, proper roles)

### Dark/Light Mode Testing
- ✅ Form inputs contrast (dark/light)
- ✅ Modal backdrop contrast
- ✅ Toast notifications contrast
- ✅ Spinner color visibility
- ✅ Tooltip background/text contrast

### Cross-browser Testing
- ✅ Chrome (latest)
- ✅ Firefox (latest)
- ✅ Safari (latest)

---

## 📝 Deliverables

1. **WEEK4-IMPLEMENTATION.md** — Detailed component documentation
2. **FORM-COMPONENT-GUIDE.md** — Usage examples for all form components
3. **WEEK4-TESTING.md** — Testing checklist and results
4. **CSS Output**`main.css` with all form/modal/interaction styles
5. **Updated Templates** — Forms integrated into existing pages
6. **HANDOFF.md** — Updated with Week 4 summary

---

## 🚀 Success Criteria

✅ All form components built and styled
✅ Dark/light mode support verified
✅ WCAG AA accessibility verified
✅ Responsive design tested (320px, 768px, 1060px+)
✅ Modal functionality working (open, close, focus trap)
✅ Client-side validation working (real-time feedback)
✅ Toast notifications auto-dismiss
✅ CSS build time < 250ms
✅ No regressions from previous weeks
✅ All components documented with examples

---

## 🔗 Dependencies & Prerequisites

- ✅ Week 3 (Cards & Navigation) completed
- ✅ CSS variables established (colors, spacing)
- ✅ Alpine.js loaded and functional
- ✅ Button/badge component library available
- ✅ Tailwind CSS build pipeline working

---

## ⚙️ Git Workflow

**Branch:** `week-4-forms` (created at session start)
**Base:** `master`
**Merge Strategy:** Review all changes, test thoroughly, merge to master at week end

### Before Starting
```bash
git checkout master
git pull origin master
git checkout -b week-4-forms
npm run watch  # Start CSS watch during development
```

### Before Committing
```bash
npm run build  # Build minified CSS
git add themes/danix-xyz-hacker/assets/css/main.* layouts/partials/...
git commit -m "feat: <component description>"
```

### At Week End
```bash
npm run build  # Final CSS build
git log week-3-cards-nav..week-4-forms  # Review commits
git checkout master
git merge week-4-forms
git push origin master
git branch -d week-4-forms
```

---

## 📚 Reference Materials

- **CSS Variables:** See `COLOR-REFERENCE.md` for all available variables
- **Button Component:** Reference `WEEK2-IMPLEMENTATION.md` for styling patterns
- **Card Component:** Reference `WEEK3-COMPLETION.md` for layout patterns
- **Alpine.js Docs:** https://alpinejs.dev/
- **Tailwind CSS Docs:** https://tailwindcss.com/docs
- **Accessible Forms:** https://www.w3.org/WAI/tutorials/forms/

---

## 🎯 Next Steps (After Week 4)

- **Week 5:** Animations & A11y (CSS keyframes, motion preferences, full audit)
- **Week 6:** Pages & Testing (About, Contact, 404 pages, end-to-end testing)

---

**Status:** Ready to start
**Assigned to:** Danilo M.
**Created:** 2026-04-16