generated from GDG-on-Campus-SKHU/24-25-Assignment-template
-
Notifications
You must be signed in to change notification settings - Fork 6
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
전병주 과제 #3
Open
ByeongJu-Jeon
wants to merge
1
commit into
GDG-on-Campus-SKHU:main
Choose a base branch
from
ByeongJu-Jeon:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
전병주 과제 #3
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# React + TypeScript + Vite | ||
|
||
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
||
Currently, two official plugins are available: | ||
|
||
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh | ||
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
||
## Expanding the ESLint configuration | ||
|
||
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: | ||
|
||
- Configure the top-level `parserOptions` property like this: | ||
|
||
```js | ||
export default tseslint.config({ | ||
languageOptions: { | ||
// other options... | ||
parserOptions: { | ||
project: ['./tsconfig.node.json', './tsconfig.app.json'], | ||
tsconfigRootDir: import.meta.dirname, | ||
}, | ||
}, | ||
}) | ||
``` | ||
|
||
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked` | ||
- Optionally add `...tseslint.configs.stylisticTypeChecked` | ||
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config: | ||
|
||
```js | ||
// eslint.config.js | ||
import react from 'eslint-plugin-react' | ||
|
||
export default tseslint.config({ | ||
// Set the react version | ||
settings: { react: { version: '18.3' } }, | ||
plugins: { | ||
// Add the react plugin | ||
react, | ||
}, | ||
rules: { | ||
// other rules... | ||
// Enable its recommended rules | ||
...react.configs.recommended.rules, | ||
...react.configs['jsx-runtime'].rules, | ||
}, | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import js from '@eslint/js' | ||
import globals from 'globals' | ||
import reactHooks from 'eslint-plugin-react-hooks' | ||
import reactRefresh from 'eslint-plugin-react-refresh' | ||
import tseslint from 'typescript-eslint' | ||
|
||
export default tseslint.config( | ||
{ ignores: ['dist'] }, | ||
{ | ||
extends: [js.configs.recommended, ...tseslint.configs.recommended], | ||
files: ['**/*.{ts,tsx}'], | ||
languageOptions: { | ||
ecmaVersion: 2020, | ||
globals: globals.browser, | ||
}, | ||
plugins: { | ||
'react-hooks': reactHooks, | ||
'react-refresh': reactRefresh, | ||
}, | ||
rules: { | ||
...reactHooks.configs.recommended.rules, | ||
'react-refresh/only-export-components': [ | ||
'warn', | ||
{ allowConstantExport: true }, | ||
], | ||
}, | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Vite + React + TS</title> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
<script type="module" src="/src/main.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "5-project", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "tsc -b && vite build", | ||
"lint": "eslint .", | ||
"preview": "vite preview" | ||
}, | ||
"dependencies": { | ||
"react": "^18.3.1", | ||
"react-dom": "^18.3.1" | ||
}, | ||
"devDependencies": { | ||
"@eslint/js": "^9.13.0", | ||
"@types/react": "^18.3.12", | ||
"@types/react-dom": "^18.3.1", | ||
"@vitejs/plugin-react-swc": "^3.5.0", | ||
"eslint": "^9.13.0", | ||
"eslint-plugin-react-hooks": "^5.0.0", | ||
"eslint-plugin-react-refresh": "^0.4.14", | ||
"globals": "^15.11.0", | ||
"typescript": "~5.6.2", | ||
"typescript-eslint": "^8.11.0", | ||
"vite": "^5.4.10" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#root { | ||
max-width: 1280px; | ||
margin: 0 auto; | ||
padding: 2rem; | ||
text-align: center; | ||
} | ||
|
||
.container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-direction: column; | ||
width: 400px; | ||
height: 550px; | ||
box-shadow: 0px 0px 3px 3px #dee2e6; | ||
border-radius: 2px 2px 2px 2px; | ||
} | ||
|
||
.title { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 100%; | ||
height: 10%; | ||
font-size: 25px; | ||
color: rgba(102, 140, 255); | ||
} | ||
|
||
.sentence { | ||
width: 100%; | ||
height: 80%; | ||
border-top: 2px solid #dee2e6; | ||
border-bottom: 2px solid #dee2e6; | ||
} | ||
|
||
.bottom { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
flex-direction: row; | ||
width: 100%; | ||
height: 10%; | ||
} | ||
|
||
.today { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 50%; | ||
height: 100%; | ||
font-size: 14px; | ||
color: rgba(102, 140, 255); | ||
} | ||
|
||
.add { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 50%; | ||
height: 100%; | ||
font-size: 14px; | ||
color: rgba(102, 140, 255); | ||
} | ||
|
||
.sentence > input { | ||
width: 98%; | ||
height: 8%; | ||
border: none; | ||
outline: none; | ||
} | ||
|
||
.sentence > input:focus { | ||
outline: none; | ||
} | ||
|
||
ul { | ||
list-style-type: circle; | ||
padding: 0; | ||
} | ||
|
||
li { | ||
padding: 0px; | ||
height: 32px; | ||
display: flex; | ||
align-items: center; | ||
font-size: 12px; | ||
color: rgba(102, 140, 255); | ||
} | ||
|
||
button { | ||
margin-left: 10px; | ||
color: rgba(102, 140, 255); | ||
background-color: white; | ||
margin-left: auto; | ||
} | ||
|
||
.completed { | ||
text-decoration: line-through; | ||
color: #888; | ||
} | ||
form { | ||
padding: 10px; | ||
} | ||
|
||
.checkbox { | ||
width: 1rem; | ||
height: 1rem; | ||
border-radius: 50%; | ||
border: 1px solid #999; | ||
appearance: none; | ||
} | ||
|
||
.checkbox:checked { | ||
background: rgba(102, 140, 255); | ||
} | ||
|
||
.text { | ||
padding-left: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React, { useState } from "react"; | ||
import "./App.css"; | ||
|
||
type TodoList = { | ||
id: number; | ||
todoText: string; | ||
isDone: boolean; | ||
}; | ||
|
||
function App() { | ||
const [count, setCount] = useState(0); | ||
const [inputValue, setInputValue] = useState(""); | ||
|
||
const [itemList, setItemList] = useState([] as TodoList[]); | ||
|
||
const InputChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
setInputValue(event.target.value); | ||
}; | ||
Comment on lines
+16
to
+18
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. 이 부분에서 event: 는 e로 축약해서 적을 수 있어요! |
||
|
||
const AddItem = () => { | ||
if (inputValue.trim()) { | ||
const newItem: TodoList = { | ||
id: itemList.length + 1, | ||
todoText: inputValue, | ||
isDone: false, | ||
}; | ||
setItemList([...itemList, newItem]); | ||
setInputValue(""); | ||
setCount(count + 1); | ||
} else { | ||
alert("등록할 일정을 입력해주세요!"); | ||
} | ||
}; | ||
|
||
const DeleteItem = (id: number) => { | ||
const updatedList = itemList.filter((_, idx) => idx !== id); | ||
setItemList(updatedList); | ||
setCount(count - 1); | ||
}; | ||
Comment on lines
+35
to
+39
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. filter(_, idx) 부분에서 _ 이건 무엇을 의미하나요? |
||
|
||
const BoxChecked = (id: number) => { | ||
const updatedList = itemList.map((item, idx) => { | ||
if (idx === id) { | ||
item.isDone = !item.isDone; | ||
} | ||
return item; | ||
}); | ||
|
||
setItemList(updatedList); | ||
|
||
if (updatedList[id].isDone) { | ||
setCount(count - 1); | ||
} else { | ||
setCount(count + 1); | ||
} | ||
}; | ||
|
||
return ( | ||
<> | ||
<div className="container"> | ||
<div className="title">TodoList</div> | ||
<div className="sentence"> | ||
<input type="text" value={inputValue} onChange={InputChange} placeholder="오늘 할 일을 추가해보세요!" /> | ||
<ul> | ||
{itemList.map((item, id) => ( | ||
<li key={id}> | ||
<input type="checkbox" className="checkbox" checked={item.isDone} onChange={() => BoxChecked(id)} /> | ||
<p | ||
className="text" | ||
style={{ | ||
textDecoration: item.isDone ? "line-through" : "none", | ||
textDecorationColor: item.isDone ? "black" : "transparent", | ||
}} | ||
> | ||
{item.todoText} | ||
</p> | ||
<button onClick={() => DeleteItem(id)}>삭제</button> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
<div className="bottom"> | ||
<p className="today">오늘 할 일 {count}</p> | ||
<p className="add" onClick={AddItem}> | ||
추가하기 | ||
</p> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default App; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
할 일 개수를 관리하는 이 count 상태가 꼭 필요한지 생각해보세요!
이렇게 타입과 초기값을 명확히 추가하시는게 좋아요!