feat: twind plugin (#513)
This adds a first-party twind plugin to use twind for styling.
This commit is contained in:
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"denoland.vscode-deno",
|
||||
"sastan.twind-intellisense"
|
||||
]
|
||||
}
|
||||
Vendored
-1
@@ -3,7 +3,6 @@
|
||||
"imports": {
|
||||
"$fresh/": "../",
|
||||
|
||||
"@twind": "../www/utils/twind.ts",
|
||||
"twind": "https://esm.sh/twind@0.16.17",
|
||||
"twind/": "https://esm.sh/twind@0.16.17/",
|
||||
|
||||
|
||||
@@ -90,9 +90,6 @@ await Deno.mkdir(join(resolvedDirectory, "components"), { recursive: true });
|
||||
if (useVSCode) {
|
||||
await Deno.mkdir(join(resolvedDirectory, ".vscode"), { recursive: true });
|
||||
}
|
||||
if (useTwind) {
|
||||
await Deno.mkdir(join(resolvedDirectory, "utils"), { recursive: true });
|
||||
}
|
||||
|
||||
const importMap = {
|
||||
"imports": {
|
||||
@@ -104,7 +101,6 @@ const importMap = {
|
||||
} as Record<string, string>,
|
||||
};
|
||||
if (useTwind) {
|
||||
importMap.imports["@twind"] = "./utils/twind.ts";
|
||||
importMap.imports["twind"] = "https://esm.sh/twind@0.16.17";
|
||||
importMap.imports["twind/"] = "https://esm.sh/twind@0.16.17/";
|
||||
}
|
||||
@@ -114,20 +110,19 @@ await Deno.writeTextFile(
|
||||
IMPORT_MAP_JSON,
|
||||
);
|
||||
|
||||
let ROUTES_INDEX_TSX = `/** @jsx h */
|
||||
import { h } from "preact";\n`;
|
||||
if (useTwind) ROUTES_INDEX_TSX += `import { tw } from "@twind";\n`;
|
||||
ROUTES_INDEX_TSX += `import Counter from "../islands/Counter.tsx";
|
||||
const ROUTES_INDEX_TSX = `/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import Counter from "../islands/Counter.tsx";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div${useTwind ? " class={tw\`p-4 mx-auto max-w-screen-md\`}" : ""}>
|
||||
<div${useTwind ? ` class="p-4 mx-auto max-w-screen-md"` : ""}>
|
||||
<img
|
||||
src="/logo.svg"
|
||||
height="100px"
|
||||
${useTwind ? `class="w-32 h-32"` : `width="128"\n height="128"`}
|
||||
alt="the fresh logo: a sliced lemon dripping with juice"
|
||||
/>
|
||||
<p${useTwind ? " class={tw\`my-6\`}" : ""}>
|
||||
<p${useTwind ? ` class="my-6"` : ""}>
|
||||
Welcome to \`fresh\`. Try updating this message in the ./routes/index.tsx
|
||||
file, and refresh.
|
||||
</p>
|
||||
@@ -144,17 +139,16 @@ await Deno.writeTextFile(
|
||||
const COMPONENTS_BUTTON_TSX = `/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
${useTwind ? 'import { tw } from "@twind";\n' : ""}
|
||||
export function Button(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
|
||||
return (
|
||||
<button
|
||||
{...props}
|
||||
disabled={!IS_BROWSER || props.disabled}
|
||||
${
|
||||
${
|
||||
useTwind
|
||||
? " class={tw\`px-2 py-1 border(gray-100 2) hover:bg-gray-200\`}\n "
|
||||
? ' class="px-2 py-1 border(gray-100 2) hover:bg-gray-200"\n'
|
||||
: ""
|
||||
}/>
|
||||
} />
|
||||
);
|
||||
}
|
||||
`;
|
||||
@@ -166,7 +160,6 @@ await Deno.writeTextFile(
|
||||
const ISLANDS_COUNTER_TSX = `/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { useState } from "preact/hooks";
|
||||
${useTwind ? 'import { tw } from "@twind";\n' : ""}
|
||||
import { Button } from "../components/Button.tsx";
|
||||
|
||||
interface CounterProps {
|
||||
@@ -176,17 +169,14 @@ interface CounterProps {
|
||||
export default function Counter(props: CounterProps) {
|
||||
const [count, setCount] = useState(props.start);
|
||||
return (
|
||||
<div${useTwind ? " class={tw\`flex gap-2 w-full\`}" : ""}>
|
||||
<p${
|
||||
useTwind ? " class={tw\`flex-grow-1 font-bold text-xl\`}" : ""
|
||||
}>{count}</p>
|
||||
<div${useTwind ? ' class="flex gap-2 w-full"' : ""}>
|
||||
<p${useTwind ? ' class="flex-grow-1 font-bold text-xl"' : ""}>{count}</p>
|
||||
<Button onClick={() => setCount(count - 1)}>-1</Button>
|
||||
<Button onClick={() => setCount(count + 1)}>+1</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
`;
|
||||
|
||||
await Deno.writeTextFile(
|
||||
join(resolvedDirectory, "islands", "Counter.tsx"),
|
||||
ISLANDS_COUNTER_TSX,
|
||||
@@ -232,19 +222,14 @@ await Deno.writeTextFile(
|
||||
ROUTES_API_JOKE_TS,
|
||||
);
|
||||
|
||||
const UTILS_TWIND_TS = `import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
import { Configuration, setup } from "twind";
|
||||
export * from "twind";
|
||||
export const config: Configuration = {
|
||||
darkMode: "class",
|
||||
mode: "silent",
|
||||
};
|
||||
if (IS_BROWSER) setup(config);
|
||||
const TWIND_CONFIG_JS =
|
||||
`/** @type {import("$fresh/plugins/twind.ts").Options} */
|
||||
export default {};
|
||||
`;
|
||||
if (useTwind) {
|
||||
await Deno.writeTextFile(
|
||||
join(resolvedDirectory, "utils", "twind.ts"),
|
||||
UTILS_TWIND_TS,
|
||||
join(resolvedDirectory, "twind.config.js"),
|
||||
TWIND_CONFIG_JS,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -277,34 +262,21 @@ let MAIN_TS = `/// <reference no-default-lib="true" />
|
||||
/// <reference lib="dom.asynciterable" />
|
||||
/// <reference lib="deno.ns" />
|
||||
|
||||
import { ${
|
||||
useTwind ? "InnerRenderFunction, RenderContext, " : ""
|
||||
}start } from "$fresh/server.ts";
|
||||
import { start } from "$fresh/server.ts";
|
||||
import manifest from "./fresh.gen.ts";
|
||||
`;
|
||||
|
||||
if (useTwind) {
|
||||
MAIN_TS += `
|
||||
import { config, setup } from "@twind";
|
||||
import { virtualSheet } from "twind/sheets";
|
||||
|
||||
const sheet = virtualSheet();
|
||||
sheet.reset();
|
||||
setup({ ...config, sheet });
|
||||
|
||||
function render(ctx: RenderContext, render: InnerRenderFunction) {
|
||||
const snapshot = ctx.state.get("twind") as unknown[] | null;
|
||||
sheet.reset(snapshot || undefined);
|
||||
render();
|
||||
ctx.styles.splice(0, ctx.styles.length, ...(sheet).target);
|
||||
const newSnapshot = sheet.reset();
|
||||
ctx.state.set("twind", newSnapshot);
|
||||
}
|
||||
|
||||
import twindPlugin from "$fresh/plugins/twind.ts";
|
||||
import twindConfig from "./twind.config.js";
|
||||
`;
|
||||
}
|
||||
|
||||
MAIN_TS += `await start(manifest${useTwind ? ", { render }" : ""});\n`;
|
||||
MAIN_TS += `
|
||||
await start(manifest${
|
||||
useTwind ? ", { plugins: [twindPlugin(twindConfig)] }" : ""
|
||||
});\n`;
|
||||
const MAIN_TS_PATH = join(resolvedDirectory, "main.ts");
|
||||
await Deno.writeTextFile(MAIN_TS_PATH, MAIN_TS);
|
||||
|
||||
@@ -368,6 +340,10 @@ const vscodeExtensions = {
|
||||
recommendations: ["denoland.vscode-deno"],
|
||||
};
|
||||
|
||||
if (useTwind) {
|
||||
vscodeExtensions.recommendations.push("sastan.twind-intellisense");
|
||||
}
|
||||
|
||||
const VSCODE_EXTENSIONS = JSON.stringify(vscodeExtensions, null, 2) + "\n";
|
||||
|
||||
if (useVSCode) {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { virtualSheet } from "twind/sheets";
|
||||
import { Plugin } from "../server.ts";
|
||||
|
||||
import { Options, setup, STYLE_ELEMENT_ID } from "./twind/shared.ts";
|
||||
export type { Options };
|
||||
|
||||
export default function twind(options: Options): Plugin {
|
||||
const sheet = virtualSheet();
|
||||
setup(options, sheet);
|
||||
return {
|
||||
name: "twind",
|
||||
entrypoints: { "main": new URL("./twind/main.ts", import.meta.url).href },
|
||||
render(ctx) {
|
||||
sheet.reset(undefined);
|
||||
const res = ctx.render();
|
||||
const cssText = [...sheet.target].join("\n");
|
||||
const snapshot = sheet.reset();
|
||||
const scripts = [];
|
||||
if (res.requiresHydration) {
|
||||
const precedences = snapshot[1];
|
||||
const mappings: (string | [string, string])[] = [];
|
||||
for (
|
||||
const [key, value] of (snapshot[3] as Map<string, string>).entries()
|
||||
) {
|
||||
if (key === value) {
|
||||
mappings.push(key);
|
||||
} else {
|
||||
mappings.push([key, value]);
|
||||
}
|
||||
}
|
||||
const state = [options, precedences, mappings];
|
||||
scripts.push({ entrypoint: "main", state });
|
||||
}
|
||||
return {
|
||||
scripts,
|
||||
styles: [{ cssText, id: STYLE_ELEMENT_ID }],
|
||||
};
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { Sheet } from "twind";
|
||||
import { Options, setup, STYLE_ELEMENT_ID } from "./shared.ts";
|
||||
|
||||
type State = [Options, string[], [string, string][]];
|
||||
|
||||
export default function hydrate(state: State) {
|
||||
const el = document.getElementById(STYLE_ELEMENT_ID) as HTMLStyleElement;
|
||||
const rules = new Set(el.innerText.split("\n"));
|
||||
const precedences = state[1];
|
||||
const mappings = new Map(state[2]
|
||||
.map((v) => typeof v === "string" ? [v, v] : v));
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const sheetState: any[] = [precedences, rules, mappings, true];
|
||||
const target = el.sheet!;
|
||||
const sheet: Sheet = {
|
||||
target,
|
||||
insert: (rule, index) => target.insertRule(rule, index),
|
||||
init: (cb) => cb(sheetState.shift()),
|
||||
};
|
||||
setup(state[0], sheet);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import { JSX, options as preactOptions, VNode } from "preact";
|
||||
import {
|
||||
Configuration,
|
||||
DarkMode,
|
||||
setup as twSetup,
|
||||
Sheet,
|
||||
ThemeConfiguration,
|
||||
tw,
|
||||
} from "twind";
|
||||
|
||||
export const STYLE_ELEMENT_ID = "__FRSH_TWIND";
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* Determines the dark mode strategy (default: `"media"`).
|
||||
*/
|
||||
darkMode?: DarkMode;
|
||||
|
||||
/**
|
||||
* The twind theme to use.
|
||||
*/
|
||||
theme?: ThemeConfiguration;
|
||||
|
||||
/**
|
||||
* ```js
|
||||
* {
|
||||
* ':new-variant': '& .selector',
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
variants?: Record<string, string>;
|
||||
|
||||
/**
|
||||
* Configure wether the class names should be emitted "as is", or if they
|
||||
* should be hashed.
|
||||
*/
|
||||
hash?: boolean;
|
||||
}
|
||||
|
||||
declare module "preact" {
|
||||
namespace JSX {
|
||||
interface DOMAttributes<Target extends EventTarget> {
|
||||
class?: string;
|
||||
className?: string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function setup(options: Options, sheet: Sheet) {
|
||||
const config: Configuration = {
|
||||
darkMode: options.darkMode,
|
||||
hash: options.hash,
|
||||
mode: "silent",
|
||||
sheet,
|
||||
variants: options.variants,
|
||||
theme: options.theme,
|
||||
};
|
||||
twSetup(config);
|
||||
|
||||
const originalHook = preactOptions.vnode;
|
||||
// deno-lint-ignore no-explicit-any
|
||||
preactOptions.vnode = (vnode: VNode<JSX.DOMAttributes<any>>) => {
|
||||
if (typeof vnode.type === "string" && typeof vnode.props === "object") {
|
||||
const { props } = vnode;
|
||||
const classes: string[] = [];
|
||||
if (props.class) {
|
||||
classes.push(tw(props.class));
|
||||
props.class = undefined;
|
||||
}
|
||||
if (props.className) {
|
||||
classes.push(tw(props.className));
|
||||
}
|
||||
if (classes.length) {
|
||||
props.class = classes.join(" ");
|
||||
}
|
||||
}
|
||||
|
||||
originalHook?.(vnode);
|
||||
};
|
||||
}
|
||||
+1
-7
@@ -206,6 +206,7 @@ Deno.test({
|
||||
{ "type": "file", "name": "README.md" },
|
||||
{ "type": "file", "name": "import_map.json" },
|
||||
{ "type": "file", "name": "fresh.gen.ts" },
|
||||
{ "type": "file", "name": "twind.config.js" },
|
||||
{
|
||||
"type": "directory",
|
||||
"name": "components",
|
||||
@@ -243,13 +244,6 @@ Deno.test({
|
||||
{ "type": "file", "name": "logo.svg" },
|
||||
],
|
||||
},
|
||||
{
|
||||
"type": "directory",
|
||||
"name": "utils",
|
||||
"contents": [
|
||||
{ "type": "file", "name": "twind.ts" },
|
||||
],
|
||||
},
|
||||
{
|
||||
"type": "directory",
|
||||
"name": ".vscode",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { tw } from "@twind";
|
||||
|
||||
export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
|
||||
return (
|
||||
@@ -9,7 +8,7 @@ export function RoundedButton(props: h.JSX.HTMLAttributes<HTMLButtonElement>) {
|
||||
touchAction: "manipulation",
|
||||
}}
|
||||
{...props}
|
||||
class={tw`p-3 border border-transparent rounded-full text-white bg-green(500 hover:600) focus:(outline-none ring(2 offset-2 green-500)) disabled:(bg-green-200 cursor-default)`}
|
||||
class="p-3 border border-transparent rounded-full text-white bg-green(500 hover:600) focus:(outline-none ring(2 offset-2 green-500)) disabled:(bg-green-200 cursor-default)}"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { apply, tw } from "@twind";
|
||||
|
||||
import {
|
||||
CATEGORIES,
|
||||
@@ -10,7 +9,7 @@ import {
|
||||
|
||||
export default function DocsSidebar(props: { path: string }) {
|
||||
return (
|
||||
<ol class={tw`list-decimal list-inside font-semibold` + " nested"}>
|
||||
<ol class="list-decimal list-inside font-semibold nested">
|
||||
{CATEGORIES.map((category) => (
|
||||
<SidebarCategory path={props.path} category={category} />
|
||||
))}
|
||||
@@ -18,24 +17,22 @@ export default function DocsSidebar(props: { path: string }) {
|
||||
);
|
||||
}
|
||||
|
||||
const link = apply`text(gray-900 hover:gray-600)`;
|
||||
const linkActive = apply`text(green-600 hover:green-500)`;
|
||||
const link = "text(gray-900 hover:gray-600)";
|
||||
const linkActive = "text(green-600 hover:green-500)";
|
||||
|
||||
export function SidebarCategory(props: {
|
||||
path: string;
|
||||
category: TableOfContentsCategory;
|
||||
}) {
|
||||
const outerItem = tw`my-2 block`;
|
||||
const innerList = tw`pl-4 list-decimal` + " nested";
|
||||
|
||||
const { title, href, entries } = props.category;
|
||||
const outerLink = tw`${href == props.path ? linkActive : link} font-bold`;
|
||||
|
||||
const outerLink = `${href == props.path ? linkActive : link} font-bold`;
|
||||
|
||||
return (
|
||||
<li class={outerItem}>
|
||||
<li class="my-2 block">
|
||||
<a href={href} class={outerLink}>{title}</a>
|
||||
{entries.length > 0 && (
|
||||
<ol class={innerList}>
|
||||
<ol class="pl-4 list-decimal nested">
|
||||
{entries.map((entry) => (
|
||||
<SidebarEntry path={props.path} entry={entry} />
|
||||
))}
|
||||
@@ -49,12 +46,12 @@ export function SidebarEntry(props: {
|
||||
path: string;
|
||||
entry: TableOfContentsCategoryEntry;
|
||||
}) {
|
||||
const innerItem = tw`my-0.5`;
|
||||
|
||||
const { title, href } = props.entry;
|
||||
const innerLink = tw`${href == props.path ? linkActive : link} font-normal`;
|
||||
|
||||
const innerLink = `${href == props.path ? linkActive : link} font-normal`;
|
||||
|
||||
return (
|
||||
<li class={innerItem}>
|
||||
<li class="my-0.5">
|
||||
<a href={href} class={innerLink}>{title}</a>
|
||||
</li>
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { tw } from "@twind";
|
||||
|
||||
const LINKS = [
|
||||
{
|
||||
@@ -18,23 +17,17 @@ const LINKS = [
|
||||
];
|
||||
|
||||
export default function Footer() {
|
||||
const footer =
|
||||
tw`border(t-2 gray-200) bg-gray-100 h-32 flex flex-col gap-4 justify-center`;
|
||||
const inner =
|
||||
tw`mx-auto max-w-screen-lg flex items-center justify-center gap-8`;
|
||||
const linkStyle = tw`text-gray-600 hover:underline`;
|
||||
const copyright = tw`text(gray-600 center)`;
|
||||
return (
|
||||
<footer class={footer}>
|
||||
<div class={inner}>
|
||||
<footer class="border(t-2 gray-200) bg-gray-100 h-32 flex flex-col gap-4 justify-center">
|
||||
<div class="mx-auto max-w-screen-lg flex items-center justify-center gap-8">
|
||||
{LINKS.map((link) => (
|
||||
<a href={link.href} class={linkStyle}>
|
||||
<a href={link.href} class="text-gray-600 hover:underline">
|
||||
{link.title}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
<div class={copyright}>
|
||||
<span>© {new Date().getFullYear()} the Fresh authors</span>
|
||||
<div class="text(gray-600 center)">
|
||||
<span>© {new Date().getFullYear()} the fresh authors</span>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { tw } from "@twind";
|
||||
|
||||
export function IconMinus() {
|
||||
return (
|
||||
<svg
|
||||
class={tw`h-6 w-6`}
|
||||
class="h-6 w-6"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -25,7 +24,7 @@ export function IconMinus() {
|
||||
export function IconPlus() {
|
||||
return (
|
||||
<svg
|
||||
class={tw`h-6 w-6`}
|
||||
class="h-6 w-6"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
/** @jsx h */
|
||||
import { h } from "preact";
|
||||
import { tw } from "@twind";
|
||||
|
||||
export default function NavigationBar(props: { active: string }) {
|
||||
const items = [
|
||||
@@ -15,13 +14,13 @@ export default function NavigationBar(props: { active: string }) {
|
||||
];
|
||||
|
||||
return (
|
||||
<nav class={tw`bg-green-200 py-2`}>
|
||||
<ul class={tw`flex justify-center gap-8 mx-4`}>
|
||||
<nav class="bg-green-200 py-2">
|
||||
<ul class="flex justify-center gap-8 mx-4">
|
||||
{items.map((item) => (
|
||||
<li>
|
||||
<a
|
||||
href={item.href}
|
||||
class={tw`text-gray-600 hover:underline ${
|
||||
class={`text-gray-600 hover:underline ${
|
||||
props.active == item.href ? "font-bold" : ""
|
||||
}`}
|
||||
>
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
"imports": {
|
||||
"$fresh/": "../",
|
||||
|
||||
"@twind": "./utils/twind.ts",
|
||||
"twind": "https://esm.sh/twind@0.16.17",
|
||||
"twind/": "https://esm.sh/twind@0.16.17/",
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { h } from "preact";
|
||||
import { useState } from "preact/hooks";
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
import { tw } from "@twind";
|
||||
import { RoundedButton } from "../components/Button.tsx";
|
||||
import { IconMinus, IconPlus } from "../components/Icons.tsx";
|
||||
|
||||
@@ -13,9 +12,7 @@ interface CounterProps {
|
||||
export default function Counter(props: CounterProps) {
|
||||
const [count, setCount] = useState(props.start);
|
||||
return (
|
||||
<div
|
||||
class={tw`bg-gray-100 p-4 border border-gray-200 flex items-center justify-around`}
|
||||
>
|
||||
<div class="bg-gray-100 p-4 border border-gray-200 flex items-center justify-around">
|
||||
<RoundedButton
|
||||
title="Subtract 1"
|
||||
onClick={() => setCount(count - 1)}
|
||||
@@ -23,7 +20,7 @@ export default function Counter(props: CounterProps) {
|
||||
>
|
||||
<IconMinus />
|
||||
</RoundedButton>
|
||||
<div class={tw`text-3xl tabular-nums`}>{count}</div>
|
||||
<div class="text-3xl tabular-nums">{count}</div>
|
||||
<RoundedButton
|
||||
title="Add 1"
|
||||
onClick={() => setCount(count + 1)}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
/** @jsxFrag Fragment */
|
||||
import { Fragment, h } from "preact";
|
||||
import { useEffect, useRef, useState } from "preact/hooks";
|
||||
import { tw } from "@twind";
|
||||
import { Spring, WaveTank } from "../components/WaveTank.ts";
|
||||
|
||||
function easeInCirc(x: number) {
|
||||
@@ -102,7 +101,7 @@ function LemonDrop() {
|
||||
viewBox="0 0 100 300"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class={tw`mt-36`}
|
||||
class="mt-36"
|
||||
role="img"
|
||||
aria-label="Fresh logo"
|
||||
>
|
||||
@@ -130,7 +129,7 @@ function LemonDrop() {
|
||||
height="100px"
|
||||
viewBox="0 0 100 100"
|
||||
preserveAspectRatio="none"
|
||||
class={tw`-mt-5`}
|
||||
class="-mt-5"
|
||||
>
|
||||
<polygon
|
||||
points={springsPath}
|
||||
|
||||
+4
-17
@@ -4,22 +4,9 @@
|
||||
/// <reference lib="deno.ns" />
|
||||
|
||||
import { start } from "$fresh/server.ts";
|
||||
import { virtualSheet } from "twind/sheets";
|
||||
import { setup, theme } from "@twind";
|
||||
import twindPlugin from "$fresh/plugins/twind.ts";
|
||||
|
||||
import routes from "./fresh.gen.ts";
|
||||
import manifest from "./fresh.gen.ts";
|
||||
import twindConfig from "./twind.config.js";
|
||||
|
||||
const sheet = virtualSheet();
|
||||
sheet.reset();
|
||||
setup({ sheet, theme });
|
||||
|
||||
await start(routes, {
|
||||
render(ctx, render) {
|
||||
const snapshot = ctx.state.get("twindSnapshot") as unknown[] | null;
|
||||
sheet.reset(snapshot || undefined);
|
||||
render();
|
||||
ctx.styles.splice(0, ctx.styles.length, ...(sheet).target);
|
||||
const newSnapshot = sheet.reset();
|
||||
ctx.state.set("twindSnapshot", newSnapshot);
|
||||
},
|
||||
});
|
||||
await start(manifest, { plugins: [twindPlugin(twindConfig)] });
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
import { Fragment, h } from "preact";
|
||||
import { Head } from "$fresh/runtime.ts";
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { apply, tw } from "@twind";
|
||||
import { frontMatter, gfm } from "../../utils/markdown.ts";
|
||||
|
||||
import DocsSidebar from "../../components/DocsSidebar.tsx";
|
||||
@@ -65,7 +64,7 @@ export default function DocsPage(props: PageProps<Data>) {
|
||||
<link rel="stylesheet" href={`/gfm.css?build=${__FRSH_BUILD_ID}`} />
|
||||
{description && <meta name="description" content={description} />}
|
||||
</Head>
|
||||
<div class={tw`flex flex-col min-h-screen`}>
|
||||
<div class="flex flex-col min-h-screen">
|
||||
<Header />
|
||||
<NavigationBar active="/docs" />
|
||||
<Main path={props.url.pathname} page={props.data.page} />
|
||||
@@ -77,7 +76,7 @@ export default function DocsPage(props: PageProps<Data>) {
|
||||
|
||||
function Logo() {
|
||||
return (
|
||||
<a href="/" class={tw`flex mr-3 items-center`}>
|
||||
<a href="/" class="flex mr-3 items-center">
|
||||
<img
|
||||
src="/logo.svg"
|
||||
alt="Fresh logo"
|
||||
@@ -89,21 +88,21 @@ function Logo() {
|
||||
}
|
||||
|
||||
function Header() {
|
||||
const header = tw`mx-auto max-w-screen-lg flex gap-3 justify-between`;
|
||||
const sidebarButton =
|
||||
tw`px-4 py-4 md:hidden border(l-2 green-200) flex items-center hover:bg-green-100`;
|
||||
return (
|
||||
<div class={tw`bg-green-300`}>
|
||||
<header class={header}>
|
||||
<div class={tw`p-4 flex`}>
|
||||
<div class="bg-green-300">
|
||||
<header class="mx-auto max-w-screen-lg flex gap-3 justify-between">
|
||||
<div class="p-4 flex">
|
||||
<Logo />
|
||||
<div>
|
||||
<Title />
|
||||
</div>
|
||||
</div>
|
||||
<label for="docs_sidebar" class={sidebarButton}>
|
||||
<label
|
||||
for="docs_sidebar"
|
||||
class="px-4 py-4 md:hidden border(l-2 green-200) flex items-center hover:bg-green-100"
|
||||
>
|
||||
<svg
|
||||
class={tw`h-6 w-6`}
|
||||
class="h-6 w-6"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
@@ -123,39 +122,37 @@ function Header() {
|
||||
}
|
||||
|
||||
function Title() {
|
||||
const title =
|
||||
tw`text(2xl gray-900) tracking-tight font-extrabold flex items-center gap-1`;
|
||||
const pageName = tw`font-light block pb-[1px]`;
|
||||
const subtitle = tw`text(sm gray-700)`;
|
||||
return (
|
||||
<>
|
||||
<a href="/" class={title}>
|
||||
<a
|
||||
href="/"
|
||||
class="text(2xl gray-900) tracking-tight font-extrabold flex items-center gap-1"
|
||||
>
|
||||
<svg
|
||||
preserveAspectRatio="xMinYMin"
|
||||
viewBox="0 0 250 75"
|
||||
fill="none"
|
||||
alt="Fresh logo"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class={tw`h-5 inline-block py-[1px]`}
|
||||
class="h-5 inline-block py-[1px]"
|
||||
>
|
||||
<path
|
||||
d="M14.0805 0.761269V70.0893H0V0.761269H14.0805ZM35.6322 30.2257V41.7803H10.3448V30.2257H35.6322ZM38.5057 0.761269V12.3159H10.3448V0.761269H38.5057ZM46.5517 0.761269H68.9655C73.5632 0.761269 77.5862 1.62785 80.7471 3.36105C83.908 4.80538 86.4943 7.11632 88.2184 10.2939C90.1641 13.8269 91.1548 17.8107 91.092 21.8485C91.092 25.6038 90.5172 28.7813 89.3678 31.3811C88.5057 34.2698 87.069 36.2919 85.0575 38.0251C83.046 39.7583 81.0345 40.9137 78.4483 42.3581L74.1379 44.669H56.0345V33.1143H68.3908C70.0971 33.2247 71.7975 32.8225 73.2759 31.9589C74.4253 31.0923 75.2874 29.9368 76.1494 28.4925C76.8253 26.6458 77.1186 24.6798 77.0115 22.7151C77.0115 20.6931 76.7241 18.9599 76.1494 17.2267C75.5747 15.7823 74.7126 14.338 73.2759 13.7603C72.4138 12.8937 70.6897 12.3159 68.9655 12.3159H60.3448V70.0893H46.5517V0.761269V0.761269ZM78.1609 70.0893L65.5172 39.1805H79.8851L93.1035 69.5115V70.0893H78.1609ZM140.517 58.5346V70.0893H110.345V58.5346H140.517ZM114.655 0.761269V70.0893H100.575V0.761269H114.943H114.655ZM136.494 29.0702V40.0471H110.345V29.0702H136.207H136.494ZM140.517 0.761269V12.3159H110.345V0.761269H140.517ZM178.161 51.8907C178.161 50.7352 178.161 49.5797 177.586 48.7131C177.586 47.5577 177.012 46.6911 176.149 45.8245L173.276 42.9358L167.816 40.6249L160.345 37.1585L154.023 32.8255C152.021 31.2537 150.359 29.2878 149.138 27.0481C148.066 24.5949 147.574 21.9252 147.701 19.2487C147.701 16.3601 147.989 13.4714 149.138 11.4493C150.166 9.00506 151.739 6.83084 153.736 5.09427C155.747 3.64994 158.046 2.20559 160.632 1.33899C167.362 -0.855543 174.677 -0.337717 181.034 2.78333C184.483 4.51653 186.782 7.11632 188.793 10.2939C190.517 13.1825 191.667 17.2267 191.667 21.2708H177.299C177.424 19.5169 177.229 17.7548 176.724 16.0712C176.149 14.6269 175.287 13.1825 173.851 12.6048C172.701 11.7382 170.977 11.1605 169.253 11.1605C167.529 11.1605 166.092 11.7382 164.943 12.3159C163.793 12.8937 162.931 14.0491 162.069 15.2046L161.494 19.2487C161.494 20.4042 161.782 21.5597 162.356 22.4263L164.655 24.7372C167.235 26.2818 169.924 27.6335 172.701 28.7813L181.034 32.8255C183.199 34.2594 185.136 36.0121 186.782 38.0251C188.793 39.7583 189.655 41.7803 190.805 43.8024C192.605 48.9619 192.503 54.5998 190.517 59.6901C189.368 62.001 187.931 64.0231 186.207 65.7563C184.115 67.5878 181.669 68.9647 179.023 69.8004C173.276 71.2447 176.149 75 170.402 75C164.655 75 166.667 70.667 161.207 69.8004C158.333 68.9338 155.46 67.4895 153.448 65.7563C151.19 63.7856 149.419 61.313 148.276 58.5346C147.126 55.6459 146.552 52.1795 146.552 48.4243H160.632C160.632 50.4463 160.632 52.1795 161.207 53.6239C161.494 55.0682 162.069 56.5125 162.931 57.3791C163.793 57.9569 164.943 58.8235 166.092 59.1123C167.529 59.6901 168.966 59.6901 170.402 59.6901C172.414 59.6901 173.851 59.6901 175 58.8235C176.149 57.9569 176.724 57.0903 177.299 55.9348C177.874 54.7793 178.161 53.335 178.161 51.8907V51.8907ZM239.943 28.7813V40.336H211.207V28.7813H239.943ZM215.23 0.761269V70.0893H201.437V0.761269H215.23ZM250 0.761269V70.0893H236.207V0.761269H250Z"
|
||||
fill="#0A140C"
|
||||
/>
|
||||
</svg>
|
||||
<span class={pageName}>docs</span>
|
||||
<span class="font-light block pb-[1px]">docs</span>
|
||||
</a>
|
||||
<p class={subtitle}>The next-gen web framework.</p>
|
||||
<p class="text(sm gray-700)">The next-gen web framework.</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Main(props: { path: string; page: Page }) {
|
||||
const main = tw`mx-auto max-w-screen-lg px-4 flex gap-6`;
|
||||
return (
|
||||
<div class={tw`flex-1`}>
|
||||
<div class="flex-1">
|
||||
<MobileSidebar path={props.path} />
|
||||
<div class={main}>
|
||||
<div class="mx-auto max-w-screen-lg px-4 flex gap-6">
|
||||
<DesktopSidebar path={props.path} />
|
||||
<Content page={props.page} />
|
||||
</div>
|
||||
@@ -164,28 +161,25 @@ function Main(props: { path: string; page: Page }) {
|
||||
}
|
||||
|
||||
function MobileSidebar(props: { path: string }) {
|
||||
const container = tw`fixed inset-0 flex z-40 hidden` + " toggled";
|
||||
const backdrop = tw`absolute inset-0 bg-gray-600 opacity-75`;
|
||||
const sidebar =
|
||||
tw`relative flex-1 flex flex-col w-[16rem] h-full bg-white border(r-2 gray-100)`;
|
||||
const heading = tw`p-4 border(b-2 gray-100) bg-green-300`;
|
||||
const items = tw`pt-2 pb-16 px-4 overflow-x-auto`;
|
||||
return (
|
||||
<>
|
||||
<input
|
||||
type="checkbox"
|
||||
class={tw`hidden` + " toggle"}
|
||||
class="hidden toggle"
|
||||
id="docs_sidebar"
|
||||
autocomplete="off"
|
||||
>
|
||||
</input>
|
||||
<div class={container}>
|
||||
<label class={backdrop} for="docs_sidebar" />
|
||||
<div class={sidebar}>
|
||||
<div class={heading}>
|
||||
<div class="fixed inset-0 flex z-40 hidden toggled">
|
||||
<label
|
||||
class="absolute inset-0 bg-gray-600 opacity-75"
|
||||
for="docs_sidebar"
|
||||
/>
|
||||
<div class="relative flex-1 flex flex-col w-[16rem] h-full bg-white border(r-2 gray-100)">
|
||||
<div class="p-4 border(b-2 gray-100) bg-green-300">
|
||||
<Title />
|
||||
</div>
|
||||
<nav class={items}>
|
||||
<nav class="pt-2 pb-16 px-4 overflow-x-auto">
|
||||
<DocsSidebar path={props.path} />
|
||||
</nav>
|
||||
</div>
|
||||
@@ -196,24 +190,21 @@ function MobileSidebar(props: { path: string }) {
|
||||
|
||||
function DesktopSidebar(props: { path: string }) {
|
||||
return (
|
||||
<nav
|
||||
class={tw`w-[16rem] flex-shrink-0 hidden md:block py-8 pr-4 border(r-2 gray-100)`}
|
||||
>
|
||||
<nav class="w-[16rem] flex-shrink-0 hidden md:block py-8 pr-4 border(r-2 gray-100)">
|
||||
<DocsSidebar path={props.path} />
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
function Content(props: { page: Page }) {
|
||||
const main = tw`py-8 overflow-hidden`;
|
||||
const title = tw`text(4xl gray-900) tracking-tight font-extrabold mt-6`;
|
||||
const body = tw`mt-6`;
|
||||
const html = gfm.render(props.page.markdown);
|
||||
return (
|
||||
<main class={main}>
|
||||
<h1 class={title}>{props.page.title}</h1>
|
||||
<main class="py-8 overflow-hidden">
|
||||
<h1 class="text(4xl gray-900) tracking-tight font-extrabold mt-6">
|
||||
{props.page.title}
|
||||
</h1>
|
||||
<div
|
||||
class={`${body} markdown-body`}
|
||||
class="mt-6 markdown-body"
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
<ForwardBackButtons slug={props.page.slug} />
|
||||
@@ -221,7 +212,7 @@ function Content(props: { page: Page }) {
|
||||
);
|
||||
}
|
||||
|
||||
const button = apply`p-2 bg-gray-100 w-full border(1 gray-200) grid`;
|
||||
const button = "p-2 bg-gray-100 w-full border(1 gray-200) grid";
|
||||
|
||||
function ForwardBackButtons(props: { slug: string }) {
|
||||
const currentIndex = SLUGS.findIndex((slug) => slug === props.slug);
|
||||
@@ -230,14 +221,14 @@ function ForwardBackButtons(props: { slug: string }) {
|
||||
const previous = TABLE_OF_CONTENTS[previousSlug];
|
||||
const next = TABLE_OF_CONTENTS[nextSlug];
|
||||
|
||||
const upper = tw`text(sm gray-600)`;
|
||||
const category = tw`font-normal`;
|
||||
const lower = tw`text-gray-900 font-medium`;
|
||||
const upper = "text(sm gray-600)";
|
||||
const category = "font-normal";
|
||||
const lower = "text-gray-900 font-medium";
|
||||
|
||||
return (
|
||||
<div class={tw`mt-8 flex flex(col md:row) gap-4`}>
|
||||
<div class="mt-8 flex flex(col md:row) gap-4">
|
||||
{previous && (
|
||||
<a href={previous.href} class={tw`${button} text-left`}>
|
||||
<a href={previous.href} class={`${button} text-left`}>
|
||||
<span class={upper}>{"←"} Previous</span>
|
||||
<span class={lower}>
|
||||
<span class={category}>
|
||||
@@ -250,7 +241,7 @@ function ForwardBackButtons(props: { slug: string }) {
|
||||
</a>
|
||||
)}
|
||||
{next && (
|
||||
<a href={next.href} class={tw`${button} text-right`}>
|
||||
<a href={next.href} class={`${button} text-right`}>
|
||||
<span class={upper}>Next {"→"}</span>
|
||||
<span class={lower}>
|
||||
<span class={category}>
|
||||
|
||||
+34
-47
@@ -3,7 +3,6 @@
|
||||
import { ComponentChildren, Fragment, h } from "preact";
|
||||
import { asset, Head } from "$fresh/runtime.ts";
|
||||
import { Handlers, PageProps } from "$fresh/server.ts";
|
||||
import { tw } from "@twind";
|
||||
import Counter from "../islands/Counter.tsx";
|
||||
import LemonDrop from "../islands/LemonDrop.tsx";
|
||||
import Footer from "../components/Footer.tsx";
|
||||
@@ -43,9 +42,9 @@ export default function MainPage(props: PageProps) {
|
||||
<meta property="og:url" content={props.url.href} />
|
||||
<meta property="og:image" content={ogImageUrl} />
|
||||
</Head>
|
||||
<div class={tw`flex flex-col min-h-screen`}>
|
||||
<div class="flex flex-col min-h-screen">
|
||||
<Hero />
|
||||
<div class={tw`flex-1`}>
|
||||
<div class="flex-1">
|
||||
<Intro />
|
||||
<GettingStarted origin={origin} />
|
||||
<Example />
|
||||
@@ -57,20 +56,17 @@ export default function MainPage(props: PageProps) {
|
||||
}
|
||||
|
||||
function Hero() {
|
||||
const container =
|
||||
tw`w-full flex justify-center items-center flex-col bg-green-300`;
|
||||
const nav = tw`flex justify-end items-center bg-green-300`;
|
||||
const a =
|
||||
tw`border(1 black) inline-flex items-center h-10 px-4 m-4 text-black bg-transparent rounded hover:bg-white`;
|
||||
|
||||
return (
|
||||
<Fragment>
|
||||
<div class={nav}>
|
||||
<a href="/docs" class={a}>
|
||||
<div class="flex justify-end items-center bg-green-300">
|
||||
<a
|
||||
href="/docs"
|
||||
class="border(1 black) inline-flex items-center h-10 px-4 m-4 text-black bg-transparent rounded hover:bg-white"
|
||||
>
|
||||
Documentation
|
||||
</a>
|
||||
</div>
|
||||
<section class={container}>
|
||||
<section class="w-full flex justify-center items-center flex-col bg-green-300">
|
||||
<LemonDrop />
|
||||
</section>
|
||||
</Fragment>
|
||||
@@ -82,9 +78,9 @@ export interface ListItemProps {
|
||||
|
||||
function ListItem(props: ListItemProps) {
|
||||
return (
|
||||
<div class={tw`flex mt-3`}>
|
||||
<div class="flex mt-3">
|
||||
<Leaf />
|
||||
<div class={tw`pl-4 flex-1`}>
|
||||
<div class="pl-4 flex-1">
|
||||
{props.children}
|
||||
</div>
|
||||
</div>
|
||||
@@ -92,28 +88,23 @@ function ListItem(props: ListItemProps) {
|
||||
}
|
||||
|
||||
function Intro() {
|
||||
const title =
|
||||
tw`py-4 text(4xl sm:4xl lg:4xl gray-900 center) sm:tracking-tight font-extrabold`;
|
||||
|
||||
return (
|
||||
<section
|
||||
class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4`}
|
||||
>
|
||||
<section class="max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4">
|
||||
<picture>
|
||||
<img
|
||||
src="/illustration/lemon-squash.svg"
|
||||
class={tw`w-64 mx-auto`}
|
||||
class="w-64 mx-auto"
|
||||
width={800}
|
||||
height={678}
|
||||
alt="deno is drinking fresh lemon squash"
|
||||
/>
|
||||
</picture>
|
||||
|
||||
<h2 class={title}>
|
||||
<h2 class="py-4 text(4xl sm:4xl lg:4xl gray-900 center) sm:tracking-tight font-extrabold">
|
||||
The next-gen web framework.
|
||||
</h2>
|
||||
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
Fresh is a next generation web framework, built for speed, reliability,
|
||||
and simplicity. Some stand out features:
|
||||
</p>
|
||||
@@ -140,7 +131,7 @@ function Intro() {
|
||||
</ListItem>
|
||||
</div>
|
||||
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
Fresh embraces the tried and true design of server side rendering and
|
||||
progressive enhancement on the client side.
|
||||
</p>
|
||||
@@ -150,47 +141,45 @@ function Intro() {
|
||||
|
||||
function GettingStarted(props: { origin: string }) {
|
||||
return (
|
||||
<section
|
||||
class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4`}
|
||||
>
|
||||
<h2 id="getting-started" class={tw`text(xl gray-600) font-bold`}>
|
||||
<a href="#getting-started" class={tw`hover:underline`}>
|
||||
<section class="max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4">
|
||||
<h2 id="getting-started" class="text(xl gray-600) font-bold">
|
||||
<a href="#getting-started" class="hover:underline">
|
||||
Getting started
|
||||
</a>
|
||||
</h2>
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
To get started, make sure you have the{" "}
|
||||
<a href="https://deno.land" class={tw`text-blue-600 hover:underline`}>
|
||||
<a href="https://deno.land" class="text-blue-600 hover:underline">
|
||||
Deno CLI
|
||||
</a>{" "}
|
||||
version 1.23.0 or higher installed.
|
||||
</p>
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
Then you can use the Fresh init script to bootstrap a new project:
|
||||
</p>
|
||||
<pre class={tw`overflow-x-auto py-2 px-4 bg(gray-100)`}>
|
||||
<pre class="overflow-x-auto py-2 px-4 bg(gray-100)">
|
||||
{`deno run -A -r ${props.origin} my-project`}
|
||||
</pre>
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
Enter the newly created project directory and run the following command
|
||||
to start the development server:
|
||||
</p>
|
||||
<pre class={tw`overflow-x-auto py-2 px-4 bg(gray-100)`}>
|
||||
<pre class="overflow-x-auto py-2 px-4 bg(gray-100)">
|
||||
deno task start
|
||||
</pre>
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
You can now open{" "}
|
||||
<a
|
||||
href="http://localhost:8000"
|
||||
class={tw`text-blue-600 hover:underline`}
|
||||
class="text-blue-600 hover:underline"
|
||||
>
|
||||
http://localhost:8000
|
||||
</a>{" "}
|
||||
in your browser to view the page.
|
||||
</p>
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
A more in-depth getting started guide is available in{" "}
|
||||
<a href="/docs" class={tw`text-blue-600 hover:underline`}>the docs</a>.
|
||||
<a href="/docs" class="text-blue-600 hover:underline">the docs</a>.
|
||||
</p>
|
||||
</section>
|
||||
);
|
||||
@@ -203,26 +192,24 @@ const timeFmt = new Intl.DateTimeFormat("en-US", {
|
||||
|
||||
function Example() {
|
||||
return (
|
||||
<section
|
||||
class={tw`max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4`}
|
||||
>
|
||||
<h2 id="example" class={tw`text(xl gray-600) font-bold`}>
|
||||
<a href="#example" class={tw`hover:underline`}>
|
||||
<section class="max-w-screen-sm mx-auto my-16 px(4 sm:6 md:8) space-y-4">
|
||||
<h2 id="example" class="text(xl gray-600) font-bold">
|
||||
<a href="#example" class="hover:underline">
|
||||
Example
|
||||
</a>
|
||||
</h2>
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
This text is being server side rendered on the fly. It was rendered at
|
||||
{" "}
|
||||
{timeFmt.format(new Date())}.
|
||||
</p>
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
The counter below was rendered on the server with a starting value of 3,
|
||||
and was then hydrated on the client to provide interactivity. Try out
|
||||
the buttons!
|
||||
</p>
|
||||
<Counter start={3} />
|
||||
<p class={tw`text-gray-600`}>
|
||||
<p class="text-gray-600">
|
||||
Only the JS required to render that counter is sent to the client.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import * as colors from "twind/colors";
|
||||
|
||||
/** @type {import("$fresh/plugins/twind.ts").Options} */
|
||||
export default {
|
||||
theme: {
|
||||
colors: {
|
||||
blue: colors.blue,
|
||||
black: colors.black,
|
||||
gray: colors.gray,
|
||||
green: colors.green,
|
||||
white: colors.white,
|
||||
yellow: colors.yellow,
|
||||
transparent: "transparent",
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,21 +0,0 @@
|
||||
export * from "twind";
|
||||
|
||||
import { IS_BROWSER } from "$fresh/runtime.ts";
|
||||
import * as colors from "twind/colors";
|
||||
import { setup } from "twind";
|
||||
|
||||
export const theme = {
|
||||
colors: {
|
||||
blue: colors.blue,
|
||||
black: colors.black,
|
||||
gray: colors.gray,
|
||||
green: colors.green,
|
||||
white: colors.white,
|
||||
yellow: colors.yellow,
|
||||
transparent: "transparent",
|
||||
},
|
||||
};
|
||||
|
||||
if (IS_BROWSER) {
|
||||
setup({ theme: { colors } });
|
||||
}
|
||||
Reference in New Issue
Block a user