chore: to new transation

This commit is contained in:
Joel 2025-02-06 18:06:55 +08:00
parent fef2326d6e
commit 7ddb568804
6 changed files with 103 additions and 192 deletions

View File

@ -242,7 +242,7 @@ const SettingsModal: FC<ISettingsModalProps> = ({
onChange={e => onDesChange(e.target.value)}
placeholder={t(`${prefixSettings}.webDescPlaceholder`) as string}
/>
{isChatBot && (
{isChat && (
<div className='w-full mt-4'>
<div className='flex justify-between items-center'>
<div className={cn('system-sm-semibold text-text-secondary')}>{t('app.answerIcon.title')}</div>

View File

@ -1,6 +1,6 @@
import { Fragment, useCallback } from 'react'
import type { ElementType, ReactNode } from 'react'
import { Dialog, DialogPanel, DialogTitle, Transition } from '@headlessui/react'
import { Dialog, DialogPanel, DialogTitle, Transition, TransitionChild } from '@headlessui/react'
import classNames from '@/utils/classnames'
// https://headlessui.com/react/dialog
@ -34,32 +34,25 @@ const CustomDialog = ({
return (
<Transition appear show={show} as={Fragment}>
<Dialog as="div" className="relative z-40" onClose={close}>
{/* <Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-25" />
</Transition.Child> */}
{/* TODO: to new Transition */}
<div className="fixed inset-0 bg-black bg-opacity-25" />
<TransitionChild>
<div className={classNames(
'fixed inset-0 bg-black bg-opacity-25',
'data-[closed]:opacity-0',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0',
)} />
</TransitionChild>
<div className="fixed inset-0 overflow-y-auto">
<div className="flex items-center justify-center min-h-full">
{/* <Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<DialogPanel className={classNames('w-full max-w-[800px] p-6 overflow-hidden transition-all transform bg-components-panel-bg border-[0.5px] border-components-panel-border shadow-xl rounded-2xl', className)}>
<TransitionChild>
<DialogPanel className={classNames(
'w-full max-w-[800px] p-6 overflow-hidden transition-all transform bg-components-panel-bg border-[0.5px] border-components-panel-border shadow-xl rounded-2xl',
'data-[closed]:opacity-0 data-[closed]:scale-95',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100 data-[enter]:scale-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0 data-[enter]:scale-95',
className,
)}>
{Boolean(title) && (
<DialogTitle
as={titleAs || 'h3'}
@ -77,26 +70,7 @@ const CustomDialog = ({
</div>
)}
</DialogPanel>
</Transition.Child> */}
{/* TODO: to new Transition */}
<DialogPanel className={classNames('w-full max-w-[800px] p-6 overflow-hidden transition-all transform bg-components-panel-bg border-[0.5px] border-components-panel-border shadow-xl rounded-2xl', className)}>
{Boolean(title) && (
<DialogTitle
as={titleAs || 'h3'}
className={classNames('pr-8 pb-3 title-2xl-semi-bold text-text-primary', titleClassName)}
>
{title}
</DialogTitle>
)}
<div className={classNames(bodyClassName)}>
{children}
</div>
{Boolean(footer) && (
<div className={classNames('flex items-center justify-end gap-2 px-6 pb-6 pt-3', footerClassName)}>
{footer}
</div>
)}
</DialogPanel>
</TransitionChild>
</div>
</div>
</Dialog>

View File

@ -1,6 +1,6 @@
import { Fragment, useCallback } from 'react'
import type { ReactNode } from 'react'
import { Dialog, DialogPanel, Transition } from '@headlessui/react'
import { Dialog, DialogPanel, Transition, TransitionChild } from '@headlessui/react'
import cn from '@/utils/classnames'
type DialogProps = {
@ -22,39 +22,29 @@ const DialogWrapper = ({
return (
<Transition appear show={show} as={Fragment}>
<Dialog as="div" className="relative z-40" onClose={close}>
{/* <Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-black bg-opacity-25" />
</Transition.Child> */}
{/* TODO: to new Transition */}
<div className="fixed inset-0 bg-black bg-opacity-25" />
<TransitionChild>
<div className={cn(
'fixed inset-0 bg-black bg-opacity-25',
'data-[closed]:opacity-0',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0',
)} />
</TransitionChild>
<div className="fixed inset-0">
<div className={cn('flex flex-col items-end justify-center min-h-full pb-2', inWorkflow ? 'pt-[112px]' : 'pt-[64px] pr-2')}>
{/* <Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<DialogPanel className={cn('grow flex flex-col relative w-[420px] h-0 p-0 overflow-hidden text-left align-middle transition-all transform bg-components-panel-bg-alt border-components-panel-border shadow-xl', inWorkflow ? 'border-t-[0.5px] border-l-[0.5px] border-b-[0.5px] rounded-l-2xl' : 'border-[0.5px] rounded-2xl', className)}>
<TransitionChild>
<DialogPanel className={cn(
'grow flex flex-col relative w-[420px] h-0 p-0 overflow-hidden text-left align-middle transition-all transform bg-components-panel-bg-alt border-components-panel-border shadow-xl',
inWorkflow ? 'border-t-[0.5px] border-l-[0.5px] border-b-[0.5px] rounded-l-2xl' : 'border-[0.5px] rounded-2xl',
'data-[closed]:opacity-0 data-[closed]:scale-95',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100 data-[enter]:scale-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0 data-[enter]:scale-95',
className,
)}>
{children}
</DialogPanel>
</Transition.Child> */}
{/* TODO: to new Transition */}
<DialogPanel className={cn('grow flex flex-col relative w-[420px] h-0 p-0 overflow-hidden text-left align-middle transition-all transform bg-components-panel-bg-alt border-components-panel-border shadow-xl', inWorkflow ? 'border-t-[0.5px] border-l-[0.5px] border-b-[0.5px] rounded-l-2xl' : 'border-[0.5px] rounded-2xl', className)}>
{children}
</DialogPanel>
</TransitionChild>
</div>
</div>
</Dialog>

View File

@ -1,7 +1,7 @@
import { Dialog, DialogPanel, Transition } from '@headlessui/react'
import { Dialog, DialogPanel, Transition, TransitionChild } from '@headlessui/react'
import { Fragment } from 'react'
import { RiCloseLargeLine } from '@remixicon/react'
import classNames from '@/utils/classnames'
import { useEffect, useState } from 'react'
type IModal = {
className?: string
@ -24,59 +24,51 @@ export default function FullScreenModal({
closable = false,
overflowVisible = false,
}: IModal) {
const [showTransition, setShowTransition] = useState(false)
useEffect(() => {
if (!open) {
setShowTransition(false)
return
}
setTimeout(() => {
setShowTransition(true)
}, 100)
}, [open])
return (
<Dialog as="div" className={classNames('modal-dialog', wrapperClassName)} onClose={onClose} open={open}>
<Transition show={showTransition}>
<div className={classNames(
'fixed inset-0 bg-background-overlay-backdrop backdrop-blur-[6px] transition',
'data-[closed]:opacity-0',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0',
)} />
</Transition>
<Transition appear show={open} as={Fragment}>
<Dialog as="div" className={classNames('modal-dialog', wrapperClassName)} onClose={onClose} open={open}>
<TransitionChild>
<div className={classNames(
'fixed inset-0 bg-background-overlay-backdrop backdrop-blur-[6px] transition',
'data-[closed]:opacity-0',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0',
)} />
</TransitionChild>
<div
className="fixed inset-0 h-screen w-screen p-4"
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
}}
>
<div className="w-full h-full bg-background-default-subtle rounded-2xl border border-effects-highlight relative">
<Transition show={showTransition}>
<DialogPanel className={classNames(
'h-full transition',
overflowVisible ? 'overflow-visible' : 'overflow-hidden',
'data-[closed]:opacity-0',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0',
className,
)}>
{closable
&& <div
className='absolute z-50 top-3 right-3 w-9 h-9 flex items-center justify-center rounded-[10px]
<div
className="fixed inset-0 h-screen w-screen p-4"
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
}}
>
<div className="w-full h-full bg-background-default-subtle rounded-2xl border border-effects-highlight relative">
<TransitionChild>
<DialogPanel className={classNames(
'h-full transition',
overflowVisible ? 'overflow-visible' : 'overflow-hidden',
'data-[closed]:opacity-0',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0',
className,
)}>
{closable
&& <div
className='absolute z-50 top-3 right-3 w-9 h-9 flex items-center justify-center rounded-[10px]
bg-components-button-tertiary-bg hover:bg-components-button-tertiary-bg-hover cursor-pointer'
onClick={(e) => {
e.stopPropagation()
onClose()
}}>
<RiCloseLargeLine className='w-3.5 h-3.5 text-components-button-tertiary-text' />
</div>}
{children}
</DialogPanel>
</Transition>
onClick={(e) => {
e.stopPropagation()
onClose()
}}>
<RiCloseLargeLine className='w-3.5 h-3.5 text-components-button-tertiary-text' />
</div>}
{children}
</DialogPanel>
</TransitionChild>
</div>
</div>
</div>
</Dialog>
</Dialog>
</Transition>
)
}

View File

@ -1,4 +1,4 @@
import { Dialog, DialogPanel, DialogTitle, Transition } from '@headlessui/react'
import { Dialog, DialogPanel, DialogTitle, Transition, TransitionChild } from '@headlessui/react'
import { Fragment } from 'react'
import { RiCloseLine } from '@remixicon/react'
import classNames from '@/utils/classnames'
@ -30,19 +30,14 @@ export default function Modal({
return (
<Transition appear show={isShow} as={Fragment}>
<Dialog as="div" className={classNames('relative z-[60]', wrapperClassName)} onClose={onClose}>
{/* <Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0"
enterTo="opacity-100"
leave="ease-in duration-200"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<div className="fixed inset-0 bg-background-overlay" />
</Transition.Child> */}
{/* TODO: to new Transition */}
<div className="fixed inset-0 bg-background-overlay" />
<TransitionChild>
<div className={classNames(
'fixed inset-0 bg-background-overlay',
'data-[closed]:opacity-0',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0',
)} />
</TransitionChild>
<div
className="fixed inset-0 overflow-y-auto"
@ -52,18 +47,13 @@ export default function Modal({
}}
>
<div className="flex min-h-full items-center justify-center p-4 text-center">
{/* <Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<TransitionChild>
<DialogPanel className={classNames(
'w-full max-w-[480px] transform rounded-2xl bg-components-panel-bg p-6 text-left align-middle shadow-xl transition-all',
overflowVisible ? 'overflow-visible' : 'overflow-hidden',
'data-[closed]:opacity-0',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0',
className,
)}>
{title && <DialogTitle
@ -86,33 +76,7 @@ export default function Modal({
</div>}
{children}
</DialogPanel>
</Transition.Child> */}
{/* TODO: to new Transition */}
<DialogPanel className={classNames(
'w-full max-w-[480px] transform rounded-2xl bg-components-panel-bg p-6 text-left align-middle shadow-xl transition-all',
overflowVisible ? 'overflow-visible' : 'overflow-hidden',
className,
)}>
{title && <DialogTitle
as="h3"
className="title-2xl-semi-bold text-text-primary"
>
{title}
</DialogTitle>}
{description && <div className='text-text-secondary body-md-regular mt-2'>
{description}
</div>}
{closable
&& <div className='absolute z-10 top-6 right-6 w-5 h-5 rounded-2xl flex items-center justify-center hover:cursor-pointer hover:bg-state-base-hover'>
<RiCloseLine className='w-4 h-4 text-text-tertiary' onClick={
(e) => {
e.stopPropagation()
onClose()
}
} />
</div>}
{children}
</DialogPanel>
</TransitionChild>
</div>
</div>
</Dialog>

View File

@ -35,22 +35,13 @@ const MenuDialog = ({
<Dialog as="div" className="relative z-[60]" onClose={() => { }}>
<div className="fixed inset-0">
<div className="flex flex-col items-center justify-center min-h-full">
{/* <Transition.Child
as={Fragment}
enter="ease-out duration-300"
enterFrom="opacity-0 scale-95"
enterTo="opacity-100 scale-100"
leave="ease-in duration-200"
leaveFrom="opacity-100 scale-100"
leaveTo="opacity-0 scale-95"
>
<DialogPanel className={cn('grow relative w-full h-full p-0 overflow-hidden text-left align-middle transition-all transform bg-background-sidenav-bg backdrop-blur-md', className)}>
<div className='absolute top-0 right-0 h-full w-1/2 bg-components-panel-bg' />
{children}
</DialogPanel>
</Transition.Child> */}
{/* TODO: to new Transition */}
<DialogPanel className={cn('grow relative w-full h-full p-0 overflow-hidden text-left align-middle transition-all transform bg-background-sidenav-bg backdrop-blur-md', className)}>
<DialogPanel className={cn(
'grow relative w-full h-full p-0 overflow-hidden text-left align-middle transition-all transform bg-background-sidenav-bg backdrop-blur-md',
'data-[closed]:opacity-0 data-[closed]:scale-95',
'data-[enter]:ease-out data-[enter]:duration-300 data-[enter]:opacity-100 data-[enter]:scale-100',
'data-[leave]:ease-in data-[leave]:duration-200 data-[leave]:opacity-0 data-[enter]:scale-95',
className,
)}>
<div className='absolute top-0 right-0 h-full w-1/2 bg-components-panel-bg' />
{children}
</DialogPanel>