mirror of
https://github.com/supabase/supabase.git
synced 2026-07-06 03:54:27 +08:00
• WIP so far. need to update Modals, Sidepanels and fix various things
• Tailwind v2 👉 v3
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { FC, useState } from 'react'
|
|
import { Button } from '@supabase/ui'
|
|
|
|
interface ActionBarProps {
|
|
applyButtonLabel?: string
|
|
backButtonLabel?: string
|
|
children?: any
|
|
disableApply?: boolean
|
|
applyFunction?: (resolve: any) => void
|
|
closePanel: () => void
|
|
}
|
|
const ActionBar: FC<ActionBarProps> = ({
|
|
applyButtonLabel = 'Apply',
|
|
backButtonLabel = 'Back',
|
|
children = null,
|
|
disableApply = false,
|
|
applyFunction = null,
|
|
closePanel,
|
|
}) => {
|
|
const [isRunning, setIsRunning] = useState(false)
|
|
|
|
// @ts-ignore
|
|
const applyCallback = () => new Promise((resolve) => applyFunction(resolve))
|
|
|
|
const onSelectApply = async () => {
|
|
setIsRunning(true)
|
|
await applyCallback()
|
|
setIsRunning(false)
|
|
}
|
|
|
|
return (
|
|
<div className="space-x-3 w-full flex justify-between px-3 py-4 border-t border-scale-500">
|
|
<Button size="small" onClick={closePanel} type="default">
|
|
{backButtonLabel}
|
|
</Button>
|
|
{children}
|
|
{applyFunction && (
|
|
<Button
|
|
size="small"
|
|
onClick={onSelectApply}
|
|
disabled={disableApply || isRunning}
|
|
loading={isRunning}
|
|
>
|
|
{applyButtonLabel}
|
|
</Button>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
export default ActionBar
|