From 7efa0318ff3fcbca084e3c8fb8eddbe2e984f338 Mon Sep 17 00:00:00 2001 From: Kaspar Kallas Date: Thu, 8 May 2025 09:42:32 +0300 Subject: [PATCH] chore: migrate to tailwind 4 (from 3) - run pnpm dlx @tailwindcss/upgrade - remove tailwindcss/nesting - pnpm dedupe --- app/globals.css | 112 +++++- components/artifact.tsx | 2 +- components/console.tsx | 4 +- components/document-preview.tsx | 2 +- components/message-actions.tsx | 4 +- components/message-editor.tsx | 2 +- components/multimodal-input.tsx | 4 +- components/sidebar-history.tsx | 2 +- components/sidebar-user-nav.tsx | 2 +- components/toolbar.tsx | 2 +- components/ui/button.tsx | 2 +- components/ui/card.tsx | 2 +- components/ui/dropdown-menu.tsx | 8 +- components/ui/input.tsx | 2 +- components/ui/select.tsx | 6 +- components/ui/sheet.tsx | 2 +- components/ui/sidebar.tsx | 44 +-- components/ui/textarea.tsx | 2 +- package.json | 5 +- pnpm-lock.yaml | 645 ++++++++++++++------------------ postcss.config.mjs | 3 +- tailwind.config.ts | 80 ---- 22 files changed, 429 insertions(+), 508 deletions(-) delete mode 100644 tailwind.config.ts diff --git a/app/globals.css b/app/globals.css index 3409b987ed..1e9d54cefe 100644 --- a/app/globals.css +++ b/app/globals.css @@ -1,25 +1,97 @@ -@tailwind base; -@tailwind components; -@tailwind utilities; +@import 'tailwindcss'; -:root { - --foreground-rgb: 0, 0, 0; - --background-start-rgb: 214, 219, 220; - --background-end-rgb: 255, 255, 255; +@custom-variant dark (&:is(.dark *)); + +@theme { + --font-sans: var(--font-geist); + --font-mono: var(--font-geist-mono); + + --breakpoint-toast-mobile: 600px; + + --radius-lg: var(--radius); + --radius-md: calc(var(--radius) - 2px); + --radius-sm: calc(var(--radius) - 4px); + + --color-background: hsl(var(--background)); + --color-foreground: hsl(var(--foreground)); + + --color-card: hsl(var(--card)); + --color-card-foreground: hsl(var(--card-foreground)); + + --color-popover: hsl(var(--popover)); + --color-popover-foreground: hsl(var(--popover-foreground)); + + --color-primary: hsl(var(--primary)); + --color-primary-foreground: hsl(var(--primary-foreground)); + + --color-secondary: hsl(var(--secondary)); + --color-secondary-foreground: hsl(var(--secondary-foreground)); + + --color-muted: hsl(var(--muted)); + --color-muted-foreground: hsl(var(--muted-foreground)); + + --color-accent: hsl(var(--accent)); + --color-accent-foreground: hsl(var(--accent-foreground)); + + --color-destructive: hsl(var(--destructive)); + --color-destructive-foreground: hsl(var(--destructive-foreground)); + + --color-border: hsl(var(--border)); + --color-input: hsl(var(--input)); + --color-ring: hsl(var(--ring)); + + --color-chart-1: hsl(var(--chart-1)); + --color-chart-2: hsl(var(--chart-2)); + --color-chart-3: hsl(var(--chart-3)); + --color-chart-4: hsl(var(--chart-4)); + --color-chart-5: hsl(var(--chart-5)); + + --color-sidebar: hsl(var(--sidebar-background)); + --color-sidebar-foreground: hsl(var(--sidebar-foreground)); + --color-sidebar-primary: hsl(var(--sidebar-primary)); + --color-sidebar-primary-foreground: hsl(var(--sidebar-primary-foreground)); + --color-sidebar-accent: hsl(var(--sidebar-accent)); + --color-sidebar-accent-foreground: hsl(var(--sidebar-accent-foreground)); + --color-sidebar-border: hsl(var(--sidebar-border)); + --color-sidebar-ring: hsl(var(--sidebar-ring)); } -@media (prefers-color-scheme: dark) { - :root { - --foreground-rgb: 255, 255, 255; - --background-start-rgb: 0, 0, 0; - --background-end-rgb: 0, 0, 0; - } +/* + The default border color has changed to `currentcolor` in Tailwind CSS v4, + so we've added these compatibility styles to make sure everything still + looks the same as it did with Tailwind CSS v3. + + If we ever want to remove these styles, we need to add an explicit border + color utility to any element that depends on these defaults. +*/ +@layer base { + *, + ::after, + ::before, + ::backdrop, + ::file-selector-button { + border-color: var(--color-gray-200, currentcolor); + } +} + +@utility text-balance { + text-wrap: balance; } @layer utilities { - .text-balance { - text-wrap: balance; + :root { + --foreground-rgb: 0, 0, 0; + --background-start-rgb: 214, 219, 220; + --background-end-rgb: 255, 255, 255; + } + + @media (prefers-color-scheme: dark) { + :root { + --foreground-rgb: 255, 255, 255; + --background-start-rgb: 0, 0, 0; + --background-end-rgb: 0, 0, 0; } + } } @layer base { @@ -129,22 +201,22 @@ .cm-editor, .cm-gutters { - @apply bg-background dark:bg-zinc-800 outline-none selection:bg-zinc-900 !important; + @apply bg-background! dark:bg-zinc-800! outline-hidden! selection:bg-zinc-900!; } .ͼo.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .ͼo.cm-selectionBackground, .ͼo.cm-content::selection { - @apply bg-zinc-200 dark:bg-zinc-900 !important; + @apply bg-zinc-200! dark:bg-zinc-900!; } .cm-activeLine, .cm-activeLineGutter { - @apply bg-transparent !important; + @apply bg-transparent!; } .cm-activeLine { - @apply rounded-r-sm !important; + @apply rounded-r-sm!; } .cm-lineNumbers { @@ -156,7 +228,7 @@ } .cm-lineNumbers .cm-activeLineGutter { - @apply rounded-l-sm !important; + @apply rounded-l-sm!; } .suggestion-highlight { diff --git a/components/artifact.tsx b/components/artifact.tsx index 67e713b1f2..d0b29e613f 100644 --- a/components/artifact.tsx +++ b/components/artifact.tsx @@ -450,7 +450,7 @@ function PureArtifact({ /> -
+