www: add hero animation & new logo (#153)

This commit is contained in:
hashrock
2022-04-23 15:09:35 +02:00
committed by GitHub
parent 4e1d4231f7
commit f1a39e2e7a
6 changed files with 270 additions and 29 deletions
+17
View File
@@ -41,3 +41,20 @@ export function IconPlus() {
</svg>
);
}
export function Leaf() {
return (
<svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill="#fff" d="M0 0h24v24H0z" />
<path
d="M2 10.276c.862-2.673 2.155-5.259 5.603-5.69"
stroke="#6BA377"
stroke-width="1.724"
/>
<path
d="M19.091 5.146c-4.44-5.697-10.945-2.374-13.643 0 2.081-1.662 3.006 4.747 4.163 9.733.925 3.987 8.71 6.409 12.486 7.121.848-3.244 1.434-11.157-3.006-16.854Z"
fill="#25D24B"
/>
</svg>
);
}
+51
View File
@@ -0,0 +1,51 @@
export interface Spring {
p: number;
v: number;
}
export class WaveTank {
springs = [] as Spring[];
waveLength = 100;
k = 0.02;
damping = 0.02;
spread = 0.02;
constructor() {
for (let i = 0; i < this.waveLength; i++) {
this.springs[i] = {
p: 0,
v: 0,
};
}
}
update(springs: Spring[]) {
for (const i of springs) {
const a = -this.k * i.p - this.damping * i.v;
i.p += i.v;
i.v += a;
}
const leftDeltas = [];
const rightDeltas = [];
for (let t = 0; t < 8; t++) {
for (let i = 0; i < springs.length; i++) {
const prev = springs[(i - 1 + springs.length) % springs.length];
const next = springs[(i + 1) % springs.length];
leftDeltas[i] = this.spread * (springs[i].p - prev.p);
rightDeltas[i] = this.spread * (springs[i].p - next.p);
}
for (let i = 0; i < springs.length; i++) {
const prev = springs[(i - 1 + springs.length) % springs.length];
const next = springs[(i + 1) % springs.length];
prev.v += leftDeltas[i];
next.v += rightDeltas[i];
prev.p += leftDeltas[i];
next.p += rightDeltas[i];
}
}
}
}
+2
View File
@@ -7,6 +7,7 @@ import * as $1 from "./routes/docs/[...slug].tsx";
import * as $2 from "./routes/gfm.css.ts";
import * as $3 from "./routes/index.tsx";
import * as $$0 from "./islands/Counter.tsx";
import * as $$1 from "./islands/LemonDrop.tsx";
const manifest = {
routes: {
@@ -17,6 +18,7 @@ const manifest = {
},
islands: {
"./islands/Counter.tsx": $$0,
"./islands/LemonDrop.tsx": $$1,
},
baseUrl: import.meta.url,
};
+138
View File
@@ -0,0 +1,138 @@
/** @jsx h */
import {
Fragment,
h,
tw,
useEffect,
useRef,
useState,
} from "../client_deps.ts";
import { Spring, WaveTank } from "../components/WaveTank.ts";
function easeInCirc(x: number) {
return 1 - Math.sqrt(1 - Math.pow(x, 2));
}
const waveTank = new WaveTank();
function LemonDrop() {
const [counter, setCounter] = useState(0);
const [dropy, setDropy] = useState(60);
const [width, setWidth] = useState(window.innerWidth);
const widthRef = useRef(width);
const [springs, setSprings] = useState<Spring[]>([]);
const requestIdRef = useRef<number>();
const grid = width / waveTank.waveLength;
const points = [
[0, 100],
[0, 0],
...springs.map((x, i) => [i * grid, x.p]),
[width, 0],
[width, 100],
];
const springsPath = `${points.map((x) => x.join(",")).join(" ")}`;
const juice = `M18 ${63 + counter} C15 ${63 + counter} 16 ${
63 + counter
} 12 61L9 56C2 33 62 -3 80 12C103 27 44 56 29 58C27 58 25 59 24 61C20 ${
63 + counter
} 21 ${63 + counter} 18 ${63 + counter}Z`;
function updateJuice(timestamp: number) {
const amp = 40;
const x = timestamp / 2000;
const saw = x - Math.floor(x);
if (saw < 0.6) {
setCounter(easeInCirc(saw) * amp);
setDropy(-100);
} else {
setCounter(easeInCirc(1 - saw) * amp * 0.1);
setDropy(70 + Math.pow(saw - 0.6, 2) * 10000);
}
}
function update(timestamp: number) {
updateJuice(timestamp);
waveTank.update(waveTank.springs);
setSprings([...waveTank.springs]);
const offset = 500;
const saw = (timestamp + offset) / 2000 -
Math.floor((timestamp + offset) / 2000);
if (saw < 0.01) {
drop();
}
requestIdRef.current = globalThis.requestAnimationFrame(update);
}
function resize() {
setWidth(document.body.clientWidth);
}
function drop() {
const dropPosition = Math.round(
((widthRef.current / 2 - 30) / widthRef.current) * 100,
);
waveTank.springs[dropPosition].p = -60;
}
useEffect(() => {
widthRef.current = width;
}, [width]);
useEffect(() => {
requestIdRef.current = requestAnimationFrame(update);
globalThis.addEventListener("resize", resize);
resize();
return () => {
globalThis.removeEventListener("resize", resize);
if (requestIdRef.current !== undefined) {
cancelAnimationFrame(requestIdRef.current);
}
};
}, []);
return (
<Fragment>
<svg
width="100"
height="300"
viewBox="0 0 100 300"
fill="none"
xmlns="http://www.w3.org/2000/svg"
class={tw`mt-36`}
role="img"
aria-label="Fresh logo"
>
<circle cx="18" cy={dropy} r="4" fill="white"></circle>
<path
d="M11.9 96.3v24H7v-24h4.9Zm7.5 10.2v4h-8.8v-4h8.8Zm1-10.2v4h-9.8v-4h9.8ZM23.2 96.3H31c1.6 0 3 .3 4.1.9 1.1.5 2 1.3 2.6 2.4a8 8 0 0 1 1 4c0 1.3-.2 2.4-.6 3.3-.3 1-.8 1.7-1.5 2.3-.7.6-1.4 1-2.3 1.5l-1.5.8h-6.3v-4h4.3a3 3 0 0 0 1.7-.4c.4-.3.7-.7 1-1.2a5 5 0 0 0 .3-2c0-.7-.1-1.3-.3-1.9-.2-.5-.5-1-1-1.2-.3-.3-.9-.5-1.5-.5h-3v20h-4.8v-24Zm11 24-4.4-10.7h5l4.6 10.5v.2h-5.2ZM55.9 116.3v4H45.4v-4h10.5Zm-9-20v24H42v-24H47Zm7.6 9.8v3.8h-9.1v-3.8h9Zm1.4-9.8v4H45.4v-4h10.5ZM69 114c0-.4 0-.8-.2-1.1 0-.4-.2-.7-.5-1l-1-1-1.9-.8-2.6-1.2-2.2-1.5a6.5 6.5 0 0 1-1.7-2 6 6 0 0 1-.5-2.7c0-1 .1-2 .5-2.7a6 6 0 0 1 1.6-2.2c.7-.5 1.5-1 2.4-1.3a9.5 9.5 0 0 1 7.1.5c1.2.6 2 1.5 2.7 2.6.6 1 1 2.4 1 3.8h-5a5 5 0 0 0-.2-1.8c-.2-.5-.5-1-1-1.2-.4-.3-1-.5-1.6-.5-.6 0-1.1.2-1.5.4-.4.2-.7.6-1 1l-.2 1.4c0 .4.1.8.3 1.1l.8.8a21.3 21.3 0 0 0 2.8 1.4l2.9 1.4a9 9 0 0 1 2 1.8c.7.6 1 1.3 1.4 2a7.9 7.9 0 0 1-.1 5.5c-.4.8-.9 1.5-1.5 2.1a7 7 0 0 1-2.5 1.4c-2 .5-1 1.8-3 1.8s-1.3-1.5-3.2-1.8c-1-.3-2-.8-2.7-1.4a6.7 6.7 0 0 1-1.8-2.5c-.4-1-.6-2.2-.6-3.5h4.9c0 .7 0 1.3.2 1.8.1.5.3 1 .6 1.3.3.2.7.5 1.1.6.5.2 1 .2 1.5.2.7 0 1.2 0 1.6-.3.4-.3.6-.6.8-1 .2-.4.3-.9.3-1.4ZM90.5 106v4h-10v-4h10Zm-8.6-9.7v24h-4.8v-24h4.8Zm12.1 0v24h-4.8v-24H94Z"
fill="#0A140C"
/>
<path
d="M84 16c13 27 1 52-7 59 0 4-9 9-12 7-12 5-38-2-53-21-6-7 1-21 21-36 13-10 33-17 51-9Z"
fill="#FFD80B"
/>
<path d={juice} fill="white" />
<path
d="M69 15c15-1 9 10-6 19L44 44c-2 1-4-2-6 0l-3 6c-3 1-13 3-16 2-5-2-5-9 5-18l7-4c-1-2-1-2 2-5 3-2 19-10 29-11l1 2 6-1Z"
fill="#FFED4E"
/>
<path
d="M38 35c1-1 3-2 3-4l8-3c0 1-1 3 1 4-2 1-7 1-8 5-1-2-1-2-4-2Z"
fill="#fff"
/>
</svg>
<svg width={width} height="100" class={tw`-mt-5`}>
<polygon
points={springsPath}
fill="white"
transform="translate(0, 50)"
>
</polygon>
</svg>
</Fragment>
);
}
export default LemonDrop;
+62 -29
View File
@@ -1,11 +1,12 @@
/** @jsx h */
/** @jsxFrag Fragment */
import { Fragment, h, Head, tw } from "../client_deps.ts";
import { ComponentChildren, Fragment, h, Head, tw } from "../client_deps.ts";
import Counter from "../islands/Counter.tsx";
import NavigationBar from "../components/NavigationBar.tsx";
import LemonDrop from "../islands/LemonDrop.tsx";
import Footer from "../components/Footer.tsx";
import WarningBanner from "../components/WarningBanner.tsx";
import { Leaf } from "../components/Icons.tsx";
export default function MainPage() {
return (
@@ -18,7 +19,7 @@ export default function MainPage() {
/>
</Head>
<Hero />
<NavigationBar active="/" />
{/* <NavigationBar active="/" /> */}
<Intro />
<GettingStarted />
<Example />
@@ -28,53 +29,85 @@ export default function MainPage() {
}
function Hero() {
const container = tw`w-full h-64 flex justify-center items-center flex-col`;
const title = tw
`text(4xl sm:5xl lg:6xl gray-900 center) sm:tracking-tight font-extrabold`;
const subtitle = tw`mt-4 text(2xl gray-600 center)`;
const container = tw
`w-full flex justify-center items-center flex-col bg(green-200)`;
const nav = tw`flex justify-end items-center bg(green-200)`;
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 (
<section class={container}>
<h1 class={title}>
fresh
</h1>
<p class={subtitle}>
The next-gen web framework.
</p>
</section>
<Fragment>
<div class={nav}>
<a href="/docs" class={a}>
Documentation
</a>
</div>
<section class={container}>
<LemonDrop />
</section>
</Fragment>
);
}
export interface ListItemProps {
children: ComponentChildren;
}
function ListItem(props: ListItemProps) {
return (
<div class={tw`flex mt-3`}>
<Leaf />
<div class={tw`pl-4 flex-1`}>
{props.children}
</div>
</div>
);
}
function Intro() {
const title = tw
`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`}
>
<img
src="/illust.jpeg"
class={tw`w-64 mx-auto`}
alt="deno is drinking fresh lemon squash"
/>
<h2 class={title}>
The next-gen web framework.
</h2>
<p class={tw`text-gray-600`}>
Fresh is a next generation web framework, built for speed, reliability,
and simplicity. Some stand out features:
</p>
<ul class={tw`text-gray-600 list-disc list-inside pl-4`}>
<li>
<div>
<ListItem>
<b>Just-in-time rendering</b> on the edge.
</li>
<li>
</ListItem>
<ListItem>
<b>Island based client hydration</b> for maximum interactivity.
</li>
<li>
</ListItem>
<ListItem>
<b>Zero runtime overhead</b>: no JS is shipped to the client by
default.
</li>
<li>
</ListItem>
<ListItem>
<b>No build step</b>.
</li>
<li>
</ListItem>
<ListItem>
<b>No configuration</b> necessary.
</li>
<li>
</ListItem>
<ListItem>
<b>TypeScript support</b> out of the box.
</li>
</ul>
</ListItem>
</div>
<p class={tw`text-gray-600`}>
Fresh embraces the tried and true design of server side rendering and
progressive enhancement on the client side.
Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB