quick fact

This commit is contained in:
tymur999
2024-10-19 19:09:02 -04:00
committed by Mark Goltsman
parent afae70d151
commit 9242466754
6 changed files with 107 additions and 25 deletions

View File

@@ -0,0 +1,51 @@
import { motion } from "framer-motion";
import Image from "next/image";
import arrow from "@/img/arrow.png";
import gradient from "@/img/gradient.png";
import { useEffect, useState } from "react";
export function Journal(props: {setIndex: (index: number) => void}) {
const [loaded, setLoaded] = useState(false);
useEffect(() => {
setLoaded(true);
}, []);
return <motion.div
onClick={() => loaded && props.setIndex(2)}
initial={{ y: 500 }}
transition={{duration: 0.2}}
animate={{ y: 0 }}
exit={{y: 500}}
className="z-[9999] bg-[#030303] absolute h-[100vh] top-0 w-full flex flex-col"
>
<div className="text-center text-5xl font-bold mt-[5rem] px-5">Take a break for journaling</div>
<div className="flex flex-col mx-auto mt-[5rem]">
<input className="z-[99999] mx-auto py-2 px-4 bg-[#383838] color-[#7f7f7f] border-2 text-xl border-none rounded-xl"
placeholder="Reflect on what you learned..." />
</div>
<div className="my-auto">
<div
unselectable="on"
className="select-none text-2xl text-center"
>
Swipe to continue
</div>
<Image
draggable={false}
unselectable={"on"}
className="mx-auto mt-10"
width={65}
alt="arrow"
src={arrow}
/>
</div>
<Image
className="absolute bottom-0 z-[-999] w-full h-[200px] opacity-30 pointer-events-none"
alt=""
draggable={false}
unselectable={"on"}
width={window.innerWidth}
src={gradient}
/>
</motion.div>
}

View File

@@ -6,28 +6,22 @@ import Image from "next/image";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Time } from "@/app/landing/time"; import { Time } from "@/app/landing/time";
import { motion } from "framer"; import { motion } from "framer";
import {useAnimate} from "framer-motion"; import { Journal } from "@/app/landing/journal";
import { QuickFact } from "@/app/landing/quick_fact";
const slides = [<Time/>];
export default function Landing() { export default function Landing() {
const [clicked1, setClicked1] = useState(false); const [clicked1, setClicked1] = useState(false);
const [scope, animate] = useAnimate(); const [index, setIndex] = useState(0);
const [animated, setAnimated] = useState(false); const slides = [<Time setIndex={setIndex} key="1" seconds={8}/>,
<Journal setIndex={setIndex} key="2"/>,
<QuickFact key="3"/>];
useEffect(() => { return clicked1 ? (
if(!clicked1) slides[index]
return;
animate(scope.current, {y:"100vh"});
setAnimated(true);
}, [animate, scope, clicked1]);
return clicked1 && animated ? (
<Time
/>
) : ( ) : (
<motion.div <motion.div
initial={{y: 0}} initial={{y: 0}}
ref={scope} exit={{y:"100vh"}}
onMouseDown={() => setClicked1(true)} onMouseDown={() => setClicked1(true)}
className="flex-grow flex flex-col" className="flex-grow flex flex-col"
> >

View File

@@ -0,0 +1,5 @@
export function QuickFact() {
return <div>
Hello
</div>
}

View File

@@ -2,19 +2,51 @@
import 'react-circular-progressbar/dist/styles.css'; import 'react-circular-progressbar/dist/styles.css';
import { CircularProgressbar, buildStyles } from 'react-circular-progressbar'; import { CircularProgressbar, buildStyles } from 'react-circular-progressbar';
import { motion } from 'framer'; import { motion } from 'framer';
// import { useState } from "react"; import { useEffect, useState } from "react";
// import CanvasClass from "@/api/canvas.class";
// import getSubtask from "../../api/openAI/openAI-API";
export function Time() { export function Time(props: {seconds: number, setIndex: (index: number) => void}) {
// const [secondsLeft, _setSecondsLeft] = useState(100); const [expectedDate] = useState(Date.now()/1000+props.seconds);
const percentage = 66; const [secondsLeft, setSecondsLeft] = useState(props.seconds);
// const [subtask, setSubtask] = useState<string | null>("");
const percentage = secondsLeft / props.seconds * 100;
return <motion.div // useEffect(() => {
// (async () => {
// const canvas = new CanvasClass("2096~VBaXaAvP39aGWhVV2xuUnTzn8wxATf98PZz7rmWQFf278B4V3a2nCW7fJkDDxURh");
// const files = await canvas.getAllFiles();
// const result: string | null = await getSubtask(files);
// setSubtask(result);
// console.log(subtask);
// })();
// }, []);
useEffect(() => {
decreaseClock();
}, []);
function decreaseClock() {
if(secondsLeft <= 0)
return;
setTimeout(() => {
setSecondsLeft(Math.max(Math.round(expectedDate - Date.now()/1000),0));
decreaseClock();
}, 1000);
}
return <motion.div onMouseDown={() => props.setIndex(1)}
initial={{y: 500}} initial={{y: 500}}
animate={{y: 0}} animate={{y: 0}}
className="absolute top-0 z-[-999] flex flex-col bg-[#ff5757] h-full w-full items-center justify-center"> exit={{y: 500}}
<h1 className="absolute text-9xl font-bold drop-shadow-md shadow-black"> className="absolute top-0 flex flex-col bg-[#ff5757] h-full w-full items-center justify-center">
<h1 className="text-3xl text-center absolute top-[15%] font-bold">
What is the average attention span?
</h1>
<h1 className="absolute text-9xl font-bold" style={{textShadow: "5px 5px 5px 5px black"}}>
{ {
Math.trunc(100 / 60) secondsLeft
} }
</h1> </h1>
<div className="flex w-[300px] h-[300px]"> <div className="flex w-[300px] h-[300px]">

View File

@@ -21,7 +21,7 @@ export default function RootLayout({
<body <body
className="antialiased overflow-hidden h-[100vh] flex flex-col" className="antialiased overflow-hidden h-[100vh] flex flex-col"
> >
<div className="flex w-100 p-5 text-5xl text-center flex-shrink py-6"> <div className="flex w-100 z-[999] p-5 text-5xl text-center flex-shrink py-6">
<h1 className={raleway_heavy.className + " top-[20px] absolute left-[50%] translate-x-[-50%]"}> <h1 className={raleway_heavy.className + " top-[20px] absolute left-[50%] translate-x-[-50%]"}>
logo logo
</h1> </h1>