2022. 3. 21. 23:25ใWEB Dev/ToyProject
๐ท CloneTodo โ - Todomate Clone Project | Team CloneMate
CloneTodo : ๋ง์ ์ฌ๋๋ค์ด ์ฌ๋ํ๋ ํฌ๋๋ฉ์ดํธ๋ฅผ ํด๋ก ํ์ฌ ์น ์๋น์ค๋ฅผ ๋ฐฐํฌํด๋ณด๋ ํ๋ก์ ํธ
์์ฐ ์์ฒญ ์ค๋๋ง์ ํ ์ดํ๋ก์ ํธ ๋ฌธ์๋ฅผ ์์ฑํด๋ณธ๋ค.
๊ทธ๋์ ์์ ์ ์ํ ๊ฑด ์๋๊ณ ๊ธ์ ์ ๋ ์๊ฐ์ ๋นจ๋ฆฌ ๊ฐ๋ฐ์ ํด์ผ๊ฒ ๋ค๋ ์๊ฐ์ ๊ธ์ ์ข ์์ ํ๋ค.
๊ทธ๋์ ํ ์ผ์
1. ํฌ๋๋ฅผ ํด๋ฆญํ์ ๋ ๋์์ง๋ ๋ชจ๋ฌ์ ๋ชจ๋ ๊ธฐ๋ฅ์ ๊ตฌํ - ์์ , ๋ด์ผํ๊ธฐ, ๋ ์ง๋ฐ๊พธ๊ธฐ, ์์๋ณ๊ฒฝ, ์ญ์
์์ , ๋ด์ผํ๊ธฐ, ๋ ์ง ๋ฐ๊พธ๊ธฐ, ์ญ์ ๊ธฐ๋ฅ์ ๊ตฌํํ๋ค.
๊ทธ๋ฆฌ๊ณ ์์ ๋ณ๊ฒฝ์ ๋ณ๋ ํ์ด์ง๋ก ๋ฆฌ๋๋ ์ ํด์ ์์๋ฅผ ๋ณ๊ฒฝํ๋๋ก ํด์ผํ๋๋ฐ
์ด ๋ก์ง์ด ์กฐ๊ธ ๋ณต์กํด์ ๋ฐฑ์๋ ํ์๋ถ๊ณผ ๋์ค์ ๊ฐ์ด ์์ ํ๊ธฐ๋ก ํ๋ค.
๋๋๊ทธ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํด์ ๋์ถฉ ๋ง๋ค์ด๋ณด๊ธฐ๋ ํ๋๋ฐ ์ง์ ์ด ๋ง์ด ์๋์๋ค.
๋ด์ผ ํ๊ธฐ์ ๋ ์ง๋ฐ๊พธ๊ธฐ๋ฅผ ํด๋ฆญํ ๊ฒฝ์ฐ datepicker๋ฅผ ์จ์ ๋ ์ง๋ฅผ ์ ํํ๊ณ , ํ์ธ์ ๋๋ฅด๋ฉด state๊ฐ ๋ฐ๋๋๋ก ํ์๋ค.
2. ๊ฐํธ ์ ๋ ฅ ๊ตฌํ
๊ฐํธ ์ ๋ ฅ์ด๋ผ๋ UI๋ช ์ด ์๋ฟ์ง ์๋ ๊ฒ ๊ฐ์ ๋ด ์์ผ๋ก ๋ฐ๊ฟจ๋ค.
๊ธฐํ์ด ์๋ ํ ์ผ ์ค์ ์ด๋ผ๋ UI๋ช ์ผ๋ก ๋ฐ๊พธ๊ณ ๋ชฉํ๋ฅผ ๋ฟ๋ ค์ค ๋ค์ ๋ชฉํ๋ฅผ ํด๋ฆญํ๋ฉด ์๋ ์์์ด ์์ฑ๋๊ณ
์์ฑ๋ ์์์ ๋ฐ๋ณตํ ์ผ์ ๊ณผ ์์ผ์ ์ค์ ํ ๋ค์ ํ์ธ์ ํด๋ฆญํ๋ฉด state์ ์ฌ๋ผ๊ฐ ์ ์๋๋ก ๋ง๋ค์๋ค.
์บ๋ฆฐ๋๊ฐ ๊ฐ๊ฐ ์์ ๋ ์ง์ ์ข ๋ฃ ๋ ์ง์ ๊ฐ์ ์ ๋ฌํด์ผ ํด์ ๋ ๊ฐ๋ฅผ ๋ง๋ค์๋๋ฐ
ํ๋์ ์บ๋ฆฐ๋ ๋ชจ๋ฌ์ ์ด์ฉํด์ ๊ฐ input ๊ฐ์ ์ ๋ฌํ๋ ๋ฐฉ๋ฒ์ ์ธ ์ ์๋ค๋ฉด ์ข์์ ๊ฑฐ ๊ฐ๋ค.
๋์ค์ ์ด ๋ถ๋ถ์ ๋ฆฌํฉํ ๋ง ํ๋ ๊ฒ์ ๋ชฉํ๋ก ํ๊ณ ์๋ค.
3. CSS ๋ฏ์ด๊ณ ์น๊ธฐ
์ด๋ฐ์ CSS๋ฅผ ๋์ง๋์ง ๋ฐ๋ผ๋์ sx={{}} ์์ฑ์ผ๋ก ๋ง์ด ๋ถ์ฌ๋จ๋ค. ์ด ๋ถ๋ถ์ ๋ค ๋ผ์ SCSS๋ก CSS๋ฅผ ๊ตฌํํ๊ณ
๋ณ์๋ ๋ฏน์ค์ธ๋ ํ์ฉ์ ํ๋ค.
๊ฐ์ ๋์์ธ์ด ์ฌ๋ฌ๊ตฐ๋ฐ ๋ค์ด๊ฐ๋๋ฐ๋ ๋ถ๊ตฌํ๊ณ ๋ฏน์ค์ธ์ ์ฐ๋ ์คํ๋ ค ๋ ๋ณด์๊ฐ ๋ถํธํ ๋๋์ด ์์๋๋ฐ
ํต์ ์ฐ๊ฒฐ๊น์ง ๋๋๋ฉด CSS๋ฅผ ์ต์ข ์์ ํด๋ณด๋ ค๊ณ ํ๋ค.
4. ๊ธฐ์กด์ ๋ชฉํ ๋ฐ๋ก ํฌ๋ ๋ฐ๋ก API Result ํตํฉ
๊ธฐ์กด์ ์๋์ ๊ฐ์ด goal ๋ฐ์ดํฐ์ todo ๋ฐ์ดํฐ๋ฅผ ๋ฐ๋ก ์ผ์๋๋ฐ
//๋ชฉํ ๋ฐ์ดํฐ
export const goalsData = atom({ // ๋ก๋ฉ ์ ๋ชจ๋ ๋ชฉํ ๋ฟ๋ฆฌ๊ธฐ
key: "goalsData",
default: [
{
"goal_id": 0,
"next_goal_id": 1,
"title": "์ฒซ ๋ฒ์งธ ๋ชฉํ",
"privacy": "PUB",
"box_color": "",
"title_color": "#3CB371"
},
{
"goal_id": 1,
"next_goal_id": 2,
"title": "๋ ๋ฒ์งธ ๋ชฉํ",
"privacy": "PRI",
"box_color": "",
"title_color": "#234d22"
},
{
"goal_id": 2,
"next_goal_id": 3,
"title": "์ธ ๋ฒ์งธ ๋ชฉํ",
"privacy": "PRI",
"box_color": "",
"title_color": "#C71585"
},
{
"goal_id": 3,
"next_goal_id": 4,
"title": "๋ค ๋ฒ์งธ ๋ชฉํ",
"privacy": "PRI",
"box_color": "",
"title_color": "#21bdbd"
}
]
})
export const goalReadOnly = atom({
key: "goalReadOnly",
default: "read"
})
export const createRepeatDay = atom({
key: "createRepeatDay",
default: {
"sun": "N", //y ๋ฉด ์ผ์์ผ ๋ฐ๋ณต, n ์ด๋ฉด ๋ฐ๋ณต x
"mon": "N",
"tue": "N",
"wed": "N",
"thu": "N",
"fri": "N",
"sat": "N",
}
});
//ํฌ๋ ๋ฐ์ดํฐ
export const todoData = atom({ // ๋ก๋ฉ ์ ์ค๋ ๊ฐ ๋ฐ์์ค๊ธฐ // ์บ๋ฆฐ๋์์ ๋ ์ง ํด๋ฆญํ๋ฉด ํด๋น ๋ ์ง๋ก ๊ฐ ๋ฐ์์ค๊ธฐ // ๋๋ฏธ ๋ฐ์ดํฐ๋ 2022-02-05
key: "todoData",
default: [
{
"todo_id": 0,
"goal_id": 0, //๋ฌถ์ฌ์๋ goal id
"next_todo_id": 1, //๋ค์ todo id (์์์ง์ ์ฉ)
"title": "์ฒซ ๋ฒ์งธ ๋ชฉํ์ ํ ์ผ 0",
"date": "2022-02-05",
"end_repeat_date": "2022-02-05", //๋ฐ๋ณต ์ข
๋ฃ ์ผ์. ๋ฐ๋ณต ์์ผ๋ฉด date ์ ๊ฐ์ด ๊ฐ๊ฑฐ๋ ์์
"repeat_days": {
"sun": "N", //y ๋ฉด ์ผ์์ผ ๋ฐ๋ณต, n ์ด๋ฉด ๋ฐ๋ณต x
"mon": "N",
"tue": "N",
"wed": "N",
"thu": "N",
"fri": "N",
"sat": "N",
},
"check_yn" : "N" //๋ฌ์ฑ์ฌ๋ถ
},
{
"todo_id": 1,
"goal_id": 0, //๋ฌถ์ฌ์๋ goal id
"next_todo_id": 2, //๋ค์ todo id (์์์ง์ ์ฉ)
"title": "์ฒซ ๋ฒ์งธ ๋ชฉํ์ ํ ์ผ 1",
"date": "2022-02-05",
"end_repeat_date": "2022-02-05", //๋ฐ๋ณต ์ข
๋ฃ ์ผ์. ๋ฐ๋ณต ์์ผ๋ฉด date ์ ๊ฐ์ด ๊ฐ๊ฑฐ๋ ์์
"repeat_days": {
"sun": "N", //y ๋ฉด ์ผ์์ผ ๋ฐ๋ณต, n ์ด๋ฉด ๋ฐ๋ณต x
"mon": "N",
"tue": "N",
"wed": "N",
"thu": "N",
"fri": "N",
"sat": "N",
},
"check_yn" : "N" //๋ฌ์ฑ์ฌ๋ถ
},
{
"todo_id": 0,
"goal_id": 1, //๋ฌถ์ฌ์๋ goal id
"next_todo_id": 1, //๋ค์ todo id (์์์ง์ ์ฉ)
"title": "๋ ๋ฒ์งธ ๋ชฉํ์ ํ ์ผ 1",
"date": "2022-02-05",
"end_repeat_date": "2022-02-05", //๋ฐ๋ณต ์ข
๋ฃ ์ผ์. ๋ฐ๋ณต ์์ผ๋ฉด date ์ ๊ฐ์ด ๊ฐ๊ฑฐ๋ ์์
"repeat_days": {
"sun": "N", //y ๋ฉด ์ผ์์ผ ๋ฐ๋ณต, n ์ด๋ฉด ๋ฐ๋ณต x
"mon": "N",
"tue": "N",
"wed": "N",
"thu": "N",
"fri": "N",
"sat": "N",
},
"check_yn" : "N" //๋ฌ์ฑ์ฌ๋ถ
}
]
})
์ด๊ฒ์ ํ๋๋ก ๋ฌถ์ผ๋ฉด์ ๋ฐฐ์ด ์์ ๊ฐ์ฒด, ๊ฐ์ฒด ์์ ๋ฐฐ์ด ์ด๋ฐ ๊ตฌ์กฐ๊ฐ ๋์ด์ ํ๋ฉด ๋ณํ ๋ ๋๋ง ๋ก์ง์ ์ ๋ฉด ๊ต์ฒดํ๋ค.
๊ธฐ์กด ๋ชฉํ / ํฌ๋ ๋ฅผ ๋ชฉํ+ํฌ๋๋ก ๋ฐ๊พผ ๊ฒ.
// todo api
export const objTodosDataResult = atom({
key: 'objTodosDataResult',
default: [
{
goalTitle : "์ฒซ ๋ฒ์งธ ๋ชฉํ",
goalId: 1,
goalOrderNo : 1,
goalTitleColor : "#ff0000",
todos : [
{goalId: 1,
todoId: 1,
orderNo: 1,
title: "์ฒซ ๋ฒ์งธ ๋ชฉํ์ ์ฒซ ๋ฒ์งธ ํ ์ผ",
date: "2022-02-13",
endRepeatDate: "2022-02-13",
repeatDays: {
THU: "N",
WEN: "N",
TUE: "N",
SAT: "N",
FRI: "N",
MON: "N",
SUN: "N"
},
checkYn: "N"
},
{goalId: 1,
todoId: 2,
orderNo: 2,
title: "์ฒซ ๋ฒ์งธ ๋ชฉํ์ ๋ ๋ฒ์งธ ํ ์ผ",
date: "2022-02-13",
endRepeatDate: "2022-02-14",
repeatDays: {
THU: "N",
WEN: "N",
TUE: "N",
SAT: "N",
FRI: "N",
MON: "N",
SUN: "N"
},
checkYn: "N"
},
{goalId: 1,
todoId: 3,
orderNo: 3,
title: "์ฒซ ๋ฒ์งธ ๋ชฉํ์ ์ธ ๋ฒ์งธ ํ ์ผ",
date: "2022-02-13",
endRepeatDate: "2022-02-17",
repeatDays: {
THU: "N",
WEN: "Y",
TUE: "N",
SAT: "N",
FRI: "Y",
MON: "N",
SUN: "N"
},
checkYn: "N"
},
]},
{
goalTitle : "๋ ๋ฒ์งธ ๋ชฉํ",
goalId: 2,
goalOrderNo : 2,
goalTitleColor : "#ff873d",
todos : [
{goalId: 2,
todoId: 1,
orderNo: 1,
title: "๋ ๋ฒ์งธ ๋ชฉํ์ ์ฒซ ๋ฒ์งธ ํ ์ผ",
date: "2022-02-13",
endRepeatDate: "2022-02-13",
repeatDays: {
THU: "N",
WEN: "N",
TUE: "N",
SAT: "N",
FRI: "N",
MON: "N",
SUN: "N"
},
checkYn: "N"
},
{goalId: 2,
todoId: 2,
orderNo: 2,
title: "๋ ๋ฒ์งธ ๋ชฉํ์ ๋ ๋ฒ์งธ ํ ์ผ",
date: "2022-02-11",
endRepeatDate: "2022-02-15",
repeatDays: {
THU: "N",
WEN: "N",
TUE: "N",
SAT: "N",
FRI: "N",
MON: "N",
SUN: "N"
},
checkYn: "N"
},
]},
{
goalTitle : "์ธ ๋ฒ์งธ ๋ชฉํ",
goalId: 3,
goalOrderNo : 3,
goalTitleColor : "#0119cb",
todos : [
{goalId: 3,
todoId: 1,
orderNo: 1,
title: "์ธ ๋ฒ์งธ ๋ชฉํ์ ์ฒซ ๋ฒ์งธ ํ ์ผ",
date: "2022-02-16",
endRepeatDate: "2022-02-16",
repeatDays: {
THU: "N",
WEN: "N",
TUE: "N",
SAT: "N",
FRI: "N",
MON: "N",
SUN: "N"
},
checkYn: "N"
},
{goalId: 3,
todoId: 2,
orderNo: 2,
title: "์ธ ๋ฒ์งธ ๋ชฉํ์ ๋ ๋ฒ์งธ ํ ์ผ",
date: "2022-02-13",
endRepeatDate: "2022-02-19",
repeatDays: {
THU: "N",
WEN: "N",
TUE: "N",
SAT: "N",
FRI: "N",
MON: "N",
SUN: "N"
},
checkYn: "N"
},
]},
{
goalTitle : "๋ค ๋ฒ์งธ ๋ชฉํ",
goalId: 4,
goalOrderNo : 4,
goalTitleColor : "#77ab59",
todos : [
{goalId: 4,
todoId: 1,
orderNo: 1,
title: "๋ค ๋ฒ์งธ ๋ชฉํ์ ์ฒซ ๋ฒ์งธ ํ ์ผ",
date: "2022-02-16",
endRepeatDate: "2022-02-16",
repeatDays: {
THU: "N",
WEN: "N",
TUE: "N",
SAT: "N",
FRI: "N",
MON: "N",
SUN: "N"
},
checkYn: "N"
},
]},
]
})
5. ํ์ฌ ๋ ์ง์ ๋ชจ๋ ํ ์ผ ์์
Feed์์ ํ๋จ์ ... ๋ฒํผ ํด๋ฆญํ๋ฉด ์ค๋์ ํ ์ผ๋ค์ ํ ๋ฒ์ ๋ค๋ฃจ๋ ๋ฉ๋ด๊ฐ ์๋๋ฐ ์๋ ์ด๋ฆ์ ๋ ์ง๋ณ ํ ์ผ ์์ ์ด์๋ค. ์ด๊ฒ๋ ๊ฐํธ ์ ๋ ฅ์ฒ๋ผ ์ด๋ฆ์ ๋ฐ๊พธ์๋ค. ๋ ์ง๋ณ ํ ์ผ ์์ ์ผ๋ก.
๊ทธ๋ฆฌ๊ณ ๊ธฐ์กด ๋ชจ๋ฌ์ฒ๋ผ ์์ด์ฝ์ ๋ฃ์ UI๋ก ๋ฐ๊พธ์๋ค. ํ๋ฉด ์ฌ์ฌ์ฉ์ ์ํด ...
6. Calendar ๋๋ ์ ๋ ๋ ์ง ์ป์ด์ฌ ์ ์๋๋ก date ์ ๋ณด ๊ฐ์
๊ฐ ์บ๋ฆฐ๋ ๋ชจ๋ฌ์์ ๊ฐ๊ฐ ๊ด๋ฆฌ๋๋ date๋ฅผ Recoil์์ ๊ด๋ฆฌํ ์ ์๋๋ก date ๋ฐ์ดํฐ ๋ถ๋ถ์ ๋ณ๋๋ก ๋ง๋ค์๋ค.
const today = new Date();
const tomorrow = new Date(today);
const nextDay = new Date(tomorrow.setDate(today.getDate()+1))
//์ค๋ ๋ ์ง, ๋ด์ผ ๋ ์ง
export const objDatesData = atom({
key: 'objDatesData',
default : {
"dtToday" : today.toJSON().substring(0, 10),
"dtTomorrow" : nextDay.toJSON().substring(0, 10),
"dtFeedCalendarDate" : today,
"selectedNewDate" : new Date(),
"selectedNewEndDate" : new Date(),
}
})
7. ๋ถํ์ํ recoil state ์ญ์
์กฑ์ ๋น๋๊ณผ ๋ํ ์ค์ ๋ถํ์ํ๊ฒ recoil state๊ฐ ๋๋ฌดํ๊ณ ์๋ค๋ ์ฌ์ค์ ์์๊ณ
ํ์ผ ๋จ์๋ก ๋๋ ์ง๋ ์ปดํฌ๋ํธ ์ต์ 2๊ฐ ์ด์์์ ํ๋์ ๋ฐ์ดํฐ๋ฅผ ๊ณต์ฉ์ผ๋ก ์ฌ์ฉํ๊ฒ ๋๋ฉด atom์ผ๋ก ๊ด๋ฆฌํ๊ธฐ๋ก ํ๋ค.
๋ ์ง ์ ๋ณด๋ main์์ ํด๋ฆญํ๋ ์บ๋ฆฐ๋ ์ปดํฌ๋ํธ๊ฐ ์ฃผ๋ก ์ฌ์ฉํ๊ณ ๋๋จธ์ง๋ ๋ ์ง ๋ณ๊ฒฝ ์ ๋ํ๋๋ ์บ๋ฆฐ๋ ์ปดํฌ๋ํธ๋ก state ์์ ์ ํด์ค์ผ ํ๊ธฐ ๋๋ฌธ์ recoil๋ก ๊ด๋ฆฌํ๋ค.
todo๋ goal์ ๋งํ ๊ฒ๋ ์๊ณ ...
๋๋จธ์ง ์์ํ readonly ์์ฑ์ด๋ true false๋ง ๊ด๋ฆฌํ๋ ๋ถ๋ถ(๋ชจ๋ฌ์ฐฝ on/off ๊ฐ์)์ ๊ฐ๋ณ ์ปดํฌ๋ํธ๋ก ๋ค์ ์ฎ๊ฒจ ๋ฃ์๋ค.
์ด๋ฒ์ฃผ ํ ์ผ์
fetch ์ด์ฉํด์ ๋ฐ์ดํฐ ํต์ ๋ชจ๋์ ์ญ ๋ง๋ค์ด๋๊ณ ๊ฐ ์คํ ํจ์์ import ์ํค๊ณ
๋ฉ๋ด ์์ฑํด์ ๋ผ์ฐํธ๋ ์ ๋ฆฌํ๋ ๊ฒ์ธ๋ฐ
ํ ์ ์๊ฒ ์ง ์ฐํํ
'WEB Dev > ToyProject' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ToyProject-Todomate] ํฌ๋๋ฉ์ดํธ ํด๋ก ํ๋ก์ ํธ 36 (0) | 2022.02.08 |
---|---|
[ToyProject-Todomate] ํฌ๋๋ฉ์ดํธ ํด๋ก ํ๋ก์ ํธ 35 (0) | 2022.02.08 |
[ToyProject-Todomate] ํฌ๋๋ฉ์ดํธ ํด๋ก ํ๋ก์ ํธ 34 (0) | 2022.02.03 |
[ToyProject-Todomate] ํฌ๋๋ฉ์ดํธ ํด๋ก ํ๋ก์ ํธ 33 (0) | 2022.02.01 |
[ToyProject-Todomate] ํฌ๋๋ฉ์ดํธ ํด๋ก ํ๋ก์ ํธ 32 (0) | 2022.01.26 |