# Examples & Case Studies Real-world examples demonstrating correct and incorrect application of frontend design principles. --- ## Table of Contents 1. [Case Study: Blog Search Bar (Design Consistency)](#case-study-blog-search-bar) 2. [Example: Component Reuse Decision Matrix](#example-component-reuse-decision) 3. [Example: Typography Consistency](#example-typography-consistency) 4. [Example: Layout Pattern Matching](#example-layout-pattern-matching) 5. [Anti-Example: Generic AI Slop](#anti-example-generic-ai-slop) --- ## Case Study: Blog Search Bar **Context:** Adding a search bar to a blog page in an existing Next.js application. ### ❌ WRONG APPROACH (Autopilot Mode) **What happened:** ``` User: "Blog page needs a search bar" Assistant: [Sees SearchBar component exists] → [Pastes component into blog page] → Done ``` **Implementation:** ```tsx // Blog page
// SearchBar component (from tools page) export default function SearchBar({ value, onChange }: SearchBarProps) { return (
{/* ← PROBLEM: Centered with narrow container */}
); } ``` **Result:** - ❌ Search bar centered on left-aligned page - ❌ max-w-2xl container inside max-w-5xl container - ❌ Visual inconsistency with rest of blog page - ❌ Breaks design language **Visual outcome:** ``` Blog Page (LEFT-ALIGNED, max-w-5xl) ┌─────────────────────────────────────────────────┐ │ Blog │ │ Real-world guides... │ │ │ │ ┌──────────────────┐ │ ← Centered, narrow │ │ [Search bar] │ │ │ └──────────────────┘ │ │ │ │ [All Posts - left-aligned cards] │ └─────────────────────────────────────────────────┘ ``` ### ✅ RIGHT APPROACH (Design-Thinking Mode) **Process:** **Phase 1: Design Language Analysis** ```markdown ## Design Language Analysis ### Files Scanned - src/app/blog/page.tsx (blog landing page) - src/app/page.tsx (tools page for comparison) - src/components/SearchBar.tsx - src/components/CategoryFilter.tsx - src/app/globals.css ### Layout Patterns - Blog page: LEFT-ALIGNED layout throughout - All blog sections use max-w-5xl container - Category filter buttons are left-aligned - Blog cards grid is left-aligned - Tools page (for comparison): CENTERED layout - Tools hero uses max-w-3xl centered - Tools SearchBar uses max-w-2xl centered **Key insight:** Blog page has CONSISTENT left-aligned pattern with max-w-5xl containers. ### Component Patterns - SearchBar component exists with built-in max-w-2xl mx-auto (centered) - This pattern works for tools page but NOT for blog page - Category filter on blog page is left-aligned (not centered) ``` **Phase 2: Design Decisions** ```markdown ## Design Decisions ### Pattern Application Blog page requires LEFT-ALIGNED full-width search within max-w-5xl container. Cannot use SearchBar's centered max-w-2xl pattern - would break consistency. ### Component Approach Options: 1. Add width/alignment variant props to SearchBar component 2. Create inline search input specifically for blog page 3. Create new FullWidthSearchBar component Decision: Option 1 - Extend SearchBar with optional props - Maintains component reuse - Allows flexibility for different layout contexts - Avoids code duplication ### Consistency Requirements MUST maintain: - max-w-5xl container (matches rest of blog page) - Full width within container (left-aligned, not centered) - Same input styling (h-11, pl-10, bg-card, search icon) - Same search functionality CAN vary: - Container width and alignment (adapts to page context) ``` **Phase 3: Implementation** ```tsx // Enhanced SearchBar component with layout props interface SearchBarProps { value: string; onChange: (value: string) => void; placeholder?: string; fullWidth?: boolean; // New prop } export default function SearchBar({ value, onChange, placeholder = "Search...", fullWidth = false // Default to centered (backward compatible) }: SearchBarProps) { return (
onChange(e.target.value)} placeholder={placeholder} className="w-full pl-10 pr-4 h-11 bg-card" />
); } // Blog page usage
// Tools page usage (unchanged, backward compatible)
``` **Result:** - ✅ Search bar matches blog page's left-aligned layout - ✅ Consistent max-w-5xl container width - ✅ Component reuse with flexibility - ✅ Backward compatible (tools page unchanged) - ✅ Design language preserved **Visual outcome:** ``` Blog Page (LEFT-ALIGNED, max-w-5xl) ┌─────────────────────────────────────────────────┐ │ Blog │ │ Real-world guides... │ │ │ │ ┌─────────────────────────────────────────────┐ │ ← Full width, left-aligned │ │ [Search bar] │ │ │ └─────────────────────────────────────────────┘ │ │ │ │ [All Posts - left-aligned cards] │ └─────────────────────────────────────────────────┘ ``` ### Key Lessons 1. **Don't skip analysis** - The checklist exists for a reason 2. **Scan multiple files** - Understanding context requires comprehensive analysis 3. **Document patterns** - Explicit output makes thinking visible 4. **Consider reuse vs creation** - Adapt existing components when possible 5. **Match the context** - Blog's left-aligned pattern ≠ Tools' centered pattern --- ## Example: Component Reuse Decision **Scenario:** Need a card component for a new dashboard section. ### Analysis **Existing components found:** 1. `ToolCard` - Border, rounded corners, hover effect, vertical layout 2. `BlogPostCard` - Border, rounded corners, gradient header, vertical layout 3. `FeatureCard` - No border, shadow effect, horizontal layout ### Decision Matrix | Option | Pros | Cons | Decision | |--------|------|------|----------| | Reuse ToolCard | Matches border/rounded style | Vertical layout might not fit | ❌ Layout mismatch | | Reuse FeatureCard | Horizontal layout fits | No border/rounded style | ❌ Style mismatch | | Create DashboardCard | Perfect fit for needs | New component = maintenance | ⚠️ Only if truly different | | **Extend ToolCard with layout prop** | Reuses existing + flexible | Small refactor needed | ✅ **Best choice** | ### Implementation ```tsx // Extended ToolCard with layout variant interface ToolCardProps { tool: Tool; layout?: 'vertical' | 'horizontal'; } export default function ToolCard({ tool, layout = 'vertical' }: ToolCardProps) { const isHorizontal = layout === 'horizontal'; return (
{/* Content adapts to layout */}
); } ``` --- ## Example: Typography Consistency **Scenario:** Adding a new "About" page to existing site. ### Analysis Output ```markdown ## Typography Patterns (from existing pages) ### Heading Hierarchy - H1: text-3xl md:text-4xl, font-semibold, tracking-tight - H2: text-xl md:text-2xl, font-semibold - H3: text-lg, font-medium ### Body Text - Default: text-base, leading-relaxed - Small: text-sm - Meta/timestamps: text-xs, text-muted-foreground ### Font Family - Primary: Inter with fallbacks - No display font used - No monospace needed (no code samples) ``` ### Correct Implementation ```tsx // About page - matches existing hierarchy

About Us

Our story begins...

Our Mission

We believe in...

``` ### ❌ Incorrect Implementation ```tsx // DON'T: Different sizes, weights, tracking

{/* ← Too large, too bold */} About Us

{/* ← Larger than existing pages */} Our story begins...

{/* ← font-bold instead of font-semibold */} Our Mission

``` --- ## Example: Layout Pattern Matching **Scenario:** Adding a "Pricing" page. ### Pattern Analysis **Existing page patterns:** - Home: Centered hero (max-w-3xl) → Wide content (max-w-5xl) - Blog: All sections left-aligned (max-w-5xl) - Tools: Centered hero (max-w-3xl) → Wide grid (max-w-5xl) **Decision:** Pricing is marketing content, matches "Home" pattern. ### Correct Implementation ```tsx // Pricing page - matches Home pattern export default function PricingPage() { return (
{/* Hero: Centered, narrow */}

Simple, Transparent Pricing

{/* Plans: Wide, centered grid */}
{/* Pricing cards */}
); } ``` --- ## Anti-Example: Generic AI Slop ### ❌ The Problem **Request:** "Create a landing page for a SaaS product" **Generic AI Output:** ```tsx // Predictable, seen-it-before structure
{/* Purple gradient hero */}

Revolutionize Your Workflow

The all-in-one platform for modern teams

{/* Three feature cards */}
{/* Testimonials */} {/* CTA */}
``` **Font:** Inter (of course) **Colors:** Purple gradient (of course) **Layout:** Centered everything (of course) **Problem:** Indistinguishable from 1000 other AI-generated SaaS pages. ### ✅ Better Approach **Apply design thinking:** - What makes THIS product different? - Who is the audience? (Technical? Creative? Enterprise?) - What feeling should the design evoke? - What's ONE memorable element? **Example re-design (Brutalist/Technical Direction):** ```tsx // Bold, distinctive approach
{/* Terminal-style hero */}
$ initialize_revolution.sh

SYSTEM
OVERRIDE

For developers who don't compromise. Raw power. Zero abstraction.

{/* Asymmetric feature layout */}
{/* Main feature */}
{/* Stats ticker */}
``` **Distinctive elements:** - Terminal/command-line aesthetic - Monospace typography - High-contrast green-on-black - Asymmetric grid layout - Technical/hacker vibe - Memorable and specific to audience --- ## More Examples For additional examples and techniques, see: - [REFERENCE.md](REFERENCE.md#advanced-techniques) - Deep-dive patterns - [NEW-PROJECT-DESIGN.md](NEW-PROJECT-DESIGN.md) - Aesthetic philosophy - [EXISTING-CODEBASE-CHECKLIST.md](EXISTING-CODEBASE-CHECKLIST.md) - Consistency workflow