@@ -3,8 +3,7 @@ import styled from 'styled-jss';
33import PropTypes from 'prop-types' ;
44
55const Wrapper = styled ( 'li' ) (
6- ( { isOpen, slideSpeed, backgroundColor, size, iconColor, margin } ) => ( {
7- margin,
6+ ( { isOpen, slideSpeed, backgroundColor, size, iconColor, margin, direction } ) => ( {
87 backgroundColor,
98 display : 'flex' ,
109 border : 'none' ,
@@ -21,37 +20,20 @@ const Wrapper = styled('li')(
2120 transition : `all ${ slideSpeed } ms` ,
2221 width : size ,
2322 height : size ,
23+ marginTop : ( direction === 'down' ) ? margin : 0 ,
24+ marginBottom : ( direction === 'up' ) ? margin : 0 ,
25+ marginLeft : ( direction === 'right' ) ? margin : 0 ,
26+ marginRight : ( direction === 'left' ) ? margin : 0 ,
2427 '& > a > svg' : {
2528 fill : iconColor ,
2629 } ,
2730 } ) ,
2831) ;
29- // ${
30- // (props) => {
31- // switch (props.direction) {
32- // // TODO: Do not fix the transform value to 60, calculate it based on given buttonSize.
33- // case 'left':
34- // return `transform: translate(${props.isOpen ? props.order * 60 * -1 : 0}px, 0px);`;
35- // case 'right':
36- // return `transform: translate(${props.isOpen ? props.order * 60 : 0}px, 0px);`;
37- // case 'up':
38- // return `transform: translate(0px, ${props.isOpen ? props.order * 60 * -1 : 0}px);`;
39- // case 'down':
40- // return `transform: translate(0px, ${props.isOpen ? props.order * 60 * 1 : 0}px);`;
41- // default:
42- // return `transform: translate(0px, ${props.isOpen ? props.order * 60 * 1 : 0}px);`;
43- // }
44- // }
45- // }
46- // ${
47- // props => ((props.direction === 'left' || props.direction === 'right') ?
48- // css`margin-top: ${(props.size.main - props.size.child) / 2}px` :
49- // css`margin-left: ${(props.size.main - props.size.child) / 2}px`)
50- // }
5132
5233class ChildButton extends Component {
5334 static propTypes = {
5435 iconButton : PropTypes . func . isRequired ,
36+ direction : PropTypes . string . isRequired ,
5537 iconColor : PropTypes . string ,
5638 isOpen : PropTypes . bool ,
5739 size : PropTypes . number ,
@@ -66,8 +48,7 @@ class ChildButton extends Component {
6648 } ;
6749
6850 render ( ) {
69- const { iconButton, ...other } = this . props ;
70- const IconButton = iconButton ;
51+ const { iconButton : IconButton , ...other } = this . props ;
7152
7253 return (
7354 < Wrapper { ...other } >
0 commit comments