-
Notifications
You must be signed in to change notification settings - Fork 10
[1주차] 조성아 과제 제출합니다. #1
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
Open
sungahChooo
wants to merge
5
commits into
CEOS-Developers:main
Choose a base branch
from
sungahChooo:sungahChooo
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Binary file not shown.
This file contains hidden or 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,30 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="ko"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <title>투두 앱</title> | ||
| <link rel="stylesheet" href="style.css" /> | ||
| <link rel="icon" href="/favicon.ico"> | ||
| </head> | ||
| <body> | ||
| <h1 id="title"">To do list</h1> | ||
|
|
||
| <!-- 날짜별 조회 및 추가 날짜도 같이 사용 --> | ||
| <section id="get-by-date"> | ||
| <label for="filterDate">날짜: </label> | ||
| <input type="date" id="selectedDateInput" /> | ||
| </section> | ||
|
|
||
| <!-- 투두 입력 영역 --> | ||
| <section id="inputDiv"> | ||
| <input type="text" id="todoInput" placeholder="할 일을 입력하세요." /> | ||
| <button id="addBtn">추가</button> | ||
| <span id="countDisplay"></span> | ||
| </section> | ||
|
|
||
| <!-- 투두 리스트 영역 --> | ||
| <ul id="todoList"></ul> | ||
|
|
||
| <script src="script.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or 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,127 @@ | ||
| document.addEventListener("DOMContentLoaded", () => { | ||
| const todoInput = document.getElementById("todoInput"); | ||
| const addBtn = document.getElementById("addBtn"); | ||
| const todoList = document.getElementById("todoList"); | ||
| const selectedDateInput = document.getElementById("selectedDateInput"); | ||
| const countDisplay = document.getElementById("countDisplay"); | ||
| const title = document.getElementById("title"); // h1 선택 | ||
|
|
||
| //데이터 로드 & 초기화 | ||
| let todos = JSON.parse(localStorage.getItem("todos")) || []; | ||
|
|
||
| // 날짜 입력 기본값: 오늘 | ||
| selectedDateInput.value = getToday(); | ||
|
|
||
| // 초기 렌더링 | ||
| renderTodos(todos); | ||
|
|
||
| /*투두 추가기능*/ | ||
| addBtn.addEventListener("click", () => { | ||
sungahChooo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| const text = todoInput.value.trim(); | ||
| const date = selectedDateInput.value; | ||
|
|
||
| if (text === "" || date === "") { | ||
| alert("할 일과 날짜를 입력하세요!"); | ||
sungahChooo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return; | ||
| } | ||
|
|
||
| const todo = { | ||
| id: Date.now(), | ||
| text, | ||
| date, | ||
| completed: false, // 완료 여부 추가 | ||
| }; | ||
|
|
||
| todos.push(todo); | ||
| saveTodos(); | ||
| filterByDate(date); | ||
|
|
||
| todoInput.value = ""; | ||
| selectedDateInput.value = date; // 날짜 유지 | ||
| }); | ||
|
|
||
| /* 날짜별 조회 기능 */ | ||
| selectedDateInput.addEventListener("change", () => { | ||
| filterByDate(selectedDateInput.value); | ||
| }); | ||
|
|
||
| function filterByDate(date) { | ||
| if (!date) return; | ||
|
|
||
| const filtered = todos.filter((t) => t.date === date); | ||
| renderTodos(filtered); | ||
| countDisplay.textContent = `${filtered.length}개`; | ||
| } | ||
|
|
||
| /* 제목 클릭시 오늘 날짜로 조회 기능 */ | ||
| title.addEventListener("click", () => { | ||
| selectedDateInput.value = getToday(); // 날짜 오늘로 초기화 | ||
| filterByDate(selectedDateInput.value); // 조회 버튼 없이 바로 조회 | ||
| }); | ||
|
|
||
| /* 투두 렌더링 */ | ||
| function renderTodos(list) { | ||
| todoList.innerHTML = ""; | ||
|
|
||
| if (!list || list.length === 0) { | ||
| const empty = document.createElement("li"); | ||
| empty.textContent = "표시할 할 일이 없습니다."; | ||
| empty.style.listStyle = "none"; | ||
| todoList.appendChild(empty); | ||
| return; | ||
| } | ||
|
|
||
| list.forEach((todo) => { | ||
| const li = document.createElement("li"); | ||
| li.dataset.id = todo.id; | ||
|
|
||
| // 투두 완료 체크박스 | ||
| const checkbox = document.createElement("input"); | ||
| checkbox.type = "checkbox"; | ||
| checkbox.checked = todo.completed; | ||
| checkbox.addEventListener("change", () => { | ||
| todo.completed = checkbox.checked; | ||
| saveTodos(); | ||
| renderTodos(list); // 상태 업데이트 후 다시 렌더링 | ||
| }); | ||
|
|
||
| // 할 일 텍스트 | ||
| const span = document.createElement("span"); | ||
| span.textContent = todo.text; | ||
| if (todo.completed) { | ||
| span.style.textDecoration = "line-through"; // 완료시 취소선 | ||
| span.style.color = "gray"; | ||
| } | ||
|
|
||
| //삭제 버튼 | ||
| const delBtn = document.createElement("button"); | ||
| delBtn.textContent = "삭제"; | ||
| delBtn.classList.add("deleteBtn"); | ||
| delBtn.addEventListener("click", () => { | ||
| todos = todos.filter((t) => t.id !== todo.id); | ||
| saveTodos(); | ||
| renderTodos(todos); | ||
| }); | ||
|
|
||
| // li에 요소 추가 | ||
| li.appendChild(checkbox); | ||
| li.appendChild(span); | ||
| li.appendChild(delBtn); | ||
| todoList.appendChild(li); | ||
| }); | ||
| } | ||
|
|
||
| /* 로컬 스토리지 저장 */ | ||
| function saveTodos() { | ||
| localStorage.setItem("todos", JSON.stringify(todos)); | ||
| } | ||
| }); | ||
|
|
||
| /* 오늘 날짜 반환 */ | ||
| function getToday() { | ||
| const today = new Date(); | ||
| const year = today.getFullYear(); | ||
| const month = String(today.getMonth() + 1).padStart(2, "0"); | ||
| const day = String(today.getDate()).padStart(2, "0"); | ||
| return `${year}-${month}-${day}`; | ||
| } | ||
This file contains hidden or 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 url("https://cdn.jsdelivr.net/npm/pretendard/dist/web/static/pretendard.css"); | ||
| body { | ||
| font-family: "Pretendard", "Noto Sans KR", sans-serif; | ||
sungahChooo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| background-color: #f5f6fa; | ||
| margin: 0; | ||
| padding: 40px; | ||
| /*todo list들이 세로로 배열되도록*/ | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| } | ||
|
|
||
| #title { | ||
| color: #636161; | ||
| font-size: 28px; | ||
| margin-bottom: 20px; | ||
| cursor: pointer; | ||
| } | ||
| #title:hover { | ||
| color: purple; | ||
| } | ||
| #inputDiv { | ||
| width: 320px; | ||
| } | ||
|
|
||
| #todoInput { | ||
| padding: 7px 10px; | ||
| font-size: 16px; | ||
| border: 1px solid #ddd; | ||
| border-radius: 8px; | ||
| } | ||
|
|
||
| #todoInput:focus { | ||
| border-color: #4a90e2; | ||
| } | ||
|
|
||
| #addBtn { | ||
| margin-left: 4px; | ||
| padding: 5px 10px; | ||
| font-size: 16px; | ||
| background-color: #4a90e2; | ||
| color: white; | ||
| border: none; | ||
| border-radius: 8px; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| #addBtn:hover { | ||
| background-color: #357abd; | ||
| } | ||
| #countDisplay { | ||
| width: 30px; | ||
| margin-left: 10px; | ||
| font-size: large; | ||
| } | ||
|
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. |
||
| /* 리스트 */ | ||
| #todoList { | ||
| margin-top: 20px; | ||
| padding: 0; | ||
| } | ||
|
|
||
| #todoList li { | ||
| width: 320px; | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| background: white; | ||
| margin: 6px 0; | ||
| padding: 12px 16px; | ||
| border-radius: 8px; | ||
| box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); | ||
| font-size: 16px; | ||
| color: #444; | ||
| } | ||
|
|
||
| /* 삭제 버튼 */ | ||
| .deleteBtn { | ||
| background-color: transparent; | ||
| color: #e74c3c; | ||
| border: none; | ||
| font-size: 14px; | ||
| cursor: pointer; | ||
| width: 40px; | ||
| flex-shrink: 0; | ||
| } | ||
|
|
||
| .deleteBtn:hover { | ||
| color: #c0392b; | ||
| } | ||
|
|
||
| #get-by-date { | ||
| margin-bottom: 50px; | ||
| } | ||
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.
전체보기를 통해서 모든 할 일들을 조회할 수 있는 점은 좋은 듯합니다. 하지만, 전체보기 후에 오늘 날짜를 보려면, 날짜 캘린더 들어가서 클릭 후, 날짜를 클릭해야한다는 점에서 사용자 ux측면에서 불편한듯합니다ㅠ