Skip to content

Add JS interactivity: SPA navigation, data structures, and dynamic content generation#1

Draft
Copilot wants to merge 2 commits into
masterfrom
copilot/add-interactivity-with-js
Draft

Add JS interactivity: SPA navigation, data structures, and dynamic content generation#1
Copilot wants to merge 2 commits into
masterfrom
copilot/add-interactivity-with-js

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 20, 2026

Converts a static multi-section HTML page into a JavaScript-driven SPA where all content is generated dynamically and navigation switches sections without reload.

Architecture

  • index.html reduced to a bare shell — only three hook elements (#nav-principal, #contenido-principal, #pie-pagina); zero repeated markup
  • main.js generates the entire UI at runtime using required data structures and control flow:
Structure Usage
Array navItems, servicios, form-field configs (camposNombre, camposDireccion, telefonos)
Map planesMap (plan → details), seccionesGeneradoras (section id → generator fn)
Set tecnologias (auto-deduplicates entries), seccionesVisitadas (visited tracking)
switch Routes mostrarSeccion() calls with per-section console logging
if Form validation (empty name / email)
for (index) Builds services <ul>
for…of Iterates Set (tech tags), Map (plans table rows), arrays (nav links, form fields)
while Generates province <option> elements
  • style.css added from scratch — dark sticky nav with active-link indicator, fade-in section transition, responsive layout

Key pattern

Navigation uses a Map<string, () => HTMLElement> to dispatch section generators, keeping each section's DOM construction isolated and the routing logic trivial:

const seccionesGeneradoras = new Map([
  ['inicio',   generarInicio],
  ['tabla',    generarTabla],
  ['galeria',  generarGaleria],
  ['contacto', generarContacto]
]);

function mostrarSeccion(id) {
  seccionesVisitadas.add(id);          // Set
  switch (id) { /* log + guard */ }
  contenido.innerHTML = '';
  contenido.appendChild(seccionesGeneradoras.get(id)());
  actualizarNavActiva(id);
}

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…ynamic content

Co-authored-by: Diegobh08 <182710950+Diegobh08@users.noreply.github.com>
Copilot AI changed the title [WIP] Add interactivity and efficiency with JavaScript Add JS interactivity: SPA navigation, data structures, and dynamic content generation Mar 20, 2026
Copilot AI requested a review from Diegobh08 March 20, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants