Files
supabase/apps/studio/components/ui/Forms/FormPanel.tsx
Jonathan Summers-Muir 79c5bb9788 [Dashboard] Data API on/off switch (#26796)
* init layouts in project settings

* Update general.tsx

* update gap

* Update Scaffold.tsx

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* spacing issues

* now added a enabled switch

* Revert "now added a enabled switch"

This reverts commit f22050302a.

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* revert

* Update project-postgrest-config-update-mutation.ts

* add bottom padding

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* fix

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* add collapible

* update FormPanel component to be more composable

* Update PostgrestConfig.tsx

* Update PostgrestConfig.tsx

* update callout to warning variant

* Update FormLayout.tsx

* Update PostgrestConfig.tsx

* Small copy changes

---------

Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
2024-06-04 16:02:47 +07:00

67 lines
1.9 KiB
TypeScript

import { HTMLAttributes, forwardRef } from 'react'
import { cn } from 'ui'
interface Props {
children: React.ReactNode
header?: React.ReactNode
footer?: React.ReactNode
/**
* Fades the panel and clicks are disabled
*/
disabled?: boolean
}
const FormPanel = ({ children, header, footer }: Props) => (
<FormPanelContainer>
{header && <FormPanelHeader>{header}</FormPanelHeader>}
<FormPanelContent className="divide-y">{children}</FormPanelContent>
{footer && <FormPanelFooter>{footer}</FormPanelFooter>}
</FormPanelContainer>
)
const FormPanelContainer = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ children, ...props }, ref) => (
<div
ref={ref}
{...props}
className={cn('bg-surface-100 border overflow-hidden rounded-md shadow', props.className)}
>
{children}
</div>
)
)
FormPanelContainer.displayName = FormPanelContainer.displayName
const FormPanelHeader = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ children, ...props }, ref) => (
<div ref={ref} {...props} className={cn('border-default border-b px-8 py-4', props.className)}>
{children}
</div>
)
)
FormPanelHeader.displayName = FormPanelHeader.displayName
const FormPanelContent = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ children, ...props }, ref) => (
<div ref={ref} {...props} className={cn('divide-border flex flex-col gap-0', props.className)}>
{children}
</div>
)
)
FormPanelContent.displayName = FormPanelContent.displayName
const FormPanelFooter = forwardRef<HTMLDivElement, HTMLAttributes<HTMLDivElement>>(
({ children, ...props }, ref) => (
<div ref={ref} {...props} className={cn('border-t', props.className)}>
{children}
</div>
)
)
FormPanelFooter.displayName = FormPanelFooter.displayName
export { FormPanel, FormPanelContainer, FormPanelContent, FormPanelHeader, FormPanelFooter }