mirror of
https://github.com/Dvorinka/MyClubServer.git
synced 2026-06-04 02:32:57 +00:00
5.1 KiB
5.1 KiB
MyUIbrix Grid Layout Feature
Overview
Enhanced the MyUIbrix Editor with comprehensive Grid Layout Controls that allow admins to split sections into different grid configurations with visual templates and fine-grained control.
New Features Added
1. Grid Layout Tab in VisualStylePanel
A new dedicated Grid tab has been added to the left sidebar style panel with:
Quick Templates (One-Click Layouts)
- 📱 Single Column -
1fr - ⚖️ Two Equal (50% / 50%) -
1fr 1fr - 📊 Left Larger (66% / 33%) -
2fr 1fr - 📊 Right Larger (33% / 66%) -
1fr 2fr - 🎯 Three Equal (33% / 33% / 33%) -
1fr 1fr 1fr - 📰 Featured + Two (50% / 25% / 25%) -
2fr 1fr 1fr - 🔲 Four Equal (25% each) -
repeat(4, 1fr) - 📋 Main + Sidebar (75% / 25%) -
3fr 1fr
Advanced Grid Controls
- Grid Template Columns: Custom input for precise control (e.g.,
300px 1fr,2fr 1fr 1fr) - Grid Template Rows: Control row sizing
- Column Gap: 0-100px slider
- Row Gap: 0-100px slider
- Auto Flow: Row, Column, Row Dense, Column Dense
- Align Items: Vertical alignment (stretch, start, center, end, baseline)
- Justify Items: Horizontal alignment (stretch, start, center, end)
2. Real-Time Style Application
- Styles are applied instantly in preview mode
- Uses CSS Grid with proper
grid-template-columns,column-gap,row-gap - Automatic camelCase to kebab-case conversion
- Smart unit handling (px for numeric values)
3. Style Persistence
- Grid styles are stored in state
- Applied to DOM elements via
data-elementattribute - Works seamlessly with existing variant system
How to Use
Step 1: Activate MyUIbrix Editor
- Navigate to the homepage as an admin
- Click the purple edit button (bottom-left corner)
- Or add
?myuibrix=editto the URL
Step 2: Select an Element
- Click on any element you want to configure (e.g., hero, news, gallery)
- The element will be highlighted with a blue border
- The VisualStylePanel will appear on the left
Step 3: Configure Grid Layout
- Click the Grid tab in the VisualStylePanel
- Toggle "Enable Grid Layout" switch to ON
- Choose a quick template or customize:
- Click a template button for instant layouts
- OR manually enter
grid-template-columnsvalues - Adjust gaps with sliders
- Fine-tune alignment options
Step 4: Preview & Publish
- Changes apply instantly in preview (only visible to you)
- Click "Publikovat" (Publish) in the top bar to save
- Page reloads and changes go live for all users
Examples
Example 1: Blog Post Layout (Left Content + Right Sidebar)
grid-template-columns: 2fr 1fr
column-gap: 32px
Creates a 66%/33% split - perfect for main content with a sidebar.
Example 2: Photo Gallery (Three Equal Columns)
grid-template-columns: 1fr 1fr 1fr
column-gap: 16px
row-gap: 16px
Creates a 3-column equal-width grid with spacing.
Example 3: Hero Section (Featured + Two)
grid-template-columns: 2fr 1fr 1fr
column-gap: 24px
Creates a 50%/25%/25% split - large featured item with two smaller items.
Example 4: Custom Fixed + Flexible
grid-template-columns: 300px 1fr
column-gap: 40px
Fixed 300px sidebar + flexible main content.
Technical Details
Files Modified
-
frontend/src/components/editor/VisualStylePanel.tsx- Added Grid tab with templates and controls
- Imported
FiGridicon andButtoncomponent - Added grid-related state variables
-
frontend/src/hooks/usePageElementConfig.ts- Added
stylesstate management - Added
handleMyUIbrixStyleChangeevent listener - Added
getStyles()function - Real-time DOM style application
- Added
Event System
- Event:
myuibrix-style-change - Detail:
{ elementName, styles, previewMode } - Flow: VisualStylePanel → MyUIbrixEditor → usePageElementConfig → DOM
CSS Properties Supported
display: gridgrid-template-columnsgrid-template-rowsgrid-column-gap/column-gapgrid-row-gap/row-gapgrid-auto-flowalign-itemsjustify-items- All standard CSS properties (padding, margin, colors, typography, etc.)
Browser Compatibility
- CSS Grid is supported in all modern browsers
- IE11 requires fallbacks (not implemented)
Future Enhancements
- Responsive grid templates (mobile/tablet breakpoints)
- Grid area naming and placement
- Visual grid template builder (drag-and-drop)
- Save/load custom grid templates
- Export grid as reusable component
Troubleshooting
Styles Not Applying?
- Ensure element has
data-element="elementName"attribute - Check browser console for errors
- Verify grid is enabled (toggle switch ON)
Changes Not Saving?
- Click Publikovat button to save
- Check for error toasts
- Verify admin authentication
Preview Mode vs Production
- In preview mode (editing): Changes visible only to you
- After publishing: Changes visible to all users
- Use this to test layouts before going live
Created: 2025-01-15
Version: 1.0
Author: MyUIbrix Development Team