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
+4 -5
View File
@@ -1,4 +1,5 @@
{
"nodeModulesDir": "auto",
"workspace": [
"./examples",
"./init",
@@ -74,14 +75,12 @@
"@std/expect": "jsr:@std/expect@^1.0.16",
"@std/testing": "jsr:@std/testing@^1.0.12",
"autoprefixer": "npm:autoprefixer@10.4.17",
"cssnano": "npm:cssnano@6.0.3",
"postcss": "npm:postcss@8.4.35",
"tailwindcss": "npm:tailwindcss@^3.4.1",
"@tailwindcss/postcss": "npm:@tailwindcss/postcss@^4.1.10",
"tailwindcss": "npm:tailwindcss@^4.1.10",
"postcss": "npm:postcss@8.5.6",
"ts-morph": "npm:ts-morph@^25.0.1",
"@fresh/plugin-tailwind": "jsr:@fresh/plugin-tailwind@^0.0.1-alpha.7",
"@std/front-matter": "jsr:@std/front-matter@^1.0.5",
"github-slugger": "npm:github-slugger@^2.0.0",
"imagescript": "https://deno.land/x/imagescript@1.3.0/mod.ts",
Generated
+577 -867
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -59,7 +59,7 @@ import { app } from "./main.ts";
const builder = new Builder({ target: "safari12" });
// Example: Enabling the tailwind plugin for Fresh
tailwind(builder, app, {});
tailwind(builder, app);
// Create optimized assets for the browser when
// running `deno run -A dev.ts build`
@@ -133,7 +133,7 @@ export default function Cart() {
Cart
</h1>
<ul class="w-full bg-gray-50 mt-2 p-2 rounded min-h-[6.5rem]">
<ul class="w-full bg-gray-50 mt-2 p-2 rounded-sm min-h-[6.5rem]">
{cart.value.length === 0 && (
<li class="text-center my-4">
<div class="text-gray-400">
+13 -9
View File
@@ -4,9 +4,12 @@ import * as path from "@std/path";
// Keep these as is, as we replace these version in our release script
const FRESH_VERSION = "2.0.0-alpha.43";
const FRESH_TAILWIND_VERSION = "0.0.1-alpha.7";
const FRESH_TAILWIND_VERSION = "0.0.1-alpha.8";
const PREACT_VERSION = "10.26.9";
const PREACT_SIGNALS_VERSION = "2.2.1";
const TAILWINDCSS_VERSION = "4.1.10";
const TAILWINDCSS_POSTCSS_VERSION = "4.1.10";
const POSTCSS_VERSION = "8.5.6";
function css(strs: TemplateStringsArray, ...exprs: string[]): string {
let out = "";
@@ -309,7 +312,7 @@ html {
.border-2 {
border-width: 2px;
}
.rounded {
.rounded-sm {
border-radius: 0.25rem;
}
.hover\\:bg-gray-200:hover {
@@ -320,11 +323,8 @@ html {
}
${GRADIENT_CSS}`;
// deno-fmt-ignore
const TAILWIND_CSS = css`@tailwind base;
@tailwind components;
@tailwind utilities;
const TAILWIND_CSS = css`@import "tailwindcss";
${GRADIENT_CSS}`;
const cssStyles = useTailwind ? TAILWIND_CSS : NO_TAILWIND_STYLES;
@@ -405,7 +405,7 @@ export function Button(props: ButtonProps) {
return (
<button
{...props}
class="px-2 py-1 border-gray-500 border-2 rounded bg-white hover:bg-gray-200 transition-colors"
class="px-2 py-1 border-gray-500 border-2 rounded-sm bg-white hover:bg-gray-200 transition-colors"
/>
);
}`;
@@ -503,7 +503,7 @@ import { Builder } from "fresh/dev";
import { app } from "./main.ts";
const builder = new Builder();
${useTailwind ? "tailwind(builder, app, {});" : ""}
${useTailwind ? "tailwind(builder, app);" : ""}
if (Deno.args.includes("build")) {
await builder.build(app);
} else {
@@ -512,6 +512,7 @@ if (Deno.args.includes("build")) {
await writeFile("dev.ts", DEV_TS);
const denoJson = {
nodeModulesDir: "auto",
tasks: {
check: "deno fmt --check . && deno lint . && deno check",
dev: "deno run -A --watch=static/,routes/ dev.ts",
@@ -546,9 +547,12 @@ if (Deno.args.includes("build")) {
};
if (useTailwind) {
denoJson.imports["tailwindcss"] = "npm:tailwindcss@^3.4.3";
denoJson.imports["tailwindcss"] = `npm:tailwindcss@^${TAILWINDCSS_VERSION}`;
denoJson.imports["@fresh/plugin-tailwind"] =
`jsr:@fresh/plugin-tailwind@^${FRESH_TAILWIND_VERSION}`;
denoJson.imports["@tailwindcss/postcss"] =
`npm:@tailwindcss/postcss@^${TAILWINDCSS_POSTCSS_VERSION}`;
denoJson.imports["postcss"] = `npm:postcss@^${POSTCSS_VERSION}`;
}
await writeFile("deno.json", denoJson);
+1 -1
View File
@@ -92,7 +92,7 @@ Deno.test("init - with tailwind", async () => {
await initProject(dir, [], {});
const css = await readProjectFile(dir, "static/styles.css");
expect(css).toMatch(/@tailwind/);
expect(css).toMatch(/@import "tailwindcss"/);
const main = await readProjectFile(dir, "main.ts");
const dev = await readProjectFile(dir, "dev.ts");
+35 -13
View File
@@ -2,26 +2,48 @@
A Tailwind CSS plugin to use in Fresh.
## Basic Usage
```ts
// dev.ts
import { tailwind } from "@fresh/plugin-tailwind";
import { FreshDevApp } from "fresh/dev";
import { Builder } from "fresh/dev";
import { app } from "./main.ts";
import { tailwind } from "@fresh/plugin-tailwind";
const devApp = new FreshDevApp();
// Enable Tailwind CSS
tailwind(devApp);
devApp.mountApp("/", app);
const builder = new Builder();
tailwind(builder, app);
if (Deno.args.includes("build")) {
await devApp.build({
target: "safari12",
});
builder.build(app);
} else {
await devApp.listen();
builder.listen(app);
}
```
## Option Configuration
```ts
// dev.ts
import { Builder } from "fresh/dev";
import { app } from "./main.ts";
import { tailwind } from "@fresh/plugin-tailwind";
const builder = new Builder();
tailwind(builder, app, {
// Exclude certain files from processing
exclude: ["/admin/**", "*.temp.css"],
// Force optimization (defaults to production mode)
optimize: true,
// Exclude base styles
base: null,
});
if (Deno.args.includes("build")) {
builder.build(app);
} else {
builder.listen(app);
}
```
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@fresh/plugin-tailwind",
"version": "0.0.1-alpha.7",
"version": "0.0.1-alpha.8",
"license": "MIT",
"exports": "./src/mod.ts"
}
-80
View File
@@ -1,80 +0,0 @@
import tailwindCss, { type Config } from "tailwindcss";
import postcss from "postcss";
import autoprefixer from "autoprefixer";
import * as path from "@std/path";
import type { TailwindPluginOptions } from "./types.ts";
import type { ResolvedFreshConfig } from "fresh";
const CONFIG_EXTENSIONS = ["ts", "js", "mjs"];
async function findTailwindConfigFile(directory: string): Promise<string> {
let dir = directory;
while (true) {
for (let i = 0; i < CONFIG_EXTENSIONS.length; i++) {
const ext = CONFIG_EXTENSIONS[i];
const filePath = path.join(dir, `tailwind.config.${ext}`);
try {
const stat = await Deno.stat(filePath);
if (stat.isFile) {
return filePath;
}
} catch (err) {
if (!(err instanceof Deno.errors.NotFound)) {
throw err;
}
}
}
const parent = path.dirname(dir);
if (parent === dir) {
throw new Error(
`Could not find a tailwind config file in the current directory or any parent directory.`,
);
}
dir = parent;
}
}
export async function initTailwind(
config: ResolvedFreshConfig,
options: TailwindPluginOptions,
): Promise<postcss.Processor> {
const root = path.dirname(config.staticDir);
const configPath = await findTailwindConfigFile(root);
const url = path.toFileUrl(configPath).href;
const tailwindConfig = (await import(url)).default as Config;
if (!Array.isArray(tailwindConfig.content)) {
throw new Error(`Expected tailwind "content" option to be an array`);
}
// deno-lint-ignore no-explicit-any
tailwindConfig.content = tailwindConfig.content.map((pattern: any) => {
if (typeof pattern === "string") {
const relative = path.relative(Deno.cwd(), path.dirname(configPath));
if (!relative.startsWith("..")) {
return path.join(relative, pattern);
}
}
return pattern;
});
// PostCSS types cause deep recursion
const plugins = [
// deno-lint-ignore no-explicit-any
tailwindCss(tailwindConfig) as any,
// deno-lint-ignore no-explicit-any
autoprefixer(options.autoprefixer) as any,
];
if (config.mode === "production") {
const { default: cssnano } = await import("cssnano");
plugins.push(cssnano());
}
const res = postcss(plugins);
return res;
}
+12 -6
View File
@@ -1,20 +1,26 @@
import type { TailwindPluginOptions } from "./types.ts";
import { initTailwind } from "./compiler.ts";
import type { Builder } from "fresh/dev";
import type { App } from "fresh";
import twPostcss from "@tailwindcss/postcss";
import postcss from "postcss";
import type { TailwindPluginOptions } from "./types.ts";
// Re-export types for public API
export type { TailwindPluginOptions } from "./types.ts";
export function tailwind<T>(
builder: Builder,
app: App<T>,
options: TailwindPluginOptions = {},
): void {
let processor: ReturnType<typeof initTailwind> | null;
const { exclude, ...tailwindOptions } = options;
const instance = postcss(twPostcss({
optimize: app.config.mode === "production",
...tailwindOptions,
}));
builder.onTransformStaticFile(
{ pluginName: "tailwind", filter: /\.css$/, exclude: options.exclude },
{ pluginName: "tailwind", filter: /\.css$/, exclude },
async (args) => {
if (!processor) processor = initTailwind(app.config, options);
const instance = await processor;
const res = await instance.process(args.text, {
from: args.path,
});
+15 -41
View File
@@ -1,48 +1,22 @@
import type { OnTransformOptions } from "@fresh/core/dev";
export interface AutoprefixerOptions {
/** environment for `Browserslist` */
env?: string;
/** should Autoprefixer use Visual Cascade, if CSS is uncompressed */
cascade?: boolean;
/** should Autoprefixer add prefixes. */
add?: boolean;
/** should Autoprefixer [remove outdated] prefixes */
remove?: boolean;
/** should Autoprefixer add prefixes for @supports parameters. */
supports?: boolean;
/** should Autoprefixer add prefixes for flexbox properties */
flexbox?: boolean | "no-2009";
/** should Autoprefixer add IE 10-11 prefixes for Grid Layout properties */
grid?: boolean | "autoplace" | "no-autoplace";
/** custom usage statistics for > 10% in my stats browsers query */
stats?: {
[browser: string]: {
[version: string]: number;
};
};
import type { OnTransformOptions } from "fresh/dev";
// based on the original code, this type is used to define options for the Tailwind plugin
type PluginOptions = {
/**
* list of queries for target browsers.
* Try to not use it.
* The best practice is to use `.browserslistrc` config or `browserslist` key in `package.json`
* to share target browsers with Babel, ESLint and Stylelint
* Base CSS to be included. Set to null to exclude base styles.
*/
overrideBrowserslist?: string | string[];
base?: string;
/**
* Enable or disable CSS optimization. Defaults to true if Fresh is in production mode and false otherwise.
* Can be a boolean or an object with minify options.
* @default app.config.mode === "production"
*/
optimize?: boolean | {
minify?: boolean;
};
};
/** do not raise error on unknown browser version in `Browserslist` config. */
ignoreUnknownVersions?: boolean;
}
export interface TailwindPluginOptions {
autoprefixer?: AutoprefixerOptions;
export interface TailwindPluginOptions extends PluginOptions {
/** Exclude paths or globs that should not be processed */
exclude?: OnTransformOptions["exclude"];
}
+2 -2
View File
@@ -115,7 +115,7 @@ Deno.test("update - 1.x project deno.json tasks + lock", async () => {
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"cli": "echo \\"import '$fresh/src/dev/cli.ts'\\" | deno run --unstable -A -",
"manifest": "deno task cli manifest $(pwd)",
"start": "deno run -A --allow-scripts --watch=static/,routes/ dev.ts",
"start": "deno run -A --watch=static/,routes/ dev.ts",
"build": "deno run -A dev.ts build",
"preview": "deno run -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ."
@@ -133,7 +133,7 @@ Deno.test("update - 1.x project deno.json tasks + lock", async () => {
build: "deno run -A dev.ts build",
check: "deno fmt --check && deno lint && deno check",
preview: "deno run -A main.ts",
start: "deno run -A --allow-scripts --watch=static/,routes/ dev.ts",
start: "deno run -A --watch=static/,routes/ dev.ts",
update: "deno run -A -r jsr:@fresh/update .",
});
});
+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;