Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nowrobin authored Jun 27, 2024
2 parents 96f37b7 + a4957f9 commit db31575
Show file tree
Hide file tree
Showing 10 changed files with 5,756 additions and 1,986 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ yarn-error.log*
*.tsbuildinfo
next-env.d.ts

.env

.env

6,930 changes: 5,051 additions & 1,879 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"test": "jest"
},
"dependencies": {
"@prisma/client": "^5.14.0",
"@vercel/postgres": "^0.8.0",

"next": "14.2.3",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {

"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.2.3",

"postcss": "^8",
"prisma": "^5.14.0",
"tailwindcss": "^3.4.1",
Expand Down
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

Binary file removed src/app/favicon.ico
Binary file not shown.
253 changes: 150 additions & 103 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,113 +1,160 @@
import Image from "next/image";
"use client";

import { useEffect, useState } from "react";

interface Word {
content: string;
sentenceIndex: number;
}

interface Letter extends Word {
wordIndex: number;
letters: string[];
}

export default function Home() {
return (
<main className="flex min-h-screen flex-col items-center justify-between p-24">
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
Get started by editing&nbsp;
<code className="font-mono font-bold">src/app/page.tsx</code>
</p>
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:size-auto lg:bg-none">
<a
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
target="_blank"
rel="noopener noreferrer"
>
By{" "}
<Image
src="/vercel.svg"
alt="Vercel Logo"
className="dark:invert"
width={100}
height={24}
priority
/>
</a>
</div>
</div>
//For sentence
const [sentenceCurrent, setSentenceCurrent] = useState(0); //sentence Current position
const [textValue, setTextValue] = useState(""); //for the print text
// let inputCollection: string[] = [];
const [inputCollection, setInputCollection] = useState<string[]>([]);
const quote = {
title: "눈물을 마시는 새",
author: "이영도",
content:
"아름다운 나의 벗이여, 내 형제여. 살았을 적 언제나 내 곁에,\n죽은 후엔 영원히 내 속에 남은 이여 다시 돌아온 봄이건만,\n꽃잎 맞으며 그대와 거닐 수 없으니 봄은 왔으되 결코 봄이 아니구나.",
};

<div className="relative z-[-1] flex place-items-center before:absolute before:h-[300px] before:w-full before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 sm:before:w-[480px] sm:after:w-[240px] before:lg:h-[360px]">
<Image
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
src="/next.svg"
alt="Next.js Logo"
width={180}
height={37}
priority
/>
</div>
const sentences = quote.content.split("\n");

const handleTextArea = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
let targetValue = e.currentTarget.value.split("\n");
let targetLength = targetValue[sentenceCurrent].length;
if (targetLength == sentences[sentenceCurrent].length) {
setInputCollection((prev: string[]) => {
//다음 index가 없거나, 처음 들어올때
if (prev[sentenceCurrent] == undefined || prev.length == 0) {
return [...prev, targetValue[sentenceCurrent]];
} else {
let newInputCollection: string[] = [...prev];
newInputCollection[sentenceCurrent] = targetValue[sentenceCurrent];
return newInputCollection;
}
});
e.currentTarget.value += "\n";
if (sentenceCurrent + 1 >= sentences.length) {
alert("The End");
}
setSentenceCurrent((prev) => ++prev);
}
setTextValue(e.currentTarget.value);
};

<div className="mb-32 grid text-center lg:mb-0 lg:w-full lg:max-w-5xl lg:grid-cols-4 lg:text-left">
<a
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className="mb-3 text-2xl font-semibold">
Docs{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className="m-0 max-w-[30ch] text-sm opacity-50">
Find in-depth information about Next.js features and API.
</p>
</a>
const handleKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {
const key = e.key;
if (key == " " || key == "Spacebar") {
}
if (key == "Backspace") {
//Prevent From going over empty text area
if (textValue == "") {
e.preventDefault();
return;
}
//if the whole length is smaller
let inputSentence = textValue.split("\n");
//If current Sentence Have Empty string
//then Skip to the previous sentence
if (inputSentence[sentenceCurrent] == "") {
setTextValue((prev) => {
return prev.slice(0, -1);
});
setSentenceCurrent((prev) => (prev -= 1));
}
}
if (key == "Enter") {
e.preventDefault();
alert("You Cannot Skip the line");
}
};
const LetterGenerator = ({
wordIndex,
content,
sentenceIndex,
letters,
}: Letter) => {
if (wordIndex != 0 && content == " ") {
return <span>&nbsp;</span>;
}
if (sentenceIndex < sentenceCurrent) {
let previousInputValue = inputCollection[sentenceIndex].split("");
return previousInputValue[wordIndex] == content ? (
<span className="text-white">{content}</span>
) : (
<span className="text-red-800">{previousInputValue[wordIndex]}</span>
);
}

<a
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className="mb-3 text-2xl font-semibold">
Learn{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className="m-0 max-w-[30ch] text-sm opacity-50">
Learn about Next.js in an interactive course with&nbsp;quizzes!
</p>
</a>
let testInput = textValue.split("\n");
let testInputLetter = testInput[sentenceCurrent].split("");

<a
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className="mb-3 text-2xl font-semibold">
Templates{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className="m-0 max-w-[30ch] text-sm opacity-50">
Explore starter templates for Next.js.
</p>
</a>
return sentenceCurrent == sentenceIndex && testInputLetter[wordIndex] ? (
testInputLetter[wordIndex] == content ? (
<span className="text-white">{content}</span>
) : testInputLetter[wordIndex] == " " ? (
<span className="text-red-600">{content}</span>
) : (
<span className="text-red-600">{testInputLetter[wordIndex]}</span>
)
) : (
<span className="text-[#818181]">{content}</span>
);
};

<a
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
target="_blank"
rel="noopener noreferrer"
>
<h2 className="mb-3 text-2xl font-semibold">
Deploy{" "}
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
-&gt;
</span>
</h2>
<p className="m-0 max-w-[30ch] text-balance text-sm opacity-50">
Instantly deploy your Next.js site to a shareable URL with Vercel.
</p>
</a>
const WordGenerator = ({ content, sentenceIndex }: Word) => {
//Split into letters
let letters = content.split("");
return (
<div className="flex flex-row gap-[0.06rem]">
{letters.map((value, index) => {
//Generate Each Letters
return (
<LetterGenerator
key={index}
wordIndex={index}
sentenceIndex={sentenceIndex}
content={value}
letters={letters}
></LetterGenerator>
);
})}
</div>
);
};
return (
<div className="flex flex-col items-start w-[50%] m-32">
<div id="print" className="flex w-[36rem] h-[13rem] gap-1 p-10">
<div className="flex flex-col">
{sentences.map((value, index) => {
return (
//Each Word generate
<WordGenerator
key={index}
content={value}
sentenceIndex={index}
></WordGenerator>
);
})}
</div>
<textarea
className="absolute top-[8rem] left-[8rem] bg-transparent text-transparent w-[36rem] h-[13rem] focus:outline-none p-10 resize-none caret-white tracking-[0.06rem]"
onChange={handleTextArea}
value={textValue}
onKeyDown={handleKeyDown}
></textarea>
</div>
</main>
<hr className=" w-[100%] h-[0.75px] bg-white"></hr>
<div>{quote.author}</div>
<div>{quote.title}</div>
</div>
);
}
38 changes: 38 additions & 0 deletions src/app/personal/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use client";

import { useState } from "react";

export default function Test() {
const s =
"Intelligence is the capacity to perceive the essential, the what is; and to awaken this capacity, in oneself and in others, is education.";
//Divide by words
const space = "\u00A0";
const words = s.split(" ");
const [current, setCurrent] = useState(0);

const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
const key = e.key;
if (key == " " || key == "Spacebar") {
console.log(key);
}
};

return (
<div>
<div
className="bg-white text-black"
onKeyDown={handleKeyDown}
tabIndex={-1}
>
{words.map((k, v) => {
return (
<span key={v}>
<span>{k}</span>
{space}
</span>
);
})}
</div>
</div>
);
}
7 changes: 7 additions & 0 deletions src/app/personal/test/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test("1 is 1", () => {
expect(1).toBe(1);
});

// test("테스트 설명", () => {
// expect("검증 대상").toXxx("기대 결과");
// });
Loading

0 comments on commit db31575

Please sign in to comment.