All files / app/components TransitionVisible.tsx

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                                                                       
import React from 'react';
import { style } from 'app/styles';
 
export interface TransitionVisibleProps {
  isVisible: boolean;
  children: string | JSX.Element | JSX.Element[];
  style?: object | string;
}
 
const outerStyle = {
  display: 'inline-block',
};
 
const visibleStyle = {
  visibility: 'visible',
  opacity: 1,
  transition: 'all 2s linear',
};
 
const hiddenStyle = {
  visibility: 'hidden',
  opacity: 0,
  transition: 'all .5s ease',
};
 
export class TransitionVisible extends React.Component<TransitionVisibleProps> {
  render() {
    const addStyle = this.props.isVisible ? visibleStyle : hiddenStyle;
    return (
      <div style={style(outerStyle, this.props.style, addStyle)}>
        {this.props.children}
      </div>
    );
  }
}