www: refresh home page (#2418)

Overhauls the Fresh homepage with a new design, new demos, and new
sections highlighting Fresh's capabilities.

---------

Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
Josh Collinsworth
2024-05-17 16:08:55 +02:00
committed by GitHub
co-authored by Marvin Hagemeister
parent 3b68a5d455
commit e8d1a68b58
55 changed files with 1206 additions and 346 deletions
+7
View File
@@ -7,6 +7,13 @@ export default function App({ Component }: PageProps) {
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>My Fresh app</title>
<link
rel="preload"
href="/fonts/FixelVariable.woff2"
as="font"
type="font/woff2"
crossorigin="true"
/>
<link rel="stylesheet" href="/styles.css" />
</head>
<body>
-92
View File
@@ -1,92 +0,0 @@
import PageFooter from "../components/Footer.tsx";
import Header from "../components/Header.tsx";
import ComponentGallery from "../islands/ComponentGallery.tsx";
import { asset, Head } from "$fresh/runtime.ts";
import { Handlers, PageProps } from "$fresh/server.ts";
function getSource(path: string) {
return Deno.readTextFile(new URL(path, import.meta.url));
}
export const handler: Handlers<HomeProps> = {
async GET(req, ctx) {
const props: HomeProps = {
sources: {
"Button": await getSource("../components/gallery/Button.tsx"),
"LinkButton": await getSource("../components/gallery/LinkButton.tsx"),
"ColoredButton": await getSource(
"../components/gallery/ColoredButton.tsx",
),
"Input": await getSource("../components/gallery/Input.tsx"),
"Header": await getSource("../components/gallery/Header.tsx"),
"Footer": await getSource("../components/gallery/Footer.tsx"),
"Hero": await getSource("../components/gallery/Hero.tsx"),
"Features": await getSource("../components/gallery/Features.tsx"),
"Carousel": await getSource("../components/gallery/Carousel.tsx"),
},
};
return ctx.render(props);
},
};
const TITLE = "Components | Fresh";
const DESCRIPTION = "A collection of components made for Fresh.";
interface HomeProps {
sources: Record<string, string>;
}
export default function Home(props: PageProps<HomeProps>) {
const ogImageUrl = new URL(asset("/home-og.png"), props.url).href;
return (
<div class="bg-white h-full">
<Head>
<title>{TITLE}</title>
<link
rel="stylesheet"
href="https://esm.sh/prismjs@1.29.0/themes/prism-dark.min.css"
/>
<meta name="description" content={DESCRIPTION} />
<meta property="og:title" content={TITLE} />
<meta property="og:description" content={DESCRIPTION} />
<meta property="og:type" content="website" />
<meta property="og:url" content={props.url.href} />
<meta property="og:image" content={ogImageUrl} />
<meta name="view-transition" content="same-origin" />
</Head>
<Header title="components" active="/components" />
<section class="my-16 px-4 sm:px-6 md:px-8 mx-auto max-w-screen-lg space-y-4">
<h2 class="text-3xl text-gray-600 font-bold">
Fresh Components
</h2>
<p class="text-gray-600">
A collection of components made for Fresh.
</p>
</section>
<div class="p-4 mx-auto max-w-screen-lg space-y-24 mb-16">
<ComponentGallery sources={props.data.sources} />
<a class="block" href="https://tabler-icons-tsx.deno.dev/">
<div
style="background-image: url(/gallery/banner-tabler-icons.png)"
class="h-48 bg-cover bg-no-repeat bg-white hover:opacity-50 hover:underline rounded"
>
<h2 class="text-4xl font-bold p-4">Icons</h2>
</div>
</a>
<a class="block" href="https://github.com/denoland/fresh_charts">
<div
style="background-image: url(/gallery/banner-chart.png)"
class="h-48 bg-cover bg-no-repeat bg-white hover:opacity-50 hover:underline rounded"
>
<h2 class="text-4xl font-bold p-4">Charts</h2>
</div>
</a>
</div>
<PageFooter />
</div>
);
}
+26 -192
View File
@@ -1,15 +1,17 @@
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 VERSIONS from "../../versions.json" with { 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 "../components/Projects.tsx";
import projects from "../data/showcase.json" with { type: "json" };
import Header from "../components/Header.tsx";
import VERSIONS from "$fresh/versions.json" with { type: "json" };
import Footer from "$fresh/www/components/Footer.tsx";
import Header from "$fresh/www/components/Header.tsx";
import { CTA } from "$fresh/www/components/homepage/CTA.tsx";
import { Hero } from "$fresh/www/components/homepage/Hero.tsx";
import { IslandsSection } from "$fresh/www/components/homepage/IslandsSection.tsx";
import { PartialsSection } from "$fresh/www/components/homepage/PartialsSection.tsx";
import { RenderingSection } from "$fresh/www/components/homepage/RenderingSection.tsx";
import { FormsSection } from "../components/homepage/FormsSection.tsx";
import { Simple } from "$fresh/www/components/homepage/Simple.tsx";
import { SocialProof } from "$fresh/www/components/homepage/SocialProof.tsx";
import { DenoSection } from "$fresh/www/components/homepage/DenoSection.tsx";
function isOpenGraphUA(header: string | null): boolean {
if (!header) {
@@ -52,22 +54,26 @@ export default function MainPage(props: PageProps) {
<meta property="og:url" content={props.url.href} />
<meta property="og:image" content={ogImageUrl} />
<meta name="view-transition" content="same-origin" />
<link rel="stylesheet" href="/prism.css" />
</Head>
<div class="flex flex-col min-h-screen">
<div class="bg-green-300 flex flex-col">
<div class="bg-transparent flex flex-col relative z-10">
<HelloBar />
<Header title="" active="/" />
<Hero />
</div>
<div class="flex-1">
<Intro origin={origin} />
<Example />
<Showcase />
<StartJourney />
<div class="flex flex-col overflow-hidden -mt-20 relative">
<Hero origin={origin} />
<Simple />
<RenderingSection />
<IslandsSection />
<FormsSection />
<PartialsSection />
<SocialProof />
<DenoSection />
<CTA />
</div>
<Footer />
<Footer class="!mt-0" />
</div>
</>
);
@@ -76,7 +82,7 @@ export default function MainPage(props: PageProps) {
function HelloBar() {
return (
<a
class="bg-green-400 text-black border-b border-green-500 p-3 text-center group"
class="bg-gradient-to-r from-blue-200 to-yellow-200 via-green-300 text-black border-b border-green-400 p-4 text-center group"
href="https://deno.com/blog/fresh-1.6"
>
<b>Fresh v1.6</b> has been released with <b>Tailwind CSS</b>,{" "}
@@ -85,175 +91,3 @@ function HelloBar() {
</a>
);
}
function Hero() {
return (
<div
class="w-full flex justify-center items-center flex-col bg-green-300"
aria-hidden="true"
>
<LemonDrop />
</div>
);
}
function Features() {
const item = "flex items-center gap-5";
const desc = "flex-1";
return (
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6 md:gap-14">
<div class={item}>
<FeatureIcons.Globe />
<div class={desc}>
<b>Just-in-time rendering</b> on the edge.
</div>
</div>
<div class={item}>
<FeatureIcons.Island />
<div class={desc}>
<b>Island based client hydration</b> for maximum interactivity.
</div>
</div>
<div class={item}>
<FeatureIcons.LightWeight />
<div class={desc}>
<b>Zero runtime overhead</b>: no JS is shipped to the client by
default.
</div>
</div>
<div class={item}>
<FeatureIcons.Garbage />
<div class={desc}>
<b>No configuration</b> necessary.
</div>
</div>
<div class={item}>
<FeatureIcons.TypeScript />
<div class={desc}>
<b>TypeScript support</b> out of the box.
</div>
</div>
</div>
);
}
function Intro(props: { origin: string }) {
return (
<section class="max-w-screen-xl mx-auto my-8 sm:my-16 px-4 sm:px-6 md:px-8 space-y-8 sm:space-y-16 lg:mb-32">
<div class="max-w-screen-xl mx-auto sm:my-8 md:my-16 sm:space-y-12 w-full">
<div class="md:flex items-center">
<div class="flex-1 text-center md:text-left">
<h2 class="py-2 text-5xl sm:text-5xl lg:text-6xl text-gray-900 sm:tracking-tight sm:leading-[1.1]! font-extrabold lg:max-w-lg mx-auto sm:mx-0">
The <span class="text-green-600">next-gen</span> web framework.
</h2>
<p class="mt-2 text-gray-600 text-xl">
Built for speed, reliability, and simplicity.
</p>
<div class="mt-8 flex flex-col justify-center md:justify-start sm:flex-row gap-4">
<div>
<a
href="/docs/getting-started"
class="inline-flex w-auto shrink-0 px-3 py-2 bg-white rounded border-gray-500 border-2 hover:bg-gray-200 active:bg-gray-300 disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap"
>
Get started
</a>
</div>
<div class="flex justify-center">
<CopyArea code={`deno run -A -r ${props.origin}`} />
</div>
</div>
</div>
<picture class="block mt-8 md:mt-0 mx-auto w-60 md:w-96 md:mr-16 xl:mr-32">
<img
src="/illustration/lemon-squash.svg"
width={800}
height={678}
alt="Deno is drinking Fresh lemon squash"
/>
</picture>
</div>
</div>
<p class="text-gray-600 text-xl">
Fresh embraces the tried and true design of server side rendering and
progressive enhancement on the client side.
</p>
<Features />
</section>
);
}
function Example() {
return (
<section class="max-w-screen-xl mx-auto my-8 sm:my-16 md:my-24 px-4 sm:px-6 md:px-8 space-y-16">
<div class="flex gap-4 md:gap-16 flex-col md:flex-row justify-between items-center">
<div class="md:basis-1/2">
<h2 id="example" class="text-4xl text-gray-600 font-bold mb-4">
<a href="#example" class="hover:underline">
Interactive islands
</a>
</h2>
<p class="text-gray-600 mb-4">
Fresh optimizes the page by only shipping JavaScript for areas that
need it. The rest is completely static HTML rendered by the server.
This means the browser needs to load less code and can display pages
more quickly.
</p>
</div>
<div class="md:basis-1/2">
<Counter start={3} />
</div>
</div>
</section>
);
}
function Showcase() {
return (
<section class="max-w-screen-xl mx-auto px-4 sm:px-6 md:px-8 space-y-4">
<h2 id="showcase" class="text-4xl text-gray-600 font-bold mb-4">
<a href="#showcase" class="hover:underline">
Showcase
</a>
</h2>
<p class="text-gray-600">
Below is a selection of projects that have been built with Fresh.
</p>
<Projects items={projects.slice(0, 3)} class="gap-8" />
<div class="flex gap-2 items-center justify-center sm:justify-end text-blue-600">
<Icons.ArrowRight />
<a href="./showcase" class="hover:underline focus:underline">
View more
</a>
</div>
</section>
);
}
function StartJourney() {
return (
<section class="max-w-screen-xl mx-auto py-16 px-4 sm:px-6 md:px-8 space-y-4 md:mb-16">
<h2 class="text-4xl text-gray-600 md:text-5xl font mb-4 mt-0">
Start your Fresh journey
</h2>
<div class="flex flex-col md:flex-row justify-start items-center gap-4">
<p class="text-xl text-gray-600">
Jump right in and build your website with Fresh. Learn everything you
need to know in seconds.
</p>
<a
href="/docs/getting-started"
class="inline-block px-3 py-2 bg-white rounded border-gray-500 border-2 hover:bg-gray-200 active:bg-gray-300 disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap"
>
Get started
</a>
</div>
</section>
);
}
+22
View File
@@ -0,0 +1,22 @@
import { PageProps } from "$fresh/server.ts";
import { Head } from "$fresh/runtime.ts";
import Header from "$fresh/www/components/Header.tsx";
export default function Layout({ Component, state }: PageProps) {
return (
<>
<Head>
<meta name="robots" content="noindex" />
</Head>
<Header active="" title="" />
<div class="w-full max-w-screen-xl px-4">
<Component />
<p class="mt-16">
This route is used only for demo purposes;{" "}
<a href="/" class="underline">see the home page</a>.
</p>
</div>
</>
);
}
+16
View File
@@ -0,0 +1,16 @@
import { Partial } from "$fresh/runtime.ts";
export const LemonHoneyTea = () => (
<Partial name="recipe">
<h2 class="mb-2 font-extrabold">Lemon-honey tea</h2>
<ul>
<li>1 cup boiling water</li>
<li>¼ tsp black tea</li>
<li>2 tsp honey</li>
<li>1 tsp lemon juice</li>
<li>Lemon peel</li>
</ul>
</Partial>
);
export default LemonHoneyTea;
+16
View File
@@ -0,0 +1,16 @@
import { Head, Partial } from "$fresh/runtime.ts";
export const Lemonade = () => (
<Partial name="recipe">
<h2 class="mb-2 font-extrabold">Lemonade</h2>
<ul>
<li>1 ¾ cups white sugar</li>
<li>1 cup water</li>
<li>9 lemons</li>
<li>7 cups ice water</li>
<li>Ice</li>
</ul>
</Partial>
);
export default Lemonade;
+17
View File
@@ -0,0 +1,17 @@
import { Partial } from "$fresh/runtime.ts";
export const LemonDrop = () => (
<Partial name="recipe">
<h2 class="mb-2 font-extrabold">Lemondrop Martini</h2>
<ul>
<li>2 oz vodka</li>
<li>3/4 oz triple sec</li>
<li>
1 oz fresh lemon juice
</li>
<li>3/4 oz simple syrup</li>
</ul>
</Partial>
);
export default LemonDrop;