-
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh(weg-tb): configurable animation for context menus
- Loading branch information
Showing
18 changed files
with
122 additions
and
37 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
41 changes: 41 additions & 0 deletions
41
src/apps/shared/components/AnimatedWrappers/AnimatedDropdown/index.tsx
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,41 @@ | ||
import { Dropdown, DropdownProps } from 'antd'; | ||
import { useState } from 'react'; | ||
|
||
import { CustomAnimationProps } from '../domain'; | ||
|
||
import { useTimeout } from '../../../hooks'; | ||
import { cx } from '../../../styles'; | ||
|
||
export interface AnimatedDropwonProps extends DropdownProps { | ||
animationDescription: CustomAnimationProps; | ||
} | ||
|
||
export function AnimatedDropdown({ children, open, dropdownRender, animationDescription, ...dropdownProps }: AnimatedDropwonProps) { | ||
const [delayedOpenPopover, setDelayedOpenPopover] = useState(false); | ||
|
||
useTimeout(() => { | ||
setDelayedOpenPopover(!!open); | ||
}, animationDescription.maxAnimationTimeMs, [open]); | ||
|
||
const animationObject = {}; | ||
if (animationDescription.openAnimationName) { | ||
animationObject[animationDescription.openAnimationName] = open && !delayedOpenPopover; | ||
} | ||
if (animationDescription.closeAnimationName) { | ||
animationObject[animationDescription.closeAnimationName] = delayedOpenPopover && !open; | ||
} | ||
|
||
return ( | ||
<Dropdown | ||
open={open || delayedOpenPopover} | ||
{...dropdownProps} | ||
dropdownRender={(origin) => dropdownRender && | ||
<div className={cx(animationObject)}> | ||
{dropdownRender(origin)} | ||
</div> | ||
} | ||
> | ||
{children} | ||
</Dropdown> | ||
); | ||
} |
14 changes: 5 additions & 9 deletions
14
...ared/components/AnimatedPopover/index.tsx → ...nimatedWrappers/AnimatedPopover/index.tsx
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,5 @@ | ||
export interface CustomAnimationProps { | ||
maxAnimationTimeMs: number; | ||
openAnimationName: String; | ||
closeAnimationName: String; | ||
} |
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,2 @@ | ||
export { AnimatedDropdown } from './AnimatedDropdown'; | ||
export { AnimatedPopover } from './AnimatedPopover'; |
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
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
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