Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

1.9 KB
Raw Blame
import type { ReactNode } from 'react'
import {
  Dialog,
  DialogBackdrop,
  DialogClose,
  DialogPopup,
  DialogPortal,
  DialogTitle,
  DialogViewport,
} from '@langgenius/dify-ui/dialog'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useTranslation } from 'react-i18next'

type MenuDialogProps = {
  children: ReactNode
  title: string
  onClose: () => void
}

const MenuDialog = ({ children, title, onClose }: MenuDialogProps) => {
  const { t } = useTranslation(['common'])

  return (
    <Dialog
      open
      onOpenChange={(open) => {
        if (!open) onClose()
      }}
    >
      <DialogPortal>
        <DialogBackdrop className="bg-transparent" />
        <DialogViewport>
          <DialogPopup className="pointer-events-none isolate h-full w-full scale-100 transition-opacity data-ending-style:scale-100 data-starting-style:scale-100">
            <DialogTitle className="sr-only">{title}</DialogTitle>
            <div className="pointer-events-auto absolute inset-e-6 top-6 z-10 flex shrink-0 flex-col items-center">
              <DialogClose
                render={
                  <IconButton
                    variant="tertiary"
                    size="xl"
                    aria-label={t(($) => $['operation.close'], { ns: 'common' })}
                  >
                    <span aria-hidden className="i-ri-close-line size-5" />
                  </IconButton>
                }
              />
              <div aria-hidden className="mt-1 system-2xs-medium-uppercase text-text-tertiary">
                ESC
              </div>
            </div>
            <div className="pointer-events-auto relative z-0 h-full w-full overflow-hidden bg-background-sidenav-bg backdrop-blur-md">
              {children}
            </div>
          </DialogPopup>
        </DialogViewport>
      </DialogPortal>
    </Dialog>
  )
}

export default MenuDialog