forked from lobehub/lobe-chat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄 style: improve portal style (lobehub#6588)
* improve portal style * update style * improve
- Loading branch information
Showing
7 changed files
with
153 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { AnimatePresence, motion } from 'framer-motion'; | ||
import { CSSProperties, ReactNode, memo } from 'react'; | ||
|
||
interface AnimatedCollapsedProps { | ||
children: ReactNode; | ||
height?: { | ||
collapsed?: string | number; | ||
open?: string | number; | ||
}; | ||
open: boolean; | ||
style?: CSSProperties; | ||
styles?: { | ||
collapsed?: CSSProperties; | ||
open?: CSSProperties; | ||
}; | ||
width?: { | ||
collapsed?: string | number; | ||
open?: string | number; | ||
}; | ||
} | ||
|
||
const AnimatedCollapsed = memo<AnimatedCollapsedProps>( | ||
({ open, children, styles, style, width, height }) => { | ||
return ( | ||
<AnimatePresence initial={false}> | ||
{open && ( | ||
<motion.div | ||
animate="open" | ||
exit="collapsed" | ||
initial="collapsed" | ||
style={style} | ||
transition={{ | ||
duration: 0.2, | ||
ease: [0.4, 0, 0.2, 1], // 使用 ease-out 缓动函数 | ||
}} | ||
variants={{ | ||
collapsed: { | ||
...(styles?.collapsed as any), | ||
height: height?.collapsed ?? 0, | ||
opacity: 0, | ||
width: width?.collapsed ?? 0, | ||
}, | ||
open: { | ||
...(styles?.open as any), | ||
height: height?.open ?? 'auto', | ||
opacity: 1, | ||
width: width?.open ?? 'auto', | ||
}, | ||
}} | ||
> | ||
{children} | ||
</motion.div> | ||
)} | ||
</AnimatePresence> | ||
); | ||
}, | ||
); | ||
|
||
export default AnimatedCollapsed; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters