feat: support tailwindcss v4 (#3054)

update /www and tailwind-plugin to support tailwind v4.

Thanks to the merge of #3034, the work of integrating and advancing
#2903 is promoted.

related #3034 
related #2903 

close #3056
close #2819

--patch-1 
based on review,

1. del compiler and make it more clean and simple,
2.  fix init tailwind part,
3. fix test tailwind part

--patch-2

1. fix the docs 
2. fix the docs of plugin and version

--patch-3
1. Addressed various maintenance tasks (chores)
2. Updated the Tailwind CSS plugin to align with this release. Generated
a fresh project using the updated init configuration and
3. deployed it via Deno Deploy EA. Deployment is functioning correctly.

--patch-4
Move postcss imports to Tailwind section in init script

--patch-5
Refactored Tailwind plugin type definitions by copying PluginOptions
properties from @tailwindcss/postcss and adding Fresh-specific exclude
option, while exporting types from package entrypoint for better
accessibility.

Test Project: https://fresh.fresh-press.deno.net/
Test Project Repository:
https://github.com/SisyphusZheng/fresh-tailwindv4
Test Plugin: https://jsr.io/@freshpress/fresh-plugin-tailwind@1.0.0

---------

Co-authored-by: 李嘉图·M·路 <146103794+Ricardo-M-Zheng@users.noreply.github.com>
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
Zhi
2025-07-21 16:13:34 +02:00
committed by GitHub
co-authored by 李嘉图·M·路 Asher Gomez Marvin Hagemeister
parent 2d308f6b9e
commit bb23643779
30 changed files with 741 additions and 1144 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ export function FancyLink(
return (
<a
href={props.href}
class={`group p-4 px-5 pb-3.5 bg-gradient-to-br from-fresh/40 to-fresh font-semibold rounded leading-none flex items-center justify-center hover:bg-fresh transition-colors duration-200 ease-in-out max-w-max text-balance ${
class={`group p-4 px-5 pb-3.5 bg-gradient-to-br from-fresh/40 to-fresh font-semibold rounded-sm leading-none flex items-center justify-center hover:bg-fresh transition-colors duration-200 ease-in-out max-w-max text-balance ${
props.class ?? ""
}`}
>
+1 -1
View File
@@ -11,7 +11,7 @@ export default function Header(props: { title: string; active: string }) {
"mx-auto flex gap-3 items-center",
isHome ? "justify-end h-20 max-w-screen-xl" : "justify-between",
isDocs
? "h-20 max-w-screen-2xl w-full sticky top-0 bg-background-primary z-50 backdrop-blur-sm"
? "h-20 max-w-screen-2xl w-full sticky top-0 bg-background-primary z-50 backdrop-blur-xs"
: "",
isShowcase ? "max-w-screen-xl w-full" : "",
].join(" ")}
+1 -1
View File
@@ -27,7 +27,7 @@ export function SideBySide(props: SideBySideProps) {
return (
<div
class={`grid grid-cols-1 items-center gap-12 md:gap-16 xl:gap-32 ${
props.reverseOnDesktop ? "md:first:[&>*]:order-1" : ""
props.reverseOnDesktop ? "[&>*]:md:first:order-1" : ""
} ${mdSplitClass} ${lgSplitClass} ${props.class ?? ""}`}
>
{props.children}
+1 -1
View File
@@ -9,7 +9,7 @@ export function Hero(props: { origin: string }) {
<div class="bg-green-300 mt-0 pt-32 md:pt-48 !mb-0 bg-gradient-to-br from-blue-100 via-green-200 to-yellow-100">
<div class="md:grid grid-cols-5 gap-8 md:gap-16 items-center w-full max-w-screen-xl mx-auto px-4 md:px-8 lg:px-16 2xl:px-0">
<div class="flex-1 text-center md:text-left md:col-span-3 pb-8 md:pb-32">
<h2 class="text-[calc(1rem+4vw)] leading-tight sm:text-5xl lg:text-6xl sm:tracking-tight sm:leading-none! font-extrabold">
<h2 class="text-[calc(1rem+4vw)] leading-tight sm:text-5xl lg:text-6xl sm:tracking-tight sm:leading-none font-extrabold">
The simple, approachable, productive web framework
</h2>
<div class="mt-12 flex flex-wrap justify-center items-stretch md:justify-start gap-4">
+1 -1
View File
@@ -4,7 +4,7 @@ export function SectionHeading(
{ children }: { children: ComponentChildren },
) {
return (
<h2 class="text-3xl lg:text-4xl xl:text-5xl text-gray-600 font-bold text-balance">
<h2 class="text-3xl lg:text-4xl xl:text-5xl text-gray-600 font-[750] text-balance">
{children}
</h2>
);
+1 -1
View File
@@ -5,7 +5,7 @@ export function Simple() {
<PageSection class="!mb-12 !mt-20">
<div class="text-center max-w-max mx-auto flex flex-col gap-4">
<p class="italic text-gray-500 text-lg">Introducing Fresh:</p>
<h2 class="text-4xl sm:text-5xl md:text-6xl lg:text-7xl sm:tracking-tight sm:leading-[1.1]! font-extrabold text-balance text-gray-600">
<h2 class="text-4xl sm:text-5xl md:text-6xl lg:text-7xl sm:tracking-tight font-extrabold text-balance text-gray-600">
The framework so simple, you already know it.
</h2>
<p class="text-xl text-balance max-w-prose mx-auto">
+1 -1
View File
@@ -6,7 +6,7 @@ export function SocialProof() {
return (
<PageSection>
<div class="text-center max-w-max mx-auto flex flex-col gap-4">
<h2 class="text-gray-600 text-4xl sm:text-5xl md:text-6xl lg:text-7xl sm:tracking-tight sm:leading-[1.1]! font-extrabold text-balance">
<h2 class="text-gray-600 text-4xl sm:text-5xl md:text-6xl lg:text-7xl sm:tracking-tight sm:leading-[1.1] font-extrabold text-balance">
Built for the edge
</h2>
<p class="text-xl text-balance max-w-prose mx-auto">
+1 -1
View File
@@ -5,7 +5,7 @@ import { app } from "./main.ts";
import { tailwind } from "@fresh/plugin-tailwind";
const builder = new Builder({ target: "safari12" });
tailwind(builder, app, {});
tailwind(builder, app);
if (Deno.args.includes("build")) {
await builder.build(app);
+3 -3
View File
@@ -32,14 +32,14 @@ export default function CopyArea(props: { code: string }) {
}, [copied.value]);
return (
<div class="bg-slate-800 rounded text-green-100 flex items-center min-w-0 overflow-x-auto">
<div class="bg-slate-800 rounded-sm text-green-100 flex items-center min-w-0 overflow-x-auto">
<pre class="overflow-x-auto w-full flex-1 px-6 py-4">
{props.code}
</pre>
<div class="relative my-2 mr-4 sm:mr-6">
<div
class={`hidden transition ease-in-out absolute pointer-events-none bg-gray-900 text-white p-2 -top-1/3 left-1/2 transform -translate-x-1/2 -translate-y-full box-border rounded opacity-0 ${
class={`hidden transition ease-in-out absolute pointer-events-none bg-gray-900 text-white p-2 -top-1/3 left-1/2 transform -translate-x-1/2 -translate-y-full box-border rounded-sm opacity-0 ${
copied.value && "block opacity-100"
}`}
>
@@ -49,7 +49,7 @@ export default function CopyArea(props: { code: string }) {
type="button"
aria-label="Copy to Clipboard"
disabled={!IS_BROWSER}
class={`rounded p-1.5 border border-foreground-secondary/30 hover:bg-foreground-secondary/70 ${
class={`rounded-sm p-1.5 border border-foreground-secondary/30 hover:bg-foreground-secondary/70 ${
copied.value ? "text-fresh-green/80" : ""
} relative`}
onClick={handleClick}
+1 -1
View File
@@ -49,7 +49,7 @@ function RoundedButton(props: JSX.HTMLAttributes<HTMLButtonElement>) {
touchAction: "manipulation",
}}
{...props}
class="p-3 rounded-full border-2 border-current bg-white/20 hover:bg-white/50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 disabled:bg-green-200 disabled:cursor-default"
class="p-3 rounded-full border-2 border-current bg-white/20 hover:bg-white/50 focus:outline-hidden focus:ring-2 focus:ring-offset-2 focus:ring-green-500 disabled:bg-green-200 disabled:cursor-default"
/>
);
}
+1 -1
View File
@@ -46,7 +46,7 @@ export function FormSubmitDemo() {
<button
type="submit"
value="Submit"
class="pt-2 pb-1 px-3 rounded border-current border-[1.5px] font-semibold"
class="pt-2 pb-1 px-3 rounded-sm border-current border-[1.5px] font-semibold"
>
Submit
</button>
+1 -1
View File
@@ -107,7 +107,7 @@ export function TableOfContents({ headings }: TableOfContentsProps) {
type="button"
id="toc-outline-btn"
onClick={() => isOpen.value = !isOpen.value}
class="bg-background-primary py-2 px-4 rounded border border-foreground-secondary/30 flex items-center hover:border-fresh-green/80 transition-colors text-sm"
class="bg-background-primary py-2 px-4 rounded-sm border border-foreground-secondary/30 flex items-center hover:border-fresh-green/80 transition-colors text-sm"
>
On this page
<svg
+1 -1
View File
@@ -36,7 +36,7 @@ export default function VersionSelect(
id="version"
class={`rounded-md block border border-foreground-primary/20 appearance-none bg-background-primary form-select-bg font-semibold ${
selectedIsLatest ? "pr-22" : "pr-10"
} py-2 pl-3 w-full h-full leading-none sm:(text-sm leading-5) focus:(outline-none border-blue-300) hover:bg-background-secondary`}
} py-2 pl-3 w-full h-full leading-none sm:text-sm sm:leading-5 focus:outline-hidden focus:border-blue-300 hover:bg-background-secondary`}
value={selectedVersion}
onChange={(e) => {
if (e.currentTarget.value !== selectedVersion) {
+5 -5
View File
@@ -158,7 +158,7 @@ export default define.page<typeof handler>(function DocsPage(props) {
<div class="flex mx-auto max-w-screen-2xl px-0 md:px-4 md:py-0 justify-start bg-background-secondary">
<label
for="docs_sidebar"
class="px-4 py-3 lg:hidden flex items-center rounded gap-2 cursor-pointer"
class="px-4 py-3 lg:hidden flex items-center rounded-sm gap-2 cursor-pointer"
>
<svg
class="h-6 w-6"
@@ -204,7 +204,7 @@ export default define.page<typeof handler>(function DocsPage(props) {
<div class="lg:order-1 min-w-0 max-w-3xl w-full">
{isCanary
? (
<div class="bg-[#F0900525] p-4 rounded text-base text-yellow-700 dark:text-yellow-500 mb-8">
<div class="bg-[#F0900525] p-4 rounded-sm text-base text-yellow-700 dark:text-yellow-500 mb-8">
🚧 This documentation is work in progress and for an
unreleased version of Fresh.
</div>
@@ -231,7 +231,7 @@ export default define.page<typeof handler>(function DocsPage(props) {
<div class="px-4 md:px-0 flex justify-between my-6">
<a
href={`https://github.com/denoland/fresh/edit/main/${page.file}`}
class="text-gray-700 dark:text-gray-200 text-md flex items-center bg-[#ebedf0] dark:bg-[#2c2d39] px-4 py-2 rounded hover:bg-gray-200 dark:hover:bg-[#36394c] transition-colors"
class="text-gray-700 dark:text-gray-200 text-md flex items-center bg-[#ebedf0] dark:bg-[#2c2d39] px-4 py-2 rounded-sm hover:bg-gray-200 dark:hover:bg-[#36394c] transition-colors"
target="_blank"
rel="noopener noreferrer"
>
@@ -303,7 +303,7 @@ function ForwardBackButtons(props: {
? (
<a
href={prev.href}
class="px-4 py-2 text-left rounded border border-foreground-secondary/20 grid border-solid w-full hover:border-green-600 transition-colors"
class="px-4 py-2 text-left rounded-sm border border-foreground-secondary/20 grid border-solid w-full hover:border-green-600 transition-colors"
>
<span class="text-sm text-gray-600 dark:text-gray-500">
Previous page
@@ -318,7 +318,7 @@ function ForwardBackButtons(props: {
? (
<a
href={next.href}
class="px-4 py-2 text-left rounded border border-foreground-secondary/20 grid border-solid w-full hover:border-green-600 transition-colors"
class="px-4 py-2 text-left rounded-sm border border-foreground-secondary/20 grid border-solid w-full hover:border-green-600 transition-colors"
>
<span class="text-sm text-gray-600 dark:text-gray-500">
Next page
+1 -1
View File
@@ -35,7 +35,7 @@ export default define.page<typeof handler>(function ThanksForSubscribing(
</p>
<a
href="/#forms-section"
class="flex items-center gap-2 max-w-max !mt-4 mx-auto pt-3 pb-2 px-4 border-[1.5px] border-current rounded"
class="flex items-center gap-2 max-w-max !mt-4 mx-auto pt-3 pb-2 px-4 border-[1.5px] border-current rounded-sm"
>
<svg
aria-hidden="true"
+18 -10
View File
@@ -4,7 +4,7 @@
--color-prettylights-syntax-constant: #0550ae;
--color-prettylights-syntax-entity: #8250df;
--color-prettylights-syntax-storage-modifier-import: var(
--foreground-secondary
--color-foreground-secondary
);
--color-prettylights-syntax-entity-tag: #22863a;
--color-prettylights-syntax-keyword: #cf222e;
@@ -16,12 +16,20 @@
--color-prettylights-syntax-markup-inserted-text: #116329;
--color-prettylights-syntax-markup-inserted-bg: #dafbe1;
--color-prettylights-syntax-constant-other-reference-link: #0a3069;
--color-fg-default: hsla(var(--foreground-secondary));
--color-fg-muted: hsla(var(--foreground-tertiary));
--color-canvas-default: hsla(var(--background-primary));
--color-canvas-subtle: hsla(var(--background-secondary));
--color-border-default: hsla(var(--foreground-secondary), 0.3);
--color-border-muted: hsla(var(--foreground-secondary), 0.1);
--color-fg-default: var(--color-foreground-secondary);
--color-fg-muted: var(--color-foreground-tertiary);
--color-canvas-default: var(--color-background-primary);
--color-canvas-subtle: var(--color-background-secondary);
--color-border-default: hsl(
from
var(--color-foreground-secondary)
h
s
l
/
0.3
);
--color-border-muted: hsl(from var(--color-foreground-secondary) h s l / 0.1);
--color-neutral-muted: rgba(175, 184, 193, 0.2);
--color-accent-fg: #02aa6f;
--color-accent-emphasis: #0969da;
@@ -689,8 +697,8 @@ html[data-theme="dark"] .markdown-body .admonition.tip .admonition-header {
}
html[data-theme="dark"] .markdown-body .admonition.info {
background-color: hsla(var(--info), 0.1);
color: hsla(var(--foreground-primary));
background-color: hsl(194 76% 41% / 0.1);
color: var(--color-foreground-primary);
}
.markdown-body .admonition.warn .admonition-header {
color: #dd6f04;
@@ -794,7 +802,7 @@ ol.nested li:before {
border-top-left-radius: 0.5rem;
border-top-right-radius: 0.5rem;
padding: 0.5rem;
background: hsla(var(--background-tertiary));
background: var(--color-background-tertiary);
display: flex;
align-items: center;
justify-content: space-between;
+40 -45
View File
@@ -1,43 +1,43 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@import "tailwindcss";
/* Light and dark theme variables */
:root {
--fresh: 50deg, 100%, 56%;
--fresh-green: 142deg, 71%, 29%;
@custom-variant dark (&:where([data-theme="dark"], [data-theme="dark"] *));
--background-primary: 215deg, 100%, 100%;
--background-secondary: 210deg, 29%, 97%;
--background-tertiary: 207deg, 33%, 95%;
--foreground-primary: 0deg, 0%, 9%;
--foreground-secondary: 0deg, 0%, 23%;
--foreground-tertiary: 0deg, 0%, 32%;
--foreground-quaternary: 0deg, 0%, 42%;
@theme {
--color-fresh: hsl(50 100% 56%);
--color-fresh-green: hsl(142 71% 29%);
--info: 194deg, 76%, 41%;
--color-background-primary: hsl(215deg 100% 100%);
--color-background-secondary: hsl(210 29% 97%);
--color-background-tertiary: hsl(207 33% 95%);
--color-foreground-primary: hsl(0 0% 9%);
--color-foreground-secondary: hsl(0 0% 23%);
--color-foreground-tertiary: hsl(0 0% 32%);
--color-foreground-quaternary: hsl(0 0% 42%);
}
@variant dark {
--color-fresh: hsl(50 100% 56%);
--color-fresh-green: hsl(142 71% 29%);
--color-background-primary: hsl(220deg 11% 11%);
--color-background-secondary: hsl(216deg 19% 18%);
--color-background-tertiary: hsl(216deg 27.7% 22%);
--color-foreground-primary: hsl(215deg 17% 99%);
--color-foreground-secondary: hsl(215deg 17% 83%);
--color-foreground-tertiary: hsl(215deg 17% 20%);
--color-foreground-quaternary: hsl(215deg 17% 10%);
--color-info: hsl(194 76% 41%);
}
html[data-theme="dark"]:root {
--fresh: 50deg, 100%, 56%;
--fresh-green: 142deg, 71%, 29%;
--background-primary: 220deg, 11%, 11%;
--background-secondary: 216deg, 19%, 18%;
--background-tertiary: 216deg, 27.7%, 22%;
--foreground-primary: 215deg, 17%, 99%;
--foreground-secondary: 215deg, 17%, 83%;
--foreground-tertiary: 215deg, 17%, 20%;
--foreground-quaternary: 215deg, 17%, 10%;
--info: 194deg, 76%, 41%;
color: var(--foreground-primary);
background-color: var(--background-primary);
color: var(--color-foreground-primary);
background-color: var(--color-background-primary);
}
/* Scrollbar colors that look good on light and dark theme */
* {
scrollbar-color: hsla(0deg, 0%, 50%, 0.5) hsla(0deg, 0%, 50%, 0.1) !important;
scrollbar-color: hsl(0deg 0% 50% / 0.5) hsl(0 0% 50% / 0.1) !important;
}
@font-face {
@@ -75,24 +75,12 @@ h6 {
scroll-margin-top: 6rem;
}
b,
strong,
.font-bold,
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 750;
}
hr {
@apply border-foreground-secondary/10;
border-color: hsl(from var(--color-foreground-secondary) h s l / 0.1);
}
.dark-mode-toggle-button img {
@apply fill-foreground-primary;
fill: var(--color-foreground-primary);
}
::selection {
@@ -102,3 +90,10 @@ hr {
html[data-theme="dark"] ::selection {
background-color: #064c9c;
}
.form-select-bg {
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3e%3cpath d='M7 7l3-3 3 3m0 6l-3 3-3-3' stroke='%239fa6b2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e");
background-position: right 0.5rem center;
background-size: 1.5em 1.5em;
background-repeat: no-repeat;
}
-41
View File
@@ -1,41 +0,0 @@
import type { Config } from "tailwindcss";
import plugin from "tailwindcss/plugin.js";
export default {
darkMode: ["selector", '[data-theme="dark"]'],
content: [
"{routes,islands,components}/**/*.{ts,tsx}",
],
plugins: [
plugin((api) => {
api.addUtilities({
".form-select-bg": {
"background-image":
`url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3e%3cpath d='M7 7l3-3 3 3m0 6l-3 3-3-3' stroke='%239fa6b2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e")`,
"background-position": "right 0.5rem center",
"background-size": "1.5em 1.5em",
"background-repeat": "no-repeat",
},
});
}),
],
theme: {
extend: {
colors: {
// Dark/light with Tailwind done right using CSS variables:
"fresh": "hsla(var(--fresh))",
"fresh-green": "hsla(var(--fresh-green))",
"background-primary": "hsla(var(--background-primary))",
"background-secondary": "hsla(var(--background-secondary))",
"background-tertiary": "hsla(var(--background-tertiary))",
"foreground-primary": "hsla(var(--foreground-primary))",
"foreground-secondary": "hsla(var(--foreground-secondary))",
"foreground-tertiary": "hsla(var(--foreground-tertiary))",
"foreground-quaternary": "hsla(var(--foreground-quaternary))",
"info": "hsla(var(--info))",
},
},
},
} satisfies Config;