Skip to content

Commit 66c861f

Browse files
Add margin property to ChildButton
1 parent 49cbb82 commit 66c861f

File tree

3 files changed

+10
-27
lines changed

3 files changed

+10
-27
lines changed

docs/src/App.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,15 @@ class App extends Component {
9797
order={1}
9898
backgroundColor="white"
9999
size={40}
100+
margin={16}
100101
/>
101102
<ChildButton
102103
iconButton={MdAdd}
103104
iconColor="black"
104105
order={2}
105106
backgroundColor="white"
106107
size={40}
108+
margin={8}
107109
/>
108110
</FloatingMenu>
109111
</Paper>

src/ChildButton.js

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import styled from 'styled-jss';
33
import PropTypes from 'prop-types';
44

55
const 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

5233
class 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}>

src/FloatingMenu.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import styledJss from 'styled-jss';
44

5-
const DIRECTIONS = {
5+
export const DIRECTIONS = {
66
up: 'column-reverse',
77
down: 'column',
88
left: 'row-reverse',

0 commit comments

Comments
 (0)