mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
* Updated package json but not updated source files * Update eslint plugin * updated files
45 lines
1.0 KiB
TypeScript
45 lines
1.0 KiB
TypeScript
import React, { FC, CSSProperties } from 'react';
|
|
import Transition, { ExitHandler } from 'react-transition-group/Transition';
|
|
|
|
interface Props {
|
|
duration: number;
|
|
children: JSX.Element;
|
|
in: boolean;
|
|
unmountOnExit?: boolean;
|
|
onExited?: ExitHandler<HTMLDivElement>;
|
|
}
|
|
|
|
export const FadeIn: FC<Props> = (props) => {
|
|
const defaultStyle: CSSProperties = {
|
|
transition: `opacity ${props.duration}ms linear`,
|
|
opacity: 0,
|
|
};
|
|
|
|
const transitionStyles: { [str: string]: CSSProperties } = {
|
|
exited: { opacity: 0, display: 'none' },
|
|
entering: { opacity: 0 },
|
|
entered: { opacity: 1 },
|
|
exiting: { opacity: 0 },
|
|
};
|
|
|
|
return (
|
|
<Transition
|
|
in={props.in}
|
|
timeout={props.duration}
|
|
unmountOnExit={props.unmountOnExit || false}
|
|
onExited={props.onExited}
|
|
>
|
|
{(state) => (
|
|
<div
|
|
style={{
|
|
...defaultStyle,
|
|
...transitionStyles[state],
|
|
}}
|
|
>
|
|
{props.children}
|
|
</div>
|
|
)}
|
|
</Transition>
|
|
);
|
|
};
|