1 estrella en GitHub = 1 componente nuevo.

Secciones de Página academyeducationcategoriescardspaths

Academy Tracks

Tarjetas de rutas por área con icono, descripción y número de cursos; cada una abre el catálogo filtrado por esa categoría.

Vista Previa en Vivo

Uso

Copia y pega este código directamente en tu página de Astro:

astro
---
import { AcademyTracks } from 'astro-component-kit/sections';
---

<AcademyTracks categories={academyCategories} courses={academyCourses} coursesHref="/cursos" />
--- import { AcademyTracks } from 'astro-component-kit/sections'; --- <AcademyTracks categories={academyCategories} courses={academyCourses} coursesHref="/cursos" />

Ejemplos en contexto

Código real del kit: cómo se usa esta pieza dentro de plantillas, secciones y otros componentes.

Plantilla Lumen · Academia online & Estudio AcademyHomePage.astro
astro
<AcademyTracks categories={data.categories} courses={data.courses} coursesHref={routes.courses} />
<AcademyTracks categories={data.categories} courses={data.courses} coursesHref={routes.courses} />

Instalación Manual

Si no estás usando el paquete npm, crea un archivo nuevo y pega el siguiente código: src/components/lib/AcademyTracks.astro:

astro
---
/**
 * AcademyTracks — Learning-path / category cards: icon, description, number of courses and a
 * link to the catalog filtered by that category.
 *
 * @param {AcademyCategory[]} categories - Categories to show.
 * @param {AcademyCourse[]} courses - Used to count courses per category.
 * @param {string} coursesHref - Catalog URL; links use `?cat=<id>`.
 * @param {string} title - Section heading.
 * @param {string} subtitle - Supporting text.
 * @param {string} headingLevel - 'h1' | 'h2'. Default 'h2'.
 * @param {string} class - Extra class for the root.
 *
 * Accessibility: cards are real links named by their heading and course count; icons are decorative.
 */
import type { HTMLAttributes } from 'astro/types';
import '../templates/academy/academy-theme.css';
import { academyCategories, academyCourses, type AcademyCategory, type AcademyCourse } from '../templates/academy/data';

interface OwnProps {
  categories?: AcademyCategory[];
  courses?: AcademyCourse[];
  coursesHref?: string;
  title?: string;
  subtitle?: string;
  headingLevel?: 'h1' | 'h2';
}

type Props = OwnProps & Omit<HTMLAttributes<'section'>, keyof OwnProps | 'class'> & { class?: string };

const {
  categories = academyCategories,
  courses = academyCourses,
  coursesHref = '/cursos',
  title = 'Elige tu camino',
  subtitle = 'Seis áreas, rutas ordenadas y cada curso termina en algo que puedes enseñar.',
  headingLevel = 'h2',
  class: classAttr,
  ...rest
} = Astro.props;

const Heading = headingLevel;
const uid = `at-${Math.random().toString(36).slice(2, 8)}`;
const icons: Record<string, string> = {
  code: '<path d="m8 8-5 4 5 4M16 8l5 4-5 4M14 5l-4 14"/>',
  design: '<path d="M12 3a9 9 0 1 0 0 18c1.5 0 2-1 1.5-2-.6-1.2.2-2.5 1.6-2.5H17a4 4 0 0 0 4-4C21 6.6 17 3 12 3Z"/><circle cx="7.5" cy="11" r="1"/><circle cx="10" cy="7" r="1"/><circle cx="15" cy="7.5" r="1"/>',
  data: '<path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/>',
  business: '<rect x="3" y="7" width="18" height="13" rx="2"/><path d="M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2M3 13h18"/>',
  language: '<path d="M4 5h9M8.5 3v2M6 5c1 4 3 7 6 9M12 5c-1 4-3 7-7 9M13 21l4-10 4 10M14.5 18h5"/>',
  music: '<path d="M9 18V5l11-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="17" cy="16" r="3"/>',
};
const countOf = (id: string) => courses.filter((c) => c.categoryId === id).length;
---

<section class:list={['academy-ui', 'academy-tracks', classAttr]} aria-labelledby={`${uid}-title`} {...rest}>
  <div class="academy-tracks__inner">
    <header class="academy-tracks__head">
      <Heading id={`${uid}-title`} class="academy-tracks__title">{title}</Heading>
      {subtitle && <p class="academy-tracks__subtitle">{subtitle}</p>}
    </header>
    <ul class="academy-tracks__grid" role="list">
      {categories.map((c) => (
        <li>
          <a class="academy-track" href={`${coursesHref}?cat=${c.id}`} style={`--track-hue:${c.hue}`}>
            <span class="academy-track__icon" aria-hidden="true">
              <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" set:html={icons[c.icon] ?? icons.code} />
            </span>
            <span class="academy-track__name">{c.name}</span>
            <span class="academy-track__desc">{c.description}</span>
            <span class="academy-track__count">{countOf(c.id)} {countOf(c.id) === 1 ? 'curso' : 'cursos'} <span aria-hidden="true">→</span></span>
          </a>
        </li>
      ))}
    </ul>
  </div>
</section>

<style>
  .academy-tracks {
    padding: var(--sp-12, 3rem) var(--sp-4, 1rem);
    background: var(--ac-bg);
    color: var(--ac-text);
    font-family: var(--ac-font-body);
  }

  .academy-tracks__inner {
    max-width: 1280px;
    margin: 0 auto;
  }

  .academy-tracks__head {
    max-width: 620px;
    margin-bottom: var(--sp-8, 2rem);
  }

  .academy-tracks__title {
    margin: 0;
    font-family: var(--ac-font-display);
    font-weight: 600;
    font-size: clamp(2rem, 4.5vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.01em;
  }

  .academy-tracks__subtitle {
    margin: var(--sp-3, 0.75rem) 0 0;
    color: var(--ac-text-2);
    line-height: 1.6;
  }

  .academy-tracks__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
    gap: var(--sp-4, 1rem);
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .academy-track {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2, 0.5rem);
    height: 100%;
    min-height: 210px;
    padding: var(--sp-5, 1.25rem);
    overflow: hidden;
    border: 1px solid var(--ac-border);
    border-radius: var(--r-lg, 20px);
    background: var(--ac-bg-raised);
    color: inherit;
    text-decoration: none;
    box-sizing: border-box;
    transition: transform 0.25s ease, border-color 0.25s ease;
  }

  .academy-track::before {
    content: '';
    position: absolute;
    inset: auto -40px -60px auto;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: radial-gradient(circle, hsl(var(--track-hue) 80% 60% / 0.28), transparent 70%);
    transition: transform 0.4s ease;
  }

  .academy-track:hover {
    transform: translateY(-3px);
    border-color: hsl(var(--track-hue) 70% 62% / 0.7);
  }

  .academy-track:hover::before {
    transform: scale(1.5);
  }

  .academy-track:focus-visible {
    outline: 2px solid var(--ac-brand);
    outline-offset: 2px;
  }

  .academy-track__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: hsl(var(--track-hue) 60% 50% / 0.18);
    color: hsl(var(--track-hue) 85% 72%);
  }

  [data-theme='light'] .academy-track__icon {
    color: hsl(var(--track-hue) 70% 30%);
  }

  .academy-track__name {
    margin-top: var(--sp-2, 0.5rem);
    font-family: var(--ac-font-display);
    font-size: 1.4rem;
    font-weight: 600;
  }

  .academy-track__desc {
    color: var(--ac-text-2);
    font-size: 0.92rem;
    line-height: 1.5;
  }

  .academy-track__count {
    margin-top: auto;
    padding-top: var(--sp-3, 0.75rem);
    color: var(--ac-text);
    font-size: 0.9rem;
    font-weight: 700;
  }

  @media (prefers-reduced-motion: reduce) {
    .academy-track,
    .academy-track::before {
      transition: none;
    }

    .academy-track:hover,
    .academy-track:hover::before {
      transform: none;
    }
  }
</style>
--- /** * AcademyTracks — Learning-path / category cards: icon, description, number of courses and a * link to the catalog filtered by that category. * * @param {AcademyCategory[]} categories - Categories to show. * @param {AcademyCourse[]} courses - Used to count courses per category. * @param {string} coursesHref - Catalog URL; links use `?cat=<id>`. * @param {string} title - Section heading. * @param {string} subtitle - Supporting text. * @param {string} headingLevel - 'h1' | 'h2'. Default 'h2'. * @param {string} class - Extra class for the root. * * Accessibility: cards are real links named by their heading and course count; icons are decorative. */ import type { HTMLAttributes } from 'astro/types'; import '../templates/academy/academy-theme.css'; import { academyCategories, academyCourses, type AcademyCategory, type AcademyCourse } from '../templates/academy/data'; interface OwnProps { categories?: AcademyCategory[]; courses?: AcademyCourse[]; coursesHref?: string; title?: string; subtitle?: string; headingLevel?: 'h1' | 'h2'; } type Props = OwnProps & Omit<HTMLAttributes<'section'>, keyof OwnProps | 'class'> & { class?: string }; const { categories = academyCategories, courses = academyCourses, coursesHref = '/cursos', title = 'Elige tu camino', subtitle = 'Seis áreas, rutas ordenadas y cada curso termina en algo que puedes enseñar.', headingLevel = 'h2', class: classAttr, ...rest } = Astro.props; const Heading = headingLevel; const uid = `at-${Math.random().toString(36).slice(2, 8)}`; const icons: Record<string, string> = { code: '<path d="m8 8-5 4 5 4M16 8l5 4-5 4M14 5l-4 14"/>', design: '<path d="M12 3a9 9 0 1 0 0 18c1.5 0 2-1 1.5-2-.6-1.2.2-2.5 1.6-2.5H17a4 4 0 0 0 4-4C21 6.6 17 3 12 3Z"/><circle cx="7.5" cy="11" r="1"/><circle cx="10" cy="7" r="1"/><circle cx="15" cy="7.5" r="1"/>', data: '<path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/>', business: '<rect x="3" y="7" width="18" height="13" rx="2"/><path d="M9 7V5a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2M3 13h18"/>', language: '<path d="M4 5h9M8.5 3v2M6 5c1 4 3 7 6 9M12 5c-1 4-3 7-7 9M13 21l4-10 4 10M14.5 18h5"/>', music: '<path d="M9 18V5l11-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="17" cy="16" r="3"/>', }; const countOf = (id: string) => courses.filter((c) => c.categoryId === id).length; --- <section class:list={['academy-ui', 'academy-tracks', classAttr]} aria-labelledby={`${uid}-title`} {...rest}> <div class="academy-tracks__inner"> <header class="academy-tracks__head"> <Heading id={`${uid}-title`} class="academy-tracks__title">{title}</Heading> {subtitle && <p class="academy-tracks__subtitle">{subtitle}</p>} </header> <ul class="academy-tracks__grid" role="list"> {categories.map((c) => ( <li> <a class="academy-track" href={`${coursesHref}?cat=${c.id}`} style={`--track-hue:${c.hue}`}> <span class="academy-track__icon" aria-hidden="true"> <svg width="26" height="26" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" set:html={icons[c.icon] ?? icons.code} /> </span> <span class="academy-track__name">{c.name}</span> <span class="academy-track__desc">{c.description}</span> <span class="academy-track__count">{countOf(c.id)} {countOf(c.id) === 1 ? 'curso' : 'cursos'} <span aria-hidden="true">→</span></span> </a> </li> ))} </ul> </div> </section> <style> .academy-tracks { padding: var(--sp-12, 3rem) var(--sp-4, 1rem); background: var(--ac-bg); color: var(--ac-text); font-family: var(--ac-font-body); } .academy-tracks__inner { max-width: 1280px; margin: 0 auto; } .academy-tracks__head { max-width: 620px; margin-bottom: var(--sp-8, 2rem); } .academy-tracks__title { margin: 0; font-family: var(--ac-font-display); font-weight: 600; font-size: clamp(2rem, 4.5vw, 3rem); line-height: 1.05; letter-spacing: -0.01em; } .academy-tracks__subtitle { margin: var(--sp-3, 0.75rem) 0 0; color: var(--ac-text-2); line-height: 1.6; } .academy-tracks__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: var(--sp-4, 1rem); margin: 0; padding: 0; list-style: none; } .academy-track { position: relative; display: flex; flex-direction: column; gap: var(--sp-2, 0.5rem); height: 100%; min-height: 210px; padding: var(--sp-5, 1.25rem); overflow: hidden; border: 1px solid var(--ac-border); border-radius: var(--r-lg, 20px); background: var(--ac-bg-raised); color: inherit; text-decoration: none; box-sizing: border-box; transition: transform 0.25s ease, border-color 0.25s ease; } .academy-track::before { content: ''; position: absolute; inset: auto -40px -60px auto; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle, hsl(var(--track-hue) 80% 60% / 0.28), transparent 70%); transition: transform 0.4s ease; } .academy-track:hover { transform: translateY(-3px); border-color: hsl(var(--track-hue) 70% 62% / 0.7); } .academy-track:hover::before { transform: scale(1.5); } .academy-track:focus-visible { outline: 2px solid var(--ac-brand); outline-offset: 2px; } .academy-track__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: hsl(var(--track-hue) 60% 50% / 0.18); color: hsl(var(--track-hue) 85% 72%); } [data-theme='light'] .academy-track__icon { color: hsl(var(--track-hue) 70% 30%); } .academy-track__name { margin-top: var(--sp-2, 0.5rem); font-family: var(--ac-font-display); font-size: 1.4rem; font-weight: 600; } .academy-track__desc { color: var(--ac-text-2); font-size: 0.92rem; line-height: 1.5; } .academy-track__count { margin-top: auto; padding-top: var(--sp-3, 0.75rem); color: var(--ac-text); font-size: 0.9rem; font-weight: 700; } @media (prefers-reduced-motion: reduce) { .academy-track, .academy-track::before { transition: none; } .academy-track:hover, .academy-track:hover::before { transform: none; } } </style>

Información Rápida

Categoría
Secciones de Página
Nombre de archivo
AcademyTracks.astro
Dependencias
Ninguna — Astro nativo + CSS puro
Etiquetas
academyeducationcategoriescardspaths