From 268d17bb4a9918ab82e140bdc5fdf834194f5c58 Mon Sep 17 00:00:00 2001 From: Alex Windett Date: Thu, 12 Jan 2017 14:19:13 +0000 Subject: [PATCH] styling modal and usuing React Close component instead of styled button --- ui/src/components/close/index.js | 7 ++++++- ui/src/components/modal/index.js | 31 ++++++++++--------------------- ui/src/components/modal/story.js | 23 +++++++++++++++++++++++ 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/ui/src/components/close/index.js b/ui/src/components/close/index.js index bc955fe9..07658740 100644 --- a/ui/src/components/close/index.js +++ b/ui/src/components/close/index.js @@ -17,14 +17,18 @@ const StyledButton = styled.button` position: absolute; top: ${remcalc(16)}; right: ${remcalc(16)}; + + ${props => props.customStyles ? props.customStyles : null} `; const Close = ({ style, - onClick + onClick, + customStyles = '' }) => { return ( @@ -37,6 +41,7 @@ const Close = ({ }; Close.propTypes = { + customStyles: React.PropTypes.string, onClick: React.PropTypes.func, style: React.PropTypes.object }; diff --git a/ui/src/components/modal/index.js b/ui/src/components/modal/index.js index 9649e705..92516c9b 100644 --- a/ui/src/components/modal/index.js +++ b/ui/src/components/modal/index.js @@ -2,6 +2,8 @@ const constants = require('../../shared/constants'); const React = require('react'); const Styled = require('styled-components'); +const Close = require('../close'); + const { colors } = constants; @@ -20,26 +22,12 @@ const StyledModal = styled.div` top: 50%; transform: translate(-50%, -50%); z-index: 1; -`; - -const StyledClose = styled.button` - background-color: #FFFFFF; - border: solid 1px #D8D8D8; - border-radius: 4px; - box-shadow: 0 2px 0 0 rgba(0, 0, 0, 0.05); - color: black; - cursor: #000000; - font-size: 20px; - padding: 0 10px; - position: absolute; - right: -20px; - text-align: center; - text-decoration: none; - top: -15px; + max-width: 80%; + min-width: 50%; `; const StyledOverlay = styled.div` - background: rgba(0, 0, 0, 0.4); + background: rgba(74, 73, 74, 0.46); height: 100%; left: 0; position: absolute; @@ -52,6 +40,7 @@ const Modal = ({ active = true, children, className, + customCloseStyle, handleDismiss, name, style @@ -68,11 +57,10 @@ const Modal = ({ tabIndex={-2} /> - X + /> {children} @@ -83,6 +71,7 @@ Modal.propTypes = { active: React.PropTypes.bool, children: React.PropTypes.node, className: React.PropTypes.string, + customCloseStyle: React.PropTypes.string, handleDismiss: React.PropTypes.func, name: React.PropTypes.string, style: React.PropTypes.object diff --git a/ui/src/components/modal/story.js b/ui/src/components/modal/story.js index 74a142fc..f28326ba 100644 --- a/ui/src/components/modal/story.js +++ b/ui/src/components/modal/story.js @@ -1,4 +1,8 @@ const React = require('react'); +const constants = require('../../shared/constants'); +const { + colors +} = constants; const { storiesOf @@ -7,6 +11,11 @@ const { const Base= require('../base'); const Modal = require('./'); +const _customCloseStyle = ` + border: solid ${colors.alert} 5px; + border-radius: 50%; +`; + storiesOf('Modal', module) .add('Default', () => ( @@ -14,4 +23,18 @@ storiesOf('Modal', module)

This is the Modal

+ )) + .add('Custom Styles on Close', () => ( + + +

This is the Modal

+
+ + )) + .add('Dismiss Function', () => ( + + +

This has a handleDismiss (noop) function

+
+ )); \ No newline at end of file