From e4211bf8c6b3554858dc978206014d34fb88b3de Mon Sep 17 00:00:00 2001 From: Jisu <92006284+jsomnium@users.noreply.github.com> Date: Sat, 21 Sep 2024 22:25:04 +0900 Subject: [PATCH 1/8] =?UTF-8?q?refactor:=20=EB=A6=AC=EC=95=A1=ED=8A=B8=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EC=97=AC=20=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 220 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 3 +- src/App.js | 85 ++++++++++++++++-- src/styles.js | 101 +++++++++++++++++++++ 4 files changed, 402 insertions(+), 7 deletions(-) create mode 100644 src/styles.js diff --git a/package-lock.json b/package-lock.json index 97dcc3a..944f69a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,8 @@ "@testing-library/user-event": "^13.5.0", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-scripts": "5.0.1", + "react-scripts": "^5.0.1", + "styled-components": "^6.1.13", "web-vitals": "^2.1.4" } }, @@ -2280,6 +2281,27 @@ "postcss-selector-parser": "^6.0.10" } }, + "node_modules/@emotion/is-prop-valid": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.2.tgz", + "integrity": "sha512-uNsoYd37AFmaCdXlg6EYD1KaPOaRWRByMCYzbKUX4+hhMfrxdVSelShywL4JVaAeM/eHUOSprYBQls+/neX3pw==", + "license": "MIT", + "dependencies": { + "@emotion/memoize": "^0.8.1" + } + }, + "node_modules/@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==", + "license": "MIT" + }, + "node_modules/@emotion/unitless": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", + "integrity": "sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==", + "license": "MIT" + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -4465,6 +4487,12 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==" }, + "node_modules/@types/stylis": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/@types/stylis/-/stylis-4.2.5.tgz", + "integrity": "sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw==", + "license": "MIT" + }, "node_modules/@types/testing-library__jest-dom": { "version": "5.14.9", "resolved": "https://registry.npmjs.org/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.9.tgz", @@ -5931,6 +5959,15 @@ "node": ">= 6" } }, + "node_modules/camelize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", + "integrity": "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/caniuse-api": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", @@ -6358,6 +6395,15 @@ "postcss": "^8.4" } }, + "node_modules/css-color-keywords": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", + "integrity": "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==", + "license": "ISC", + "engines": { + "node": ">=4" + } + }, "node_modules/css-declaration-sorter": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", @@ -6499,6 +6545,17 @@ "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==" }, + "node_modules/css-to-react-native": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz", + "integrity": "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==", + "license": "MIT", + "dependencies": { + "camelize": "^1.0.0", + "css-color-keywords": "^1.0.0", + "postcss-value-parser": "^4.0.2" + } + }, "node_modules/css-tree": { "version": "1.0.0-alpha.37", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz", @@ -14963,6 +15020,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-5.0.1.tgz", "integrity": "sha512-8VAmEm/ZAwQzJ+GOMLbBsTdDKOpuZh7RPs0UymvBR2vRk4iZWCskjbFnxqjrzoIvlNNRZ3QJFx6/qDSi6zSnaQ==", + "license": "MIT", "dependencies": { "@babel/core": "^7.16.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.3", @@ -15823,6 +15881,12 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, + "node_modules/shallowequal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", + "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==", + "license": "MIT" + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -16382,6 +16446,68 @@ "webpack": "^5.0.0" } }, + "node_modules/styled-components": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-6.1.13.tgz", + "integrity": "sha512-M0+N2xSnAtwcVAQeFEsGWFFxXDftHUD7XrKla06QbpUMmbmtFBMMTcKWvFXtWxuD5qQkB8iU5gk6QASlx2ZRMw==", + "license": "MIT", + "dependencies": { + "@emotion/is-prop-valid": "1.2.2", + "@emotion/unitless": "0.8.1", + "@types/stylis": "4.2.5", + "css-to-react-native": "3.2.0", + "csstype": "3.1.3", + "postcss": "8.4.38", + "shallowequal": "1.1.0", + "stylis": "4.3.2", + "tslib": "2.6.2" + }, + "engines": { + "node": ">= 16" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/styled-components" + }, + "peerDependencies": { + "react": ">= 16.8.0", + "react-dom": ">= 16.8.0" + } + }, + "node_modules/styled-components/node_modules/postcss": { + "version": "8.4.38", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", + "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.7", + "picocolors": "^1.0.0", + "source-map-js": "^1.2.0" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/styled-components/node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "license": "0BSD" + }, "node_modules/stylehacks": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-5.1.1.tgz", @@ -16397,6 +16523,12 @@ "postcss": "^8.2.15" } }, + "node_modules/stylis": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.2.tgz", + "integrity": "sha512-bhtUjWd/z6ltJiQwg0dUfxEJ+W+jdqQd8TbWLWyeIJHlnsqmGLRFFd8e5mA0AZi/zx90smXRlN66YMTcaSFifg==", + "license": "MIT" + }, "node_modules/sucrase": { "version": "3.35.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", @@ -19681,6 +19813,24 @@ "integrity": "sha512-+OJ9konv95ClSTOJCmMZqpd5+YGsB2S+x6w3E1oaM8UuR5j8nTNHYSz8c9BEPGDOCMQYIEEGlVPj/VY64iTbGw==", "requires": {} }, + "@emotion/is-prop-valid": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-1.2.2.tgz", + "integrity": "sha512-uNsoYd37AFmaCdXlg6EYD1KaPOaRWRByMCYzbKUX4+hhMfrxdVSelShywL4JVaAeM/eHUOSprYBQls+/neX3pw==", + "requires": { + "@emotion/memoize": "^0.8.1" + } + }, + "@emotion/memoize": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.8.1.tgz", + "integrity": "sha512-W2P2c/VRW1/1tLox0mVUalvnWXxavmv/Oum2aPsRcoDJuob75FC3Y8FbpfLwUegRcxINtGUMPq0tFCvYNTBXNA==" + }, + "@emotion/unitless": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/@emotion/unitless/-/unitless-0.8.1.tgz", + "integrity": "sha512-KOEGMu6dmJZtpadb476IsZBclKvILjopjUii3V+7MnXIQCYh8W3NgNcgwo21n9LXZX6EDIKvqfjYxXebDwxKmQ==" + }, "@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -21307,6 +21457,11 @@ "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.3.tgz", "integrity": "sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==" }, + "@types/stylis": { + "version": "4.2.5", + "resolved": "https://registry.npmjs.org/@types/stylis/-/stylis-4.2.5.tgz", + "integrity": "sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw==" + }, "@types/testing-library__jest-dom": { "version": "5.14.9", "resolved": "https://registry.npmjs.org/@types/testing-library__jest-dom/-/testing-library__jest-dom-5.14.9.tgz", @@ -22367,6 +22522,11 @@ "resolved": "https://registry.npmjs.org/camelcase-css/-/camelcase-css-2.0.1.tgz", "integrity": "sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==" }, + "camelize": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/camelize/-/camelize-1.0.1.tgz", + "integrity": "sha512-dU+Tx2fsypxTgtLoE36npi3UqcjSSMNYfkqgmoEhtZrraP5VWq0K7FkWVTYa8eMPtnU/G2txVsfdCJTn9uzpuQ==" + }, "caniuse-api": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-3.0.0.tgz", @@ -22682,6 +22842,11 @@ "postcss-selector-parser": "^6.0.9" } }, + "css-color-keywords": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz", + "integrity": "sha512-FyyrDHZKEjXDpNJYvVsV960FiqQyXc/LlYmsxl2BcdMb2WPx0OGRVgTg55rPSyLSNMqP52R9r8geSp7apN3Ofg==" + }, "css-declaration-sorter": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/css-declaration-sorter/-/css-declaration-sorter-6.4.1.tgz", @@ -22754,6 +22919,16 @@ "resolved": "https://registry.npmjs.org/css-select-base-adapter/-/css-select-base-adapter-0.1.1.tgz", "integrity": "sha512-jQVeeRG70QI08vSTwf1jHxp74JoZsr2XSgETae8/xC8ovSnL2WF87GTLO86Sbwdt2lK4Umg4HnnwMO4YF3Ce7w==" }, + "css-to-react-native": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz", + "integrity": "sha512-e8RKaLXMOFii+02mOlqwjbD00KSEKqblnpO9e++1aXS1fPQOpS1YoqdVHBqPjHNoxeF2mimzVqawm2KCbEdtHQ==", + "requires": { + "camelize": "^1.0.0", + "css-color-keywords": "^1.0.0", + "postcss-value-parser": "^4.0.2" + } + }, "css-tree": { "version": "1.0.0-alpha.37", "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-1.0.0-alpha.37.tgz", @@ -29258,6 +29433,11 @@ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" }, + "shallowequal": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz", + "integrity": "sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==" + }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -29678,6 +29858,39 @@ "integrity": "sha512-0WqXzrsMTyb8yjZJHDqwmnwRJvhALK9LfRtRc6B4UTWe8AijYLZYZ9thuJTZc2VfQWINADW/j+LiJnfy2RoC1w==", "requires": {} }, + "styled-components": { + "version": "6.1.13", + "resolved": "https://registry.npmjs.org/styled-components/-/styled-components-6.1.13.tgz", + "integrity": "sha512-M0+N2xSnAtwcVAQeFEsGWFFxXDftHUD7XrKla06QbpUMmbmtFBMMTcKWvFXtWxuD5qQkB8iU5gk6QASlx2ZRMw==", + "requires": { + "@emotion/is-prop-valid": "1.2.2", + "@emotion/unitless": "0.8.1", + "@types/stylis": "4.2.5", + "css-to-react-native": "3.2.0", + "csstype": "3.1.3", + "postcss": "8.4.38", + "shallowequal": "1.1.0", + "stylis": "4.3.2", + "tslib": "2.6.2" + }, + "dependencies": { + "postcss": { + "version": "8.4.38", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz", + "integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==", + "requires": { + "nanoid": "^3.3.7", + "picocolors": "^1.0.0", + "source-map-js": "^1.2.0" + } + }, + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==" + } + } + }, "stylehacks": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/stylehacks/-/stylehacks-5.1.1.tgz", @@ -29687,6 +29900,11 @@ "postcss-selector-parser": "^6.0.4" } }, + "stylis": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/stylis/-/stylis-4.3.2.tgz", + "integrity": "sha512-bhtUjWd/z6ltJiQwg0dUfxEJ+W+jdqQd8TbWLWyeIJHlnsqmGLRFFd8e5mA0AZi/zx90smXRlN66YMTcaSFifg==" + }, "sucrase": { "version": "3.35.0", "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", diff --git a/package.json b/package.json index af506b2..64e289d 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "@testing-library/user-event": "^13.5.0", "react": "^18.3.1", "react-dom": "^18.3.1", - "react-scripts": "5.0.1", + "react-scripts": "^5.0.1", + "styled-components": "^6.1.13", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/src/App.js b/src/App.js index 777b355..013527d 100644 --- a/src/App.js +++ b/src/App.js @@ -1,9 +1,84 @@ -function App() { +import React, { useState, useEffect } from "react"; +import { + AppContainer, Header, Main, TodoContainer, + TodoHeader, TodoList, TodoItem, TodoInput, + Input, Button, RemoveButton +} from './styles'; +import { GlobalStyle } from './styles'; + +const App = () => { + const [todos, setTodos] = useState([]); // 할 일 목록 관리 + const [newTodo, setNewTodo] = useState(""); // 새로 추가될 할 일 관리 + const [currentDate, setCurrentDate] = useState(""); // 현재 날짜 저장 + + // 컴포넌트 마운트 시 현재 날짜 설정 + useEffect(() => { + const today = new Date(); + const days = ["일", "월", "화", "수", "목", "금", "토"]; + setCurrentDate( + `${today.getMonth() + 1}월 ${today.getDate()}일 ${days[today.getDay()]}요일` + ); + }, []); + + // 할 일 추가 + const addTodo = () => { + if (newTodo.trim()) { + setTodos([...todos, newTodo]); + setNewTodo(""); // 입력창 초기화 + } + }; + + // 할 일 삭제 + const removeTodo = (index) => { + const updatedTodos = todos.filter((_, i) => i !== index); + setTodos(updatedTodos); + }; + + // 엔터키로 할 일 추가 + const handleKeyDown = (e) => { + if (e.key === "Enter") { + addTodo(); + } + }; + return ( -
-

🐶CEOS 20기 프론트엔드 최고🐶

-
+ <> + {/* 글로벌 스타일 적용 */} + +
+

✔ To Do

+
+
+ + +

오늘 할 일

+

{currentDate}

{/* 현재 날짜 출력 */} +
+ + + {todos.map((todo, index) => ( + + {todo} + removeTodo(index)}>삭제 + + ))} + + + + setNewTodo(e.target.value)} + onKeyDown={handleKeyDown} + placeholder="할 일 추가" + /> + + +
+
+
+ ); -} +}; export default App; diff --git a/src/styles.js b/src/styles.js new file mode 100644 index 0000000..ec6960c --- /dev/null +++ b/src/styles.js @@ -0,0 +1,101 @@ +import styled from 'styled-components'; +import { createGlobalStyle } from 'styled-components'; + +export const GlobalStyle = createGlobalStyle` + * { + margin: 0; + padding: 0; + box-sizing: border-box; + } + + html, body { + height: 100%; + } + + body { + font-family: Arial, sans-serif; + background-color: #121212; + color: white; + } +`; + +export const AppContainer = styled.div` + background-color: #121212; + color: white; + display: flex; + justify-content: center; + align-items: center; + height: 100vh; +`; + +export const Header = styled.header` + position: absolute; + top: 0; + left: 0; + padding: 20px; +`; + +export const Main = styled.main` + width: 300px; +`; + +export const TodoContainer = styled.section` + background-color: #1f1f1f; + padding: 20px; + border-radius: 10px; +`; + +export const TodoHeader = styled.div` + margin-bottom: 20px; +`; + +export const TodoList = styled.ul` + list-style: none; + padding: 0; + margin-bottom: 20px; +`; + +export const TodoItem = styled.li` + background-color: #2c2c2c; + padding: 10px; + border-radius: 5px; + margin-bottom: 10px; + display: flex; + justify-content: space-between; +`; + +export const TodoInput = styled.div` + display: flex; + justify-content: space-between; +`; + +export const Input = styled.input` + flex-grow: 1; + padding: 10px; + border-radius: 5px; + border: none; + margin-right: 10px; +`; + +export const Button = styled.button` + padding: 10px 20px; + background-color: #4caf50; + border: none; + border-radius: 5px; + cursor: pointer; + &:hover { + background-color: #45a049; + } +`; + +export const RemoveButton = styled.button` + background-color: red; + color: white; + border: none; + border-radius: 5px; + cursor: pointer; + padding: 5px 10px; + &:hover { + background-color: darkred; + } +`; From a24bb81a5764b1f77ed4f99b1d546d853af4f5c5 Mon Sep 17 00:00:00 2001 From: Jisu <92006284+jsomnium@users.noreply.github.com> Date: Sat, 21 Sep 2024 23:28:09 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=ED=88=AC=EB=91=90=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C=20=EB=B2=84=ED=8A=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index 013527d..65eed13 100644 --- a/src/App.js +++ b/src/App.js @@ -23,7 +23,8 @@ const App = () => { // 할 일 추가 const addTodo = () => { if (newTodo.trim()) { - setTodos([...todos, newTodo]); + // 새로운 투두 객체를 생성 (complete 속성 추가) + setTodos([...todos, { text: newTodo, complete: false }]); setNewTodo(""); // 입력창 초기화 } }; @@ -34,6 +35,14 @@ const App = () => { setTodos(updatedTodos); }; + // 할 일 완료 + const completeTodo = (index) => { + const updatedTodos = todos.map((todo, i) => + i === index ? { ...todo, complete: !todo.complete } : todo + ); + setTodos(updatedTodos); // 상태 업데이트 + }; + // 엔터키로 할 일 추가 const handleKeyDown = (e) => { if (e.key === "Enter") { @@ -58,7 +67,14 @@ const App = () => { {todos.map((todo, index) => ( - {todo} + + {todo.text} + + removeTodo(index)}>삭제 ))} From 537121d72e91cac311c138c69dcceb800d271e54 Mon Sep 17 00:00:00 2001 From: Jisu <92006284+jsomnium@users.noreply.github.com> Date: Sat, 21 Sep 2024 23:34:23 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20todo,=20complete=20=EA=B0=9C?= =?UTF-8?q?=EC=88=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/App.js b/src/App.js index 65eed13..449e8e2 100644 --- a/src/App.js +++ b/src/App.js @@ -50,6 +50,9 @@ const App = () => { } }; + // 완료된 할 일 개수 + const completedTodosCount = todos.filter(todo => todo.complete).length; + return ( <> {/* 글로벌 스타일 적용 */} @@ -62,6 +65,12 @@ const App = () => {

오늘 할 일

{currentDate}

{/* 현재 날짜 출력 */} +
+ todo: {todos.length} {/* 투두 개수 */} +
+
+ complete: {completedTodosCount} {/* 완료된 투두 개수 */} +
From 2e0971a872c60d294099f1c1ad78af03d9cb982f Mon Sep 17 00:00:00 2001 From: Jisu <92006284+jsomnium@users.noreply.github.com> Date: Sat, 21 Sep 2024 23:51:10 +0900 Subject: [PATCH 4/8] =?UTF-8?q?style:=20css=20=EC=88=98=EC=A0=95=20(1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/styles.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/styles.js b/src/styles.js index ec6960c..4940bef 100644 --- a/src/styles.js +++ b/src/styles.js @@ -89,12 +89,13 @@ export const Button = styled.button` `; export const RemoveButton = styled.button` - background-color: red; + background-color: black; color: white; border: none; border-radius: 5px; cursor: pointer; padding: 5px 10px; + margin-left: 10px; /* 완료 버튼과 10px 간격 설정 */ &:hover { background-color: darkred; } From 931552909ceec0faf9415f24e99c74ba8b31390e Mon Sep 17 00:00:00 2001 From: Jisu <92006284+jsomnium@users.noreply.github.com> Date: Sun, 22 Sep 2024 02:04:40 +0900 Subject: [PATCH 5/8] =?UTF-8?q?style:=20css=20=EC=88=98=EC=A0=95=20(2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 20 ++++++++--------- src/styles.js | 61 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 48 insertions(+), 33 deletions(-) diff --git a/src/App.js b/src/App.js index 449e8e2..3a77ecb 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,7 @@ import React, { useState, useEffect } from "react"; import { - AppContainer, Header, Main, TodoContainer, - TodoHeader, TodoList, TodoItem, TodoInput, + AppContainer, Main, TodoContainer, MainText, Line, + TodoHeader, TodoList, TodoItem, TodoInput, TodoHeaderNew, Input, Button, RemoveButton } from './styles'; import { GlobalStyle } from './styles'; @@ -57,19 +57,19 @@ const App = () => { <> {/* 글로벌 스타일 적용 */} -
-

✔ To Do

-
+ Better

than

Yesterday!
+
-

오늘 할 일

{currentDate}

{/* 현재 날짜 출력 */}
- todo: {todos.length} {/* 투두 개수 */} -
-
- complete: {completedTodosCount} {/* 완료된 투두 개수 */} +
+ todo: {todos.length} {/* 투두 개수 */} +
+
+ complete: {completedTodosCount} {/* 완료된 투두 개수 */} +
diff --git a/src/styles.js b/src/styles.js index 4940bef..6b33a94 100644 --- a/src/styles.js +++ b/src/styles.js @@ -14,49 +14,53 @@ export const GlobalStyle = createGlobalStyle` body { font-family: Arial, sans-serif; - background-color: #121212; - color: white; + color: black; } `; +export const MainText = styled.div` +font-size: 50px; +font-weight: 600; +` + +export const Line = styled.div` +background-color: black; +width: 1.5px; +height: 100px; +margin-bottom: 10px; +` + export const AppContainer = styled.div` - background-color: #121212; - color: white; + margin-left: 70px; display: flex; justify-content: center; - align-items: center; height: 100vh; -`; - -export const Header = styled.header` - position: absolute; - top: 0; - left: 0; - padding: 20px; + flex-direction: column; `; export const Main = styled.main` - width: 300px; + height: 300px; + width: 800px; `; + export const TodoContainer = styled.section` - background-color: #1f1f1f; - padding: 20px; + height: 300px; + border-color: black; border-radius: 10px; -`; - -export const TodoHeader = styled.div` - margin-bottom: 20px; + border-width: 2px; + border-style: solid; + padding: 20px; `; export const TodoList = styled.ul` list-style: none; padding: 0; - margin-bottom: 20px; + margin-bottom: 10px; `; export const TodoItem = styled.li` - background-color: #2c2c2c; + background-color: #c1cad6; padding: 10px; border-radius: 5px; margin-bottom: 10px; @@ -67,6 +71,9 @@ export const TodoItem = styled.li` export const TodoInput = styled.div` display: flex; justify-content: space-between; + border-radius: 10px; + border-style: solid; + border-width: 1px; `; export const Input = styled.input` @@ -75,16 +82,18 @@ export const Input = styled.input` border-radius: 5px; border: none; margin-right: 10px; + background-color: transparent; + border-radius: 10px; `; export const Button = styled.button` padding: 10px 20px; - background-color: #4caf50; + background-color: #9899C2; border: none; border-radius: 5px; cursor: pointer; &:hover { - background-color: #45a049; + background-color: #6c6ea0; } `; @@ -100,3 +109,9 @@ export const RemoveButton = styled.button` background-color: darkred; } `; + +export const TodoHeader = styled.div` +display: flex; +height: 60px; +justify-content: space-between; +` \ No newline at end of file From 1d3fdcfc24dba38263379486bc76d98f89f07cba Mon Sep 17 00:00:00 2001 From: Jisu <92006284+jsomnium@users.noreply.github.com> Date: Sun, 22 Sep 2024 02:28:15 +0900 Subject: [PATCH 6/8] =?UTF-8?q?style:=20css=20=EC=88=98=EC=A0=95=20(3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 39 +++++++++++++++++++++++---------------- src/styles.js | 31 ++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/App.js b/src/App.js index 3a77ecb..27e9657 100644 --- a/src/App.js +++ b/src/App.js @@ -1,7 +1,7 @@ import React, { useState, useEffect } from "react"; import { - AppContainer, Main, TodoContainer, MainText, Line, - TodoHeader, TodoList, TodoItem, TodoInput, TodoHeaderNew, + AppContainer, Main, TodoContainer, MainText, Line, TodosBody, + TodoHeader, TodoList, TodoItem, TodoInput, Input, Button, RemoveButton } from './styles'; import { GlobalStyle } from './styles'; @@ -57,7 +57,11 @@ const App = () => { <> {/* 글로벌 스타일 적용 */} - Better

than

Yesterday!
+ + Better

+ than

+ Yesterday! +
@@ -73,9 +77,22 @@ const App = () => { - + + setNewTodo(e.target.value)} + onKeyDown={handleKeyDown} + placeholder="할 일 추가" + /> + + + + + {todos.map((todo, index) => ( + { > {todo.text} - removeTodo(index)}>삭제 ))} - - - setNewTodo(e.target.value)} - onKeyDown={handleKeyDown} - placeholder="할 일 추가" - /> - - + +
diff --git a/src/styles.js b/src/styles.js index 6b33a94..0164d91 100644 --- a/src/styles.js +++ b/src/styles.js @@ -39,13 +39,13 @@ export const AppContainer = styled.div` `; export const Main = styled.main` - height: 300px; - width: 800px; + height: 400px; + width: 400px; `; export const TodoContainer = styled.section` - height: 300px; + height: 400px; border-color: black; border-radius: 10px; border-width: 2px; @@ -60,7 +60,7 @@ export const TodoList = styled.ul` `; export const TodoItem = styled.li` - background-color: #c1cad6; + background-color: aliceblue; padding: 10px; border-radius: 5px; margin-bottom: 10px; @@ -74,21 +74,38 @@ export const TodoInput = styled.div` border-radius: 10px; border-style: solid; border-width: 1px; + margin-bottom: 10px; `; export const Input = styled.input` flex-grow: 1; padding: 10px; - border-radius: 5px; + border-radius: 7px; border: none; margin-right: 10px; background-color: transparent; border-radius: 10px; `; +export const TodosBody = styled.div` + height: 250px; + border-radius: 5px; + overflow-y: auto; + &::-webkit-scrollbar { + width: 8px; + height: 8px; + border-radius: 6px; + background: rgba(255, 255, 255, 0.4); + } + &::-webkit-scrollbar-thumb { + background: rgba(0, 0, 0, 0.3); + border-radius: 6px; + } +` + export const Button = styled.button` - padding: 10px 20px; - background-color: #9899C2; + padding: 8px 8px; + background-color: skyblue; border: none; border-radius: 5px; cursor: pointer; From 6b1e2996f4616c571d254200f923a52830a6ae4c Mon Sep 17 00:00:00 2001 From: Jisu <92006284+jsomnium@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:06:45 +0900 Subject: [PATCH 7/8] =?UTF-8?q?style:=20todo=EB=A5=BC=20=EB=82=A8=EC=9D=80?= =?UTF-8?q?=20=ED=95=A0=20=EC=9D=BC=20=EA=B0=9C=EC=88=98=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD,=20style=20=EC=9D=BC=EB=B6=80=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 25 +++++++++++++++++++++++++ package.json | 3 +++ src/App.js | 2 +- src/styles.js | 2 ++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 944f69a..9fdbd9c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,9 @@ "react-scripts": "^5.0.1", "styled-components": "^6.1.13", "web-vitals": "^2.1.4" + }, + "devDependencies": { + "prettier": "^3.3.3" } }, "node_modules/@adobe/css-tools": { @@ -14558,6 +14561,22 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", @@ -28471,6 +28490,12 @@ "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==" }, + "prettier": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", + "dev": true + }, "pretty-bytes": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/pretty-bytes/-/pretty-bytes-5.6.0.tgz", diff --git a/package.json b/package.json index 64e289d..cb1b16e 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "prettier": "^3.3.3" } } diff --git a/src/App.js b/src/App.js index 27e9657..937cc69 100644 --- a/src/App.js +++ b/src/App.js @@ -69,7 +69,7 @@ const App = () => {

{currentDate}

{/* 현재 날짜 출력 */}
- todo: {todos.length} {/* 투두 개수 */} + todo: {todos.length - completedTodosCount} {/* 투두 개수 */}
complete: {completedTodosCount} {/* 완료된 투두 개수 */} diff --git a/src/styles.js b/src/styles.js index 0164d91..52d2f7a 100644 --- a/src/styles.js +++ b/src/styles.js @@ -66,6 +66,7 @@ export const TodoItem = styled.li` margin-bottom: 10px; display: flex; justify-content: space-between; + word-break: break-all; `; export const TodoInput = styled.div` @@ -112,6 +113,7 @@ export const Button = styled.button` &:hover { background-color: #6c6ea0; } + white-space: nowrap; `; export const RemoveButton = styled.button` From 9f0b355bbf6b96ed9c216a4daad5337fe6b027c1 Mon Sep 17 00:00:00 2001 From: Jisu <92006284+jsomnium@users.noreply.github.com> Date: Mon, 23 Sep 2024 14:12:30 +0900 Subject: [PATCH 8/8] =?UTF-8?q?style:=20=EB=B2=84=ED=8A=BC=20=EC=A4=84?= =?UTF-8?q?=EB=B0=94=EA=BF=88=20=EA=B8=88=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/styles.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/styles.js b/src/styles.js index 52d2f7a..6648b16 100644 --- a/src/styles.js +++ b/src/styles.js @@ -127,6 +127,7 @@ export const RemoveButton = styled.button` &:hover { background-color: darkred; } + white-space: nowrap; `; export const TodoHeader = styled.div`