diff --git a/emotiondiary/public/assets/emotion1.png b/emotiondiary/public/assets/emotion1.png new file mode 100644 index 00000000..a4dbd08e Binary files /dev/null and b/emotiondiary/public/assets/emotion1.png differ diff --git a/emotiondiary/public/assets/emotion2.png b/emotiondiary/public/assets/emotion2.png new file mode 100644 index 00000000..52f61822 Binary files /dev/null and b/emotiondiary/public/assets/emotion2.png differ diff --git a/emotiondiary/public/assets/emotion3.png b/emotiondiary/public/assets/emotion3.png new file mode 100644 index 00000000..88d353fa Binary files /dev/null and b/emotiondiary/public/assets/emotion3.png differ diff --git a/emotiondiary/public/assets/emotion4.png b/emotiondiary/public/assets/emotion4.png new file mode 100644 index 00000000..b152643e Binary files /dev/null and b/emotiondiary/public/assets/emotion4.png differ diff --git a/emotiondiary/public/assets/emotion5.png b/emotiondiary/public/assets/emotion5.png new file mode 100644 index 00000000..047fcda9 Binary files /dev/null and b/emotiondiary/public/assets/emotion5.png differ diff --git a/emotiondiary/src/App.css b/emotiondiary/src/App.css index d1ff3d52..bb82961f 100644 --- a/emotiondiary/src/App.css +++ b/emotiondiary/src/App.css @@ -1,3 +1,102 @@ -.App { - padding: 20px; +@import url("https://fonts.googleapis.com/css2?family=Nanum+Pen+Script&family=Yeon+Sung&display=swap"); + +body { + background-color: #f6f6f6; + display: flex; + justify-content: center; + align-items: center; + font-family: "Nanum Pen Script", cursive; + min-height: 100vh; + margin: 0px; +} + +@media (min-width: 650px) { + .App { + width: 640px; + } +} + +@media (max-width: 650px) { + .App { + width: 90vw; + } +} + +#root { + background-color: white; + box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px; +} + +.App { + min-height: 100vh; + padding-left: 20px; + padding-right: 20px; +} + +/* My Button */ + +.MyButton { + cursor: pointer; + border: none; + border-radius: 5px; + + padding-top: 10px; + padding-bottom: 10px; + padding-left: 20px; + padding-right: 20px; + + font-size: 18px; + white-space: nowrap; + + font-family: "Nanum Pen Script", cursive; +} + +.MyButton_default { + background-color: #ececec; + color: black; +} + +.MyButton_positive { + background-color: #64c964; + color: white; +} + +.MyButton_negative { + background-color: #fd565f; + color: white; +} + +/* HEADER */ + +header { + padding-top: 20px; + padding-bottom: 20px; + + display: flex; + align-items: center; + border-bottom: 1px solid #e2e2e2; +} + +header > div { + display: flex; +} + +header .head_text { + width: 50%; + font-size: 25px; + justify-content: center; +} + +header .head_btn_left { + width: 25%; + justify-content: start; +} + +header .head_btn_right { + width: 25%; + justify-content: end; +} + +header button { + font-family: "Nanum Pen Script", cursive; } diff --git a/emotiondiary/src/App.js b/emotiondiary/src/App.js index dbe54f27..578a6f1c 100644 --- a/emotiondiary/src/App.js +++ b/emotiondiary/src/App.js @@ -1,10 +1,104 @@ import "./App.css"; +import { BrowserRouter, Route, Routes } from "react-router-dom"; + +import Home from "./pages/Home"; +import New from "./pages/New"; +import Edit from "./pages/Edit"; +import Diary from "./pages/Diary"; +import React, { useReducer, useRef } from "react"; + +const reducer = (state, action) => { + let newState = []; + + switch (action.type) { + case "INIT": { + return action.data; + } + case "CREATE": { + newState = [action.data, ...state]; + break; + } + case "REMOVE": { + newState = state.filter((it) => it.id !== action.targetId); + break; + } + case "EDIT": { + newState = state.map((it) => + it.id === action.data.id ? { ...action.data } : it + ); + break; + } + default: + return state; + } + + return newState; +}; + +export const DiaryStateContext = React.createContext(); +export const DiaryDispatchContext = React.createContext(); function App() { + const [data, dispatch] = useReducer(reducer, []); + + const dataId = useRef(0); + + // CREATE + const onCreate = (date, content, emotion) => { + dispatch({ + type: "CREATE", + data: { + id: dataId.current, + date: new Date(date).getTime(), + content, + emotion, + }, + }); + dataId.current += 1; + }; + + // REMOVE + const onRemove = (targetId) => { + dispatch({ + type: "REMOVE", + targetId, + }); + }; + + // EDIT + const onEdit = (targetId, date, content, emotion) => { + dispatch({ + type: "EDIT", + data: { + id: targetId, + date: new Date(date).getTime(), + content, + emotion, + }, + }); + }; + return ( -
이곳은 일기 상세 페이지 입니다.
+이곳은 일기 수정 페이지 입니다.
+ + + + +이곳은 홈 입니다.
+이곳은 일기 작성 페이지 입니다.
+