diff --git a/index.html b/index.html index cf22c16cb..25b67361f 100644 --- a/index.html +++ b/index.html @@ -1,5 +1,4 @@ -<<<<<<< HEAD 서윤의 블로그 @@ -17,28 +16,4 @@

제 블로그에 오신 것을 환영합니다!

-======= - - 서윤의 블로그 - - - -

제 블로그에 오신 것을 환영합니다!

-
- - - - - - - - - ->>>>>>> member/seooyuun diff --git a/my-app/package-lock.json b/my-app/package-lock.json index d6fbd2198..8e8b0f239 100644 --- a/my-app/package-lock.json +++ b/my-app/package-lock.json @@ -14,7 +14,7 @@ "@testing-library/user-event": "^13.5.0", "react": "^19.0.0", "react-dom": "^19.0.0", - "react-scripts": "5.0.1", + "react-scripts": "^5.0.1", "web-vitals": "^2.1.4" } }, diff --git a/my-app/package.json b/my-app/package.json index bd0e84783..75a8a4863 100644 --- a/my-app/package.json +++ b/my-app/package.json @@ -9,7 +9,7 @@ "@testing-library/user-event": "^13.5.0", "react": "^19.0.0", "react-dom": "^19.0.0", - "react-scripts": "5.0.1", + "react-scripts": "^5.0.1", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/my-app/src/chapter_03/Book.jsx b/my-app/src/chapter_03/Book.jsx index 5c15cdf36..73cba8634 100644 --- a/my-app/src/chapter_03/Book.jsx +++ b/my-app/src/chapter_03/Book.jsx @@ -1,12 +1,12 @@ import React from "react"; function Book(props) { - return ( -
-

{`이 책의 이름은 ${props.name}입니다.`}

-

{`이 책은 총 ${props.numOfPage}페이지로 이뤄져 있습니다.`}

-
- ); + return ( +
+

{`이 책의 이름은 ${props.name}입니다.`}

+

{`이 책은 총 ${props.numOfPage}페이지로 이뤄져 있습니다.`}

+
+ ); } -export default Book; \ No newline at end of file +export default Book; diff --git a/my-app/src/chapter_03/Library.jsx b/my-app/src/chapter_03/Library.jsx index d25518901..2570fdf9f 100644 --- a/my-app/src/chapter_03/Library.jsx +++ b/my-app/src/chapter_03/Library.jsx @@ -2,7 +2,6 @@ import React from "react"; import Book from "./Book"; function Library(props) { -<<<<<<< HEAD return (
@@ -12,16 +11,4 @@ function Library(props) { ); } -export default Library; -======= - return ( -
- - - -
- ); -} - -export default Library; ->>>>>>> member/seooyuun +export default Library; \ No newline at end of file diff --git a/my-app/src/chapter_03/efub5-first-react-study.code-workspace b/my-app/src/chapter_03/efub5-first-react-study.code-workspace new file mode 100644 index 000000000..e446dc1bc --- /dev/null +++ b/my-app/src/chapter_03/efub5-first-react-study.code-workspace @@ -0,0 +1,8 @@ +{ + "folders": [ + { + "path": "../../.." + } +], + "settings": {} +} diff --git a/my-app/src/chapter_07/Accommodate.jsx b/my-app/src/chapter_07/Accommodate.jsx new file mode 100644 index 000000000..e2b667119 --- /dev/null +++ b/my-app/src/chapter_07/Accommodate.jsx @@ -0,0 +1,35 @@ +import React, { useState, useEffect } from "react"; +import useCounter from "./useCounter"; + +const MAX_CAPACITY = 10; + +function Accommodate(props) { + const [isFull, setIsFull] = useState(false); + const [count, increaseCount, decreaseCount] = useCounter(0); + + useEffect(() => { + console.log("============================"); + console.log("useEffect() is called."); + console.log(`isFull: ${isFull}`); + }); + + useEffect(() => { + setIsFull(count >= MAX_CAPACITY); + console.log(`Current count value: ${count}`); + }, [count]); + + return ( +
+

{`총 ${count}명 수용했습니다.`}

+ + + + + {isFull &&

정원이 가득찼습니다.

} +
+ ); +} + +export default Accommodate; diff --git a/my-app/src/chapter_07/useCounter.jsx b/my-app/src/chapter_07/useCounter.jsx new file mode 100644 index 000000000..b9f512ccb --- /dev/null +++ b/my-app/src/chapter_07/useCounter.jsx @@ -0,0 +1,12 @@ +import React, { use, useState } from "react"; + +function useCounter(initialValue) { + const [count, setCount] = useState(initialValue); + + const increaseCount = () => setCount((count) => count + 1); + const decreaseCount = () => setCount((count) => Math.max(count - 1, 0)); + + return [count, increaseCount, decreaseCount]; +} + +export default useCounter; diff --git a/my-app/src/chapter_08/ConfirmButton.jsx b/my-app/src/chapter_08/ConfirmButton.jsx new file mode 100644 index 000000000..9c9887bc2 --- /dev/null +++ b/my-app/src/chapter_08/ConfirmButton.jsx @@ -0,0 +1,17 @@ +import React, { useState } from "react"; + +function ConfirmButton(props) { + const [isConfirmed, setIsConfirmed] = useState(false); + + const handleConfirm = () => { + setIsConfirmed((prevIsConfirmed) => !prevIsConfirmed); + }; + + return ( + + ); +} + +export default ConfirmButton; diff --git a/my-app/src/chapter_09/LandingPage.jsx b/my-app/src/chapter_09/LandingPage.jsx new file mode 100644 index 000000000..f32c145ca --- /dev/null +++ b/my-app/src/chapter_09/LandingPage.jsx @@ -0,0 +1,27 @@ +import React, { useState } from "react"; +import Toolbar from "./Toolbar"; + +function LandingPage(props) { + const [isLoggedIn, setIsLoggedIn] = useState(false); + + const onClickLogin = () => { + setIsLoggedIn(true); + }; + + const onClickLogout = () => { + setIsLoggedIn(false); + }; + + return ( +
+ +
소플과 함께하는 리액트 공부!
+
+ ); +} + +export default LandingPage; diff --git a/my-app/src/chapter_09/Toolbar.jsx b/my-app/src/chapter_09/Toolbar.jsx new file mode 100644 index 000000000..f902ffbac --- /dev/null +++ b/my-app/src/chapter_09/Toolbar.jsx @@ -0,0 +1,31 @@ +import React from "react"; + +const styles = { + wrapper: { + padding: 16, + display: "flex", + flexDirection: "row", + borderBottom: "1px solid grey", + }, + greeting: { + marginRight: 8, + }, +}; + +function Toolbar(props) { + const { isLoggedIn, onClickLogin, onClickLogout } = props; + + return ( +
+ {isLoggedIn && 환영합니다!} + + {isLoggedIn ? ( + + ) : ( + + )} +
+ ); +} + +export default Toolbar; diff --git a/my-app/src/chapter_10/AttendanceBook.jsx b/my-app/src/chapter_10/AttendanceBook.jsx new file mode 100644 index 000000000..ebc8676ee --- /dev/null +++ b/my-app/src/chapter_10/AttendanceBook.jsx @@ -0,0 +1,32 @@ +import React from "react"; + +const students = [ + { + id: 1, + name: "Inje", + }, + { + id: 2, + name: "Steve", + }, + { + id: 3, + name: "Bill", + }, + { + id: 4, + name: "Jeff", + }, +]; + +function AttendanceBook(props) { + return ( + + ); +} + +export default AttendanceBook; diff --git a/my-app/src/chapter_11/SignUp.jsx b/my-app/src/chapter_11/SignUp.jsx new file mode 100644 index 000000000..837c59be3 --- /dev/null +++ b/my-app/src/chapter_11/SignUp.jsx @@ -0,0 +1,39 @@ +import React, { useState } from "react"; + +function SignUp(props) { + const [name, setName] = useState(""); + const [gender, setGender] = useState("남자"); + + const handleChangeName = (event) => { + setName(event.target.value); + }; + + const handleChangeGender = (event) => { + setGender(event.target.value); + }; + + const handleSubmit = (event) => { + alert(`이름: ${name}, 성별: ${gender}`); + event.preventDefault(); + }; + + return ( +
+ +
+ + +
+ ); +} + +export default SignUp; diff --git a/my-app/src/chapter_12/Calculator.jsx b/my-app/src/chapter_12/Calculator.jsx new file mode 100644 index 000000000..999c55636 --- /dev/null +++ b/my-app/src/chapter_12/Calculator.jsx @@ -0,0 +1,65 @@ +import React, { useState } from "react"; +import TemperatureInput from "./TemperatureInput"; + +function BoilindVerdict(props) { + if (props.celsius >= 100) { + return

물이 끓습니다.

; + } + return

물이 끓지 않습니다.

; +} + +function toCelsius(fahrenheit) { + return ((fahrenheit - 32) * 5) / 9; +} + +function toFahrenheit(celsius) { + return (celsius * 9) / 5 + 32; +} + +function tryConvert(temperature, convert) { + const input = parseFloat(temperature); + if (Number.isNaN(input)) { + return ""; + } + const output = convert(input); + const rounded = Math.round(output * 1000) / 1000; + return rounded.toString(); +} + +function Calculator(props) { + const [temperature, setTemperature] = useState(""); + const [scale, setScale] = useState("c"); + + const handleCelsiusChange = (temperature) => { + setTemperature(temperature); + setScale("c"); + }; + + const handleFahrenheitChange = (temperature) => { + setTemperature(temperature); + setScale("f"); + }; + + const celsius = + scale === "f" ? tryConvert(temperature, toCelsius) : temperature; + const fahrenheit = + scale === "c" ? tryConvert(temperature, toFahrenheit) : temperature; + + return ( +
+ + + +
+ ); +} + +export default Calculator; diff --git a/my-app/src/chapter_12/TemperatureInput.jsx b/my-app/src/chapter_12/TemperatureInput.jsx new file mode 100644 index 000000000..a268aafdd --- /dev/null +++ b/my-app/src/chapter_12/TemperatureInput.jsx @@ -0,0 +1,19 @@ +const scaleNames = { + c: "섭씨", + f: "화씨", +}; + +function TemperatureInput(props) { + const handleChange = (event) => { + props.onTemperatureChange(event.target.value); + }; + + return ( +
+ 온도를 입력해주세요(단위:{scaleNames[props.scale]}); + +
+ ); +} + +export default TemperatureInput; diff --git a/my-app/src/chapter_13/Card.jsx b/my-app/src/chapter_13/Card.jsx new file mode 100644 index 000000000..0615fc429 --- /dev/null +++ b/my-app/src/chapter_13/Card.jsx @@ -0,0 +1,20 @@ +function Card(props) { + const { title, backgroundColor, children } = props; + + return ( +
+ {title &&

{title}

} + {children} +
+ ); +} + +export default Card; diff --git a/my-app/src/chapter_13/ProfileCard.jsx b/my-app/src/chapter_13/ProfileCard.jsx new file mode 100644 index 000000000..4ec7622b5 --- /dev/null +++ b/my-app/src/chapter_13/ProfileCard.jsx @@ -0,0 +1,12 @@ +import Card from "./Card"; + +function ProfileCard(props) { + return ( + +

안녕하세요, 소플입니다.

+

저는 리액트를 사용해서 개발하고 있습니다.

+
+ ); +} + +export default ProfileCard; diff --git a/my-app/src/index.js b/my-app/src/index.js index fae87feb2..0dbd8b64d 100644 --- a/my-app/src/index.js +++ b/my-app/src/index.js @@ -9,11 +9,19 @@ import Clock from "./chapter_04/Clock"; import CommentList from "./chapter_05/CommentList"; import NotificationList from "./chapter_06/NotificationList"; +import Accommodate from "./chapter_07/Accommodate"; +import ConfirmButton from "./chapter_08/ConfirmButton"; +import LandingPage from "./chapter_09/LandingPage"; +import AttendanceBook from "./chapter_10/AttendanceBook"; + +import SignUp from "./chapter_11/SignUp"; +import Calculator from "./chapter_12/Calculator"; +import ProfileCard from "./chapter_13/ProfileCard"; const root = ReactDOM.createRoot(document.getElementById("root")); root.render( - + ); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..85c4d8a5a --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "efub5-first-react-study", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/styles.css b/styles.css index 81528be05..637db5290 100644 --- a/styles.css +++ b/styles.css @@ -1,4 +1,4 @@ h1 { - color:green; - font-style: italic; -} \ No newline at end of file + color: green; + font-style: italic; +}