-
Notifications
You must be signed in to change notification settings - Fork 2
feature: first page markup #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: petit-project/team3
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,14 @@ | ||
| import * as React from 'react'; | ||
| import { styled } from '@stitches/react'; | ||
| import Wonjong from './components/wonjong'; | ||
| import { Route, Routes } from 'react-router-dom'; | ||
|
|
||
| const App: React.FC = () => { | ||
| const [count, setCount] = React.useState<number>(0); | ||
|
|
||
| const increment = () => setCount((prev) => prev + 1); | ||
| const decrement = () => setCount((prev) => prev - 1); | ||
|
|
||
| return ( | ||
| <CounterBox> | ||
| <IncrementButton onClick={increment}>+</IncrementButton> | ||
| <CounterNumber>{count}</CounterNumber> | ||
| <DecrementButton onClick={decrement}>-</DecrementButton> | ||
| </CounterBox> | ||
| <Routes> | ||
| <Route path='wonjong' element={<Wonjong />} /> | ||
| {/*여기에 각자 route 처리해서 컴포넌트 넣어주시면 될 것 같아요.*/} | ||
| </Routes> | ||
| ); | ||
| }; | ||
|
|
||
| export default App; | ||
|
|
||
| const CounterBox = styled('div', { | ||
| width: '100vw', | ||
| height: '100vh', | ||
| display: 'flex', | ||
| alignItems: 'center', | ||
| justifyContent: 'center', | ||
| gap: 16, | ||
| }); | ||
|
|
||
| const CounterNumber = styled('span', { | ||
| fontSize: 24, | ||
| fontWeight: 700, | ||
| }); | ||
|
|
||
| const IncrementButton = styled('button', { | ||
| fontSize: 20, | ||
| fontWeight: 700, | ||
| }); | ||
|
|
||
| const DecrementButton = styled('button', { | ||
| fontSize: 20, | ||
| fontWeight: 700, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import React from "react"; | ||
| import { motion } from "framer-motion"; | ||
| import * as $ from './styles' | ||
|
|
||
| // Word wrapper | ||
| const Wrapper = (props: any) => { | ||
| // We'll do this to prevent wrapping of words using CSS | ||
| return <span className="word-wrapper">{props.children}</span>; | ||
| }; | ||
|
|
||
| // AnimatedText | ||
| // Handles the deconstruction of each word and character to setup for the | ||
| // individual character animations | ||
| const AnimatedText = (props: any) => { | ||
| // Framer Motion variant object, for controlling animation | ||
| const item = { | ||
| hidden: { | ||
| y: "200%", | ||
| color: "#FFFFFF", | ||
| transition: { ease: [0.455, 0.03, 0.515, 0.955], duration: 0.85 } | ||
| }, | ||
| visible: { | ||
| y: 0, | ||
| color: "#FFFFFF", | ||
| transition: { ease: [0.455, 0.03, 0.515, 0.955], duration: 0.75 } | ||
| } | ||
| }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AnimatedText 컴포넌트 함수 내부에서 정의할 필요 없이, 컴포넌트 선언 밖으로 뽑아도 좋을 것 같습니다.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 컴포넌트 선언 밖으로 뽑는 것과 안에 선언하는 것에 어떤 차이가 있을까요? 이 부분은 제가 생각하기에는 마이너한 부분인 것 같은데, 혹시 코멘트 주신 이유가 있을 수도 있어 보여서 질문드렸습니다. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 마이너한 부분은 맞습니다. 다만 함수 내부에 정적 변수가 선언되어서 이후 해당 컴포넌트가 계산될 때 마다 변수가 생성될텐데, 불필요하게 변수를 생성시킬 필요가 없이 함수 외부에서 한번만 생성할 수 있을 것 같아 코멘트 남겨놓았습니다! |
||
|
|
||
| // Split each word of props.text into an array | ||
| const splitWords = props.text.split(" "); | ||
|
|
||
| // Create storage array | ||
| const words: string[][] = []; | ||
|
|
||
| // Push each word into words array | ||
| for (const [, item] of splitWords.entries()) { | ||
| words.push(item.split("")); | ||
| } | ||
|
|
||
| // Add a space ("\u00A0") to the end of each word | ||
| words.map((word) => { | ||
| return word.push("\u00A0"); | ||
| }); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 해당 부분의 가공 로직이 너무 찢어져있는 것 같은데, method chaining을 통해 정리할 수도 있을 것 같습니다. const words = props.text.split(" ")
.map((el) => el.split(""))
.map((el) => [...el, "\u00A0"]);요런식으로 정리하는 것도 좋을 것 같습니다.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수형으로 정리하면 훨씬 더 깔끔하네요! 반영하도록 하겠습니다. |
||
|
|
||
| return ( | ||
| <$.H1Container> | ||
| {words.map((word, index) => { | ||
| return ( | ||
| // Wrap each word in the Wrapper component | ||
| <Wrapper key={index}> | ||
| {words[index].flat().map((element, index) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요 부분 flat().map() 해당 구분이랑 flatMap()과는 다른 동작이 진행되나요?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. flapMap 메서드는 제가 몰랐었는데 한 번 알아볼께요 |
||
| return ( | ||
| <span | ||
| style={{ | ||
| overflow: "hidden", | ||
| display: "inline-block" | ||
| }} | ||
| key={index} | ||
| > | ||
| <motion.span | ||
| style={{ display: "inline-block" }} | ||
| variants={item} | ||
| > | ||
| {element} | ||
| </motion.span> | ||
| </span> | ||
| ); | ||
| })} | ||
| </Wrapper> | ||
| ); | ||
| })} | ||
| {/* {} */} | ||
| </$.H1Container> | ||
| ); | ||
| }; | ||
|
|
||
| export default AnimatedText; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { styled } from '@stitches/react'; | ||
|
|
||
| export const H1Container = styled('h1', { | ||
| margin: '0' | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import React, { useEffect, useState } from 'react'; | ||
| import * as $ from './styles'; | ||
| import { motion } from 'framer-motion'; | ||
| import AnimatedText from '../AnimatedText'; | ||
|
|
||
| const Wonjong = () => { | ||
| const [randomNumbers, setRandomNumbers] = useState<number[]>([]); | ||
| useEffect(() => { | ||
| const number1 = Math.floor(Math.random() * 30 + 10); | ||
| const number2 = Math.floor(Math.random() * 30 + 40); | ||
| const number3 = Math.floor(Math.random() * 30 + 70); | ||
| setRandomNumbers([number1, number2, number3]); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <$.Wrapper> | ||
| <$.LeftTitleContainer> | ||
| Wonjong Oh <br /> | ||
| Frontend Web Developer | ||
| </$.LeftTitleContainer> | ||
| <motion.div | ||
| initial='hidden' | ||
| animate='visible' | ||
| variants={{ | ||
| visible: { | ||
| transition: { | ||
| staggerChildren: 0.025, | ||
| }, | ||
| }, | ||
| }} | ||
| > | ||
| <AnimatedText text={String(randomNumbers[2])} | ||
| style={{ fontSize: '60px', fontWeight: '900', textAlign: 'right', margin: '0 40px 0 0' }} /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 정의되어있지 않은 style을 props으로 받아서 사용중인 상태라 수정이 필요할 것 같습니다.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 수정하도록 할께요 |
||
| <AnimatedText text={String(randomNumbers[1])} | ||
| style={{ fontSize: '60px', fontWeight: '900', textAlign: 'right', margin: '0 40px 0 0' }} /> | ||
| <AnimatedText text={String(randomNumbers[0])} | ||
| style={{ fontSize: '60px', fontWeight: '900', textAlign: 'right', margin: '0 40px 0 0' }} /> | ||
| </motion.div> | ||
| </$.Wrapper> | ||
| ); | ||
| }; | ||
|
|
||
| export default Wonjong; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { styled } from '@stitches/react'; | ||
|
|
||
| export const Wrapper = styled('div', { | ||
| backgroundColor: 'black', | ||
| color: 'white', | ||
| width: '100vw', | ||
| height: '100vh', | ||
| top: '0', | ||
| left: '0', | ||
| position: 'absolute', | ||
| fontSize: '60px', | ||
| fontWeight: '900', | ||
| textAlign: 'right', | ||
| margin: '0 40px 0 0' | ||
| }); | ||
|
|
||
| export const LeftTitleContainer = styled('p', { | ||
| fontSize: '40px', | ||
| fontWeight: '600', | ||
| textAlign: 'left', | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,12 @@ | ||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom/client'; | ||
| import App from './App'; | ||
| import { BrowserRouter } from 'react-router-dom'; | ||
|
|
||
| ReactDOM.createRoot(document.getElementById('root')!).render( | ||
| <React.StrictMode> | ||
| <App /> | ||
| </React.StrictMode> | ||
| <BrowserRouter> | ||
| <App /> | ||
| </BrowserRouter> | ||
| </React.StrictMode>, | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TypeScript 환경이기 때문에 해당 부분의 props을 타입 정의해주는 것이 좋을 것 같습니다.
해당 컴포넌트의 경우
{ children: React.ReactNode }로 정의할 수 있을 것 같습니다.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 이 부분 수정하도록 하겠습니다!