From 9e0193de7dbcd284b65445ed3cc41e1dc9d7168b Mon Sep 17 00:00:00 2001 From: Alex Windett Date: Wed, 23 Nov 2016 11:59:37 +0000 Subject: [PATCH] Adding modal to side nav and refactoring --- ui/src/components/modal/index.js | 60 +++++++++++++++++++++++-------- ui/src/components/modal/readme.md | 22 +++++++++--- ui/src/components/modal/style.css | 23 +++++++----- ui/src/docs.js | 3 +- ui/src/index.js | 3 +- 5 files changed, 82 insertions(+), 29 deletions(-) diff --git a/ui/src/components/modal/index.js b/ui/src/components/modal/index.js index 239ca02c..43aead46 100644 --- a/ui/src/components/modal/index.js +++ b/ui/src/components/modal/index.js @@ -8,6 +8,7 @@ const Modal = React.createClass({ children: React.PropTypes.node, className: React.PropTypes.string, name: React.PropTypes.string, + trigger: React.PropTypes.func.isRequired }, getInitialState: function() { @@ -19,7 +20,7 @@ const Modal = React.createClass({ handleReveal: function(e) { e.preventDefault(); this.setState({ - active: true + active: this.state.active ? false : true }); }, @@ -27,37 +28,68 @@ const Modal = React.createClass({ const { children, className, - name + name, + trigger } = this.props; + const { + active + } = this.state; + + const { + handleReveal + } = this; + + const triggerClass = classNames( + className, + styles.trigger + ); + const modal = classNames( className, styles.modal, - this.state.active ? styles['modal-active'] : '' ); const overlay = classNames( className, styles.overlay, - this.state.active ? styles['overlay-active'] : '' ); return (
- - Click me to reveal modal - + {trigger()} + -
-
- X -

This is the Modal

- {children} -
+ { active ? ( +
+ ) : null } + + { active ? ( +
+ + {children} +
+ ) : null }
); } diff --git a/ui/src/components/modal/readme.md b/ui/src/components/modal/readme.md index bb6cc58a..84fec49a 100644 --- a/ui/src/components/modal/readme.md +++ b/ui/src/components/modal/readme.md @@ -12,15 +12,21 @@ const Column = require('../column'); const Modal = require('./index.js'); const styles = require('./style.css'); +const trigger = () => { + return ( +

This is the trigger

+ ) +}; + nmodule.exports = ReactDOM.renderToString( - - Create an Instance + +

This is the Modal

-
+ ); ``` @@ -31,10 +37,16 @@ nmodule.exports = ReactDOM.renderToString( const React = require('react'); const Modal = require('ui/button'); +const trigger = () => { + return ( +

This is the trigger

+ ) +}; + module.exports = () => { return ( - - Hello World + +

This is the Modal

); } diff --git a/ui/src/components/modal/style.css b/ui/src/components/modal/style.css index 8ce79f52..880d7b9b 100644 --- a/ui/src/components/modal/style.css +++ b/ui/src/components/modal/style.css @@ -1,4 +1,4 @@ -.overlay-active { +.overlay { background: rgba(0, 0, 0, 0.4); height: 100%; left: 0; @@ -10,7 +10,7 @@ .modal { background: white; - display: none; + display: block; left: 50%; margin: 0 auto; padding: 20px; @@ -20,17 +20,24 @@ z-index: 1; } -.modal-active { - display: block; -} - .close { - background: red; + background-color: #FFFFFF; + border: solid 1px #D8D8D8; + border-radius: 4px; + box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.05); color: black; - font-size: 24px; + cursor: #000000; + font-size: 20px; padding: 0 10px; position: absolute; right: -20px; text-align: center; + text-decoration: none; top: -15px; } + +.trigger { + cursor: pointer; + display: inline-block; + outline: none; +} diff --git a/ui/src/docs.js b/ui/src/docs.js index 3b828e9a..abf70293 100644 --- a/ui/src/docs.js +++ b/ui/src/docs.js @@ -21,7 +21,8 @@ module.exports = { Tab: require('./components/tab/readme.md'), Tabs: require('./components/tabs/readme.md'), Widget: require('./components/widget/readme.md'), - Pagination: require('./components/pagination/readme.md') + Pagination: require('./components/pagination/readme.md'), + Modal: require('./components/modal/readme.md') }, FAQ: require('./faq.md') }; diff --git a/ui/src/index.js b/ui/src/index.js index 9e265238..80d7c1e0 100644 --- a/ui/src/index.js +++ b/ui/src/index.js @@ -15,5 +15,6 @@ module.exports = { RadioGroup: require('./components/radio-group'), Select: require('./components/select'), Widget: require('./components/widget'), - Pagination: require('./components/pagination') + Pagination: require('./components/pagination'), + Modal: require('./components/modal') };