Phase 1: Style Standardization Implementation
🎯 Overview
Phase 1 of the style standardization initiative has been successfully implemented, providing a robust foundation for consistent styling across the vertical farming app. This implementation focuses on enhanced utility systems, farm-specific design tokens, and standardized component patterns.
🔧 What Was Implemented
1. Enhanced @theme Design Tokens
Location: src/app/globals.css
(lines 41-66)
Added farm-specific design tokens to the @theme inline
directive:
/* Farm-specific Design Tokens */
--spacing-plant: 0.75rem;
--spacing-row: 1.5rem;
--spacing-rack: 2rem;
--spacing-shelf: 1rem;
--spacing-sensor: 0.5rem;
--size-plant-icon: 1.5rem;
--size-sensor-icon: 1.25rem;
--size-control-btn: 2.5rem;
--size-status-indicator: 0.5rem;
--duration-fast: 150ms;
--duration-normal: 250ms;
--duration-slow: 350ms;
--duration-pulse: 2s;
--ease-farm: cubic-bezier(0.4, 0, 0.2, 1);
--ease-gentle: cubic-bezier(0.25, 0.46, 0.45, 0.94);
--ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
--font-size-plant-label: 0.75rem;
--font-size-sensor-value: 1.125rem;
--font-size-farm-title: 1.5rem;
--font-size-control-label: 0.875rem;
--line-height-tight: 1.2;
--line-height-farm: 1.25;
--line-height-sensor: 1.1;
--z-index-farm-overlay: 10;
--z-index-sensor-popup: 20;
--z-index-control-panel: 30;
--z-index-modal: 40;
2. Modernized Utility System (v4 Compatible)
Converted from @layer utilities
to @utility
directive following Tailwind CSS v4 best practices:
Farm Hierarchy Gradients
gradient-farm
- Blue gradient for farm-level componentsgradient-row
- Green gradient for row-level componentsgradient-rack
- Yellow gradient for rack-level componentsgradient-shelf
- Purple gradient for shelf-level components
Typography Utilities
text-plant-label
- Small, muted text for plant metadatatext-sensor-value
- Prominent, tabular-numeric sensor displaystext-farm-title
- Large, bold headings for farm sectionstext-control-label
- Medium text for form labels and controls
Component Utilities
farm-control-btn
- Standardized control button with glass effectplant-card
- Card layout for individual plantssensor-panel
- Compact sensor data displayfarm-grid
- Responsive grid for farm componentsrack-layout
- Vertical layout for rack structures
State Pattern Utilities
state-active
- Green ring and background for active statesstate-maintenance
- Amber ring and background for maintenancestate-offline
- Red ring and background with reduced opacitystate-growing
- Active state with pulsing animation
Enhanced Shadows
card-shadow
- Standard component elevationsensor-shadow
- Subtle sensor panel shadowcontrol-shadow
- Elevated control element shadow
Animations
animate-pop
- Entrance animation with scale and movementanimate-pulse-slow
- Slow pulsing glow effectanimate-float
- Gentle floating animation
3. Farm-Specific Component Library
Created standardized components utilizing the new utility system:
FarmControlButton
Location: src/components/ui/farm-control-button.tsx
Type-safe button component with CVA variants: - Variants: default, primary, maintenance, offline, growing - Sizes: sm, default, lg - Animations: none, float, pop - Features: Icon support, accessibility focus states
<FarmControlButton
variant="growing"
animation="float"
icon={<Leaf />}
/>
PlantCard
Location: src/components/ui/plant-card.tsx
Comprehensive plant information display: - Status variants: healthy, growing, maintenance, issue - Auto-sizing: Uses design tokens for consistent spacing - Data display: Plant name, variety, stage, health percentage - Visual feedback: Color-coded health indicators
<PlantCard
status="healthy"
plantName="Basil"
variety="Sweet Genovese"
health={92}
icon={<Leaf />}
/>
SensorPanel
Location: src/components/ui/sensor-panel.tsx
Compact sensor data visualization: - Status indicators: online, offline, maintenance, warning - Trend arrows: up, down, stable - Metadata: Last updated timestamps - Type safety: Proper TypeScript interfaces
<SensorPanel
sensorType="Temperature"
value="24.5"
unit="°C"
trend="up"
status="online"
/>
FarmLayout Components
Location: src/components/ui/farm-layout.tsx
Specialized layout components for farm structures: - FarmLayout: Main grid container with headers - RackSection: Vertical rack organization - ShelfRow: Horizontal shelf layouts - Responsive: Mobile-first design approach
4. Demo Implementation
Location: src/app/style-demo/page.tsx
Comprehensive demonstration page showcasing: - Typography system in action - Component variants and states - Layout patterns for farm interfaces - Animation and interaction examples - Shadow and visual hierarchy demonstrations
🎨 Design System Benefits
Consistency
- Unified visual language across farm interfaces
- Consistent spacing and sizing through design tokens
- Standardized color and state patterns
Developer Experience
- Type-safe component props with CVA
- Auto-completion for utility classes
- Clear component hierarchy and naming
Performance
- Optimized CSS through modern
@utility
directive - Reduced CSS bundle size with consolidated utilities
- Better tree-shaking of unused styles
Accessibility
- Consistent focus states across all interactive elements
- Proper semantic markup in component templates
- High contrast support in dark mode
🚀 Usage Examples
Basic Farm Interface
import { FarmLayout, PlantCard, SensorPanel } from '@/components/ui'
export function FarmDashboard() {
return (
<FarmLayout
title="Greenhouse A"
subtitle="Main growing area"
layout="grid"
>
<PlantCard
status="growing"
plantName="Tomatoes"
health={88}
/>
<SensorPanel
sensorType="Temperature"
value="22.5"
unit="°C"
status="online"
/>
</FarmLayout>
)
}
Custom Styling with Utilities
<div className="glass card-shadow farm-grid">
<div className="state-active animate-pop">
<h3 className="text-farm-title">System Status</h3>
<p className="text-sensor-value">All Systems Online</p>
</div>
</div>
📋 Next Steps (Phase 2+)
Planned Enhancements
- Form component standardization with farm-specific validation
- Data visualization utilities for charts and graphs
- Mobile-specific optimizations for field worker interfaces
- Advanced state management patterns for real-time updates
- Theme customization tools for different farm environments
Migration Strategy
- Existing components can gradually adopt new utilities
- Backwards compatibility maintained during transition
- Component library can be extended with additional variants
🔍 Performance Metrics
Before Phase 1
- Inconsistent styling patterns across 40+ components
- Multiple shadow and spacing definitions
- Limited reusable utility classes
After Phase 1
- Standardized design system with 15+ new utilities
- Type-safe component library with CVA variants
- Consistent visual hierarchy across all farm interfaces
- Improved development velocity with reusable patterns
📚 Resources
- Tailwind CSS v4 Documentation
- Class Variance Authority (CVA)
- Radix UI Primitives
- Demo Page:
/style-demo
- Live examples of all implementations
This implementation provides a solid foundation for consistent, maintainable, and scalable styling across the vertical farming application. The design system is built to grow with the application's needs while maintaining visual and functional consistency.