-
Notifications
You must be signed in to change notification settings - Fork 10
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
[2주차] 김다희 미션 제출합니다. #7
base: master
Are you sure you want to change the base?
Changes from 1 commit
6dcc574
28b3988
98ebea1
8413d7b
c891652
a5cb109
a998d9d
cb4021e
cad0a1b
06e9d32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,16 +6,27 @@ dayjs.locale('ko') | |
|
||
//styles | ||
const DateWrapper = styled.div` | ||
background-color: bisque; | ||
width: 100%; | ||
height: 8.583rem; | ||
display: flex; | ||
flex-direction: column; | ||
border-bottom: 0.05rem solid #968E8E; | ||
` | ||
const Title = styled.div` | ||
|
||
text-align: end; | ||
color: #968E8E; | ||
font-weight: 200; | ||
font-size: 1.3rem; | ||
` | ||
const GetDate = styled.h1` | ||
|
||
margin: 0; | ||
font-size: 3rem; | ||
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. 코드 전반적으로 rem이라는 기준이 딱 잡혀있는 크기 단위를 적용해주신 것이, 여러 디바이스를 고려할 때 반응형 웹 디자인을 구축할 때 좋은 것 같습니다. 이렇게 적용하고 필요한 디바이스에서는 미디어 쿼리를 사용하여 예외 처리 느낌으로 코드를 구성하면 좋을 것 같네요 :) |
||
font-weight: bold; | ||
` | ||
const GetWeek = styled.h3` | ||
|
||
margin: 0.5rem 0; | ||
font-size: 2rem; | ||
font-weight: normal; | ||
` | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,42 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import { useState } from 'react' | ||
import {styled, css} from 'styled-components' | ||
import iconLineCheck from '../../assets/circle-check-regular.svg' | ||
import iconSolidCheck from '../../assets/circle-check-solid.svg' | ||
import iconDelete from '../../assets/circle-minus-solid.svg' | ||
|
||
|
||
|
||
const ItemsWrapper = styled.div` | ||
|
||
background-color: #fff; | ||
width: 90%; | ||
margin: 0.9rem auto; | ||
border: 0.05rem solid #CBC0C0; | ||
border-radius: 10px; | ||
box-shadow: 0px 4px 4px #CBC0C0; | ||
display: flex; | ||
flex-direction: row; | ||
` | ||
const TodoText = styled.div` | ||
|
||
display: flex; | ||
align-items: center; | ||
flex-grow: 1; | ||
margin: 1.4rem 0; | ||
padding: 0 1rem; | ||
font-size: 1.2rem; | ||
font-weight: normal; | ||
word-break:break-all; | ||
` | ||
const DeleteButton = styled.button` | ||
|
||
export const button = css` | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
margin: auto 1rem auto 0rem; | ||
` | ||
const CheckButton = styled.button` | ||
|
||
|
||
const DeleteButton = styled.img` | ||
${button} | ||
` | ||
const CheckButton = styled.img` | ||
${button} | ||
` | ||
|
||
function ListsItems({todo, data, deleteTodo, toggleTodo}) { | ||
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 앱 정도는 사실 상태의 개수가 그렇게 많지는 않기에 상위 컴포넌트에서 state를 선언하고 prop으로 꽂아주는
|
||
|
@@ -22,8 +45,13 @@ function ListsItems({todo, data, deleteTodo, toggleTodo}) { | |
return ( | ||
<ItemsWrapper> | ||
<TodoText>{todo}</TodoText> | ||
<DeleteButton onClick={() => deleteTodo(data.id)}>delete</DeleteButton> | ||
<CheckButton onClick={() => toggleTodo(data.id)}>check</CheckButton> | ||
<CheckButton | ||
onClick={() => toggleTodo(data.id)} | ||
src = {data.completed ? iconSolidCheck: iconLineCheck} | ||
></CheckButton> | ||
<DeleteButton | ||
onClick={() => deleteTodo(data.id)} | ||
Comment on lines
+50
to
+54
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. prop으로 전달 받은 핸들러 함수들을 |
||
src = {iconDelete}/> | ||
</ItemsWrapper> | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import React, { useEffect } from 'react'; | ||
import Date from './Date'; | ||
import styled from 'styled-components'; | ||
import {css} from 'styled-components'; | ||
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. 기존의 Scss나 Sass 같은 css 전처리기에서는 스타일링 코드를 일종의 "변수"처럼 활용할 수 있는데 |
||
import TodoInputField from './Lists/TodoInputField'; | ||
import { useState } from 'react'; | ||
import ListsItems from './Lists/ListsItems'; | ||
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. 매번 다른 컴포넌트들을 import 해올 때, 상대 경로로 적어주는 것이 약간 가독성을 해친다는 생각이 들었어요(근데 저도 이렇게 과제 했습니다....🤣). 유담님 코드 구경하는데 |
||
//전체 틀 잡기 | ||
const TodoContainer = styled.div` | ||
background-color: aliceblue; | ||
display: flex; | ||
flex-direction: column; | ||
width: 70vw; | ||
|
@@ -20,25 +20,47 @@ const TodoContainer = styled.div` | |
` | ||
|
||
//list가 표시되는 하단부 | ||
export const textCenter = css` | ||
width: 90%; | ||
display: flex; | ||
align-items: center; | ||
font-size: 1.4rem; | ||
font-weight: normal; | ||
` | ||
|
||
const Wrapper = styled.div` | ||
background-color: antiquewhite; | ||
display: flex; | ||
flex-direction: row; | ||
width: 100%; | ||
height: 40rem; | ||
` | ||
|
||
const TodoLists = styled.div` | ||
background-color: beige; | ||
display: flex; | ||
flex-direction: column; | ||
width:50%; | ||
` | ||
const DoneLists = styled.div` | ||
background-color: beige; | ||
display: flex; | ||
flex-direction: column; | ||
width:50%; | ||
h4{ | ||
${textCenter} | ||
color: black; | ||
margin: 0 auto; | ||
height: 4.5rem; | ||
} | ||
` | ||
|
||
const ListsWrapper = styled.div` | ||
flex-grow: 1; | ||
overflow: scroll; | ||
` | ||
const ListsCount = styled.div` | ||
|
||
${textCenter} | ||
color: #968E8E; | ||
justify-content: center; | ||
margin-top: 0.9rem; | ||
` | ||
|
||
export default function Todos() { | ||
|
@@ -63,8 +85,8 @@ const toggleTodo = (id) => { | |
}; | ||
|
||
|
||
const todoCount = lists.filter((data) => !data.completed).length; | ||
const doneCount = lists.filter((data) => data.completed).length; | ||
const todoCount = lists.filter((data) => !data.completed).length; | ||
const doneCount = lists.filter((data) => data.completed).length; | ||
|
||
|
||
return ( | ||
|
@@ -78,6 +100,7 @@ const toggleTodo = (id) => { | |
setLists={setLists} | ||
setValue={setValue} | ||
/> | ||
<ListsWrapper> | ||
{lists.map((data)=> | ||
data.completed ? <></>: | ||
<ListsItems | ||
|
@@ -88,12 +111,13 @@ const toggleTodo = (id) => { | |
deleteTodo = {deleteTodo} | ||
/> | ||
)} | ||
</ListsWrapper> | ||
<ListsCount>{todoCount} lists are left</ListsCount> | ||
</TodoLists> | ||
|
||
<DoneLists> | ||
<h4>Done</h4> | ||
<ListsWrapper> | ||
{lists.map((data)=> | ||
data.completed ? | ||
<ListsItems | ||
|
@@ -104,7 +128,7 @@ const toggleTodo = (id) => { | |
deleteTodo = {deleteTodo} | ||
/> : <></> | ||
)} | ||
|
||
</ListsWrapper> | ||
<ListsCount>{doneCount} lists are done! way to go : )</ListsCount> | ||
</DoneLists> | ||
</Wrapper> | ||
|
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.
check버튼 클릭시 todo ↔ done으로 이동하는걸
그냥 취소선이 아니라, 직접 이미지를 사용하셔서 체크 버튼이 채워지는 것으로 표현하신게 화면으로 보기에도 좋아 좋은 아이디어인 것 같습니다!