-
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.
[FEATURE] 공홈 어드민 배포 전 모달 띄우고 성공 시 성공 alert 띄우기
- Loading branch information
Showing
7 changed files
with
172 additions
and
99 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
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,70 @@ | ||
import { CheckBox } from '@sopt-makers/ui'; | ||
import { type HTMLAttributes, useState } from 'react'; | ||
import type { FieldValues, SubmitHandler } from 'react-hook-form'; | ||
|
||
import Modal from '@/components/common/modal'; | ||
|
||
import { | ||
StActionButton, | ||
StCancelButton, | ||
StModalBtnWrapper, | ||
StModalContainer, | ||
} from './style'; | ||
|
||
interface ActionModalProps extends Omit<HTMLAttributes<HTMLDivElement>, 'id'> { | ||
isOpen: boolean; | ||
onCancel?: () => void; | ||
onAction?: () => void | SubmitHandler<FieldValues>; | ||
variant: 'add' | 'delete' | 'deploy'; | ||
alertText: string; | ||
description?: string; | ||
} | ||
|
||
export const ActionModal = ({ | ||
isOpen, | ||
onCancel, | ||
onAction, | ||
variant, | ||
alertText, | ||
description, | ||
}: ActionModalProps) => { | ||
const [checked, setChecked] = useState(false); | ||
|
||
return ( | ||
isOpen && ( | ||
<Modal> | ||
<StModalContainer> | ||
<h2>{alertText}</h2> | ||
<p>{description}</p> | ||
<CheckBox | ||
label="확인했어요." | ||
checked={checked} | ||
onChange={() => setChecked((prev) => !prev)} | ||
/> | ||
<StModalBtnWrapper> | ||
<StCancelButton | ||
onClick={() => { | ||
onCancel && onCancel(); | ||
setChecked(false); | ||
}}> | ||
취소 | ||
</StCancelButton> | ||
<StActionButton | ||
btntype={variant} | ||
disabled={!checked} | ||
onClick={() => { | ||
setChecked(false); | ||
onAction && onAction(); | ||
}}> | ||
{variant === 'add' | ||
? '추가' | ||
: variant === 'delete' | ||
? '삭제' | ||
: '배포'} | ||
</StActionButton> | ||
</StModalBtnWrapper> | ||
</StModalContainer> | ||
</Modal> | ||
) | ||
); | ||
}; |
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,54 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
import { fontsObject } from '@sopt-makers/fonts'; | ||
import { Button } from '@sopt-makers/ui'; | ||
|
||
export const StModalContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 12px; | ||
padding: 24px; | ||
& > h2 { | ||
${fontsObject.TITLE_4_20_SB}; | ||
color: ${colors.gray10}; | ||
} | ||
& > p { | ||
${fontsObject.BODY_2_16_R}; | ||
color: ${colors.gray100}; | ||
white-space: pre-line; | ||
} | ||
`; | ||
|
||
export const StModalBtnWrapper = styled.div` | ||
place-self: end; | ||
display: flex; | ||
gap: 12px; | ||
padding-top: 24px; | ||
`; | ||
|
||
export const StCancelButton = styled(Button)` | ||
background-color: ${colors.gray600}; | ||
color: ${colors.white}; | ||
&:hover { | ||
color: ${colors.black}; | ||
} | ||
`; | ||
|
||
export const StActionButton = styled(Button)<{ | ||
btntype: 'add' | 'delete' | 'deploy'; | ||
}>` | ||
color: ${(props) => (props.btntype === 'add' ? colors.black : colors.white)}; | ||
background-color: ${(props) => | ||
props.btntype === 'add' ? colors.white : colors.error}; | ||
&:disabled { | ||
cursor: default; | ||
} | ||
`; |
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