diff --git a/.vscode/import_map.json b/.vscode/import_map.json index f6797c8a..c6eaf205 100644 --- a/.vscode/import_map.json +++ b/.vscode/import_map.json @@ -2,8 +2,10 @@ ".": "THIS FILE EXISTS ONLY FOR VSCODE! IT IS NOT USED AT RUNTIME.", "imports": { "$fresh/": "../", - "$twind": "https://esm.sh/twind@0.16.16", - "$twind/": "https://esm.sh/twind@0.16.16/", + + "@twind": "../www/utils/twind.ts", + "twind": "https://esm.sh/twind@0.16.16", + "twind/": "https://esm.sh/twind@0.16.16/", "preact": "https://esm.sh/preact@10.8.1", "preact/": "https://esm.sh/preact@10.8.1/", diff --git a/init.ts b/init.ts index ec807c59..9fccd891 100644 --- a/init.ts +++ b/init.ts @@ -91,16 +91,16 @@ const importMap = { } as Record, }; if (useTwind) { - importMap.imports["$twind"] = "https://esm.sh/twind@0.16.17"; - importMap.imports["$twind/"] = "https://esm.sh/twind@0.16.17/"; - importMap.imports["twind"] = "./utils/twind.ts"; + 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/"; } const IMPORT_MAP_JSON = JSON.stringify(importMap, null, 2) + "\n"; await Deno.writeTextFile(join(directory, "import_map.json"), IMPORT_MAP_JSON); let ROUTES_INDEX_TSX = `/** @jsx h */ import { h } from "preact";\n`; -if (useTwind) ROUTES_INDEX_TSX += `import { tw } from "twind";\n`; +if (useTwind) ROUTES_INDEX_TSX += `import { tw } from "@twind";\n`; ROUTES_INDEX_TSX += `import Counter from "../islands/Counter.tsx"; export default function Home() { @@ -129,7 +129,7 @@ let ISLANDS_COUNTER_TSX = `/** @jsx h */ import { h } from "preact"; import { useState } from "preact/hooks"; import { IS_BROWSER } from "$fresh/runtime.ts"; -${useTwind ? 'import { tw } from "twind";\n' : ""} +${useTwind ? 'import { tw } from "@twind";\n' : ""} interface CounterProps { start: number; } @@ -222,8 +222,8 @@ await Deno.writeTextFile( ); const UTILS_TWIND_TS = `import { IS_BROWSER } from "$fresh/runtime.ts"; -import { Configuration, setup } from "$twind"; -export * from "$twind"; +import { Configuration, setup } from "twind"; +export * from "twind"; export const config: Configuration = { darkMode: "class", mode: "silent", @@ -275,8 +275,8 @@ import manifest from "./fresh.gen.ts"; if (useTwind) { MAIN_TS += ` -import { virtualSheet } from "$twind/sheets"; -import { config, setup } from "twind"; +import { config, setup } from "@twind"; +import { virtualSheet } from "twind/sheets"; const sheet = virtualSheet(); sheet.reset(); diff --git a/www/components/Button.tsx b/www/components/Button.tsx index 7a04f1ce..53be18c9 100644 --- a/www/components/Button.tsx +++ b/www/components/Button.tsx @@ -1,6 +1,6 @@ /** @jsx h */ import { h } from "preact"; -import { tw } from "../utils/twind.ts"; +import { tw } from "@twind"; export function RoundedButton(props: h.JSX.HTMLAttributes) { return ( diff --git a/www/components/DocsSidebar.tsx b/www/components/DocsSidebar.tsx index 6f1c042c..27e4658a 100644 --- a/www/components/DocsSidebar.tsx +++ b/www/components/DocsSidebar.tsx @@ -1,6 +1,6 @@ /** @jsx h */ import { h } from "preact"; -import { apply, tw } from "../utils/twind.ts"; +import { apply, tw } from "@twind"; import { CATEGORIES, diff --git a/www/components/Footer.tsx b/www/components/Footer.tsx index b968e41f..b1252399 100644 --- a/www/components/Footer.tsx +++ b/www/components/Footer.tsx @@ -1,6 +1,6 @@ /** @jsx h */ import { h } from "preact"; -import { tw } from "../utils/twind.ts"; +import { tw } from "@twind"; const LINKS = [ { diff --git a/www/components/Icons.tsx b/www/components/Icons.tsx index 7fb10822..4a94ad8e 100644 --- a/www/components/Icons.tsx +++ b/www/components/Icons.tsx @@ -1,6 +1,6 @@ /** @jsx h */ import { h } from "preact"; -import { tw } from "../utils/twind.ts"; +import { tw } from "@twind"; export function IconMinus() { return ( diff --git a/www/components/NavigationBar.tsx b/www/components/NavigationBar.tsx index 817a582b..4a06a2bb 100644 --- a/www/components/NavigationBar.tsx +++ b/www/components/NavigationBar.tsx @@ -1,6 +1,6 @@ /** @jsx h */ import { h } from "preact"; -import { tw } from "../utils/twind.ts"; +import { tw } from "@twind"; export default function NavigationBar(props: { active: string }) { const items = [ diff --git a/www/components/WarningBanner.tsx b/www/components/WarningBanner.tsx index 8e4da3c1..d0df8e0b 100644 --- a/www/components/WarningBanner.tsx +++ b/www/components/WarningBanner.tsx @@ -1,6 +1,6 @@ /** @jsx h */ import { h } from "preact"; -import { tw } from "../utils/twind.ts"; +import { tw } from "@twind"; export default function WarningBanner() { const warning = tw`bg-yellow-100 border(1 yellow-200) p-4 mb-4`; diff --git a/www/import_map.json b/www/import_map.json index c3227f9d..55f97ff5 100644 --- a/www/import_map.json +++ b/www/import_map.json @@ -1,11 +1,15 @@ { "imports": { "$fresh/": "../", - "$twind": "https://esm.sh/twind@0.16.16", - "$twind/": "https://esm.sh/twind@0.16.16/", + + "@twind": "./utils/twind.ts", + "twind": "https://esm.sh/twind@0.16.16", + "twind/": "https://esm.sh/twind@0.16.16/", + "preact": "https://esm.sh/preact@10.8.1", "preact/": "https://esm.sh/preact@10.8.1/", "preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.0?deps=preact@10.8.1", + "$semver/": "https://deno.land/x/semver@v1.4.0/" } } diff --git a/www/islands/Counter.tsx b/www/islands/Counter.tsx index ab3688cc..0edf21c5 100644 --- a/www/islands/Counter.tsx +++ b/www/islands/Counter.tsx @@ -2,7 +2,7 @@ import { h } from "preact"; import { useState } from "preact/hooks"; import { IS_BROWSER } from "$fresh/runtime.ts"; -import { tw } from "../utils/twind.ts"; +import { tw } from "@twind"; import { RoundedButton } from "../components/Button.tsx"; import { IconMinus, IconPlus } from "../components/Icons.tsx"; diff --git a/www/islands/LemonDrop.tsx b/www/islands/LemonDrop.tsx index e5731f15..1e9b93bc 100644 --- a/www/islands/LemonDrop.tsx +++ b/www/islands/LemonDrop.tsx @@ -2,7 +2,7 @@ /** @jsxFrag Fragment */ import { Fragment, h } from "preact"; import { useEffect, useRef, useState } from "preact/hooks"; -import { tw } from "../utils/twind.ts"; +import { tw } from "@twind"; import { Spring, WaveTank } from "../components/WaveTank.ts"; function easeInCirc(x: number) { diff --git a/www/main.ts b/www/main.ts index cd4e98d9..f7715e16 100644 --- a/www/main.ts +++ b/www/main.ts @@ -5,8 +5,8 @@ /// import { start } from "$fresh/server.ts"; -import { virtualSheet } from "$twind/sheets"; -import { setup, theme } from "./utils/twind.ts"; +import { virtualSheet } from "twind/sheets"; +import { setup, theme } from "@twind"; import routes from "./fresh.gen.ts"; diff --git a/www/routes/docs/[...slug].tsx b/www/routes/docs/[...slug].tsx index e9fb8e9c..5d718276 100644 --- a/www/routes/docs/[...slug].tsx +++ b/www/routes/docs/[...slug].tsx @@ -3,7 +3,7 @@ import { Fragment, h } from "preact"; import { Head } from "$fresh/runtime.ts"; import { Handlers, PageProps } from "$fresh/server.ts"; -import { apply, tw } from "../../utils/twind.ts"; +import { apply, tw } from "@twind"; import { frontMatter, gfm } from "../../utils/markdown.ts"; import DocsSidebar from "../../components/DocsSidebar.tsx"; diff --git a/www/routes/index.tsx b/www/routes/index.tsx index 9fc545a2..20690c78 100644 --- a/www/routes/index.tsx +++ b/www/routes/index.tsx @@ -3,7 +3,7 @@ import { ComponentChildren, Fragment, h } from "preact"; import { asset, Head } from "$fresh/runtime.ts"; import { Handlers, PageProps } from "$fresh/server.ts"; -import { tw } from "../utils/twind.ts"; +import { tw } from "@twind"; import Counter from "../islands/Counter.tsx"; import LemonDrop from "../islands/LemonDrop.tsx"; import Footer from "../components/Footer.tsx"; diff --git a/www/utils/twind.ts b/www/utils/twind.ts index 1e40b3a4..73652504 100644 --- a/www/utils/twind.ts +++ b/www/utils/twind.ts @@ -1,7 +1,9 @@ +export * from "twind"; + import { IS_BROWSER } from "$fresh/runtime.ts"; -import { apply, setup, tw } from "$twind"; -import * as colors from "$twind/colors"; -export { apply, setup, tw }; +import * as colors from "twind/colors"; +import { setup } from "twind"; + export const theme = { colors: { blue: colors.blue, @@ -13,6 +15,7 @@ export const theme = { transparent: "transparent", }, }; + if (IS_BROWSER) { setup({ theme: { colors } }); }