NoticeBar.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { AnimatePresence, motion } from 'framer-motion'
  2. import { type ComponentProps, type ReactNode } from 'react'
  3. import { cn } from 'ui'
  4. import { Admonition } from 'ui-patterns'
  5. /**
  6. * @deprecated Use Admonition from ui-patterns instead
  7. * Pass actions as a prop to the Admonition component
  8. */
  9. interface NoticeBarProps extends Omit<ComponentProps<typeof Admonition>, 'description'> {
  10. title?: string
  11. description?: string
  12. icon?: ReactNode
  13. visible: boolean
  14. actions?: ReactNode
  15. }
  16. export function NoticeBar({ visible, description, actions, ...props }: NoticeBarProps) {
  17. return (
  18. <AnimatePresence>
  19. {visible && (
  20. <motion.div
  21. initial={{ opacity: 0, height: 0, y: 4 }}
  22. animate={{ opacity: 1, height: 'auto', y: 0 }}
  23. exit={{ opacity: 0, height: 0, y: 4 }}
  24. transition={{ duration: 0.15 }}
  25. >
  26. <Admonition {...props} className={cn(props.className, 'mb-0')}>
  27. {description}
  28. <div className="flex flex-col gap-2">
  29. {actions && <div className="mt-2">{actions}</div>}
  30. </div>
  31. </Admonition>
  32. </motion.div>
  33. )}
  34. </AnimatePresence>
  35. )
  36. }