-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
모달 frame 구축, 텍스트만 들어오는 경우와 이미지 텍스트 모두 들어오는 경우를 고려해서 모달 작성 feed component재사용을 위해서 feed component에서 사이즈 받도록 수정
- Loading branch information
1 parent
aa85ab5
commit 11d6e68
Showing
3 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { ReactNode } from 'react'; | ||
|
||
const ModalFrame = styled.div` | ||
background-color: white; | ||
height: 80%; | ||
position: fixed; | ||
z-index: 2000; | ||
display: flex; | ||
`; | ||
|
||
const ImageContent = styled.div` | ||
flex: 1; | ||
`; | ||
|
||
const TextContent = styled.div` | ||
flex: 0.5; | ||
`; | ||
const ModalBackgroud = styled.div` | ||
width: 100%; | ||
height: 100%; | ||
background: rgba(0, 0, 0, 0.8); | ||
position: fixed; | ||
z-index: 1000; | ||
top: 0; | ||
left: 0; | ||
`; | ||
|
||
const CloseModal = styled.p` | ||
color: white; | ||
float: right; | ||
margin: 1rem; | ||
font-size: 1rem; | ||
cursor: pointer; | ||
`; | ||
interface IProps { | ||
textChildren?: ReactNode; | ||
imageChildren?: ReactNode; | ||
className?: string; | ||
onClick?: () => void; | ||
} | ||
|
||
function Commonmodal({ | ||
onClick, | ||
textChildren, | ||
imageChildren, | ||
className | ||
}: IProps) { | ||
const [isOpen, setIsOpen] = useState(true); | ||
const closeModal = () => { | ||
setIsOpen(false); | ||
}; | ||
return isOpen ? ( | ||
<> | ||
<ModalBackgroud> | ||
<CloseModal onClick={closeModal}>X</CloseModal> | ||
</ModalBackgroud> | ||
|
||
<ModalFrame onClick={onClick} className={className}> | ||
{imageChildren && <ImageContent>{imageChildren}</ImageContent>} | ||
<TextContent>{textChildren}</TextContent> | ||
</ModalFrame> | ||
</> | ||
) : ( | ||
<></> | ||
); | ||
} | ||
|
||
export default Commonmodal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import CommonModal from './CommonModal'; | ||
import Feed from '../Feed/Feed'; | ||
import { useGetfeedsQuery } from 'react-components.d'; | ||
import { getDate } from 'utils/dateUtil'; | ||
import styled from 'styled-components'; | ||
|
||
const ModalFeed = styled(Feed)` | ||
border: none; | ||
border-radius: 0px; | ||
`; | ||
const DetailFeed: React.FC = () => { | ||
const { data } = useGetfeedsQuery({ | ||
variables: { first: 1, currentCursor: '9999-12-31T09:29:26.050Z' } | ||
}); | ||
|
||
const valuecheck = () => { | ||
return data && data.feeds && data.feeds.feedItems | ||
? data.feeds.feedItems.map((feed, idx) => { | ||
return feed && feed.feed && feed.feed.createdAt ? ( | ||
<ModalFeed | ||
key={getDate(feed.feed.createdAt).toISOString() + idx} | ||
content={feed.feed.content} | ||
feedinfo={feed} | ||
createdAt={getDate(feed.feed.createdAt).toISOString()} | ||
feedSize={'30rem'} | ||
/> | ||
) : ( | ||
<></> | ||
); | ||
}) | ||
: ''; | ||
}; | ||
return <CommonModal textChildren={valuecheck()} imageChildren={<></>} />; | ||
}; | ||
|
||
export default DetailFeed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters