Communitygithub.com

frontend-architecture

Configura, reestructura o amplía la arquitectura frontend de un sitio web inmersivo con muchas animaciones (portafolio, estudio, showcase, campaña, lookbook) — un shell de aplicación basado en clases sin framework, con transiciones SPA, scroll suave virtual, animaciones DOM impulsadas por atributos de datos, capa WebGL (OGL) con mallas posicionadas por marcadores DOM, texturas precargadas, GSAP, Pug + SCSS/BEM y contenido renderizado desde datos estáticos sin backend. Incluye un starter Vite probado para iniciar proyectos.

¿Qué es frontend-architecture?

Esta skill implementa una arquitectura frontend especializada para sitios web donde la animación y el movimiento son el centro del producto: transiciones de página coreografiadas, scroll suave, revelaciones de texto línea por línea e imágenes renderizadas en WebGL para permitir efectos con shaders. Sin framework UI, utiliza una pequeña jerarquía de clases, un único bucle de renderizado y el DOM como motor de diseño para todo, incluido WebGL. Es ideal para proyectos de hasta aproximadamente 10 rutas con contenido conocido en tiempo de compilación, priorizando la calidad visual sobre el tiempo de interacción, con enfoque desktop-first y soporte móvil. La skill incluye un starter Vite completo y probado con dos páginas, galería WebGL infinita, transiciones, precargador, scroll suave y animaciones de texto y parallax, y está diseñada para usarse con Claude Code, Cursor, Codex o cualquier agente de IA que necesite configurar o extender la arquitectura frontend de un sitio creativo de alto impacto visual.

Compatible con~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/umershabir/frontend-architecuture-claude-skill/tree/HEAD

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

Frontend Architecture

An architecture for sites where motion is the product: every page transition is choreographed, scroll is smoothed, text reveals line by line, and images live in WebGL so shaders can bend them. No UI framework — a small class hierarchy, one render loop, and the DOM as the layout engine for everything (including WebGL).

assets/starter/ is a complete, tested Vite project implementing it (2 pages, WebGL infinite gallery, transition, preloader, smooth scroll, text + parallax animations). Prefer copying it over writing from scratch.

When to use it — and when not

Good fit: up to ~10 routes, content known at build time, visual/motion quality matters more than time-to-interactive, desktop-first with mobile support.

Push back (or adapt per references/content-and-build.md) when:

  • many routes or large content → per-route documents with fetch-and-swap navigation instead of one document;
  • app-like UI with lots of state/forms → a component framework fits better; the WebGL layer can still be borrowed;
  • per-route SEO is critical → static per-route HTML (the starter already emits one file per route) plus real <title>s.

Core ideas (the "why" behind every file)

  1. One document, every page. All page markup is rendered into a single HTML file. Navigation never fetches HTML; it plays a transition, swaps the active page class, swaps the active WebGL scene. This is what makes seamless DOM↔WebGL transitions possible: everything exists at once.
  2. The DOM lays out WebGL. Images meant for WebGL are invisible placeholders (img[data-gl-src]). Each mesh copies its placeholder's getBoundingClientRect() on resize and maps px → world units. Designers keep working in CSS; responsive layout comes for free.
  3. The DOM is the asset manifest. The preloader collects every [data-gl-src] in the document and builds textures keyed by that exact string. Manifest and markup cannot drift apart.
  4. One loop, top-down. App.update() → page.update() (virtual scroll + scroll-linked animations) → canvas.update(page.scroll) → render. Nothing else calls requestAnimationFrame for continuous work.
  5. One owner for input. App owns every window listener (resize, wheel, pointer, popstate, link clicks) and forwards to the active page and the canvas, which forwards to the active scene.
  6. Registries, not wiring. data-animation="x" → animations/index.js map; route → page in App.pages; route → scene in Canvas SCENES. Adding a feature = one class + one registry line.
  7. No backend. Content is JSON rendered through templates at dev/build time. A CMS can be plugged in at build time by replacing one loader function; runtime code never knows.

Layers

app/
  index.js                 App shell: routing, event fan-out, RAF loop
  classes/                 Component (DOM base), Page (scroll + auto-wiring), Animation (in-view base),
                           AsyncLoad (lazy <img data-src>), Detection (device class)
  pages/<Name>/index.js    one Page subclass per route
  animations/              one class per data-animation value + index.js registry
  components/              Preloader, Navigation, Transition (2D wipe)
  components/Canvas/       WebGL root (renderer, camera, textures, SCENES registry)
    <Route>/index.js       a scene: owns a Transform group, input, infinite-loop logic
    <Route>/Media.js       one mesh per DOM placeholder
  shaders/                 .vert/.frag imported with ?raw
  utils/                   math, dom, text splitting, constants, EventEmitter
views/                     Pug: index.pug (document), partials/, pages/
content/site.json          all copy, image URLs, routes, page colors
styles/                    SCSS: utils (tokens, z(), mixins), base, components, layout, pages
scripts/render-site.js     content + views → HTML (used by the Vite plugin)
vite.config.js             renders the document, '@' alias, per-route HTML on build

Workflows

A. New project

  1. Copy assets/starter/ (everything, including .gitignore) to the target directory.
  2. npm install then npm run dev. Confirm: preloader reaches 100%, gallery renders, nav to /about plays the wipe, wheel scrolls About. (npm run build emits dist/ with one HTML per route.)
  3. Replace content in content/site.json (local images in public/ are faster and avoid CORS).
  4. Restyle via styles/utils/_variables.scss (+ the mirrored app/utils/constants.js).
  5. Add pages/animations/scenes with references/recipes.md. Tell the user what was copied and what is placeholder content.

B. Existing project

Read references/architecture.md, map the existing code onto the layers above, and migrate in this order — each step leaves the site working: (1) single App shell owning listeners and the loop, (2) Page base class + virtual scroll, (3) animation registry, (4) router + transition, (5) Canvas root + texture preloading, (6) scenes. Don't rewrite working pieces just to match names.

C. Extending or debugging

Find the layer, read its sibling files first (they're deliberately uniform — match them), then use references/recipes.md. For anything that "doesn't show up", "jumps" or "is black", check references/pitfalls.md before reading code.

Contracts in one screen

  • Component: new X({ element, elements, classes }). elements values: 'sel' → node or null, ['sel'] → array. Methods auto-bound. Lifecycle runs from the base constructor (create() → addEventListeners()), so subclasses override create()/setup() rather than relying on constructor order.
  • Page: super({ id, element, elements: { wrapper }, isScrollable }). show()/hide() return promises, toggle ${id}--active, apply data-background/data-color, enable/disable animations. scroll = { current, target, limit, ease } is what animations and scenes receive.
  • Animation: setup(), enable()/disable(), onResize(scroll), update(scroll), animateIn/Out().
  • Scene: show({ isPreloaded }), hide(), isVisible, onResize({ sizes }), onPointerDown/Move/Up(pointer), onWheel({ pixelY }), update(scroll). sizes = world width/height visible at z=0. DOM→world: scale = sizes * (box / viewport), x = -w/2 + scale.x/2 + (left/innerWidth)*w, y = h/2 - scale.y/2 - ((top - scroll)/innerHeight)*h.
  • Markup: BEM classes are the JS contract. data-animation, data-src (lazy DOM img), data-gl-src (WebGL placeholder), page root data-title/data-background/data-color.
  • Styles: 1rem = 10px of the design comp at any width; z-index only via z('layer'); pages stay laid out while hidden (opacity/visibility, never display: none).

References

ReadWhen
references/architecture.mdDesigning or migrating: lifecycle, routing, loop, scroll, transitions in depth
references/webgl.mdAnything in components/Canvas, shaders, textures, raycasting, DOM↔WebGL transitions
references/content-and-build.mdContent model, templates, plugging a CMS, hosting/SPA fallback, scaling beyond one document
references/recipes.mdAdding a page, animation, scene, shader, route, page transition
references/pitfalls.mdDebugging, code review, or before shipping

Skills relacionados