# Recetas y Plantillas de Componentes y Páginas - CPIC Conecta
Este archivo provee recetas completas listas para copiar y pegar de los componentes y páginas clave de **CPIC Conecta**.
---
## 1. Plantilla Astro Base (`ScrollLayout.astro`)
Utilizada para envolver cualquier página en Astro con detección instantánea de tema oscuro/claro y precarga de fuentes e iconos:
```astro
---
import '../styles/global.css';
import '@fortawesome/fontawesome-free/css/all.min.css';
export interface Props {
title?: string;
description?: string;
lang?: string;
}
const {
title = "CPIC - Conecta",
description = "Asistente Virtual e Intranet del CPIC - SENA",
lang = "es"
} = Astro.props;
---
{title}
{/* Page transition loader */}
Cargando…
```
---
## 2. Componente de Entrada de Cristal (`GlassInput.jsx`)
Estándar para formularios en modo oscuro y claro:
```jsx
import React from "react";
export const GLASS_INPUT_CLASS =
"w-full px-4 py-3 bg-white/60 dark:bg-black/40 backdrop-blur-xl border border-black/10 dark:border-white/12 rounded-2xl text-gray-900 dark:text-white placeholder-gray-400 dark:placeholder-white/30 focus:outline-none focus:border-[#39A900] focus:ring-2 focus:ring-[#39A900]/20 focus:bg-white/80 dark:focus:bg-black/60 shadow-[inset_0_1px_2px_rgba(0,0,0,0.05)] transition-all text-sm";
export const GlassInput = React.forwardRef(function GlassInput(
{ type = "text", value, onChange, placeholder, disabled, icon, ...props },
ref
) {
return (
{icon && (
)}
);
});
```
---
## 3. Botones Estándar del Sistema
```jsx
// 1. Botón Primario Institucional (Acento Lima con sombra resplandeciente)
// 2. Botón Secundario (Vidrio Fantasma)
// 3. Botón de Peligro / Eliminar
```
---
## 4. Modal de Confirmación Estándar (`ConfirmModal.jsx`)
Modal con elevación Tier 3, animación elástica y soporte para cierre con tecla Escape:
```jsx
import React, { useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
export default function ConfirmModal({
isOpen,
title,
message,
confirmText = "Confirmar",
cancelText = "Cancelar",
isDanger = false,
onConfirm,
onCancel
}) {
useEffect(() => {
const handleKeyDown = (e) => {
if (e.key === "Escape" && isOpen) onCancel();
};
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
}, [isOpen, onCancel]);
return (
{isOpen && (
{/* Fondo oscuro con desenfoque */}
{/* Tarjeta del diálogo */}
{title}
{message}
)}
);
}
```
---
## 5. Esqueletos de Carga Shimmer (`Skeleton.jsx`)
Para evitar saltos de diseño (Cumulative Layout Shift):
```jsx
export function SkeletonBlock({ className = "h-10 w-full" }) {
return (
);
}
export function TableRowSkeleton({ cols = 5 }) {
return (