Skip to content

Adopt Tailwind v4 without changing the visual design#2

Merged
finallyjay merged 1 commit into
mainfrom
tailwind-migration
Jun 3, 2026
Merged

Adopt Tailwind v4 without changing the visual design#2
finallyjay merged 1 commit into
mainfrom
tailwind-migration

Conversation

@finallyjay
Copy link
Copy Markdown
Owner

Qué hace

Adopción incremental de Tailwind v4 en el proyecto (Astro 5) sin cambiar el aspecto — verificado pixel a pixel.

Cambios

  • @tailwindcss/vite en astro.config.mjs (vía actual para Astro 5; la integración @astrojs/tailwind está deprecada para v4).
  • src/styles/global.css: los estilos globales salen del <style is:global> del Layout a @layer base/components, con los tokens de diseño puenteados a @theme → existen utilidades (text-brass-hi, font-display, bg-paper…) y a la vez los var(--brass) existentes siguen resolviendo.
  • Preflight desactivado a propósito: el diseño se apoya en defaults del navegador (márgenes de <p>, etc.); el reset de Tailwind habría movido el espaciado. Se importan solo theme + utilities.
  • Orden de capas explícito (@layer theme, base, components, utilities;) para que las utilidades ganen la cascada sobre base/components.
  • style= inline → utilidades en index.astro y roulette.astro (text-center, mb-4, flex-1, w-full, -mt-4…). Los --i de los agujeros del tambor se quedan como custom properties inline.
  • El CSS exótico (revólver, póster, toast, keyframes, grano/viñeta) se mantiene como CSS de componente.

Verificación

Diff de píxeles real (canvas) entre antes/después a 1400×2200:

Página Diferencia
/ 0 px
/roulette?demo=1 0 px

El proceso destapó un bug de cascada (utilities importadas antes de base/components perdían precedencia → la mode-card se desplazaba ~6.4px); corregido con el orden de capas explícito.

Build de producción OK; CSS final ~7.9K (tree-shaken).

spike/shots.mjs queda como helper de screenshots para re-comparar en el futuro.

Cómo probar en local

```bash
git checkout tailwind-migration
npm install
npm run dev # http://localhost:4321
```

🤖 Generated with Claude Code

Incremental adoption via @tailwindcss/vite (Astro 5's recommended path):
- Move the global saloon styles out of Layout's <style is:global> into
  src/styles/global.css, organized into @layer base/components, with the
  design tokens bridged into @theme so utilities (text-brass-hi, font-display,
  etc.) exist alongside the original var(--brass) references.
- Skip Preflight on purpose — the design leans on browser-default typography,
  so resetting it would shift spacing. Declare the layer order explicitly so
  utilities still win over base/components.
- Convert the inline style= attributes on index/roulette to utility classes
  (the --i hole rotation vars stay as inline custom properties).

Verified pixel-identical: 0 px difference on / and /roulette?demo=1 at
1400x2200 (see spike/shots.mjs for the screenshot helper).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 3, 2026 13:28
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
daily-dev-roulette Ready Ready Preview, Comment Jun 3, 2026 1:28pm

@finallyjay finallyjay merged commit 19abddd into main Jun 3, 2026
3 checks passed
@finallyjay finallyjay deleted the tailwind-migration branch June 3, 2026 13:30
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Incrementally migrates the Astro 5 project to Tailwind v4 while aiming to keep the current visual design unchanged, by introducing Tailwind’s theme/utilities layers, bridging existing design tokens into @theme, and swapping a few inline styles for utility classes.

Changes:

  • Add Tailwind v4 via @tailwindcss/vite (Astro/Vite plugin) and include Tailwind theme + utilities CSS while intentionally skipping Preflight.
  • Move prior global styles from Layout.astro’s <style is:global> into src/styles/global.css, with explicit cascade layer ordering and token bridging via @theme.
  • Replace selected inline styles in index.astro / roulette.astro with Tailwind utility classes; add a Playwright screenshot helper script.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/styles/global.css New Tailwind v4 entry CSS; defines cascade layers, bridges tokens via @theme, and contains prior global/base/component styles.
src/layouts/Layout.astro Imports the new global stylesheet and removes the in-layout global <style is:global> block.
src/pages/index.astro Replaces a few inline styles with Tailwind utility classes (spacing/layout/text).
src/pages/roulette.astro Replaces inline text alignment and color with Tailwind utilities.
spike/shots.mjs Adds a Playwright-based screenshot helper for pixel-diff verification.
astro.config.mjs Enables Tailwind v4 through the @tailwindcss/vite plugin.
package.json Adds tailwindcss and @tailwindcss/vite dev dependencies.
package-lock.json Locks Tailwind v4 and related dependency graph updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
Comment on lines 17 to 21
"devDependencies": {
"playwright": "^1.60.0"
"@tailwindcss/vite": "^4.3.0",
"playwright": "^1.60.0",
"tailwindcss": "^4.3.0"
}
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