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
5주차 과제 제출... #6
Open
k-loopy
wants to merge
1
commit into
GDG-on-Campus-SKHU:main
Choose a base branch
from
k-loopy: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
5주차 과제 제출... #6
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": "todolist", | ||
"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,11 @@ | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
} | ||
.App { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
} |
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 @@ | ||
import React from 'react'; | ||
import './App.css'; | ||
import TodoList from './TodoList'; | ||
|
||
const App: React.FC = () => { | ||
return ( | ||
<div className="App"> | ||
<TodoList /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default App; |
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,103 @@ | ||
.container { | ||
width: 400px; | ||
height: 600px; | ||
margin: auto; | ||
border-radius: 4px; | ||
box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.15); | ||
padding: 20px; | ||
background-color: white; | ||
color: rgba(102, 140, 255); | ||
font-family: Arial, sans-serif; | ||
} | ||
h1 { | ||
font-size: 25px; | ||
text-align: center; | ||
color: rgba(102, 140, 255); | ||
border-bottom: 1px solid #f4f0f0; | ||
padding-bottom: 10px; | ||
margin-bottom: 20px; | ||
} | ||
.todo-input { | ||
display: flex; | ||
width: 100%; | ||
} | ||
.todo-input input { | ||
width: 100%; | ||
height: 50%; | ||
padding: 15px; | ||
font-size: 14px; | ||
border: none; | ||
outline: none; | ||
border-radius: 5px; | ||
margin-top: 10px; | ||
box-sizing: border-box; | ||
} | ||
ul { | ||
list-style: none; | ||
padding: 0; | ||
margin-top: 10px; | ||
max-height: 400px; | ||
overflow-y: auto; | ||
} | ||
li { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 10px; | ||
padding: 10px; | ||
border-radius: 5px; | ||
font-size: 14px; | ||
} | ||
li.done { | ||
text-decoration: line-through; | ||
color: rgba(102, 140, 255); | ||
} | ||
li.done span { | ||
text-decoration: line-through; | ||
color: inherit; | ||
} | ||
.circle-checkbox { | ||
display: flex; | ||
align-items: center; | ||
} | ||
.circle-checkbox input { | ||
display: none; | ||
} | ||
.circle-checkbox .checkmark { | ||
height: 14px; | ||
width: 14px; | ||
background-color: white; | ||
border: 2px solid rgba(102, 140, 255); | ||
border-radius: 50%; | ||
cursor: pointer; | ||
} | ||
.circle-checkbox input:checked + .checkmark { | ||
background-color: rgba(102, 140, 255); | ||
border: 2px solid rgba(102, 140, 255); | ||
} | ||
.delete-btn { | ||
background: none; | ||
border: none; | ||
color: rgba(102, 140, 255); | ||
font-size: 14px; | ||
cursor: pointer; | ||
text-decoration: none; | ||
} | ||
footer { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
font-size: 12px; | ||
padding-top: 20px; | ||
border-top: 1px solid #eee; | ||
} | ||
.footer-add-btn { | ||
background-color: white; | ||
color: rgba(102, 140, 255); | ||
padding: 6px 12px; | ||
border: none; | ||
border-radius: 5px; | ||
border-top: #ccc; | ||
cursor: pointer; | ||
font-size: 12px; | ||
} | ||
|
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,79 @@ | ||
import React, { useState } from 'react'; | ||
import './TodoList.css'; | ||
|
||
type Todo = { | ||
id: number; | ||
todoText: string; | ||
isDone: boolean; | ||
}; | ||
|
||
const TodoList: React.FC = () => { | ||
const [todos, setTodos] = useState<Todo[]>([]); | ||
const [input, setInput] = useState<string>(""); | ||
|
||
const addTodo = (): void => { | ||
if (input.trim() === "") { | ||
alert("등록할 일정을 입력해주세요!"); | ||
return; | ||
} | ||
const newTodo: Todo = { | ||
id: Date.now(), | ||
todoText: input, | ||
isDone: false, | ||
}; | ||
setTodos([...todos, newTodo]); | ||
setInput(""); | ||
}; | ||
|
||
const toggleTodo = (id: number): void => { | ||
setTodos( | ||
todos.map((todo) => | ||
todo.id === id ? { ...todo, isDone: !todo.isDone } : todo | ||
) | ||
); | ||
}; | ||
|
||
const deleteTodo = (id: number): void => { | ||
setTodos(todos.filter((todo) => todo.id !== id)); | ||
}; | ||
Comment on lines
+14
to
+38
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. 함수의 반환값이 없다는 것을 명시적으로 작성해주셨네요! |
||
|
||
const remainingTodos: number = todos.filter((todo) => !todo.isDone).length; | ||
|
||
return ( | ||
<div className="container"> | ||
<h1>TodoList</h1> | ||
<div className="todo-input"> | ||
<input | ||
type="text" | ||
value={input} | ||
onChange={(e) => setInput(e.target.value)} | ||
placeholder="오늘 할 일을 추가해보세요!" | ||
/> | ||
</div> | ||
<ul> | ||
{todos.map((todo) => ( | ||
<li key={todo.id} className={todo.isDone ? "done" : ""}> | ||
<label className="circle-checkbox"> | ||
<input | ||
type="checkbox" | ||
checked={todo.isDone} | ||
onChange={() => toggleTodo(todo.id)} | ||
/> | ||
<span className="checkmark"></span> | ||
</label> | ||
<span>{todo.todoText}</span> | ||
<button onClick={() => deleteTodo(todo.id)} className="delete-btn"> | ||
삭제 | ||
</button> | ||
</li> | ||
))} | ||
</ul> | ||
<footer> | ||
<span>오늘 할 일 {remainingTodos}</span> | ||
<button onClick={addTodo} className="footer-add-btn">추가하기</button> | ||
</footer> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TodoList; |
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,8 @@ | ||
html, body { | ||
width: 100%; | ||
height: 100%; | ||
font-family: Arial, sans-serif; | ||
} | ||
#root { | ||
height: 100%; | ||
} |
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,10 @@ | ||
import { StrictMode } from 'react' | ||
import { createRoot } from 'react-dom/client' | ||
import './index.css' | ||
import App from './App.tsx' | ||
|
||
createRoot(document.getElementById('root')!).render( | ||
<StrictMode> | ||
<App /> | ||
</StrictMode>, | ||
) |
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 @@ | ||
/// <reference types="vite/client" /> |
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.
React.FC가 무엇인가요? 이렇게 작성하신 이유도 알려주세요