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

이미지 클릭 시 리뷰 모달 오픈 및 리뷰모달 글쓰기 모달 전체적인 스타일 변경 #364

Merged
merged 4 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions client/src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
@import "@/styles/global-style";
@import "@/styles/theme";

* {
Copy link
Collaborator

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.

제가 확인하고 있던 뷰에선 없었습니다

padding: 0;
margin: 0;
}

html,
body {
height: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface ProgressiveImageProps {
width: number | "100%";
height: number | "100%";
alt: string;
handleClickImage?: () => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

optional로 두신 부분이 좋네요!

}

const ProgressiveImage = ({
Expand All @@ -18,6 +19,7 @@ const ProgressiveImage = ({
width,
height,
alt,
handleClickImage,
}: ProgressiveImageProps): JSX.Element => {
const { observeImage } = useImageIntersect();

Expand All @@ -26,6 +28,7 @@ const ProgressiveImage = ({
ref={observeImage}
className={`progressive-image ${className}`}
src={placeholder}
onClick={handleClickImage}
Copy link
Collaborator

Choose a reason for hiding this comment

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

onClick에 undefined가 들어가도 상관없으려나요?

Copy link
Member Author

Choose a reason for hiding this comment

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

넵 따로 값을 넣어주지 않으면 기본이 undefined인 것 같습니다.

data-lazysrc={src}
width={width}
height={height}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
@import "@/styles/theme";
@import "@/styles/responsive";
@import "@/styles/global-style";
@import "@/styles/animation";

.modal-container {
// root 의 가운데 정렬
position: absolute;
top: 0;
right: 0;
left: 0;
z-index: $modal-content-z-index;
z-index: $modal-content-z-index !important;
box-sizing: border-box;

display: flex;
width: 100%;
width: fit-content;
max-width: $desktop-main-width;
height: 100%;

height: 80%;
// 모달 내용들은 공통으로 2rem 패딩 내에 존재
padding: 2rem;
margin: 0 auto;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React, { useCallback, MouseEvent } from "react";
import CloseIcon from "@mui/icons-material/Close";

import ModalContainer from "@/components/main/Modal/ModalContainer/ModalContainer";
import useCommonModalStore from "@/store/useCommonModalStore";
import { isCloseModalElement } from "@/utils/dom";

import "./ModalWrapper.scss";

Expand All @@ -12,16 +14,22 @@ const CommonModalWrapper = (): JSX.Element => {
]);

const clickWrapperBackGround = useCallback(
(e: MouseEvent<HTMLDivElement>) => {
(e: MouseEvent<HTMLDivElement | SVGSVGElement>) => {
if (!isCloseModalElement(e.target as HTMLElement)) return;
closeModal();
},
[]
);

return modalContent !== null ? (
<>
<div className="modal-background" onClick={clickWrapperBackGround} />
<ModalContainer content={modalContent} />
<div className="modal-background" onClick={clickWrapperBackGround}>
<CloseIcon
Copy link
Collaborator

Choose a reason for hiding this comment

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

닫는 아이콘을 추가하셨군요!

className="modal-close-button"
onClick={clickWrapperBackGround}
/>
<ModalContainer content={modalContent} />
</div>
</>
) : (
<></>
Expand Down
17 changes: 17 additions & 0 deletions client/src/components/main/Modal/ModalWrapper/ModalWrapper.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
@import "@/styles/_global-style.scss";
@import "@/styles/theme.scss";
@import "@/styles/responsive";

.modal-background {
position: absolute;
top: 0;
z-index: $modal-background-z-index !important;
display: flex;
align-items: center;
width: 100vw;
height: 100vh;
min-height: 100vh;
background-color: rgba(0, 0, 0, 0.75);
}

.modal-close-button {
position: absolute;
top: 2rem;
right: 2rem;
z-index: $modal-content-z-index;
font-size: 2rem;
color: $line-color;
cursor: pointer;
transform: scale(2);
}
25 changes: 18 additions & 7 deletions client/src/components/main/Modal/ReviewModal/ReviewModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
@import "@/styles/mixin";

$code-line-width: 4rem;
$review-code-width: calc($device-editor-width - $code-line-width);
$review-code-width: calc($device-editor-width - $code-line-width - 8rem);
$github-dark-font-color: #c9d1d9;

.review-modal {
display: flex;

width: 100%;
height: 100%;

Expand All @@ -18,6 +17,7 @@ $github-dark-font-color: #c9d1d9;
width: $review-code-width;
min-width: $review-code-width;
height: 100%;

background-color: $codeblock-color;
border-radius: $radius-small;

Expand All @@ -30,13 +30,24 @@ $github-dark-font-color: #c9d1d9;
margin: 0;
overflow-x: hidden;
overflow-y: auto;
font-size: $font-medium;
white-space: pre-wrap;

font-size: $font-large;

&::-webkit-scrollbar {
display: none;
}
}

&--view {
left: $code-line-width;
width: calc(100% - $code-line-width);
overflow-x: scroll;
color: $github-dark-font-color;
letter-spacing: 1px;

& > code {
font-family: D2Coding, "D2 coding", monospace;
}
}

&--lines {
Expand All @@ -48,9 +59,9 @@ $github-dark-font-color: #c9d1d9;
box-sizing: border-box;
display: flex;
flex-direction: column;
width: 100%;
max-width: $device-review-max-width;
width: 40rem;
max-width: 50rem;
height: 100%;
margin-left: calc($device-review-modal-gap / 2);
margin-left: calc($device-review-modal-gap);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $review-form-header-height: 4rem;

box-sizing: border-box;
display: flex;
gap: 1.6rem;
gap: 1rem;

width: 100%;
height: auto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const ReviewScroll = ({ postId }: ReviewScrollProps): JSX.Element => {
);

return (
<div className="review-modal__review-container">
<>
<ul className="review-list">
{reviewInfos.map((reviewInfo: ReviewInfo) => (
<Review key={reviewInfo.id} reviewInfo={reviewInfo} />
Expand All @@ -36,7 +36,7 @@ const ReviewScroll = ({ postId }: ReviewScrollProps): JSX.Element => {
/>
</ul>
<ReviewForm postId={postId} refetch={refetch} />
</div>
</>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
flex-direction: column;
flex-grow: 1;
align-items: center;
width: auto !important;
width: 35rem !important;
height: 100%;
overflow-x: hidden;
overflow-y: auto;
Expand All @@ -14,16 +14,16 @@
box-shadow: $shadow-box;

&__item {
width: 40rem;
height: 40rem;
width: 30rem;
height: 30rem;
margin: 1rem 0;

&--img {
width: 40rem;
height: 40rem;
width: 100%;
height: 100%;
cursor: pointer;
border-radius: $radius-medium;
object-fit: cover;
object-fit: contain;
}
}
@media screen and (max-width: 720px) {
Expand Down
3 changes: 3 additions & 0 deletions client/src/components/main/Modal/WriteModal/WriteModal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
gap: 1rem;
width: 100%;
height: 100%;
@media screen and (max-width: 720px) {
flex-direction: column;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
&--image {
width: inherit;
height: inherit;
cursor: pointer;
object-fit: cover; // 가로-세로 비율 맞춰서 꽉 차게
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@ import React, { useContext } from "react";
import { PostContext } from "@/components/main/PostScroll/Post/Post";
import ProgressiveImage from "@/components/commons/ProgressiveImage/ProgressiveImage";
import codePlaceholder from "@/assets/progressive-image.jpg";
import useCommonModalStore from "@/store/useCommonModalStore";
import ReviewModal from "@/components/main/Modal/ReviewModal/ReviewModal";

import "./PostImageSlider.scss";

const PostImageSlider = (): JSX.Element => {
const { images } = useContext(PostContext);
const { images, id: postId, code, language } = useContext(PostContext);
const [openModal] = useCommonModalStore((state) => [state.openModal]);

const handleClickImage = (): void => {
openModal(<ReviewModal postId={postId} code={code} language={language} />);
};

return (
<div className="post__image-slider">
Expand All @@ -18,6 +25,7 @@ const PostImageSlider = (): JSX.Element => {
width="100%"
height="100%"
alt="이미지 설명"
handleClickImage={handleClickImage}
/>
</div>
);
Expand Down
7 changes: 3 additions & 4 deletions client/src/constants/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ export const LANGUAGES = [
export const DEFAULT_LANGUAGE = "JavaScript";

export const IMAGE_OPTIONS = {
width: 400,
height: 400,
width: 600,
height: 600,
bgcolor: "#292c33",
style: {
display: "flex",
justifyContent: "center",
alignItems: "center",
paddingInline: "15px",
paddingInline: "16px",
},
};
1 change: 1 addition & 0 deletions client/src/hooks/useViewerScroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const useViewerScroll = (): UseEditorScroll => {
const handleScrollChange = useCallback((): void => {
if (lineRef.current !== null && preRef.current !== null) {
lineRef.current.scrollTop = preRef.current.scrollTop;
preRef.current.scrollTop = lineRef.current.scrollTop;
}
}, [preRef, lineRef]);
return { preRef, lineRef, handleScrollChange };
Expand Down
2 changes: 1 addition & 1 deletion client/src/mocks/datasource/mockDataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const posts: PostInfo[] = Array.from(Array(1024).keys()).map((id) => ({
likeCount: id % 10,
lineCount: 1,
updatedAt: "2022-11-16 12:26:56.124939",
code: `sourcecode: ~~~~~~~~~~~~~~~~~~`,
code: `sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~sourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\nsourcecode: ~~~~~~~~~~~~~~~~~~\n`,
language: `javascript`,
isLiked: false,
}));
Expand Down
7 changes: 3 additions & 4 deletions client/src/styles/_global-style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,13 @@ $desktop-main-width: $main-nav-width + $main-post-bar-width + $main-gap +
*/

$default-z-index: 0;
$modal-background-z-index: 1;
$modal-content-z-index: 2;
$modal-upper-z-index: 3;
$modal-background-z-index: 20000;
Copy link
Collaborator

Choose a reason for hiding this comment

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

정리하신 부분 좋습니다!

$modal-content-z-index: 20001;
$modal-upper-z-index: 20002;

/**
* editor
*/

$editing-form-width: 72rem;
$device-editor-width: 64rem; // device 최대 너비가 69.5rem - 6:4정도 유지를 위해 40rem 선정
$line-width: 4rem;
Expand Down
3 changes: 3 additions & 0 deletions client/src/styles/_mixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
white-space: pre-wrap;
background-color: $codeblock-color;
border-right: 1px solid $line-color;
&::-webkit-scrollbar{
display: none;
}
}

@mixin flex-middle-start {
Expand Down
4 changes: 4 additions & 0 deletions client/src/utils/dom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const isCloseModalElement = (element: HTMLElement): boolean =>
Copy link
Collaborator

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.

이벤트 버블링이 발생해서 이벤트 버블링을 막기 위해 닫혀야할 곳만 추가하였습니다.

Copy link
Member Author

Choose a reason for hiding this comment

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

모달에 있는 버튼 클릭 이벤트에 이벤트 버블링을 제어하기 위해 작성한 코드입니다

element.matches(".modal-background") ||
element.matches(".modal-close-button") ||
element.matches("path");