buildHeader($componentId); // Layout 2 columnas $html .= '
'; $html .= '
'; $html .= $this->buildVisibilityGroup($componentId); $html .= $this->buildContentGroup($componentId); $html .= '
'; $html .= '
'; $html .= $this->buildColorsGroup($componentId); $html .= $this->buildTypographyAndSpacingGroup($componentId); $html .= '
'; $html .= '
'; return $html; } private function buildHeader(string $componentId): string { $html = '
renderer->getFieldValue($componentId, 'visibility', 'is_enabled', true); $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' '; $html .= '
'; $html .= '
'; // Switch: Show on Mobile $showOnMobile = $this->renderer->getFieldValue($componentId, 'visibility', 'show_on_mobile', true); $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' '; $html .= '
'; $html .= '
'; // Switch: Show on Desktop $showOnDesktop = $this->renderer->getFieldValue($componentId, 'visibility', 'show_on_desktop', true); $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' '; $html .= '
'; $html .= '
'; // ============================================= // Checkboxes de visibilidad por tipo de página // Grupo especial: _page_visibility // ============================================= $html .= '
'; $html .= '

'; $html .= ' '; $html .= ' Mostrar en tipos de pagina'; $html .= '

'; $showOnHome = $this->renderer->getFieldValue($componentId, '_page_visibility', 'show_on_home', true); $showOnPosts = $this->renderer->getFieldValue($componentId, '_page_visibility', 'show_on_posts', true); $showOnPages = $this->renderer->getFieldValue($componentId, '_page_visibility', 'show_on_pages', true); $showOnArchives = $this->renderer->getFieldValue($componentId, '_page_visibility', 'show_on_archives', false); $showOnSearch = $this->renderer->getFieldValue($componentId, '_page_visibility', 'show_on_search', false); $html .= '
'; $html .= '
'; $html .= $this->buildPageVisibilityCheckbox('topBarVisibilityHome', 'Home', 'bi-house', $showOnHome); $html .= '
'; $html .= '
'; $html .= $this->buildPageVisibilityCheckbox('topBarVisibilityPosts', 'Posts', 'bi-file-earmark-text', $showOnPosts); $html .= '
'; $html .= '
'; $html .= $this->buildPageVisibilityCheckbox('topBarVisibilityPages', 'Paginas', 'bi-file-earmark', $showOnPages); $html .= '
'; $html .= '
'; $html .= $this->buildPageVisibilityCheckbox('topBarVisibilityArchives', 'Archivos', 'bi-archive', $showOnArchives); $html .= '
'; $html .= '
'; $html .= $this->buildPageVisibilityCheckbox('topBarVisibilitySearch', 'Busqueda', 'bi-search', $showOnSearch); $html .= '
'; $html .= '
'; // ============================================= // Reglas de exclusion avanzadas // Grupo especial: _exclusions (Plan 99.11) // ============================================= $exclusionPartial = new ExclusionFormPartial($this->renderer); $html .= $exclusionPartial->render($componentId, 'topBar'); // Switch: CSS Crítico $isCritical = $this->renderer->getFieldValue($componentId, 'visibility', 'is_critical', true); $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' '; $html .= '
'; $html .= '
'; $html .= '
'; $html .= ''; return $html; } private function buildContentGroup(string $componentId): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Contenido'; $html .= '
'; // icon_class + label_text (row) $html .= '
'; $html .= '
'; $html .= ' '; $iconClass = $this->renderer->getFieldValue($componentId, 'content', 'icon_class', 'bi-megaphone-fill'); $html .= ' '; $html .= '
'; $html .= '
'; $html .= ' '; $labelText = $this->renderer->getFieldValue($componentId, 'content', 'label_text', 'Nuevo:'); $html .= ' '; $html .= '
'; $html .= '
'; // message_text (textarea) $messageText = $this->renderer->getFieldValue($componentId, 'content', 'message_text', 'Accede a más de 200,000 Análisis de Precios Unitarios actualizados para 2025.'); $html .= '
'; $html .= ' '; $html .= ' '; $html .= ' Máximo 200 caracteres'; $html .= '
'; // link_text + link_url (row) $html .= '
'; $html .= '
'; $html .= ' '; $linkText = $this->renderer->getFieldValue($componentId, 'content', 'link_text', 'Ver Catálogo'); $html .= ' '; $html .= '
'; $html .= '
'; $html .= ' '; $linkUrl = $this->renderer->getFieldValue($componentId, 'content', 'link_url', '#'); $html .= ' '; $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } private function buildColorsGroup(string $componentId): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Colores'; $html .= '
'; // Grid 2x3 de color pickers $html .= '
'; // Background Color $bgColor = $this->renderer->getFieldValue($componentId, 'colors', 'background_color', '#0E2337'); $html .= $this->buildColorPicker('topBarBackgroundColor', 'Color de fondo', 'paint-bucket', $bgColor); // Text Color $textColor = $this->renderer->getFieldValue($componentId, 'colors', 'text_color', '#FFFFFF'); $html .= $this->buildColorPicker('topBarTextColor', 'Color de texto', 'fonts', $textColor); // Label Color $labelColor = $this->renderer->getFieldValue($componentId, 'colors', 'label_color', '#FF8600'); $html .= $this->buildColorPicker('topBarLabelColor', 'Color etiqueta', 'tag-fill', $labelColor); // Icon Color $iconColor = $this->renderer->getFieldValue($componentId, 'colors', 'icon_color', '#FF8600'); $html .= $this->buildColorPicker('topBarIconColor', 'Color ícono', 'star', $iconColor); $html .= '
'; // Row 2 de color pickers $html .= '
'; // Link Color $linkColor = $this->renderer->getFieldValue($componentId, 'colors', 'link_color', '#FFFFFF'); $html .= $this->buildColorPicker('topBarLinkColor', 'Color enlace', 'link', $linkColor); // Link Hover Color $linkHoverColor = $this->renderer->getFieldValue($componentId, 'colors', 'link_hover_color', '#FF8600'); $html .= $this->buildColorPicker('topBarLinkHoverColor', 'Color enlace (hover)', 'hand-index', $linkHoverColor); $html .= '
'; $html .= '
'; $html .= '
'; return $html; } private function buildTypographyAndSpacingGroup(string $componentId): string { $html = '
'; $html .= '
'; $html .= '
'; $html .= ' '; $html .= ' Tipografía y Espaciado'; $html .= '
'; $html .= '
'; // Font Size $html .= '
'; $html .= ' '; $fontSize = $this->renderer->getFieldValue($componentId, 'spacing', 'font_size', '0.9rem'); $html .= ' '; $html .= ' Ej: 0.9rem, 14px'; $html .= '
'; // Padding $html .= '
'; $html .= ' '; $padding = $this->renderer->getFieldValue($componentId, 'spacing', 'padding', '0.5rem 0'); $html .= ' '; $html .= ' Ej: 0.5rem 0'; $html .= '
'; $html .= '
'; $html .= '
'; $html .= '
'; return $html; } private function buildColorPicker(string $id, string $label, string $icon, string $value): string { $html = '
'; $html .= ' '; $html .= ' '; $html .= ' ' . esc_html(strtoupper($value)) . ''; $html .= '
'; return $html; } private function buildPageVisibilityCheckbox(string $id, string $label, string $icon, mixed $checked): string { $checked = $checked === true || $checked === '1' || $checked === 1; $html = '
'; $html .= sprintf( ' ', esc_attr($id), $checked ? 'checked' : '' ); $html .= sprintf( ' '; $html .= '
'; return $html; } }