PLATFORM AGNOSTIC LAYOUT
Documentation for Plans
🌍 Platform-Agnostic Layout System - Design Document
🎯 Problem Statement
Current Issue: CSS Grid is web-specific and doesn't translate to Flutter, React Native, or other platforms.
User's Concern:
"Our platform-builder is supposed to generate platform-agnostic content, including for Flutter. We might be shooting ourselves in the foot if we allow CSS Grid."
Solution: Flexbox-only approach with smart layout presets that work everywhere.
✅ Why Flexbox?
Cross-Platform Support:
- ✅ Web (CSS):
display: flex - ✅ Flutter:
Row,Column,Flexwidgets - ✅ React Native:
ViewwithflexDirection - ✅ SwiftUI:
HStack,VStack,ZStack - ✅ Jetpack Compose:
Row,Column,Box
CSS Grid Limitations:
- ❌ Flutter: No direct CSS Grid equivalent
- ❌ React Native: No grid support
- ❌ Complex Translation: Requires custom layout engines
🎨 Layout System Design
1. Core Concepts (Flexbox-Only)
Every section uses Flexbox with:
- Direction: Row (horizontal) or Column (vertical)
- Justify: How items align along main axis
- Align: How items align along cross axis
- Gap: Spacing between children
- Wrap: Whether items wrap to next line
Additional Properties:
- Flex Grow/Shrink/Basis: For advanced users
- Width/Height: Fixed or percentage
- Min/Max Constraints: Responsive boundaries
2. Smart Layout Presets
Instead of CSS Grid, we provide 8 powerful presets:
Preset 1: Stack (Vertical) 📚
Container (Column, Center)
├─ Child 1 (100% width)
├─ Child 2 (100% width)
└─ Child 3 (100% width)
Use Case: Default stacking layout
Flutter Equivalent: Column(children: [...])
Preset 2: Sidebar (Fixed + Flexible) 📐
Container (Row)
├─ Sidebar (width: 250px, fixed)
└─ Content (flex: 1, scrollable)
Use Case: Admin panels, dashboards
Flutter Equivalent:
Row(children: [
Container(width: 250, child: Sidebar()),
Expanded(child: Content())
])
Preset 3: Split View (50/50 or 30/70) ⚖️
Container (Row)
├─ Left (flex: 1)
└─ Right (flex: 1)
Use Case: Comparison views, dual panels
Flutter Equivalent:
Row(children: [
Expanded(flex: 1, child: Left()),
Expanded(flex: 1, child: Right())
])
Preset 4: Card Grid (Wrap) 🎴
Container (Row, Wrap)
├─ Card (width: 30%, margin: 1%)
├─ Card (width: 30%, margin: 1%)
├─ Card (width: 30%, margin: 1%)
└─ (wraps to next row...)
Use Case: Product grids, gallery
Flutter Equivalent: Wrap(children: [...])
Preset 5: Header/Content/Footer 📄
Container (Column)
├─ Header (height: auto)
├─ Content (flex: 1, scrollable)
└─ Footer (height: auto)
Use Case: Classic page layout
Flutter Equivalent:
Column(children: [
Header(),
Expanded(child: Content()),
Footer()
])
Preset 6: Center (Absolute Center) 🎯
Container (Column, Center, Center)
└─ Child (centered both axes)
Use Case: Hero sections, modals
Flutter Equivalent: Center(child: ...)
Preset 7: Toolbar (Icons Row) 🔧
Container (Row, Center, Space Between)
├─ Icon 1
├─ Icon 2
└─ Icon 3
Use Case: Action bars, button groups
Flutter Equivalent:
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [Icon1(), Icon2(), Icon3()]
)
Preset 8: Stack/Overlay (Absolute Positioning) 🗂️
Container (position: relative)
├─ Background Layer (z: 0)
├─ Content Layer (z: 1)
└─ Overlay Layer (z: 2)
Use Case: Modals, tooltips, overlays
Flutter Equivalent: Stack(children: [...])
🧩 Module Integration Strategy
Module Placement Metadata
Based on GoGrab-modules architecture, add to ModuleManifest:
interface ModuleManifest {
id: string;
name: string;
// ... existing fields
// NEW: Placement preferences
placementPreferences?: {
preferredLayout: 'stack' | 'sidebar' | 'split' | 'cards' | 'header-content-footer' | 'center' | 'toolbar' | 'stack-overlay';
preferredWidth?: string; // '100%', '300px', '30%'
preferredHeight?: string; // 'auto', '200px', '100vh'
flexGrow?: number; // 0 = fixed, 1 = flexible
canNest?: boolean; // Can contain other modules?
suggestedPosition?: 'header' | 'sidebar' | 'main' | 'footer'; // Hint for auto-placement
};
}
Example Module Definitions
// Structural Module: Sidebar Navigation
{
id: 'module-sidenav',
name: 'Side Navigation',
type: 'structural',
placementPreferences: {
preferredLayout: 'sidebar',
preferredWidth: '250px',
flexGrow: 0, // Fixed width
canNest: true,
suggestedPosition: 'sidebar'
}
}
// Content Module: User Profile Widget
{
id: 'module-user-profile',
name: 'User Profile',
type: 'content',
placementPreferences: {
preferredWidth: '30%',
preferredHeight: '400px',
flexGrow: 0,
canNest: false,
suggestedPosition: 'main'
}
}
// Structural Module: Dashboard Container
{
id: 'module-dashboard',
name: 'Dashboard',
type: 'structural',
placementPreferences: {
preferredLayout: 'cards',
canNest: true,
suggestedPosition: 'main'
}
}
🎯 Auto-Placement Intelligence
When user drops a module on canvas:
Check Module Type:
- Structural → Suggest creating new section
- Content → Place in nearest section
Apply Preferences:
- Read
placementPreferences.preferredWidth/Height - Set section flex properties
- Apply suggested layout preset
- Read
Smart Positioning:
suggestedPosition: 'sidebar'→ Add to left/rightsuggestedPosition: 'header'→ Add to topsuggestedPosition: 'footer'→ Add to bottomsuggestedPosition: 'main'→ Add to center content
Validate Nesting:
- If
canNest: true→ Allow dropping modules inside - If
canNest: false→ Block nested drops
- If
🔧 Implementation Plan
Phase 1: Remove CSS Grid ✅
- Remove
gridlayout type from types - Remove Grid controls from config panel
- Keep only Flexbox controls
Phase 2: Add Layout Presets 🎨
- Create
LayoutPresettype - Add preset selector in config panel
- Implement 8 preset configurations
- Add "Apply Preset" button
- Show visual preview of each preset
Phase 3: Module Placement Metadata 🧩
- Extend
ModuleManifestwithplacementPreferences - Create
ModulePlacementService(smart auto-placement) - Update module palette to show placement hints
- Implement drag-drop with preference application
Phase 4: Auto-Placement Logic 🤖
- Detect module type (structural vs content)
- Apply width/height preferences
- Suggest section layout based on module
- Validate nesting rules
📚 References
Design Inspiration
- Figma Auto-Layout: Direction, spacing, alignment presets
- Flutter Layout Widgets: Row, Column, Stack, Wrap
- Webflow: Visual flexbox builder with presets
GoGrab-Modules Integration
- Widget positioning system (x, y, width, height in 12-column grid)
- Dashboard layout configuration
- Module manifest structure
- RBAC integration
✅ Success Criteria
- ✅ No CSS Grid - Flexbox-only approach
- ✅ 8 Layout Presets - Cover 90% of use cases
- ✅ Module Metadata - Placement preferences in manifests
- ✅ Smart Auto-Placement - Modules know where they belong
- ✅ Flutter-Compatible - All layouts translate to Flutter
- ✅ Intuitive UX - Visual preset selector
- ✅ Reusable - Modules inside modules (nesting)
Status: 📋 In Design
Next Step: Implement Phase 1 (Remove CSS Grid)
Goal: Platform-agnostic, intuitive, powerful layout system