Skip to content

Commit

Permalink
[#3] feat: Common Modal->ModalContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
hanbin9775 committed Aug 7, 2021
1 parent 48bbf82 commit f075576
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 95 deletions.
83 changes: 0 additions & 83 deletions src/common/Modal/Modal.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/common/Modal/index.ts

This file was deleted.

47 changes: 47 additions & 0 deletions src/common/ModalContainer/ModalContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react';
import styled from 'styled-components';

type Props = {
isPopup?: boolean;
contentComponent?: React.ReactNode;
onClickOverlay?: (e: React.MouseEvent<HTMLElement>) => void;
onClickClose?: (e: React.MouseEvent<HTMLElement>) => void;
};

const ModalContainer = ({
isPopup = false,
contentComponent,
onClickOverlay,
onClickClose,
}: Props) => {
return isPopup ? (
<Overlay onClick={onClickOverlay}>{contentComponent}</Overlay>
) : (
<></>
);
};

export default ModalContainer;

const Overlay = styled.div`
display: flex;
position: fixed;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
background-color: rgba(0, 0, 0, 0.5);
justify-content: center;
align-items: center;
`;

ModalContainer.defaultProps = {
isPopup: false,
onClickOverlay: () => {
console.log('modal overlay clicked');
},
onClickClose: () => {
console.log('modal close clicked');
},
contentComponent: '',
};
1 change: 1 addition & 0 deletions src/common/ModalContainer/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './ModalContainer';
14 changes: 3 additions & 11 deletions src/components/Main/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import React, { useState } from 'react';
import { datas } from 'data/main';
import VideoWrapper from 'styles/mainStyles/videoComponents/videoWrapper';
import Modal from 'common/Modal';
import Modal from 'common/ModalContainer';
import VideoModal from 'components/VideoModal';
import LazyItem from './LazyItem';
import VideoSelectBar from './VideoSelectBar';
Expand All @@ -13,15 +13,7 @@ const Main = () => {
return (
<div style={{ width: '65%', margin: 'auto' }}>
<VideoSelectBar popularTags={datas.popularTags} />
<Modal
isOverlayOn
isPopup
width="50%"
height="50%"
borderRadius={5}
borderStyle="none"
contentComponent={<VideoModal />}
/>
<Modal isPopup={false} contentComponent={<VideoModal />} />
<VideoWrapper>
<div>
{lVideos.map((data) => (
Expand Down

0 comments on commit f075576

Please sign in to comment.