Skip to content
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주차] 유세은 미션 제출합니다. #17

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c373848
css:Background.js
YoommY2 Mar 25, 2022
a9ae2e3
Clock.js
YoommY2 Mar 25, 2022
017d1e3
css in js : clock.js
YoommY2 Mar 25, 2022
66eddc7
prettierrc
YoommY2 Mar 25, 2022
b93a1a7
Input form
YoommY2 Mar 25, 2022
4b31b4d
usestate를 통해 toDo와 toDos 관리
YoommY2 Mar 25, 2022
9c7dc48
input 설명 추가
YoommY2 Mar 25, 2022
bffe993
css 사용
YoommY2 Mar 25, 2022
11f9be4
todolist에서 이동과 삭제 구현
YoommY2 Mar 25, 2022
86baa08
donelist에서 이동과 삭제 구현
YoommY2 Mar 25, 2022
1a80341
style.css
YoommY2 Mar 25, 2022
69e228c
f
YoommY2 Mar 25, 2022
01d0f97
style: styled components install
YoommY2 Mar 27, 2022
2ac5314
modified: donelist nameing
YoommY2 Mar 27, 2022
cf4f6da
modified: toDo.js + styled components
YoommY2 Mar 27, 2022
87c6f95
modified : styled components in js
YoommY2 Mar 27, 2022
d2db47d
modified: done.js
YoommY2 Mar 27, 2022
ccf83f3
modified: styled components in done.js
YoommY2 Mar 27, 2022
e8fa5c5
modified : 중복된 스타일링 제거
YoommY2 Mar 27, 2022
34f5101
modified : Clocked component
YoommY2 Mar 27, 2022
96aadaa
refactor : todojs & style for list
YoommY2 Mar 29, 2022
2bc838e
style : todolist donelist design using props
YoommY2 Mar 29, 2022
bcf61ef
refactor : js in ts
YoommY2 Mar 29, 2022
c919dc0
build : eslintrc add
YoommY2 Mar 29, 2022
cae7c49
refactor : using hook for todo.js and done.js
YoommY2 Mar 30, 2022
9e5c1a7
refactor : Inputform.js
YoommY2 Mar 30, 2022
b18eb6f
chore : 주석 정리
YoommY2 Mar 30, 2022
7edb589
stlye : autofocus & spellCheck
YoommY2 Mar 30, 2022
d54b32f
chore : clock.js
YoommY2 Mar 30, 2022
1778e95
backup for js
YoommY2 Mar 30, 2022
661a42f
refactor : name for tsx
YoommY2 Mar 31, 2022
722a2f8
refactor : make a design interface
YoommY2 Mar 31, 2022
e505470
refactor : modified clock.tsx
YoommY2 Mar 31, 2022
8654c3b
refactor : make toDo prop type
YoommY2 Mar 31, 2022
056454c
refactor : make hook for Input and todo/done list
YoommY2 Mar 31, 2022
7a3fff3
chore : 디렉토리 루트 정리
YoommY2 Mar 31, 2022
9c89bdf
refactor : 전체 박스 디자인을 위한 tsx파일 추가
YoommY2 Mar 31, 2022
08fa742
chore : tsx파일로 바꾸기
YoommY2 Mar 31, 2022
261dbac
chore : props 추가하기
YoommY2 Mar 31, 2022
f205724
chore : 디렉토리 정리
YoommY2 Mar 31, 2022
023c79f
chore : usetoDo에 대한 코멘트 추가
YoommY2 Mar 31, 2022
dc76fa8
chore : type에 대한 코멘트 추가
YoommY2 Mar 31, 2022
efc3160
f
YoommY2 Apr 1, 2022
717e487
f
YoommY2 Apr 1, 2022
0a3ffab
fixed : prettier 적용
YoommY2 Apr 3, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules\\typescript\\lib"
}
17,213 changes: 17,150 additions & 63 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,25 @@
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.4",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^27.4.1",
"@types/node": "^17.0.23",
"@types/react": "^17.0.43",
"@types/react-dom": "^17.0.14",
"@types/styled-components": "^5.1.24",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"styled-components": "^5.3.3",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"lint": "eslint './src/**/*.{ts,tsx,js,jsx}'",
"prettier": "prettier --write --config ./.prettierrc './src/**/*.{ts,tsx}'",
"lint:fix": "eslint --fix './src/**/*.{ts,tsx,js,jsx}'"
},
"eslintConfig": {
"extends": [
Expand All @@ -34,5 +43,18 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^5.17.0",
"@typescript-eslint/parser": "^5.17.0",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
"prettier": "^2.6.2",
"typescript": "^4.6.3"
}
}
24 changes: 24 additions & 0 deletions public/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"prettier/react",
"prettier",
"airbnb",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

에어비앤비 룰 좋아요

"airbnb/hooks",
"prettier/react",
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
"rules": {
"no-console": 1,
"no-loops/no-loops": 2
}
}
7 changes: 7 additions & 0 deletions src/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"parser": "typescript",
"singleQuote": true
}
10 changes: 0 additions & 10 deletions src/App.js

This file was deleted.

47 changes: 47 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { useState } from "react";
import './Design/background';
import Clock from './clock';
import Todobox from "./component/ToDo";
import Donebox from "./component/Done";
import InputForm from "./component/Inputform";
import {Container, InputBox} from "./Design/BoxDesign";

function App() {
const [toDoList, setToDoList] = useState<string[]>([]);
const [doneToDoList, setDoneToDoList] = useState<string[]>([]);
Comment on lines +10 to +11

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useState 에도 타입설정을 해줘야하는지 지금 알았어요
세세한 디테일 좋네요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이상하게 타입을 지정해주지 않으면 제 코드에선 오류가 나더라구요😅아마 저는 props로 직접 전달해서 그런 것 같아요 ! 보통 생략하는 경우도 많더라구요!




return (
<div>
<Clock/>
<Container>
<h1>❗투두리스트❗</h1>
<InputBox>

<InputForm
toDoList={toDoList}
setToDoList ={setToDoList}/>
</InputBox>
<hr/>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음보는 태그입니다, 새롭게 배워가요~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hr태그가 있으면 중간에 선이 생겨 구분이 가능해지더라구요!


<Todobox
type = "Todo"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

텍스트는 중괄호 없이도 prop 전달이 되는군요!

setDoneToDoList ={setDoneToDoList}
ItemList = {toDoList}
setToDoList ={setToDoList}/>
<hr/>

<Donebox
type = "Done"
setDoneToDoList ={setDoneToDoList}
ItemList = {doneToDoList}
setToDoList ={setToDoList}/>
</Container>
</div>

);

}

export default App;
26 changes: 26 additions & 0 deletions src/Design/BoxDesign.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//Container 디자인 관리

import styled from 'styled-components';


export const Container = styled.div
`
text-align: center;
width: 360px;
height: 600px;
background-color: white;
display: flex;
flex-direction: column;
border-bottom: 1px solid grey;
border-radius: 9px;
`
;

export const InputBox = styled.header
`
font-family: 'SuncheonB';
flex: 0.2;
border-bottom: 1px solid grey;

`
;
43 changes: 43 additions & 0 deletions src/Design/ListDesign.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//list 디자인 관리
import styled from 'styled-components';

interface ILIst {

color ?:string;
decoration ?:string;

}
Comment on lines +4 to +9

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 이 부분 신경 못 썼는데 styled-components 에도 꼼꼼하게 해주셨네요


export const ListTitle = styled.div
`font-size: 20px;
`
;

export const List = styled.li<ILIst>
`
color: ${(props) => props.color || "black"};
text-decoration: ${(props) => props.decoration || "none"};
`
Comment on lines +4 to +20
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

styled component에서 interface를 사용하고, 태그 요소에 제네릭 사용하시는게 신기하네요. 심지어 props까지 받아서 사용하시고 styled component 잘쓰시는 것 같아요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이상하게 인터페이스를 만들지 않으면 props가 전달이 안되더라구요 ,,! 그래서 구글링 했더니 styled-component에서 props를 받으려면 인터페이스를 만들어줘야 한다고 합니다(?) 사실 저도 잘 모르겠다는,,,,


export const Button = styled.span
`
margin:4px;
`

export const Ul = styled.ul

`

margin: 0;
padding: 0;
flex: 0.5;
border-bottom: 1px solid grey;
overflow: auto;
list-style:none;
cursor: pointer;

`
;



13 changes: 13 additions & 0 deletions src/Design/background.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const colors : string[] = [
"#0fbcf9",
"#00d8d6",
"#05c46b",
"#ffc048",
"#ffdd59"

];

const firstColor = colors[Math.floor(Math.random() * colors.length)];
const secondColor = colors[Math.floor(Math.random() * colors.length)];

document.body.style.background = `linear-gradient(${firstColor}, ${secondColor})`;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

새로고침 할 때 마다 배경이 바뀌는 부분 예쁘네요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 컬러들도 추가해보겠습니다 😄

28 changes: 28 additions & 0 deletions src/GlobalStyle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { createGlobalStyle } from "styled-components";

const GlobalStyle = createGlobalStyle`

@font-face {
font-family: 'SuncheonB';
src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/[email protected]/SuncheonB.woff') format('woff');
font-weight: normal;
font-style: normal;
}

body{

font-family: 'SuncheonB';
font-size: 15px;
display: flex;
width: 100vh;
height: 100vh;
justify-content: center;
align-items: center;
margin: 0 auto;


}

`;

export default GlobalStyle;
36 changes: 36 additions & 0 deletions src/clock.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useEffect ,useState } from "react";
import styled from "styled-components";

function Clock() {
const [time, setTime] = useState<string>();

function getTime (){
const date = new Date();

const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");

let nowTime =`${hours}:${minutes}:${seconds}`;
setTime(nowTime);
}
Comment on lines +3 to +16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getTime을 functional component밖에서 정의하고 nowTime을 리턴하도록 해서
setTime(getTime()) 형태로 정의해도 좋을 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

훨씬 코드가 깔끔해질 것 같습니다 감사합니다!!


useEffect(()=>{
setInterval(getTime, 1000);
return () => {
setInterval(getTime, 1000)
}

},[]);

const Clock = styled.h1
`text-align: center`
;
Comment on lines +26 to +28
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

styled component도 functional component 밖에서 정의하는걸 추천하더라구요~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 놓친 부분~ 감사합니다!!



return <Clock>{time}</Clock>;

};


export default Clock;
36 changes: 36 additions & 0 deletions src/component/Done.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import styled, { createGlobalStyle } from "styled-components";
import { ListTitle, Button, Ul,List} from "../Design/ListDesign";
import useToDo from "../hooks/useToDo";
import {ItemList} from "../type/type";

/*type DoneProps = {

type : string;
setDoneToDoList: ()=>void;
doneToDoList : Array<string>;
setToDoList: ()=>void;
}
*/

function Done({type,setDoneToDoList ,ItemList ,setToDoList} : ItemList){

let list : string[] = ItemList;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list를 따로 정의하는 이유가 있는 것 인가요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ItemList를 props로 받아오고 바로 useToDo훅에 그 ItemList를 또 props로 전달하는데 이 과정에서 둘이 이름이 같아서인지(?) 제대로 전달이 안되더라구요 ㅠㅠ 그래서 한번 변수에 저장하고 했더니 전달이 잘 됐습니다!


const {deleteButton, moveButton} = useToDo({type,setDoneToDoList ,list ,setToDoList});
return (
<Ul className = "done-box">
<ListTitle>👻Done({ItemList.length})</ListTitle>
{ItemList.map((item, id) => (
<List color="gray" decoration ="line-through" key={id}>
<Button onClick={() => moveButton(item,id)}>📂</Button>
{item}
<Button onClick={() => deleteButton(item,id)}>❌</Button>
</List>

))}
</Ul>

);
}

export default Done;
Loading