import React from 'react';
import { TransitionSpring, presets } from 'react-motion';
export default class Modal {
static propTypes = {
shown: React.PropTypes.bool,
onClose: React.PropTypes.func
};
renderModal(anim) {
const { shown, onClose, children } = this.props;
return (
);
}
getEndValue() {
const { shown } = this.props;
if (!shown) return {};
return {
modal: {
scale: { val: 1, config: presets.wobbly },
opacity: { val: 1, config: presets.stiff }
}
};
}
willEnter() {
return {
scale: { val: .9 },
opacity: { val: .5 }
}
}
willLeave(key, value, endValue, currentValue, currentSpeed) {
return {
scale: { val: .9 },
opacity: { val: 0 }
}
}
render() {
const { shown, onClose } = this.props;
return (
{currentValue =>
{Object.keys(currentValue).map(key =>
this.renderModal(currentValue[key])
)}
}
);
}
}