+
@@ -81,20 +114,33 @@ const CreateArticleBody = () => {
- {curCate}
+
+ {
+ setCurCate(cateList[e.target.value]);
+ }}
+ >
+ {cateList.map((cate, idx) => {
+ return ;
+ })}
+
+
-
>
diff --git a/src/Pages/CreateArticlePage/CreateArticlePage.jsx b/src/Pages/CreateArticlePage/CreateArticlePage.jsx
index 76a27af..ac86fea 100644
--- a/src/Pages/CreateArticlePage/CreateArticlePage.jsx
+++ b/src/Pages/CreateArticlePage/CreateArticlePage.jsx
@@ -1,5 +1,7 @@
import { CreateArticleBody } from './Components';
+
import Styled from './CreateArticlePage.styled';
+
const CreateArticlePage = () => {
return (
<>
diff --git a/src/Pages/CreateArticlePage/CreateArticlePage.styled.js b/src/Pages/CreateArticlePage/CreateArticlePage.styled.js
index 99616b9..7c7e3f9 100644
--- a/src/Pages/CreateArticlePage/CreateArticlePage.styled.js
+++ b/src/Pages/CreateArticlePage/CreateArticlePage.styled.js
@@ -1,7 +1,9 @@
import styled from 'styled-components';
+
import GlobalStyled from 'Styled/Global.styled';
+
const CreateArticlePage = styled.div`
- .header {
+ .page_header {
position: fixed;
box-sizing: border-box;
@@ -74,7 +76,6 @@ const CreateArticlePage = styled.div`
flex-direction: column;
flex-grow: 1;
input {
- position: sticky;
top: 4.5rem;
flex-grow: 0;
box-sizing: border-box;
@@ -82,34 +83,66 @@ const CreateArticlePage = styled.div`
display: flex;
background-color: #fff;
padding: 0.9rem 1rem;
- border: 1px solid #ccc;
+ border: 1px solid
+ ${GlobalStyled.theme.createArticlePageInputBorderColor};
font-size: 1rem;
&:focus {
outline: none;
}
}
- textarea {
+ .editor {
flex-grow: 1;
box-sizing: border-box;
width: 100%;
- overflow: hidden;
-
- display: flex;
- background-color: #fff;
- padding: 0.9rem 1rem;
- border: 1px solid #ccc;
- resize: none;
- &:focus {
- outline: none;
+ .toastui-editor-dropdown-toolbar {
+ flex-wrap: wrap;
+ height: auto;
+ width: min-content;
+ }
+ .toastui-editor-popup {
+ width: auto;
+ max-width: 400px;
+ .toastui-editor-file-select-button {
+ width: auto;
+ padding: 0 4px;
+ font-size: 0.7rem;
+ }
+ @media (max-width: 480px) {
+ margin-left: 0px;
+ }
}
}
}
- p {
- position: fixed;
- color: rgba(0, 0, 0, 30%);
- bottom: 10px;
- right: 10px;
+
+ .category_form {
+ * {
+ border: none !important;
+ border-bottom: none !important;
+ }
+ *:hover {
+ border: none !important;
+ border-bottom: none !important;
+ }
+ *::before {
+ border: none !important;
+ border-bottom: none !important;
+ }
+ *::after {
+ border: none !important;
+ border-bottom: none !important;
+ }
+
+ select {
+ color: ${GlobalStyled.theme.categoryNameTextColor};
+ font-size: 1.1rem;
+ font-weight: 700;
+ padding-top: 0;
+ padding-bottom: 0;
+ }
+ svg {
+ color: ${GlobalStyled.theme.categoryNameTextColor};
+ }
}
}
`;
diff --git a/src/Pages/EditArticlePage/Components/EditArticlePageBody.jsx b/src/Pages/EditArticlePage/Components/EditArticlePageBody.jsx
new file mode 100644
index 0000000..2ad231a
--- /dev/null
+++ b/src/Pages/EditArticlePage/Components/EditArticlePageBody.jsx
@@ -0,0 +1,132 @@
+import { useState, useEffect, useContext, useRef } from 'react';
+import { useLocation, useNavigate, useParams } from 'react-router-dom';
+
+import '@toast-ui/editor/dist/toastui-editor.css';
+import { Editor } from '@toast-ui/react-editor';
+
+import Button from '@mui/material/Button';
+import ArrowBackIcon from '@mui/icons-material/ArrowBack';
+
+import { getCategoryById } from 'Utils';
+import { AuthContext } from 'App';
+import { ArticleService } from 'Network';
+
+import GlobalStyled from 'Styled/Global.styled';
+
+const EditArticlePageBody = () => {
+ const [title, setTitle] = useState('');
+ const [content, setContent] = useState('');
+ const [categoryId, setCategoryId] = useState(0);
+
+ const loca = useLocation();
+ const navi = useNavigate();
+ const { id } = useParams();
+
+ const editorRef = useRef(null);
+
+ const handleChangeTitle = e => {
+ setTitle(e.target.value);
+ };
+
+ const handleChangeContent = e => {
+ setContent(editorRef.current.getInstance().getMarkdown());
+ };
+
+ const handleClickCancel = () => {
+ navi(-1);
+ };
+
+ const handleClickSubmit = async () => {
+ setContent(editorRef.current.getInstance().getMarkdown());
+
+ console.log(content);
+ if (title === '') {
+ alert('제목을 입력하세요!');
+ return;
+ }
+ if (content === '') {
+ alert('내용을 입력하세요!');
+ return;
+ }
+ // 수정하려고 카테고리 아이디 API 받는 게 조회로 인식.
+ // 이동한 뒤에 API 실행됨
+ const result = await ArticleService.editArticles(id, {
+ title: title,
+ content: content,
+ categoryId: categoryId, // + 붙이면 number 타입
+ });
+ navi(-1);
+ };
+
+ const handleFormSubmit = e => {
+ e.preventDefault();
+ handleClickSubmit();
+ };
+
+ const markdownEditorSetting = () => {
+ const editor = editorRef.current;
+ //console.log(editor);
+ editor.getRootElement().classList.add('editor');
+ //console.log(editor.getInstance());
+ };
+
+ useEffect(() => {
+ if (loca.state) {
+ const { article } = loca.state;
+ setTitle(article.title);
+ setContent(article.content);
+ setCategoryId(article.categoryId);
+ editorRef.current.getInstance().setMarkdown(article.content);
+ } else {
+ alert('없는 페이지입니다');
+ navi('/');
+ }
+ markdownEditorSetting();
+ }, []);
+ return (
+ <>
+
+
+
+ 글 수정하기
+
+
+
+
+
+
+
+
+ {getCategoryById(categoryId)}
+
+
+
+
+ >
+ );
+};
+
+export default EditArticlePageBody;
diff --git a/src/Pages/EditArticlePage/Components/index.jsx b/src/Pages/EditArticlePage/Components/index.jsx
new file mode 100644
index 0000000..51a8a07
--- /dev/null
+++ b/src/Pages/EditArticlePage/Components/index.jsx
@@ -0,0 +1,3 @@
+import EditArticlePageBody from './EditArticlePageBody';
+
+export { EditArticlePageBody };
diff --git a/src/Pages/EditArticlePage/Conponents/EditArticlePageBody.jsx b/src/Pages/EditArticlePage/Conponents/EditArticlePageBody.jsx
deleted file mode 100644
index 88709a9..0000000
--- a/src/Pages/EditArticlePage/Conponents/EditArticlePageBody.jsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import TextareaAutosize from 'react-textarea-autosize';
-import GlobalStyled from '../../../Styled/Global.styled';
-import { getCategoryById } from '../../../Utils';
-
-const EditArticlePageBody = ({
- categoryId,
- curLength,
- onChangeTitle,
- title,
- onChangeContent,
- content,
- onSubmit,
-}) => {
- const handleFormSubmit = e => {
- e.preventDefault();
- onSubmit();
- };
- return (
-
-
- {getCategoryById(categoryId)}
-
-
-
-
{curLength}/4200
-
- );
-};
-
-export default EditArticlePageBody;
diff --git a/src/Pages/EditArticlePage/Conponents/EditArticlePageHeader.jsx b/src/Pages/EditArticlePage/Conponents/EditArticlePageHeader.jsx
deleted file mode 100644
index 08f703c..0000000
--- a/src/Pages/EditArticlePage/Conponents/EditArticlePageHeader.jsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import Button from '@mui/material/Button';
-import ArrowBackIcon from '@mui/icons-material/ArrowBack';
-
-const EditArticlePageHeader = ({ onClickCancel, onClickSubmit }) => {
- return (
-
-
-
- 글 수정하기
-
-
-
-
-
- );
-};
-
-export default EditArticlePageHeader;
diff --git a/src/Pages/EditArticlePage/Conponents/index.jsx b/src/Pages/EditArticlePage/Conponents/index.jsx
deleted file mode 100644
index 82e8dc1..0000000
--- a/src/Pages/EditArticlePage/Conponents/index.jsx
+++ /dev/null
@@ -1,4 +0,0 @@
-import EditArticlePageHeader from './EditArticlePageHeader';
-import EditArticlePageBody from './EditArticlePageBody';
-
-export { EditArticlePageHeader, EditArticlePageBody };
diff --git a/src/Pages/EditArticlePage/EditArticlePage.jsx b/src/Pages/EditArticlePage/EditArticlePage.jsx
index 7184c3f..5828d2b 100644
--- a/src/Pages/EditArticlePage/EditArticlePage.jsx
+++ b/src/Pages/EditArticlePage/EditArticlePage.jsx
@@ -1,83 +1,14 @@
-import { useState, useEffect, useContext, useRef } from 'react';
-import { useLocation, useNavigate } from 'react-router-dom';
+import { EditArticlePageBody } from './Components';
-import ArticleService from '../../Network/ArticleService';
-import { AuthContext } from '../../App';
-import { getCategoryByUrl } from '../../Utils';
-
-import { EditArticlePageHeader, EditArticlePageBody } from './Conponents';
import Styled from './EditArticlePage.styled';
const EditArticlePage = () => {
- const [title, setTitle] = useState('');
- const [content, setContent] = useState('');
- const [categoryId, setCategoryId] = useState(0);
-
- const auth = useContext(AuthContext);
-
- const loca = useLocation();
- const navi = useNavigate();
- const pathArray = loca.pathname.split('/');
-
- const handleChangeTitle = e => {
- setTitle(e.target.value);
- };
-
- const handleChangeContent = e => {
- setContent(e.target.value);
- };
-
- const handleClickCancel = () => {
- navi(-1);
- };
-
- const handleClickSubmit = async () => {
- if (title === '') {
- alert('제목을 입력하세요!');
- return;
- }
- if (content === '') {
- alert('내용을 입력하세요!');
- return;
- }
- // 수정하려고 카테고리 아이디 API 받는 게 조회로 인식.
- // 이동한 뒤에 API 실행됨
- const result = await ArticleService.editArticles(+pathArray[2], {
- title: title,
- content: content,
- categoryId: categoryId, // + 붙이면 number 타입
- });
- navi(-1);
- };
-
- useEffect(() => {
- const getArticle = async () => {
- const response = await ArticleService.getArticlesById(pathArray[2]);
- const article = response;
- setTitle(article.title);
- setContent(article.content);
- setCategoryId(article.categoryId);
- };
- getArticle();
- }, [setTitle, setContent, categoryId]);
-
return (
-
-
-
-
+ <>
+
+
+
+ >
);
};
-
export default EditArticlePage;
diff --git a/src/Pages/EditArticlePage/EditArticlePage.styled.js b/src/Pages/EditArticlePage/EditArticlePage.styled.js
index ad706f4..ef3d762 100644
--- a/src/Pages/EditArticlePage/EditArticlePage.styled.js
+++ b/src/Pages/EditArticlePage/EditArticlePage.styled.js
@@ -99,11 +99,28 @@ const EditArticlePage = styled.div`
}
}
}
- p {
- position: fixed;
- color: rgba(0, 0, 0, 30%);
- bottom: 10px;
- right: 10px;
+
+ .editor {
+ flex-grow: 1;
+ box-sizing: border-box;
+ width: 100%;
+ .toastui-editor-dropdown-toolbar {
+ flex-wrap: wrap;
+ height: auto;
+ width: min-content;
+ }
+ .toastui-editor-popup {
+ width: auto;
+ max-width: 400px;
+ .toastui-editor-file-select-button {
+ width: auto;
+ padding: 0 4px;
+ font-size: 0.7rem;
+ }
+ @media (max-width: 480px) {
+ margin-left: 0px;
+ }
+ }
}
}
`;
diff --git a/src/Pages/ErrorPage/ErrorPage.jsx b/src/Pages/ErrorPage/ErrorPage.jsx
index a025cac..d57f99d 100644
--- a/src/Pages/ErrorPage/ErrorPage.jsx
+++ b/src/Pages/ErrorPage/ErrorPage.jsx
@@ -1,4 +1,5 @@
import { useNavigate } from 'react-router-dom';
+
import Styled from './ErrorPage.styled';
const ErrorPage = () => {
diff --git a/src/Pages/LikedArticlePage/Components/LikedArticle.jsx b/src/Pages/LikedArticlePage/Components/LikedArticle.jsx
index 532e690..58e8aaf 100644
--- a/src/Pages/LikedArticlePage/Components/LikedArticle.jsx
+++ b/src/Pages/LikedArticlePage/Components/LikedArticle.jsx
@@ -1,8 +1,10 @@
-import { FavoriteBorder, SmsOutlined } from '@mui/icons-material';
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
-import UserService from 'Network/UserService';
+
+import { UserService } from 'Network';
+
import { PreviewArticle } from 'Components';
+import { FavoriteBorder, SmsOutlined } from '@mui/icons-material';
import Styled from './LikedArticle.styled';
diff --git a/src/Pages/LikedArticlePage/LikedArticlePage.jsx b/src/Pages/LikedArticlePage/LikedArticlePage.jsx
index fa3bf27..5a2db2e 100644
--- a/src/Pages/LikedArticlePage/LikedArticlePage.jsx
+++ b/src/Pages/LikedArticlePage/LikedArticlePage.jsx
@@ -1,8 +1,8 @@
-import { Footer } from 'Components';
-import { ProfileHeader } from 'Components';
-import GlobalStyled from 'Styled/Global.styled';
+import { Footer, ProfileHeader } from 'Components';
import { LikedArticle } from './Components';
+import GlobalStyled from 'Styled/Global.styled';
+
const LikedArticlePage = () => {
return (
diff --git a/src/Pages/LoginPage/LoginPage.jsx b/src/Pages/LoginPage/LoginPage.jsx
index abc3524..c639ccc 100644
--- a/src/Pages/LoginPage/LoginPage.jsx
+++ b/src/Pages/LoginPage/LoginPage.jsx
@@ -1,14 +1,15 @@
import { useEffect, useContext } from 'react';
import { useNavigate } from 'react-router-dom';
-import Styled from './LoginPage.styled';
-import qs from 'qs';
-import AuthService from '../../Network/AuthService';
+import { AuthContext } from 'App';
+import { AuthService } from 'Network';
+import qs from 'qs';
import Button from '@mui/material/Button';
-import GitHubIcon from '@mui/icons-material/GitHub';
import CircularProgress from '@mui/material/CircularProgress';
-import { AuthContext } from '../../App';
+import GitHubIcon from '@mui/icons-material/GitHub';
+
+import Styled from './LoginPage.styled';
const LoginPage = ({ isCallback }) => {
const auth = useContext(AuthContext);
@@ -55,7 +56,9 @@ const LoginPage = ({ isCallback }) => {
) : (
<>
- GitHub 계정으로 로그인 하기
+
+ GitHub 계정으로 로그인 하기
+
>
)}
diff --git a/src/Pages/MainPage/Components/Body.styled.js b/src/Pages/MainPage/Components/Body.styled.js
index ec6235e..0fafd9f 100644
--- a/src/Pages/MainPage/Components/Body.styled.js
+++ b/src/Pages/MainPage/Components/Body.styled.js
@@ -1,6 +1,8 @@
import styled from 'styled-components';
+
import List from '@mui/material/List';
-import GlobalStyled from '../../../Styled/Global.styled';
+
+import GlobalStyled from 'Styled/Global.styled';
const ListDivider = styled.div`
box-sizing: border-box;
@@ -11,16 +13,23 @@ const ListDivider = styled.div`
const StyledList = styled(List)`
padding: 0;
-`;
-const BestStyledList = styled(List)`
- padding: 0;
- img {
- position: absolute;
- margin-left: 1em;
- margin-top: 0.7em;
- }
- .top {
- padding-left: 2.2em;
+
+ .fab_button {
+ position: fixed;
+ bottom: 1.8rem;
+ right: 1.5rem;
+ z-index: 100;
+ background-color: ${GlobalStyled.theme.secondary};
+ color: ${GlobalStyled.theme.headerIconColor};
+ border-radius: 40%;
+ cursor: 'pointer';
+ @media (min-width: ${GlobalStyled.theme.mobileMinWidth}) {
+ bottom: 1.8rem;
+ left: calc(50% + 7rem);
+ }
+ &:hover {
+ background-color: ${GlobalStyled.theme.primary};
+ }
}
`;
const BoardTitleDiv = styled.div`
@@ -140,7 +149,6 @@ const CheckInBody = styled.div`
const Styled = {
BoardTitleDiv,
- BestStyledList,
StyledList,
ListDivider,
CheckInHeader,
diff --git a/src/Pages/MainPage/Components/BodyPreView.jsx b/src/Pages/MainPage/Components/BodyPreView.jsx
index 20c8d5b..75900af 100644
--- a/src/Pages/MainPage/Components/BodyPreView.jsx
+++ b/src/Pages/MainPage/Components/BodyPreView.jsx
@@ -1,5 +1,6 @@
import ListItem from '@mui/material/ListItem';
import ListItemText from '@mui/material/ListItemText';
+
import Styled from './BodyPreView.styled';
const BodyPreView = ({ onChangeTab, highlight }) => {
diff --git a/src/Pages/MainPage/Components/BodyPreView.styled.js b/src/Pages/MainPage/Components/BodyPreView.styled.js
index 4d5f804..d7097e3 100644
--- a/src/Pages/MainPage/Components/BodyPreView.styled.js
+++ b/src/Pages/MainPage/Components/BodyPreView.styled.js
@@ -1,4 +1,5 @@
import styled from 'styled-components';
+
import { Tab, Tabs } from '@mui/material';
const StyledTabs = styled(Tabs)`
diff --git a/src/Pages/MainPage/Components/Community.jsx b/src/Pages/MainPage/Components/Community.jsx
index 59bd2e1..560ace0 100644
--- a/src/Pages/MainPage/Components/Community.jsx
+++ b/src/Pages/MainPage/Components/Community.jsx
@@ -1,4 +1,7 @@
-import { PreviewArticle } from '../../../Components';
+import { Fragment } from 'react';
+import { List } from '@mui/material';
+
+import { PreviewArticle } from 'Components';
import Styled from './Body.styled';
@@ -11,26 +14,22 @@ const Community = ({
}) => {
return (
<>
-
+
{bestArticles &&
bestArticles.map(article => {
return (
- <>
-
+
moveArticles(article.id)}
/>
- >
+
);
})}
-
+
{/* margin="0.4rem" */}
- {/* margin="0.4rem" */}
+
{/* {
const [checkInStatus, setCheckInStatus] = useState({
max: {
diff --git a/src/Pages/MainPage/Components/MainBody.jsx b/src/Pages/MainPage/Components/MainBody.jsx
index b6df42f..296cdc2 100644
--- a/src/Pages/MainPage/Components/MainBody.jsx
+++ b/src/Pages/MainPage/Components/MainBody.jsx
@@ -1,17 +1,18 @@
import { useState, useEffect } from 'react';
import { useNavigate, useSearchParams, useLocation } from 'react-router-dom';
+
+import { BestService, ArticleService } from 'Network';
import qs from 'qs';
import BodyPreView from './BodyPreView';
import Community from './Community';
import Home from './Home';
+import Divider from '@mui/material/Divider';
+import Fab from '@mui/material/Fab';
+import CreateIcon from '@mui/icons-material/Create';
-import BestService from '../../../Network/BestService';
-import ArticleService from '../../../Network/ArticleService';
import Styled from './Body.styled';
-import Divider from '@mui/material/Divider';
-
const MainBody = () => {
const navi = useNavigate();
const location = useLocation();
@@ -34,19 +35,23 @@ const MainBody = () => {
navi(`/article/${articleId}`);
};
+ const handleClickWrite = () => {
+ navi('/create');
+ };
+
useEffect(() => {
const getFreeArticles = async () => {
- const response = await ArticleService.getArticles(1);
+ const response = await ArticleService.getAllArticles(1);
setFreeArticles(response.data);
};
const getAnonyArticles = async () => {
- const response = await ArticleService.getArticles(2);
+ const response = await ArticleService.getAllArticles(2);
setAnonyArticles(response.data);
};
const getNotiArticles = async () => {
- const response = await ArticleService.getArticles(3);
+ const response = await ArticleService.getAllArticles(3);
setNotiArticles(response.data);
};
@@ -56,7 +61,7 @@ const MainBody = () => {
};
getBestArticles();
getFreeArticles();
- getAnonyArticles();
+ // getAnonyArticles();
getNotiArticles();
}, []);
@@ -68,22 +73,28 @@ const MainBody = () => {
aria-label="mailbox folders"
>
+
+
+ {highlight === 'home' ? (
+
+ ) : (
+
+ )}
+
+
+
+
-
- {/**/}
-
- {highlight === 'home' ? (
-
- ) : (
-
- )}
-
);
};
diff --git a/src/Pages/MainPage/MainPage.jsx b/src/Pages/MainPage/MainPage.jsx
index 37f2f3f..252a111 100644
--- a/src/Pages/MainPage/MainPage.jsx
+++ b/src/Pages/MainPage/MainPage.jsx
@@ -1,7 +1,6 @@
-import { useEffect } from 'react';
+import { Header, Footer } from 'Components';
import { MainBody } from './Components';
-import { Header } from '../../Components';
-import Footer from '../../Components/Footer';
+
import Styled from './MainPage.styled';
// 프론트 -> github API -> 깃허브 인증 -> 쿼리 스트링으로 code가 날아옴 -> githubCallback API -> 서버에서 쿠키 보내줌.
diff --git a/src/Pages/MainPage/MainPage.styled.js b/src/Pages/MainPage/MainPage.styled.js
index a724a41..146772e 100644
--- a/src/Pages/MainPage/MainPage.styled.js
+++ b/src/Pages/MainPage/MainPage.styled.js
@@ -1,4 +1,5 @@
import styled from 'styled-components';
+
import ListItem from '@mui/material/ListItem';
const MainHeader = styled.div``;
diff --git a/src/Pages/MyArticlePage/Components/MyArticle.jsx b/src/Pages/MyArticlePage/Components/MyArticle.jsx
index 1e73a0c..a0c975e 100644
--- a/src/Pages/MyArticlePage/Components/MyArticle.jsx
+++ b/src/Pages/MyArticlePage/Components/MyArticle.jsx
@@ -1,8 +1,9 @@
-import { FavoriteBorder, SmsOutlined } from '@mui/icons-material';
import { useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';
+
+import { UserService } from 'Network';
+
import { PreviewArticle } from 'Components';
-import UserService from 'Network/UserService';
import Styled from './MyArticle.styled';
diff --git a/src/Pages/MyArticlePage/MyArticlePage.jsx b/src/Pages/MyArticlePage/MyArticlePage.jsx
index b67788a..8a094cb 100644
--- a/src/Pages/MyArticlePage/MyArticlePage.jsx
+++ b/src/Pages/MyArticlePage/MyArticlePage.jsx
@@ -1,8 +1,8 @@
-import { Footer } from 'Components';
-import { ProfileHeader } from 'Components';
-import GlobalStyled from 'Styled/Global.styled';
+import { Footer, ProfileHeader } from 'Components';
import { MyArticle } from './Components';
+import GlobalStyled from 'Styled/Global.styled';
+
const MyArticlePage = () => {
return (