Browse Source

Add side margin to modals by default and minor styles updates

master
meriadec 7 years ago
parent
commit
ce40e3d96f
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 2
      src/components/SideBar/index.js
  2. 15
      src/components/base/Modal/index.js
  3. 2
      src/components/base/Modal/stories.js
  4. 3
      src/styles/theme.js

2
src/components/SideBar/index.js

@ -30,7 +30,7 @@ const Container = styled(Box).attrs({
noShrink: true, noShrink: true,
})` })`
background-color: ${p => rgba(p.theme.colors[p.bg], process.platform === 'darwin' ? 0.4 : 1)}; background-color: ${p => rgba(p.theme.colors[p.bg], process.platform === 'darwin' ? 0.4 : 1)};
width: 250px; width: ${p => p.theme.sizes.sideBarWidth}px;
` `
const BtnAddAccount = styled(Box).attrs({ const BtnAddAccount = styled(Box).attrs({

15
src/components/base/Modal/index.js

@ -20,7 +20,8 @@ import Box from 'components/base/Box'
type Props = { type Props = {
isOpened?: boolean, isOpened?: boolean,
onClose: Function, onClose: Function,
preventBackdropClick: boolean, preventBackdropClick?: boolean,
preventSideMargin?: boolean,
render: Function, render: Function,
} }
@ -73,13 +74,14 @@ const Wrapper = styled(Box).attrs({
transform: `translate3d(0, ${p.offset}px, 0)`, transform: `translate3d(0, ${p.offset}px, 0)`,
}), }),
})` })`
width: 430px; margin-left: ${p => (p.preventSideMargin ? 0 : p.theme.sizes.sideBarWidth)}px;
width: 570px;
z-index: 2; z-index: 2;
` `
const Body = styled(Box).attrs({ const Body = styled(Box).attrs({
bg: p => p.theme.colors.white, bg: p => p.theme.colors.white,
p: 20, p: 3,
})` })`
border-radius: 5px; border-radius: 5px;
` `
@ -87,12 +89,13 @@ const Body = styled(Box).attrs({
export class Modal extends PureComponent<Props> { export class Modal extends PureComponent<Props> {
static defaultProps = { static defaultProps = {
onClose: noop, onClose: noop,
preventBackdropClick: true, preventBackdropClick: false,
preventSideMargin: false,
isOpened: false, isOpened: false,
} }
render() { render() {
const { preventBackdropClick, isOpened, onClose, render } = this.props const { preventBackdropClick, preventSideMargin, isOpened, onClose, render } = this.props
return ( return (
<Mortal <Mortal
isOpened={isOpened} isOpened={isOpened}
@ -105,7 +108,7 @@ export class Modal extends PureComponent<Props> {
{(m, isVisible) => ( {(m, isVisible) => (
<Container isVisible={isVisible}> <Container isVisible={isVisible}>
<Backdrop op={m.opacity} onClick={preventBackdropClick ? undefined : onClose} /> <Backdrop op={m.opacity} onClick={preventBackdropClick ? undefined : onClose} />
<Wrapper op={m.opacity} offset={m.y}> <Wrapper preventSideMargin={preventSideMargin} op={m.opacity} offset={m.y}>
{render({ onClose })} {render({ onClose })}
</Wrapper> </Wrapper>
</Container> </Container>

2
src/components/base/Modal/stories.js

@ -8,9 +8,11 @@ const stories = storiesOf('Modal', module)
stories.add('basic', () => { stories.add('basic', () => {
const isOpened = boolean('isOpened', true) const isOpened = boolean('isOpened', true)
const preventSideMargin = boolean('preventSideMargin', true)
return ( return (
<Modal <Modal
isOpened={isOpened} isOpened={isOpened}
preventSideMargin={preventSideMargin}
render={({ onClose }) => ( render={({ onClose }) => (
<Fragment> <Fragment>
<ModalBody>Hey!</ModalBody> <ModalBody>Hey!</ModalBody>

3
src/styles/theme.js

@ -1,6 +1,9 @@
// @flow // @flow
export default { export default {
sizes: {
sideBarWidth: 250,
},
colors: { colors: {
black: '#000000', black: '#000000',
white: '#ffffff', white: '#ffffff',

Loading…
Cancel
Save