Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
208 changes: 208 additions & 0 deletions docs/component-migration-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
# Component Migration Plan - FL to BEM Architecture

## Progress Summary

### ✅ Completed
1. **Critical CSS Removal** - 312KB of duplicated inline CSS removed
- All critical CSS injections disabled across 16 template files
- Hugo build successful after removal
- Site functional with render-blocking CSS (acceptable trade-off)
- Test failures reduced from 10 to 7

### 🎯 Current State
- FL-Builder CSS: 1.33MB (active framework, not removable yet)
- Visual regression tests: 7 failures (improvement from 10)
- Site performance: Slightly degraded initial render, but better caching

## Component Migration Strategy

### Phase 1: Core Component Structure (Current)
Create reusable BEM components to replace FL-Builder patterns:

#### 1.1 Navigation Component (c-nav)
```css
.c-nav { /* Main navigation wrapper */ }
.c-nav__menu { /* Menu container */ }
.c-nav__item { /* Individual menu items */ }
.c-nav__link { /* Navigation links */ }
.c-nav--mobile { /* Mobile variation */ }
```
- Replace: `.fl-page-nav`, `.fl-nav-menu`
- Files affected: All page templates

#### 1.2 Hero Component (c-hero)
```css
.c-hero { /* Hero section wrapper */ }
.c-hero__content { /* Content container */ }
.c-hero__title { /* Main heading */ }
.c-hero__description { /* Subtitle/description */ }
.c-hero__cta { /* Call-to-action buttons */ }
.c-hero--centered { /* Centered variation */ }
```
- Replace: `.fl-row-bg-photo`, `.fl-heading`
- High impact: Used on homepage, services, about

#### 1.3 Content Block Component (c-content)
```css
.c-content { /* Content section */ }
.c-content__wrapper { /* Inner wrapper */ }
.c-content__title { /* Section title */ }
.c-content__body { /* Main content */ }
.c-content__media { /* Images/videos */ }
.c-content--reversed { /* Media on left */ }
```
- Replace: `.fl-module-rich-text`, `.fl-col-content`
- Most frequently used component

#### 1.4 Card Component (c-card)
```css
.c-card { /* Card container */ }
.c-card__image { /* Card image */ }
.c-card__body { /* Card content */ }
.c-card__title { /* Card heading */ }
.c-card__text { /* Card description */ }
.c-card__link { /* Card CTA */ }
.c-card--horizontal { /* Horizontal layout */ }
```
- Replace: `.fl-module`, service cards, testimonials
- Used in services, use-cases, clients

### Phase 2: Specialized Components

#### 2.1 Testimonial Component (c-testimonial)
```css
.c-testimonial { /* Testimonial wrapper */ }
.c-testimonial__quote { /* Quote text */ }
.c-testimonial__author { /* Author info */ }
.c-testimonial__company { /* Company/role */ }
.c-testimonial__avatar { /* Author image */ }
```

#### 2.2 CTA Component (c-cta)
```css
.c-cta { /* Call-to-action section */ }
.c-cta__heading { /* CTA title */ }
.c-cta__text { /* CTA description */ }
.c-cta__button { /* CTA button */ }
.c-cta--centered { /* Centered variation */ }
```

#### 2.3 Form Component (c-form) - Already Started
```css
.c-form { /* Form wrapper */ }
.c-form__field { /* Form field */ }
.c-form__label { /* Field label */ }
.c-form__input { /* Input field */ }
.c-form__submit { /* Submit button */ }
```

### Phase 3: Layout Components

#### 3.1 Grid System (c-grid)
```css
.c-grid { /* Grid container */ }
.c-grid__item { /* Grid item */ }
.c-grid--2-col { /* 2 column grid */ }
.c-grid--3-col { /* 3 column grid */ }
.c-grid--responsive { /* Responsive grid */ }
```

#### 3.2 Section Component (c-section)
```css
.c-section { /* Page section */ }
.c-section__container { /* Content container */ }
.c-section--full-width { /* Full width section */ }
.c-section--padded { /* With padding */ }
```

## Implementation Approach

### Micro-refactoring Strategy
1. **Dual-class approach** during transition
- Add BEM classes alongside FL classes
- Gradually remove FL dependencies
- Maintain visual consistency

2. **Component-by-component migration**
- Start with most used components (content blocks)
- Test after each component migration
- Maximum 3 components per sprint

3. **Testing protocol**
- Visual regression test after each component
- Cross-browser validation
- Mobile responsiveness check
- Performance impact measurement

### File Organization
```
themes/beaver/assets/css/components/
├── base/
│ ├── c-grid.css
│ └── c-section.css
├── layout/
│ ├── c-nav.css
│ └── c-footer.css
└── blocks/
├── c-hero.css
├── c-card.css
├── c-content.css
├── c-testimonial.css
├── c-cta.css
└── c-form.css (existing)
```
Comment on lines +138 to +153
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add a language to this fenced code block

Markdownlint (MD040) flags the bare triple backtick fence around the directory tree. Add a language identifier (e.g., text) so the docs pipeline passes.

-```
+```text
 themes/beaver/assets/css/components/
 ├── base/
 │   ├── c-grid.css
🧰 Tools
🪛 markdownlint-cli2 (0.18.1)

138-138: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
In docs/component-migration-plan.md around lines 138 to 153, the fenced code
block showing the directory tree is missing a language identifier which triggers
markdownlint MD040; update the opening triple-backtick fence to include a
language (for example "text") so it becomes ```text and leave the block contents
unchanged, then save the file so the docs pipeline no longer flags the block.


## Success Metrics

### Target Outcomes
- CSS reduction: 1.33MB → <500KB (62% reduction)
- Page load improvement: 20-30% faster
- Maintenance effort: 50% reduction
- Component reusability: 80% of UI from components

### Quality Gates
- ✅ Visual regression tests pass
- ✅ Lighthouse score maintained/improved
- ✅ Cross-browser compatibility verified
- ✅ Mobile responsiveness validated
- ✅ No accessibility regressions

## Next Actions

### Immediate (Sprint 1)
1. Create c-hero component for homepage
2. Create c-content component for main sections
3. Update templates with dual classes
4. Test and validate changes

### Short-term (Sprint 2-3)
1. Migrate navigation to c-nav
2. Create c-card for services/testimonials
3. Implement c-cta components
4. Begin FL class removal

### Medium-term (Sprint 4-6)
1. Complete all component migrations
2. Remove FL-Builder CSS files
3. Optimize component CSS
4. Document component library

## Risk Mitigation

### Rollback Strategy
- Git commits after each micro-change
- Backup FL CSS files before removal
- Feature flags for component switching
- A/B testing capability

### Testing Safeguards
- Automated visual regression tests
- Manual QA on staging
- Performance monitoring
- User acceptance testing

---

*Goal: Remove all CSS duplications and migrate to reusable component architecture*
*Method: XP methodology with micro-refactoring and continuous validation*
*Timeline: 6 sprints (12 weeks) for complete migration*
110 changes: 110 additions & 0 deletions docs/css-optimization-findings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# CSS Optimization Findings & Migration Strategy

## Current State Analysis

### Critical CSS Duplication Problem
- **312KB** of critical CSS files duplicating the entire FL-Builder framework inline on every page
- Location: `themes/beaver/layouts/partials/header/critical/`
- Each page loads 30-50KB of inline CSS that cannot be cached
- FL framework repeated 10+ times across the site

### FL-Builder CSS Framework Status
- **1.33MB** total CSS framework (not legacy, but active layout system)
- Visual regression tests confirm FL CSS is required for site functionality
- 10 tests failed when FL CSS was removed in Phase 2

### Files Using Critical CSS Injections
Templates with critical CSS partials:
- `themes/beaver/layouts/page/careers.html` → `critical/careers.html`
- `themes/beaver/layouts/page/services.html` → `critical/services.html`
- `themes/beaver/layouts/clients/single.html` → `critical/single/clients.html`
- `themes/beaver/layouts/services/single.html` → `critical/single/services.html`
- `themes/beaver/layouts/careers/single.html` → `critical/single/careers.html`
- And 11 more templates

## Migration Strategy

### Phase 1: Remove Critical CSS Injections (Immediate)
1. Comment out all `{{ partial "header/critical/*.html" . }}` includes
2. Accept temporary performance degradation (render-blocking CSS)
3. Reduce HTML payload by 30-50KB per page
4. Enable browser caching of FL CSS files

### Phase 2: Create Reusable Component Architecture
1. Migrate from FL-Builder classes to BEM components
2. Use existing `forms-migration.css` as template for dual-class strategy
3. Target components:
- Navigation (c-nav)
- Hero sections (c-hero)
- Content blocks (c-content)
- CTAs (c-cta)
- Forms (c-form) - already started

### Phase 3: Optimize FL Framework
1. Remove orphaned FL node definitions (est. 200-400KB savings)
2. Extract common patterns into shared utilities
3. Consolidate page-specific CSS into component bundles
4. Target: Reduce 1.33MB to <500KB

## Technical Decisions

### Why Disable Critical CSS?
- Eliminates 312KB of duplication
- Reduces maintenance complexity
- Improves cacheability
- Acceptable trade-off: slight increase in render time for massive reduction in payload

### Component Migration Approach
- Dual-class strategy during transition (FL + BEM classes)
- Gradual migration per component
- Maintain visual consistency throughout
- Zero downtime deployment

## Implementation Plan

### Micro-refactoring Strategy (XP Methodology)
- Maximum 3 lines changed per commit
- Run `bin/test` after each change
- Target 5-20 commits per hour
- Shameless green first, then apply flocking rules

### Testing Protocol
1. Visual regression tests after each component migration
2. Performance monitoring with Lighthouse
3. Cross-browser validation
4. Mobile responsiveness checks

## Future Extensibility

### Component Library Benefits
- Reusable across all pages
- Easy to extend with new variations
- Consistent naming conventions
- Reduced CSS footprint
- Better maintainability

### Content Extension Support
- Components designed for content flexibility
- Variant modifiers for different contexts
- Responsive by default
- Accessibility built-in

## Next Steps

1. ✅ Document findings (this document)
2. ⏳ Disable critical CSS injections
3. ⏳ Create component migration plan
4. ⏳ Begin incremental migration
5. ⏳ Optimize remaining FL CSS

## Risk Mitigation

- All changes reversible via git
- Incremental approach minimizes risk
- Visual regression tests catch issues early
- Performance metrics tracked throughout

---

*Last Updated: [Current Date]*
*Goal: Remove all CSS duplications and migrate to reusable component architecture*
Loading