1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 07:10:05 +02:00

styling modal and usuing React Close component instead of styled button

This commit is contained in:
Alex Windett 2017-01-12 14:19:13 +00:00
parent 4866b3585f
commit 268d17bb4a
3 changed files with 39 additions and 22 deletions

View File

@ -17,14 +17,18 @@ const StyledButton = styled.button`
position: absolute; position: absolute;
top: ${remcalc(16)}; top: ${remcalc(16)};
right: ${remcalc(16)}; right: ${remcalc(16)};
${props => props.customStyles ? props.customStyles : null}
`; `;
const Close = ({ const Close = ({
style, style,
onClick onClick,
customStyles = ''
}) => { }) => {
return ( return (
<StyledButton <StyledButton
customStyles={customStyles}
onClick={onClick} onClick={onClick}
style={style} style={style}
> >
@ -37,6 +41,7 @@ const Close = ({
}; };
Close.propTypes = { Close.propTypes = {
customStyles: React.PropTypes.string,
onClick: React.PropTypes.func, onClick: React.PropTypes.func,
style: React.PropTypes.object style: React.PropTypes.object
}; };

View File

@ -2,6 +2,8 @@ const constants = require('../../shared/constants');
const React = require('react'); const React = require('react');
const Styled = require('styled-components'); const Styled = require('styled-components');
const Close = require('../close');
const { const {
colors colors
} = constants; } = constants;
@ -20,26 +22,12 @@ const StyledModal = styled.div`
top: 50%; top: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
z-index: 1; z-index: 1;
`; max-width: 80%;
min-width: 50%;
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;
`; `;
const StyledOverlay = styled.div` const StyledOverlay = styled.div`
background: rgba(0, 0, 0, 0.4); background: rgba(74, 73, 74, 0.46);
height: 100%; height: 100%;
left: 0; left: 0;
position: absolute; position: absolute;
@ -52,6 +40,7 @@ const Modal = ({
active = true, active = true,
children, children,
className, className,
customCloseStyle,
handleDismiss, handleDismiss,
name, name,
style style
@ -68,11 +57,10 @@ const Modal = ({
tabIndex={-2} tabIndex={-2}
/> />
<StyledModal aria-label={name}> <StyledModal aria-label={name}>
<StyledClose <Close
customStyles={customCloseStyle}
onClick={handleDismiss} onClick={handleDismiss}
role='dialog' />
tabIndex={-1}
>X</StyledClose>
{children} {children}
</StyledModal> </StyledModal>
</div> </div>
@ -83,6 +71,7 @@ Modal.propTypes = {
active: React.PropTypes.bool, active: React.PropTypes.bool,
children: React.PropTypes.node, children: React.PropTypes.node,
className: React.PropTypes.string, className: React.PropTypes.string,
customCloseStyle: React.PropTypes.string,
handleDismiss: React.PropTypes.func, handleDismiss: React.PropTypes.func,
name: React.PropTypes.string, name: React.PropTypes.string,
style: React.PropTypes.object style: React.PropTypes.object

View File

@ -1,4 +1,8 @@
const React = require('react'); const React = require('react');
const constants = require('../../shared/constants');
const {
colors
} = constants;
const { const {
storiesOf storiesOf
@ -7,6 +11,11 @@ const {
const Base= require('../base'); const Base= require('../base');
const Modal = require('./'); const Modal = require('./');
const _customCloseStyle = `
border: solid ${colors.alert} 5px;
border-radius: 50%;
`;
storiesOf('Modal', module) storiesOf('Modal', module)
.add('Default', () => ( .add('Default', () => (
<Base> <Base>
@ -14,4 +23,18 @@ storiesOf('Modal', module)
<h2>This is the Modal</h2> <h2>This is the Modal</h2>
</Modal> </Modal>
</Base> </Base>
))
.add('Custom Styles on Close', () => (
<Base>
<Modal customCloseStyle={_customCloseStyle}>
<h2>This is the Modal</h2>
</Modal>
</Base>
))
.add('Dismiss Function', () => (
<Base>
<Modal handleDismiss={function noop() {}}>
<p>This has a handleDismiss (noop) function</p>
</Modal>
</Base>
)); ));