{{-- Universal Component Renderer --}} @php $type = $componentData['type'] ?? 'unknown'; $content = $componentData['content'] ?? []; $children = $componentData['children'] ?? []; $classes = $componentData['classes'] ?? []; $styles = $componentData['styles'] ?? []; $variables = $componentData['variables'] ?? []; // Build class string $classString = is_array($classes) ? implode(' ', $classes) : $classes; // Build style string $styleString = ''; if (is_array($styles) && !empty($styles)) { $styleParts = []; foreach ($styles as $property => $value) { $styleParts[] = $property . ': ' . $value; } $styleString = implode('; ', $styleParts); } @endphp @if($type === 'container') {{-- Container Component --}} @php $containerSettings = $content['containerSettings'] ?? []; $width = $containerSettings['width'] ?? 'container'; $background = $containerSettings['background'] ?? []; $minHeight = $containerSettings['minHeight'] ?? null; $minHeightUnit = $containerSettings['minHeightUnit'] ?? 'px'; $padding = $containerSettings['padding'] ?? null; $widthClass = $width === 'full' ? 'container-fluid' : 'container'; $containerStyles = []; if (isset($background['type']) && $background['type'] === 'color' && isset($background['color'])) { $containerStyles[] = 'background-color: ' . $background['color']; } if ($minHeight) { $containerStyles[] = 'min-height: ' . $minHeight . $minHeightUnit; } if ($padding) { $containerStyles[] = 'padding: ' . $padding; } if ($styleString) { $containerStyles[] = $styleString; } $containerStyleAttr = !empty($containerStyles) ? 'style="' . implode('; ', $containerStyles) . '"' : ''; @endphp
{!! $text !!}
@elseif($type === 'button') {{-- Button Component --}} @php $text = $content['text'] ?? 'Button'; $href = $content['href'] ?? '#'; @endphp {{ $text }} @elseif($type === 'image') {{-- Image Component --}} @php $src = $content['src'] ?? 'https://via.placeholder.com/400x300'; $alt = $content['alt'] ?? 'Image'; @endphp