feat: twind plugin (#513)

This adds a first-party twind plugin to use twind for styling.
This commit is contained in:
Luca Casonato
2022-08-09 21:41:11 +02:00
committed by GitHub
parent fd4e2bbe17
commit 660e0f5fef
20 changed files with 296 additions and 238 deletions
+4 -17
View File
@@ -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)] });