FormMessage.tsx32 lines · main
1import { AnimatePresence, motion } from 'framer-motion'
2import { Admonition } from 'ui-patterns'
3
4interface FormMessageProps {
5 message: string
6 type?: 'error' | 'success'
7 children?: React.ReactNode
8}
9
10function FormMessage({ message = 'error', type, children }: FormMessageProps) {
11 return (
12 <AnimatePresence>
13 {message && (
14 <motion.div
15 initial={{ opacity: 0, height: 0 }}
16 animate={{ opacity: 1, height: 'auto' }}
17 exit={{ opacity: 0, height: 0 }}
18 >
19 <Admonition
20 type={type === 'error' ? 'destructive' : 'default'}
21 className="mt-2"
22 title={message}
23 >
24 {children}
25 </Admonition>
26 </motion.div>
27 )}
28 </AnimatePresence>
29 )
30}
31
32export default FormMessage