action-panel.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { ComponentProps, forwardRef } from 'react'
  2. import { Button, Card, CardDescription, CardHeader, CardTitle } from 'ui'
  3. interface ActionPanelProps extends Omit<React.ComponentProps<typeof Card>, 'onClick' | 'type'> {
  4. title: string
  5. description: string
  6. buttonLabel: ComponentProps<typeof Button>['children']
  7. onClick: ComponentProps<typeof Button>['onClick']
  8. loading: ComponentProps<typeof Button>['loading']
  9. icon?: ComponentProps<typeof Button>['icon']
  10. type?: ComponentProps<typeof Button>['type']
  11. }
  12. export const ActionPanel = forwardRef<HTMLDivElement, ActionPanelProps>(
  13. ({ title, description, buttonLabel, onClick, loading, icon, type, ...props }, ref) => {
  14. return (
  15. <Card
  16. className="first:rounded-b-none last:rounded-t-none shadow-none only:rounded-lg"
  17. ref={ref}
  18. {...props}
  19. >
  20. <CardHeader className="lg:flex-row lg:items-center gap-3 lg:gap-10 py-4 border-0">
  21. <div className="flex flex-col gap-2 flex-1 grow">
  22. <CardTitle className="text-sm">{title}</CardTitle>
  23. <CardDescription className="max-w-xl">{description}</CardDescription>
  24. </div>
  25. <div className="flex lg:justify-end flex-">
  26. <Button onClick={onClick} loading={loading} icon={icon} type={type}>
  27. {buttonLabel}
  28. </Button>
  29. </div>
  30. </CardHeader>
  31. </Card>
  32. )
  33. }
  34. )
  35. ActionPanel.displayName = 'ActionPanel'