6.6 KiB
MyUIbrix Editor Fixes - December 2024
Issues Fixed
1. ✅ Element Picker Shows Only Implemented Elements
Problem: The element picker was showing ALL available element types (30+), but only a subset were actually implemented on the HomePage.
Solution:
- Created
HOMEPAGE_IMPLEMENTED_ELEMENTSarray indefaultElements.tslisting only implemented elements - Updated MyUIbrixEditor to filter
PREDEFINED_ELEMENTSby what's actually available on the current page - Now only shows: hero, news, matches, table, team, videos, merch, newsletter, sponsors, banner
2. ✅ Live Preview Now Works
Problem: Changing variants and visibility in the editor didn't show changes in real-time. You had to save and reload to see effects.
Solution:
- Integrated
useAllPageElementConfigshook into HomePage component - Hook listens to
myuibrix-changeevents and updates visibility/variant state in real-time - All sections now use
isVisible('elementName', defaultValue)to control rendering - Variant changes use
getVariant('elementName', fallback)to switch between styles
3. ✅ All Sections Have data-element Attributes
Problem: Some sections were missing data-element attributes, so the editor couldn't highlight or edit them.
Solution:
- Added
data-elementattributes to all major sections:hero- Main hero section (grid/scroller/swiper variants)news- Featured news articlesmatches- Upcoming matches displaytable- League standings tableteam- Players scrollervideos- Videos sectionmerch- Merchandise/fanshopnewsletter- Newsletter subscriptionsponsors- Sponsors/partnersbanner- Advertisement banners
4. ✅ Visibility Controls Work
Problem: Hiding/showing elements didn't work at all.
Solution:
- All sections now wrapped with
isVisible()checks - Changes in the editor immediately toggle visibility
- Default visibility set appropriately (hero=true, videos=false, etc.)
How It Works Now
For Admins (Editing Mode)
- Activate Editor: Click the floating edit button (bottom left)
- Select Element: Click on any section to select it
- Change Style: Pick from available style variants for that element
- Move Elements: Use up/down arrows to reorder sections
- Hide/Show: Toggle element visibility in the layers panel
- Preview: Changes appear IMMEDIATELY (live preview mode)
- Save: Click "Publikovat" to save changes permanently
Technical Details
Live Preview Architecture:
MyUIbrixEditor (editing)
→ Dispatches 'myuibrix-change' event
→ useAllPageElementConfigs hook listens
→ Updates getVariant() & isVisible() functions
→ HomePage re-renders with new configuration
Only Editing User Sees Changes:
- Preview mode is indicated by
previewMode: truein events - Changes only apply in browser memory during editing
- Other users see the published version until you click "Publikovat"
Element Variants Available
Hero Section
grid- Grid layout with featured articlescroller- Horizontal scrolling cardsswiper- Carousel/swiperswiper_full- Full-width carousel
Matches
compact- Compact next match displaycompact_split- Split layout with multiple matches
Table
split_news- News + table side-by-side (default)standard- Table only
Sponsors
grid- Grid layoutslider- Animated slider
Videos, Team, News, etc.
- See
ELEMENT_VARIANTSinpageElements.tsfor full list
Default Configuration
New installations use these defaults (from defaultElements.ts):
- Hero (grid) - Visible
- News (grid) - Visible
- Matches (compact) - Visible
- Table (split_news) - Visible
- Merch (grid) - Visible
- Sponsors (grid) - Visible
- Videos - Hidden (must enable)
- Team - Hidden (must enable)
- Newsletter - Hidden (must enable)
- Banner - Hidden (must enable)
✅ NEW: Drag-and-Drop Reordering (Just Added!)
Visual Reordering Works
- Up/Down arrows now visually reorder sections immediately
- Drag-and-drop support in layers panel - grab any element and drag it
- Changes apply in real-time (live preview)
- DOM elements are physically reordered to match your layout
How to Reorder
Method 1: Arrow Buttons
- Click on an element to select it
- Use ↑ ↓ arrows in the contextual panel or layers panel
- Section moves immediately
Method 2: Drag and Drop (Recommended)
- Open Layers Panel (L key or layers button)
- Grab the drag handle (⋮⋮ icon) or any layer item
- Drag to desired position
- Drop - section reorders instantly!
Visual Feedback
- Dragging: Item becomes semi-transparent with "grabbing" cursor
- Drop target: Highlighted in blue with scale effect
- Grip handle: Shows ⋮⋮ icon to indicate draggability
- Position label: Shows "Position 1 of 10" etc.
Some Variants Not Fully Styled
- Not all variant options have complete styling
- Most common variants (grid, compact, standard) work well
- Exotic variants may need CSS work
Testing Checklist
After deployment, test these scenarios:
- Click edit button → editor UI appears
- Click on hero section → style picker appears
- Change hero from "grid" to "scroller" → updates immediately
- Hide "sponsors" section → disappears immediately
- Show "videos" section → appears immediately
- NEW: Click ↑ arrow on "matches" → moves up visually
- NEW: Open layers panel (L) → see all sections with drag handles
- NEW: Drag "newsletter" above "sponsors" → reorders immediately
- NEW: Drag "hero" to bottom → entire page reorders
- Open element picker (+ button) → only shows 10 implemented elements
- Save changes (Publikovat) → page reloads with saved state
- NEW: Reload page → sections appear in saved order
- Open page in incognito → sees published version (not draft)
Files Modified
- defaultElements.ts - Added
HOMEPAGE_IMPLEMENTED_ELEMENTSlist - MyUIbrixEditor.tsx - Filter element picker, add overlays, drag-drop handlers, visual reordering
- HomePage.tsx - Integrated
useAllPageElementConfigshook, added visibility controls - usePageElementConfig.ts - Added DOM reordering, element order state, initial order application
Migration Notes
Existing Sites: No data migration needed. The system will:
- Load existing configurations from database
- Fall back to defaults for missing elements
- Mark as "hasChanges" if using defaults (so admin can save)
New Sites: Defaults are applied automatically on first page load.