Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: remove `Modal` (#46425)

Gildas Garcia49292c0e125d
diff --git a/packages/ui/index.tsx b/packages/ui/index.tsx
index 0ad715c9a99..3e6041569d3 100644
--- a/packages/ui/index.tsx
+++ b/packages/ui/index.tsx
@@ -14,7 +14,6 @@ export * from './src/components/NavMenu'
// OVERLAYS
-export * from './src/components/Modal'
export * from './src/components/SidePanel'
// HTML
diff --git a/packages/ui/src/components/Modal/Modal.module.css b/packages/ui/src/components/Modal/Modal.module.css
deleted file mode 100644
index d87648a4794..00000000000
--- a/packages/ui/src/components/Modal/Modal.module.css
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- Modal animations imported first as so placement styles are not affected.
-*/
-
-/* overlay animation */
-.sbui-modal-overlay--enter {
- @apply ease-out duration-200;
-}
-.sbui-modal-overlay--enterFrom {
- @apply opacity-0;
-}
-.sbui-modal-overlay--enterTo {
- @apply opacity-100;
-}
-.sbui-modal-overlay--leave {
- @apply ease-in duration-150;
-}
-.sbui-modal-overlay--leaveFrom {
- @apply opacity-100;
-}
-.sbui-modal-overlay--leaveTo {
- @apply opacity-0;
-}
-
-/* modal animation */
-.sbui-modal--enter {
- @apply ease-out duration-150 delay-150;
-}
-.sbui-modal--enterFrom {
- @apply opacity-0 translate-y-4 sm:translate-y-0 transform sm:scale-95;
-}
-.sbui-modal--enterTo {
- @apply opacity-100 translate-y-0 transform sm:scale-100;
-}
-.sbui-modal--leave {
- @apply ease-in duration-150;
-}
-.sbui-modal--leaveFrom {
- @apply opacity-100 translate-y-0 transform sm:scale-100;
-}
-.sbui-modal--leaveTo {
- @apply opacity-0 translate-y-4 sm:translate-y-0 transform sm:scale-95;
-}
-
-.sbui-modal-container {
- @apply fixed z-50 inset-0;
-}
-
-.sbui-modal-flex-container {
- @apply flex items-end justify-center min-h-screen pt-4 px-6 pb-20 text-center sm:block sm:p-0;
-}
-
-.sbui-modal-overlay-container {
- @apply fixed inset-0 transition-opacity;
-}
-
-.sbui-modal-overlay {
- @apply absolute inset-0 bg-gray-900 opacity-75;
-}
-
-.sbui-modal-div-trick {
- @apply hidden sm:inline-block sm:align-middle sm:h-screen;
-}
-
-/* .sbui-modal {
- @apply inline-block bg-white dark:bg-dark-800 rounded-lg text-left overflow-hidden shadow-xl transform transition-all align-middle;
- @apply border-gray-400 border border-solid;
- @apply dark:border-gray-600 border border-solid;
-
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
-} */
-
-.sbui-modal--tiny {
- @apply sm:align-middle sm:w-full sm:max-w-xs;
-}
-
-.sbui-modal--small {
- @apply sm:align-middle sm:w-full sm:max-w-sm;
-}
-
-.sbui-modal--medium {
- @apply sm:align-middle sm:w-full sm:max-w-lg;
-}
-
-.sbui-modal--large {
- @apply sm:align-middle sm:w-full max-w-xl;
-}
-
-.sbui-modal-content {
- @apply px-6 pt-5 pb-5 sm:p-6;
-}
-
-.sbui-modal-footer {
- @apply sm:flex sm:flex-row justify-end;
-}
-
-.sbui-modal-footer--with-bg {
- @apply bg-gray-50 dark:bg-dark-600 px-6 py-3 sm:px-6 sm:flex sm:flex-row justify-end;
-}
-
-.sbui-modal-icon-container {
- @apply mx-auto shrink-0 flex items-center justify-center h-12 w-12 rounded-full sm:mx-0 sm:h-10 sm:w-10;
-}
-
-.sbui-modal-icon-container--danger {
- @apply text-red-600 bg-red-600/20;
-}
-
-.sbui-modal-icon-container--warning {
- @apply text-yellow-500 bg-yellow-500/20;
-}
-
-.sbui-modal-icon-container--success {
- @apply text-brand-300 bg-brand-300/20;
-}
-
-.sbui-modal-close-container {
- @apply absolute right-1 top-1;
-}
-
-.sbui-modal-close-container button,
-.dark .sbui-modal-close-container button {
- @apply text-gray-300;
- @apply hover:text-gray-400;
-
- /* @apply dark:text-dark-400; */
- @apply hover:text-dark-300;
-
- @apply hover:bg-transparent;
-}
-
-.sbui-sidepanel__trigger {
- @apply border-none bg-transparent p-0 focus:ring-0;
-}
diff --git a/packages/ui/src/components/Modal/Modal.tsx b/packages/ui/src/components/Modal/Modal.tsx
deleted file mode 100644
index 72cfa9066dd..00000000000
--- a/packages/ui/src/components/Modal/Modal.tsx
+++ /dev/null
@@ -1,172 +0,0 @@
-'use client'
-
-import React, { forwardRef, useEffect } from 'react'
-
-import { cn } from '../../lib/utils/cn'
-import { Button, ButtonVariantProps } from '../Button/Button'
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogFooter,
- DialogHeader,
- DialogSection,
- DialogSectionSeparator,
- DialogTitle,
- DialogTrigger,
-} from '../shadcn/ui/dialog'
-
-export interface ModalProps extends React.ComponentProps<typeof DialogContent> {
- Separator?: React.ComponentType
- Content?: React.ComponentType
- visible?: boolean
- /** @deprecated please add the footer directly in component children. This is to prepare for using <DialogFooter/> component */
- customFooter?: React.ReactNode
- description?: string
- /** @deprecated please add the footer directly in component children. This is to prepare for using <DialogFooter/> component */
- hideFooter?: boolean
- /** @deprecated please add the footer directly in component children. This is to prepare for using <DialogFooter/> component */
- alignFooter?: 'right' | 'left'
- /** @deprecated please add the footer directly in component children. This is to prepare for using <DialogFooter/> component */
- layout?: 'horizontal' | 'vertical'
- loading?: boolean
- onCancel?: any
- cancelText?: string
- onConfirm?: any
- confirmText?: string
- showCloseButton?: boolean
- footerBackground?: boolean
- /** @deprecated please add the footer directly in component children. This is to prepare for using <DialogFooter/> component */
- variant?: ButtonVariantProps['type']
- overlayStyle?: React.CSSProperties
- contentStyle?: React.CSSProperties
- dialogOverlayProps?: React.ComponentProps<typeof DialogContent>['dialogOverlayProps']
- /** @deprecated please consider using <Dialog/> and <DialogTrigger/> components */
- triggerElement?: React.ReactNode
- /** @deprecated please consider using <Dialog/> and <DialogHeader/> components */
- header?: React.ReactNode
- modal?: React.ComponentProps<typeof Dialog>['modal']
- defaultOpen?: React.ComponentProps<typeof Dialog>['defaultOpen']
- /**
- * @deprecated No longer in use
- */
- closable?: boolean
-}
-
-interface ModalType extends React.ForwardRefExoticComponent<
- React.ComponentPropsWithoutRef<typeof DialogContent> & ModalProps
-> {
- Content: React.ComponentType<{ children: React.ReactNode; className?: string }>
- Separator: React.ComponentType
-}
-
-/** @deprecated Use `import { Dialog } from "ui"` instead */
-const Modal = forwardRef<
- React.ElementRef<typeof DialogContent>,
- React.ComponentPropsWithoutRef<typeof DialogContent> & ModalProps
->(
- (
- {
- children,
- customFooter = undefined,
- description,
- hideFooter = false,
- alignFooter = 'left',
- layout = 'horizontal',
- loading = false,
- cancelText = 'Cancel',
- onConfirm = () => {},
- onCancel = () => {},
- confirmText = 'Confirm',
- showCloseButton = true,
- footerBackground,
- variant = 'success',
- visible = false,
- size = 'large',
- style,
- overlayStyle,
- contentStyle,
- triggerElement,
- header,
- modal,
- defaultOpen,
- ...props
- },
- ref
- ) => {
- const [open, setOpen] = React.useState(visible ? visible : false)
-
- useEffect(() => {
- setOpen(visible)
- }, [visible])
-
- const footerContent = customFooter ? (
- customFooter
- ) : (
- <div
- className="flex w-full space-x-2"
- style={{
- width: '100%',
- justifyContent:
- layout === 'vertical' ? 'center' : alignFooter === 'right' ? 'flex-end' : 'flex-start',
- }}
- >
- <Button type="default" onClick={onCancel} disabled={loading}>
- {cancelText}
- </Button>
- <Button
- onClick={onConfirm}
- disabled={loading}
- loading={loading}
- type={variant === 'danger' ? 'danger' : variant === 'warning' ? 'warning' : 'primary'}
- >
- {confirmText}
- </Button>
- </div>
- )
-
- function handleOpenChange(open: boolean) {
- if (visible !== undefined && !open) {
- // controlled component behavior
- onCancel()
- } else {
- // un-controlled component behavior
- setOpen(open)
- }
- }
-
- return (
- <Dialog open={open} defaultOpen={defaultOpen} onOpenChange={handleOpenChange} modal={modal}>
- {triggerElement && <DialogTrigger>{triggerElement}</DialogTrigger>}
- <DialogContent ref={ref} hideClose={!showCloseButton} {...props} size={size}>
- {header || description ? (
- <DialogHeader className={cn('border-b')} padding={'small'}>
- {header && <DialogTitle>{header}</DialogTitle>}
- {description && <DialogDescription>{description}</DialogDescription>}
- </DialogHeader>
- ) : null}
- {children}
- {!hideFooter && <DialogFooter padding={'small'}>{footerContent}</DialogFooter>}
- </DialogContent>
- </Dialog>
- )
- }
-) as ModalType
-
-const Content = forwardRef<
- React.ElementRef<typeof DialogSection>,
- React.ComponentPropsWithoutRef<typeof DialogSection>
->(({ ...props }, ref) => {
- return <DialogSection ref={ref} {...props} padding="small" className={cn(props.className)} />
-})
-
-const Separator = forwardRef<
- React.ElementRef<typeof DialogSectionSeparator>,
- React.ComponentPropsWithoutRef<typeof DialogSectionSeparator>
->(({ ...props }, ref) => {
- return <DialogSectionSeparator ref={ref} {...props} />
-})
-
-Modal.Content = Content
-Modal.Separator = Separator
-export default Modal
diff --git a/packages/ui/src/components/Modal/index.tsx b/packages/ui/src/components/Modal/index.tsx
deleted file mode 100644
index 7a4f2d1dc1e..00000000000
--- a/packages/ui/src/components/Modal/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { default as Modal } from './Modal'