Files
front-ui-registry/registry/components/kri-editor/KriEditorKko.tsx

60 lines
2.6 KiB
TypeScript

'use client'
import { User } from 'lucide-react'
import { cn } from '@/lib/utils'
import type { KriEditorProps } from './types'
type KkoEditorProps = Omit<KriEditorProps, 'mode'> & { mode: 'kko' }
export function KriEditorKko({
label,
value,
placeholder = '미리볼 내용이 없습니다.',
className,
kkoTitle = '',
kkoSenderName = '',
kkoHeaderLabel = '알림톡 도착',
}: KkoEditorProps) {
const body = value ?? ''
return (
<div className={cn('mx-auto w-full max-w-[320px]', className)}>
{label ? <div className="mb-2 text-sm font-semibold">{label}</div> : null}
<div className="relative h-[600px] w-full overflow-hidden rounded-[40px] border-8 border-gray-800 bg-white shadow-2xl">
<div className="absolute top-0 left-1/2 z-10 h-6 w-32 -translate-x-1/2 rounded-b-2xl bg-gray-800" />
<div className="flex h-full flex-col bg-[#d6e4f7] pt-8 pb-4">
{kkoSenderName ? (
<div className="border-b border-black/10 px-4 pb-3 text-center text-sm font-bold text-gray-900">{kkoSenderName}</div>
) : null}
<div className="flex-1 overflow-y-auto px-3 py-3">
{kkoSenderName ? (
<div className="mb-1 flex items-center gap-2">
<span aria-hidden="true" className="flex size-8 shrink-0 items-center justify-center rounded-full bg-gray-300 text-white">
<User className="size-5" />
</span>
<span className="text-xs text-gray-600">{kkoSenderName}</span>
</div>
) : null}
<div className="relative mr-3 ml-10 rounded-xl bg-white shadow-sm">
<span
aria-hidden="true"
className="absolute -top-3 -right-3 flex size-8 items-center justify-center rounded-full bg-gray-800 text-[9px] font-bold text-white"
>
kakao
</span>
<div className="rounded-t-xl bg-[#FEE500] px-4 py-3 text-sm font-bold text-gray-900">{kkoHeaderLabel}</div>
{kkoTitle ? <div className="px-4 pt-3 text-sm font-bold break-words whitespace-pre-wrap text-gray-800">{kkoTitle}</div> : null}
{body.trim() ? (
<div className="px-4 py-3 text-sm leading-relaxed break-words whitespace-pre-wrap text-gray-700">{body}</div>
) : (
<div className="px-4 py-3 text-sm text-gray-400">{placeholder}</div>
)}
</div>
</div>
</div>
<div className="absolute bottom-2 left-1/2 h-1 w-32 -translate-x-1/2 rounded-full bg-gray-800" />
</div>
</div>
)
}