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