Skip to content

Commit

Permalink
play around with animated text
Browse files Browse the repository at this point in the history
  • Loading branch information
setsun committed Jun 30, 2023
1 parent 5a8b6c8 commit 9f73f85
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
4 changes: 2 additions & 2 deletions components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const Layout: React.FC<Props> = (props) => (
<div className="flex h-screen overflow-hidden">
<Navigation />

<div className="w-full overflow-scroll relative">
<main className="p-4" style={{ minHeight: 'calc(100vh - 4rem)'}}>
<div className="w-full overflow-y-auto relative">
<main className="p-4" style={{ minHeight: 'calc(100vh - 5rem)'}}>
{props.children}
</main>

Expand Down
42 changes: 32 additions & 10 deletions pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTrail, animated, config } from '@react-spring/web';
import React from "react"
import { GetStaticProps } from "next"
import Layout from "../components/Layout"
import { Canvas } from "@react-three/fiber";
import WireframePlanet from "../components/hero-scenes/WireframePlanet";

Expand All @@ -13,6 +13,13 @@ import WireframePlanet from "../components/hero-scenes/WireframePlanet";
// { ssr: false },
// );

const ANIMATED_TEXT = [
"I'll miss the sea, but a person needs new experiences.",
"They jar something deep inside, allowing him to grow",
"Without change something sleeps inside us, and seldom awakens.",
"The sleeper must awaken."
];

export const getStaticProps: GetStaticProps = async () => {
// todo: determine what data to fetch in home page

Expand All @@ -22,18 +29,33 @@ export const getStaticProps: GetStaticProps = async () => {
}
}

interface Props {}
interface Props { }

const Index: React.FC<Props> = (props) => {
const trails = useTrail(ANIMATED_TEXT.length, {
delay: 500,
config: { mass: 5, tension: 200, friction: 300 },
from: { opacity: 0, transform: 'translate3d(0, -48px, 0)' },
to: { opacity: 1, transform: 'translate3d(0, 0px, 0)' },
});

return (
<Canvas
className="w-full aspect-video"
camera={{
position: [0, 0, -30]
}}
>
<WireframePlanet />
</Canvas>
<div className='relative'>
<div className='absolute top-0 ml-2 mt-2'>
{trails.map((props, i) => (
<animated.div className="text-3xl font-extralight mb-3" style={props} key={i}>{ANIMATED_TEXT[i]}</animated.div>
))}
</div>

<Canvas
className="w-full aspect-video"
camera={{
position: [0, 0, -30]
}}
>
<WireframePlanet />
</Canvas>
</div>
)
}

Expand Down

1 comment on commit 9f73f85

@vercel
Copy link

@vercel vercel bot commented on 9f73f85 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

setsun-xyz – ./

setsun.xyz
www.setsun.xyz
setsun-xyz-setsun.vercel.app
setsun-xyz-git-main-setsun.vercel.app

Please sign in to comment.