FormPanel.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import { forwardRef, HTMLAttributes } from 'react'
  2. import { cn } from 'ui'
  3. interface Props {
  4. children: React.ReactNode
  5. header?: React.ReactNode
  6. footer?: React.ReactNode
  7. /**
  8. * Fades the panel and clicks are disabled
  9. */
  10. disabled?: boolean
  11. }
  12. /** @deprecated Use Card instead, refer to BasicAuthSettingsForm.tsx for reference */
  13. export const FormPanel = ({ children, header, footer }: Props) => (
  14. <FormPanelContainer>
  15. {header && <FormPanelHeader>{header}</FormPanelHeader>}
  16. <FormPanelContent className="divide-y">{children}</FormPanelContent>
  17. {footer && <FormPanelFooter>{footer}</FormPanelFooter>}
  18. </FormPanelContainer>
  19. )
  20. export const FormPanelContainer = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
  21. ({ children, ...props }, ref) => (
  22. <div
  23. ref={ref}
  24. {...props}
  25. className={cn(
  26. 'bg-surface-100 border overflow-hidden rounded-md shadow-sm max-w-full',
  27. props.className
  28. )}
  29. >
  30. {children}
  31. </div>
  32. )
  33. )
  34. FormPanelContainer.displayName = FormPanelContainer.displayName
  35. export const FormPanelHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
  36. ({ children, ...props }, ref) => (
  37. <div ref={ref} {...props} className={cn('border-default border-b px-8 py-4', props.className)}>
  38. {children}
  39. </div>
  40. )
  41. )
  42. FormPanelHeader.displayName = FormPanelHeader.displayName
  43. export const FormPanelContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
  44. ({ children, ...props }, ref) => (
  45. <div ref={ref} {...props} className={cn('divide-border flex flex-col gap-0', props.className)}>
  46. {children}
  47. </div>
  48. )
  49. )
  50. FormPanelContent.displayName = FormPanelContent.displayName
  51. export const FormPanelFooter = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
  52. ({ children, ...props }, ref) => (
  53. <div ref={ref} {...props} className={cn('border-t', props.className)}>
  54. {children}
  55. </div>
  56. )
  57. )
  58. FormPanelFooter.displayName = FormPanelFooter.displayName