-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init Preview License * [ISSUE-319/콜라보레이션] PR 생성 시 본인에게 지정 (#321) * Create pr-auto-assign.yml * Create pr-auto-assign_configs.yml * init Preview License * add: Preview License Btn * ing * css: previewLicense Img --------- Co-authored-by: ImKunYoung <[email protected]>
- Loading branch information
1 parent
f303262
commit 22ccfde
Showing
3 changed files
with
158 additions
and
16 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
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,57 @@ | ||
import React from 'react'; | ||
import { Modal, Typography, Button } from '@mui/material'; | ||
import CheckIcon from '@mui/icons-material/Check'; | ||
import { StyledModalBox, StyledLabel, ImagesContainer, ButtonContainer } from './StyledComponents'; | ||
|
||
const PreviewLicense = ({ optionItems, onHandleImg, open, handleClose }) => { | ||
const [selectedOption, setSelectedOption] = React.useState(null); | ||
|
||
return ( | ||
<Modal | ||
open={open} | ||
onClose={handleClose} | ||
aria-labelledby='modal-modal-title' | ||
aria-describedby='modal-modal-description' | ||
> | ||
<StyledModalBox> | ||
<Typography variant='h6' component='h2'> | ||
라이센스 이미지 | ||
</Typography> | ||
<ImagesContainer> | ||
{optionItems?.map((optionItem) => { | ||
const isSelected = selectedOption === optionItem.id; | ||
|
||
return ( | ||
<StyledLabel key={optionItem.id} isSelected={isSelected}> | ||
<input | ||
type='radio' | ||
name='test' | ||
checked={isSelected} | ||
onChange={() => setSelectedOption(optionItem.id)} | ||
/> | ||
<img | ||
src={optionItem.artUrl} | ||
alt={optionItem.artName} | ||
onContextMenu={(e) => { | ||
e.preventDefault(); | ||
}} | ||
onClick={(e) => { | ||
setSelectedOption(optionItem.id); | ||
onHandleImg(optionItem.id, e.target.src); | ||
}} | ||
/> | ||
<CheckIcon className='check-icon' /> | ||
</StyledLabel> | ||
); | ||
})} | ||
</ImagesContainer> | ||
<ButtonContainer> | ||
<Button onClick={handleClose}>취소</Button> | ||
<Button onClick={handleClose}>확인</Button> | ||
</ButtonContainer> | ||
</StyledModalBox> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default PreviewLicense; |
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 styled from 'styled-components'; | ||
import { Box } from '@mui/system'; | ||
|
||
export const StyledModalBox = styled(Box)` | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
background-color: #ffffff; | ||
border: 2px solid #000; | ||
box-shadow: 24px; | ||
padding: 16px; | ||
`; | ||
|
||
export const StyledLabel = styled.label` | ||
position: relative; | ||
width: 100%; | ||
height: 100%; | ||
cursor: pointer; | ||
transition: box-shadow 0.3s; | ||
input { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
opacity: 0; | ||
cursor: pointer; | ||
} | ||
img { | ||
width: 100%; | ||
height: 100%; | ||
transition: transform 0.3s; | ||
transform-origin: center center; | ||
} | ||
.check-icon { | ||
position: absolute; | ||
top: 8px; | ||
right: 8px; | ||
display: ${({ isSelected }) => (isSelected ? 'block' : 'none')}; | ||
color: blue; | ||
background-color: white; | ||
border-radius: 50%; | ||
padding: 4px; | ||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.5); | ||
} | ||
&:hover { | ||
img { | ||
transform: scale(1.05); | ||
} | ||
} | ||
`; | ||
|
||
export const ImagesContainer = styled.div` | ||
display: flex; | ||
gap: 16px; | ||
overflow-x: auto; | ||
padding: 16px; | ||
`; | ||
|
||
export const ButtonContainer = styled.div` | ||
display: flex; | ||
justify-content: flex-end; | ||
gap: 8px; | ||
margin-top: 16px; | ||
`; |