Skip to content
Open
Show file tree
Hide file tree
Changes from 43 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
71e1223
Design: scss 설정 / icon 추가
chunwookJoo Nov 14, 2022
1c3eac2
Feat: 스토리지 관리 / 템플릿
chunwookJoo Nov 14, 2022
05f68f1
Feat: API 관련 추가
chunwookJoo Nov 14, 2022
2703e9d
Feat: 404페이지 (수정 필요) / 홈 페이지 추가
chunwookJoo Nov 14, 2022
242561c
Feat: 글 작성, 수정, 삭제 기능 구현
chunwookJoo Nov 14, 2022
98fd172
Feat: Nested List 기능 구현
chunwookJoo Nov 15, 2022
efc3f7b
Feat: Nested List 기능 구현
chunwookJoo Nov 15, 2022
0785669
Fix: 포스트 리스트 렌더링 에러 수정
chunwookJoo Nov 15, 2022
8a73357
Fix: 포스트 리스트 스타일링 수정
chunwookJoo Nov 15, 2022
46e9e55
Fix: contenteditable 추가 구현
chunwookJoo Nov 16, 2022
445905f
Fix: 하위 페이지 생성 모달창 연결
chunwookJoo Nov 16, 2022
7a4e603
Feat: 포스트 생성 모달 구현, 비어있는 제목 예외처리 추가
chunwookJoo Nov 16, 2022
ca1ef88
Add: 폰트 추가
chunwookJoo Nov 16, 2022
7ca2535
Add: 포스트 생성 시간, contenteditable 추가
chunwookJoo Nov 16, 2022
b1c68c2
Add: 리스트 클릭 시 active 기능 추가
chunwookJoo Nov 16, 2022
fbca9c7
Add: 404페이지 추가
chunwookJoo Nov 16, 2022
d8bf6e3
Feat: 포스트 생성 날짜, 수정 날짜 출력
chunwookJoo Nov 16, 2022
46ce2d0
Design: 전체적인 스타일 수정
chunwookJoo Nov 16, 2022
21d7077
Fix: 하위페이지 삭제 에러 수정
chunwookJoo Nov 16, 2022
fe8a166
Feat: Vercel 세팅 작업
chunwookJoo Nov 17, 2022
06c55d8
Update README.md
chunwookJoo Nov 17, 2022
7d72a2f
Update README.md
chunwookJoo Nov 17, 2022
7dce486
Add: 새로고침, 글 수정해도 list-active 유지
chunwookJoo Nov 17, 2022
617497d
Add: 새로고침, 글 수정해도 list-active 유지
chunwookJoo Nov 17, 2022
be1d071
Add: 포스트 리스트 비었을 시, 안내 문구 추가
chunwookJoo Nov 17, 2022
2824447
Test: vercel 환경변수 추가 테스트
chunwookJoo Nov 17, 2022
d445e42
Design: 비어있는 리스트 디자인 추가
chunwookJoo Nov 17, 2022
2e6a039
Merge branch 'main' of https://github.com/chunwookJoo/JooNotion
chunwookJoo Nov 17, 2022
00813cd
Test: vercel 환경변수 테스트
chunwookJoo Nov 17, 2022
a4249e0
Fix: api.js 루트 디랙토리로 이동
chunwookJoo Nov 17, 2022
a34cfae
Test: vercel 환경변수 테스트
chunwookJoo Nov 17, 2022
d985d08
Fix: api.js에서 index.js로 변경
chunwookJoo Nov 17, 2022
e160330
vercel 배포
chunwookJoo Nov 17, 2022
a7b67dd
vercel 배포
chunwookJoo Nov 17, 2022
75850fe
vercel 배포
chunwookJoo Nov 17, 2022
6eb102f
Fix: api.js 절대경로로 수정
chunwookJoo Nov 17, 2022
242d481
vercel 배포
chunwookJoo Nov 17, 2022
c488676
vercel 배포
chunwookJoo Nov 17, 2022
78d087c
Fix: vercel 환경변수 설정 취소
chunwookJoo Nov 18, 2022
bb931c3
Fix: vercel 배포
chunwookJoo Nov 18, 2022
5089d3e
Fix: 하위 페이지 open 고정, 새로고침 해도 유지하기, child-ul hide 삭제
chunwookJoo Nov 20, 2022
bda6983
Fix: 함수 이름 통일, SideNavHeader 컴포넌트 -> PostsPageHeader로 이름 변경
chunwookJoo Nov 20, 2022
b0f28ae
Fix: 불필요한 setState 제거
chunwookJoo Nov 21, 2022
fbd23f5
Update README.md
chunwookJoo Mar 28, 2023
763cd7a
Update README.md
chunwookJoo Mar 28, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc.txt
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# 📌 4주차 프로젝트[Project1]
# 바닐라 자바스크립트로 만든 노션 클로닝 프로젝트
## 사이트 주소
[🔳 JooNotion](https://joo-notion.vercel.app/)

## 필수 프로젝트

- 프로젝트 기한
- 프로젝트 수행 기간 : 2022년 11월 8일(화) ~ 2022년 11월 16일(수)
- 멘티 코드 리뷰 기간 : 2022년 11월 17일(목) ~ 2022년 11월 20일(일)
- 멘토 코드 리뷰 기간 : 2022년 11월 17일(목) ~ 2022년 11월 22일(화)
- 코드 리뷰 반영 기간 : 2022년 11월 23일(수) ~ 2022년 11월 25일(금)
- 내용
- **Day 17 [프로젝트] 노션 클로닝 요구사항** 확인 부탁드립니다.
(작성중...)
Copy link

Choose a reason for hiding this comment

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

ㅋㅋㅋㅋ 귀엽네요

1 change: 1 addition & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const OPENED_LIST_KEY = "local-save-open-list";
19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="/src/assets/css/style.css" />
<link rel="stylesheet" href="/src/assets/css/fontello.css" />
<title>🔳 JooNotion</title>
</head>
<body>
<main id="app" class="global-container"></main>
<script src="/src/index.js" type="module"></script>
</body>
</html>
89 changes: 89 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import PostEdit from "./components/PostEdit.js";
import PostsPage from "./components/PostsPage.js";
import HomePage from "./pages/HomePage.js";
import { initRouter } from "./routes/router.js";
import NotFound from "./pages/NotFound.js";
import { request } from "./api/index.js";

export default function App({ $target }) {
const $postListContainer = document.createElement("div");
const $homeContainer = document.createElement("div");
const $postEditContainer = document.createElement("div");
Comment on lines +9 to +11
Copy link
Member

Choose a reason for hiding this comment

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

App에서 이러한 Container들을 만들어주신 이유를 여쭤봐도 될까요?

Copy link
Author

Choose a reason for hiding this comment

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

저 코드가 display:none을 하기위해서 추가된 코드에요.
처음엔 각각 렌더링을 하려고 했는데 App에서 pathname에 따라 렌더링 되는부분이 잘 안되더라고요..
404페이지에서 list가 보인다거나 그런 현상이 발생해서 임시방편으로 저렇게 넣어둔겁니다ㅎ.ㅎ
저도 혜준님 생각대로 불필요한 렌더링이 발생한다고 생각해서 저 부분은 변경하도록 하겠습니다~~


$homeContainer.className = "post-edit-container";
$postListContainer.className = "post-list-container";
$postEditContainer.className = "post-edit-container";
Comment on lines +13 to +15
Copy link
Member

Choose a reason for hiding this comment

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

저는 클래스를 줄 때 classList.add를 이용했는데 이렇게 설정하는 방법도 있군요

Copy link

@fly1chop fly1chop Nov 21, 2022

Choose a reason for hiding this comment

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

className을 이용하면 안에있는 클래스는 모두 지우고 정의하는 방법이라서 되도록 사용하지 않습니다.

Copy link
Author

Choose a reason for hiding this comment

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

className을 이용하면 안에있는 클래스는 모두 지우고 정의하는 방법이라서 대도록 사용하지 않습니다.

대도록 (x) 되도록 (o)
맞아요! 보통 한개의 class만 지정해줄때 사용합니당


$target.appendChild($postListContainer);
$target.appendChild($homeContainer);
$target.appendChild($postEditContainer);

this.state = {
selectedPost: {},
};

const homePage = new HomePage({
$target: $homeContainer,
});

const notFound = new NotFound({
$target,
});

/**
* PostList 감싸는 컴포넌트
*/
const postsPage = new PostsPage({
$target: $postListContainer,
});

/**
* Editor 감싸는 컴포넌트
*/
const postEdit = new PostEdit({
$target: $postEditContainer,
initialState: this.state,
updatePost: (updatePost) => {
postsPage.setState(updatePost);
},
});

postsPage.setState();

this.init = async () => {
const { pathname } = window.location;
if (pathname === "/") {
$postEditContainer.style.display = "none";
$homeContainer.style.display = "flex";
} else if (pathname.indexOf("/documents/") === 0) {
$postEditContainer.style.display = "flex";
$homeContainer.style.display = "none";

const [, , id] = pathname.split("/");
if (id === "new") {
postEdit.setState({
...this.state,
id,
});
} else {
const post = await request(`/documents/${id}`, {
method: "GET",
});
postsPage.setState(post);
postEdit.setState(post);
}
} else {
notFound.render();
$postListContainer.style.display = "none";
$postEditContainer.style.display = "none";
$homeContainer.style.display = "none";
Comment on lines +56 to +79

Choose a reason for hiding this comment

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

이런 style 부분은 className on/off 하는 방법은 어떨까요?

}
};
Comment on lines +53 to +81

Choose a reason for hiding this comment

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

pathname에 따라 렌더링을 이해하기 쉽게 잘 작성하신 것 같아요~


this.init();
initRouter(() => this.init());

window.addEventListener("popstate", () => {
this.init();
});
}
19 changes: 19 additions & 0 deletions src/api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const API_END_POINT = "https://kdt-frontend.programmers.co.kr";
Copy link
Member

Choose a reason for hiding this comment

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

이 부분은 따로 빼셔야 할 것 같습니다!

Copy link
Author

Choose a reason for hiding this comment

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

vercel 환경변수에 넣으려고 시도했었는데 생각처럼 잘 안돼서 ㅠㅠ gitignore라도 해야겠네요


export const request = async (url, options = {}) => {
try {
const res = await fetch(`${API_END_POINT}${url}`, {
...options,
headers: {
"Content-Type": "application/json",
"x-username": "woogie",
},
});
if (res.ok) {
return await res.json();
}
throw new Error("API 호출 실패!!!!!!!");
Copy link

Choose a reason for hiding this comment

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

호출 실패하면 안될텐데!!!!!!

} catch (error) {
alert(error);
}
};
61 changes: 61 additions & 0 deletions src/assets/css/fontello.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@font-face {
font-family: 'fontello';
src: url('../font/fontello.eot?10205068');
src: url('../font/fontello.eot?10205068#iefix') format('embedded-opentype'),
url('../font/fontello.woff2?10205068') format('woff2'),
url('../font/fontello.woff?10205068') format('woff'),
url('../font/fontello.ttf?10205068') format('truetype'),
url('../font/fontello.svg?10205068#fontello') format('svg');
font-weight: normal;
font-style: normal;
}
/* Chrome hack: SVG is rendered more smooth in Windozze. 100% magic, uncomment if you need it. */
/* Note, that will break hinting! In other OS-es font will be not as sharp as it could be */
/*
@media screen and (-webkit-min-device-pixel-ratio:0) {
@font-face {
font-family: 'fontello';
src: url('../font/fontello.svg?10205068#fontello') format('svg');
}
}
*/
[class^="icon-"]:before, [class*=" icon-"]:before {
font-family: "fontello";
font-style: normal;
font-weight: normal;
speak: never;

display: inline-block;
text-decoration: inherit;
width: 1em;
margin-right: .2em;
text-align: center;
/* opacity: .8; */

/* For safety - reset parent styles, that can break glyph codes*/
font-variant: normal;
text-transform: none;

/* fix buttons height, for twitter bootstrap */
line-height: 1em;

/* Animation center compensation - margins should be symmetric */
/* remove if not needed */
margin-left: .2em;

/* you can be more comfortable with increased icons size */
/* font-size: 120%; */

/* Font smoothing. That was taken from TWBS */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

/* Uncomment for 3D effect */
/* text-shadow: 1px 1px 1px rgba(127, 127, 127, 0.3); */
}

.icon-trash:before { content: '\e803'; } /* '' */
.icon-plus-1:before { content: '\e804'; } /* '' */
.icon-down-open:before { content: '\f004'; } /* '' */
.icon-right-open:before { content: '\f006'; } /* '' */
.icon-circle-thin:before { content: '\f1db'; } /* '' */
52 changes: 52 additions & 0 deletions src/assets/css/libs/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@import "./vars.scss";

@mixin base-button {
Copy link
Member

Choose a reason for hiding this comment

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

@mixin@include를 처음 봐서 검색해봤는데 중복 코드를 줄일 수 있고 코드가 훨씬 간결해지네요! 배워갑니다 :)

Copy link
Author

Choose a reason for hiding this comment

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

scss의 가장 큰 장점인것같아요! 알아두면 정말 많이 쓰일것같습니당 ㅎㅎ

Choose a reason for hiding this comment

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

@mixin을 잘 많이 활용해서 좋네요 ^^

button {
font-family: "Noto Sans KR", Sans-serif;
border: 0;
color: $color-base-font;
background-color: transparent;
}

button:hover {
cursor: pointer;
}
}

@mixin input-title {
.title {
cursor: text;
font-size: 2.5rem;
font-weight: 700;
line-height: 4rem;
outline: none;
}

.title:empty:before {
content: attr(placeholder);
font-size: 2.5rem;
font-weight: 700;
line-height: 4rem;
color: #ccc;
outline: none;
}
}

@mixin input-content {
.content {
height: 600px;
cursor: text;
font-size: 1rem;
line-height: 3rem;
outline: none;
}

.content:empty::before {
content: attr(placeholder);
top: 0;
font-size: 1rem;
line-height: 3rem;
color: #ccc;
outline: none;
}
}
16 changes: 16 additions & 0 deletions src/assets/css/libs/_vars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// font
$color-home-font: #c7c7c7;
$color-base-font: #5e5e5e;

// background
$color-post-edit-background: #ffffff;
$color-post-list-background: rgb(251 251 250);

// hover
$color-post-list-hover: rgb(235, 235, 235);
$color-post-button-hover: rgb(209, 209, 209);

// button
$color-modal-close-btn-background: #6b6b6b;
$color-post-create-btn-background: rgb(35, 131, 226);
$color-white: #ffffff;
75 changes: 75 additions & 0 deletions src/assets/css/modal.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@import "./libs/vars.scss";
@import "./libs/mixins.scss";

.container-modal {
display: none;

.modal {
z-index: 2;
position: absolute;
max-width: 970px;
margin: 0 auto;
width: 100%;
height: 400px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: $color-post-edit-background;
padding: 2rem 4rem;
border-radius: 4px;
box-shadow: rgb(15 15 15 / 5%) 0px 0px 0px 1px,
rgb(15 15 15 / 10%) 0px 5px 10px, rgb(15 15 15 / 20%) 0px 15px 40px;

.modal-title {
position: relative;

h2 {
font-size: 1.5rem;
font-weight: bold;
}

.title-input-container {
position: relative;
margin-top: 1.5rem;
height: 300px;

@include input-title;
}
}

.modal-btn-container {
display: flex;
justify-content: end;
gap: 1rem;

button {
padding: 8px 1rem;
border-radius: 10px;
color: $color-white;
font-size: 1rem;
}

.close {
background-color: $color-modal-close-btn-background;
}

.create-post-btn {
background-color: $color-post-create-btn-background;
}
}
}

.overlay {
z-index: 1;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.4);
}
}

.post-modal-show {
display: block;
}
Loading