diff --git a/deno.jsonc b/deno.jsonc index 54a8134d..cf82765a 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -2,7 +2,8 @@ "tasks": { "test": "deno test -A && deno check --config=www/deno.json www/main.ts www/dev.ts && deno check init.ts", "fixture": "deno run -A --watch=static/,routes/ tests/fixture/dev.ts", - "www": "deno run -A --watch=static/,routes/ www/dev.ts" + "www": "deno run -A --watch=static/,routes/ www/dev.ts", + "screenshot": "deno run -A www/utils/screenshot.ts" }, "importMap": "./tests/fixture/import_map.json" } diff --git a/www/components/FeatureIcons.tsx b/www/components/FeatureIcons.tsx new file mode 100644 index 00000000..976e2db7 --- /dev/null +++ b/www/components/FeatureIcons.tsx @@ -0,0 +1,253 @@ +/** @jsx h */ +import { h } from "preact"; + +export function NoBuild() { + return ( + + + + + + ); +} + +export function TypeScript() { + return ( + + + + + + + + + + + + + ); +} + +export function Island() { + return ( + + + + + + + + ); +} + +// from https://heroicons.com/ +export function Globe() { + return ( + + + + + ); +} + +export function LightWeight() { + return ( + + + + + + + + + + ); +} + +export function Gabage() { + return ( + + + + + + + + ); +} diff --git a/www/components/Icons.tsx b/www/components/Icons.tsx index 14a5f27c..a5fc9f87 100644 --- a/www/components/Icons.tsx +++ b/www/components/Icons.tsx @@ -57,3 +57,75 @@ export function Leaf() { ); } + +export function Copy() { + return ( + + + + ); +} + +// from https://heroicons.com/ +export function Check() { + return ( + + + + ); +} + +// from https://heroicons.com/ +export function Info() { + return ( + + + + ); +} + +export function GitHub(props: { class?: string }) { + return ( + + + + ); +} diff --git a/www/data/showcase.json b/www/data/showcase.json new file mode 100644 index 00000000..f671c4e7 --- /dev/null +++ b/www/data/showcase.json @@ -0,0 +1,20 @@ +[ + { + "title": "Deno Merch", + "link": "https://merch.deno.com/", + "github": "denoland/merch", + "image": "merch" + }, + { + "title": "Deno Chat", + "link": "https://showcase-chat.deno.dev/", + "github": "denoland/showcase_chat", + "image": "chat" + }, + { + "title": "Fresh Website", + "link": "https://fresh.deno.dev/", + "github": "denoland/fresh/tree/main/www", + "image": "fresh" + } +] diff --git a/www/fresh.gen.ts b/www/fresh.gen.ts index dace9fbb..87a7d2d0 100644 --- a/www/fresh.gen.ts +++ b/www/fresh.gen.ts @@ -6,8 +6,9 @@ import * as $0 from "./routes/docs/[...slug].tsx"; import * as $1 from "./routes/gfm.css.ts"; import * as $2 from "./routes/index.tsx"; import * as $3 from "./routes/raw.ts"; -import * as $$0 from "./islands/Counter.tsx"; -import * as $$1 from "./islands/LemonDrop.tsx"; +import * as $$0 from "./islands/CopyArea.tsx"; +import * as $$1 from "./islands/Counter.tsx"; +import * as $$2 from "./islands/LemonDrop.tsx"; const manifest = { routes: { @@ -17,8 +18,9 @@ const manifest = { "./routes/raw.ts": $3, }, islands: { - "./islands/Counter.tsx": $$0, - "./islands/LemonDrop.tsx": $$1, + "./islands/CopyArea.tsx": $$0, + "./islands/Counter.tsx": $$1, + "./islands/LemonDrop.tsx": $$2, }, baseUrl: import.meta.url, }; diff --git a/www/islands/CopyArea.tsx b/www/islands/CopyArea.tsx new file mode 100644 index 00000000..cd7c0cb8 --- /dev/null +++ b/www/islands/CopyArea.tsx @@ -0,0 +1,60 @@ +/** @jsx h */ +import { ComponentChildren, h } from "preact"; +import { useEffect, useState } from "preact/hooks"; +import { IS_BROWSER } from "$fresh/runtime.ts"; +import * as Icons from "../components/Icons.tsx"; + +export default function CopyArea(props: { children: ComponentChildren }) { + const [copied, setCopied] = useState(false); + + async function handleClick() { + if (props.children === undefined || props.children === null) { + return; + } + try { + await navigator.clipboard.writeText(props.children.toString()); + setCopied(true); + } catch (error) { + setCopied(false); + console.error((error && error.message) || "Copy failed"); + } + } + + useEffect(() => { + if (!copied) { + return; + } + const timer = setTimeout(() => { + setCopied(false); + }, 2000); + return () => clearTimeout(timer); + }, [copied]); + + return ( +
+
+        {props.children}
+      
+ +
+
+ Copied! +
+ +
+
+ ); +} diff --git a/www/routes/index.tsx b/www/routes/index.tsx index b78d5d9a..6ec453b6 100644 --- a/www/routes/index.tsx +++ b/www/routes/index.tsx @@ -1,13 +1,23 @@ /** @jsx h */ /** @jsxFrag Fragment */ -import { ComponentChildren, Fragment, h } from "preact"; +import { Fragment, h } from "preact"; import { asset, Head } from "$fresh/runtime.ts"; import { Handlers, PageProps } from "$fresh/server.ts"; import Counter from "../islands/Counter.tsx"; import LemonDrop from "../islands/LemonDrop.tsx"; import Footer from "../components/Footer.tsx"; -import { Leaf } from "../components/Icons.tsx"; import VERSIONS from "../../versions.json" assert { type: "json" }; +import * as FeatureIcons from "../components/FeatureIcons.tsx"; +import CopyArea from "../islands/CopyArea.tsx"; +import * as Icons from "../components/Icons.tsx"; +import projects from "../data/showcase.json" assert { type: "json" }; + +interface Project { + image: string; + title: string; + link: string; + github?: string; +} export const handler: Handlers = { GET(req, ctx) { @@ -48,6 +58,7 @@ export default function MainPage(props: PageProps) { +