From b471adb0ef64266a03f618c752b9c09226062da2 Mon Sep 17 00:00:00 2001 From: Eric Schultz Date: Thu, 14 Feb 2019 16:16:26 -0600 Subject: [PATCH] Add Javascript animation to modal opening and closing --- javascripts/src/components/common/Modal.tsx | 70 ++++++++--- .../common/__snapshots__/Modal.spec.tsx.snap | 114 ++++++++++++++---- 2 files changed, 146 insertions(+), 38 deletions(-) diff --git a/javascripts/src/components/common/Modal.tsx b/javascripts/src/components/common/Modal.tsx index 679c8728..819915d3 100644 --- a/javascripts/src/components/common/Modal.tsx +++ b/javascripts/src/components/common/Modal.tsx @@ -2,37 +2,73 @@ import * as React from 'react'; import { observer } from 'mobx-react'; import AriaModal = require('react-aria-modal'); +import { VelocityTransitionGroup } from 'velocity-react'; +import 'velocity-animate'; +import 'velocity-animate/velocity.ui'; -export interface ModalProps -{ +export interface ModalProps { onClose?: () => void // if you want your modal to close, this needs to set modalActive to false modalActive?: boolean titleText?: string - focusDialog?:boolean - dialogStyle?:any - childGenerator:() => any + focusDialog?: boolean + dialogStyle?: any + childGenerator: () => any } class Modal extends React.Component { static defaultProps = { - dialogStyle: {minWidth:'768px'} + dialogStyle: { minWidth: '768px' } } render() { - const modal = this.props.modalActive ? - -
-

{this.props.titleText}

-
-
- {this.props.childGenerator()} -
-
: false; - return modal + const innerModal = this.props.modalActive ? +
+

{this.props.titleText}

+
+
+ {this.props.childGenerator()} +
+
: false + + const modal = + + {innerModal} + ; + + return modal } + } export default observer(Modal) diff --git a/javascripts/src/components/common/__snapshots__/Modal.spec.tsx.snap b/javascripts/src/components/common/__snapshots__/Modal.spec.tsx.snap index bf79ae7c..178f305f 100644 --- a/javascripts/src/components/common/__snapshots__/Modal.spec.tsx.snap +++ b/javascripts/src/components/common/__snapshots__/Modal.spec.tsx.snap @@ -1,32 +1,104 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Modal active modal displays 1`] = ` - -
-

- title text -

-
-
-
-
- +

+ title text +

+ +
+
+
+ + `; -exports[`Modal nothing displayed if inactive 1`] = `""`; +exports[`Modal nothing displayed if inactive 1`] = ` + +`;