261012_01_FST: first commit
This commit is contained in:
76
src/components/common/KriDialog.tsx
Normal file
76
src/components/common/KriDialog.tsx
Normal file
@@ -0,0 +1,76 @@
|
||||
'use client'
|
||||
|
||||
import type { ReactNode } from 'react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
import { cn } from '@/lib/utils'
|
||||
|
||||
export interface KriDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
title: ReactNode
|
||||
description?: ReactNode
|
||||
children?: ReactNode
|
||||
footer?: ReactNode
|
||||
showDefaultFooter?: boolean
|
||||
closeLabel?: string
|
||||
showCloseButton?: boolean
|
||||
contentClassName?: string
|
||||
bodyClassName?: string
|
||||
footerClassName?: string
|
||||
}
|
||||
|
||||
export function KriDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
title,
|
||||
description,
|
||||
children,
|
||||
footer,
|
||||
showDefaultFooter = true,
|
||||
closeLabel = '닫기',
|
||||
showCloseButton = true,
|
||||
contentClassName,
|
||||
bodyClassName,
|
||||
footerClassName,
|
||||
}: KriDialogProps) {
|
||||
const renderFooter = () => {
|
||||
if (footer !== undefined) {
|
||||
if (footer === null) return null
|
||||
return <DialogFooter className={footerClassName}>{footer}</DialogFooter>
|
||||
}
|
||||
|
||||
if (!showDefaultFooter) return null
|
||||
|
||||
return (
|
||||
<DialogFooter className={footerClassName}>
|
||||
<DialogClose asChild>
|
||||
<Button type="button" variant="outline">
|
||||
{closeLabel}
|
||||
</Button>
|
||||
</DialogClose>
|
||||
</DialogFooter>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className={contentClassName} showCloseButton={showCloseButton}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>{title}</DialogTitle>
|
||||
{description ? <DialogDescription>{description}</DialogDescription> : null}
|
||||
</DialogHeader>
|
||||
<div className={cn('min-h-0', bodyClassName)}>{children}</div>
|
||||
{renderFooter()}
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user