Skip to content

Commit

Permalink
Merge pull request #15 from smollweide/develop
Browse files Browse the repository at this point in the history
v0.4.4
  • Loading branch information
smollweide committed Apr 19, 2017
2 parents 45c19e5 + 6c1228b commit ab2092f
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 22 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-speed-dial",
"version": "0.4.3",
"version": "0.4.4",
"description": "React Component that implements a speed dial using Material-UI.",
"email": "simon.mollweide@web.de",
"author": "Simon Mollweide <simon.mollweide@web.de>",
Expand Down
21 changes: 10 additions & 11 deletions src/components/bubble-list-item/bubble-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class BubbleListItem extends React.Component {
* @returns {Object} styles for root element
*/
getStylesMain() {
const { isOpen, direction, alignment } = this.props;
const { isOpen, direction, alignment, style } = this.props;
const styles = this.styles;
const visibleStr = isOpen ? 'visible' : 'invisible';
return Object.assign(
Expand All @@ -86,7 +86,8 @@ class BubbleListItem extends React.Component {
styles.root[visibleStr].main,
styles.root.direction[direction],
styles.root[visibleStr].direction[direction],
styles.root.alignment[alignment]
styles.root.alignment[alignment],
style
);
}

Expand All @@ -109,14 +110,15 @@ class BubbleListItem extends React.Component {
*/
getStylesText() {

const { alignment } = this.props;
const { alignment, styleText } = this.props;
const styles = this.styles;

return Object.assign(
{},
styles.text.main,
styles.text.alignment[alignment],
this.getStylesFocus('text')
this.getStylesFocus('text'),
styleText
);
}

Expand All @@ -143,17 +145,14 @@ class BubbleListItem extends React.Component {
*/
renderContent() {

const { primaryText, direction } = this.props;
let content = (<span style={this.getStylesText()}>{primaryText}</span>);

if (['left', 'right'].indexOf(direction) >= 0) {
content = null;
}
const { primaryText } = this.props;

return (
<span>
{this.renderAvatar('leftAvatar')}
{content}
<span style={this.getStylesText()}>
{primaryText}
</span>
{this.renderAvatar('rightAvatar')}
</span>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export default {
positionV: PropTypes.string,
primaryText: PropTypes.string,
rightAvatar: PropTypes.object,
style: PropTypes.object,
styleText: PropTypes.object,
tabIndex: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
Expand Down
5 changes: 2 additions & 3 deletions src/components/bubble-list-item/bubble-list-item.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,14 @@ describe('<BubbleListItem />', () => {
expect(getDomFromString(wrapper.find('a').html()).getAttribute('tabindex')).toEqual('1');
});

it('renderContent returns null if direction is left or right', () => {
it('renderContent returns something if direction is left or right', () => {
const props = {
isOpen: true,
primaryText: 'Hallo',
direction: 'left',
};
const instance = new BubbleListItem(props, context);
expect(instance.renderContent().props.children[1]).toEqual(null);
expect(typeof instance.renderContent().props.children[1]).toEqual('object');
});

});

6 changes: 6 additions & 0 deletions src/components/bubble-list-item/bubble-list-item.styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ export default ({ paper, baseTheme }) => {
right: {
marginRight: 24,
},
up: {
display: 'none',
},
down: {
display: 'none',
}
},
},

Expand Down
8 changes: 5 additions & 3 deletions src/components/speed-dial/speed-dial.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,11 @@ class SpeedDial extends React.Component {
* @returns {void}
*/
componentWillReceiveProps(nextProps) {
this.setState({
isOpen: nextProps.isOpen,
});
if (this.isControlled) {
this.setState({
isOpen: nextProps.isOpen,
});
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/examples/example-bug11/example-bug11.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class ExampleBasic extends React.Component {
return (
<BubbleListItem
key={item.primaryText}
styleText={{
backgroundColor: '#ccc',
}}
onClick={this.handleToogleSpeedDialOpen}
{...item}
/>
Expand Down
7 changes: 5 additions & 2 deletions src/examples/example-direction/example-direction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ const avatarImgUrl = 'http://lorempixel.com/80/80/people';
const list = {
items: [
{
id: 0,
primaryText: 'Kerem Suer',
rightAvatar: <Avatar src={`${avatarImgUrl}/6`} />,
},
{
id: 1,
primaryText: 'Raquel Parrado',
rightAvatar: <Avatar src={`${avatarImgUrl}/7`} />,
},
{
id: 2,
primaryText: 'Write',
rightAvatar: <Avatar backgroundColor={blue500} icon={<IconEdit />} />,
},
Expand All @@ -33,8 +36,8 @@ const ExampleDirection = () => {
alignment="up"
direction="left"
>
{list.items.reverse().map((item, index) => {
return (<BubbleListItem key={index} {...item} />);
{list.items.reverse().map((item) => {
return (<BubbleListItem key={item.id} {...item} />);
})}
</BubbleList>
</SpeedDial>
Expand Down
7 changes: 5 additions & 2 deletions src/examples/example-toolbox/example-toolbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import { SpeedDial } from '../../speed-dial';
const list = {
items: [
{
id: '0',
icon: <IconForwards color={cyan900} />,
},
{
id: '1',
icon: <IconPause color={cyan900} />,
},
{
id: '2',
icon: <IconRewind color={cyan900} />,
},
],
Expand Down Expand Up @@ -75,10 +78,10 @@ const Toolbox = ({ onClickCloseToolbox }) => (
<BottomNavigation
style={{ background: teal300 }}
>
{[].concat(list.items).reverse().map((item, index) => {
{[].concat(list.items).reverse().map((item) => {
return (
<BottomNavigationItem
key={index}
key={item.id}
onTouchTap={onClickCloseToolbox}
{...item}
/>);
Expand Down
10 changes: 10 additions & 0 deletions src/examples/table-props/table-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ const props = {
required: false,
desc: 'This is the index to define the tabIndex for the link.',
},
style: {
type: 'object',
required: false,
desc: 'This style object defines the styles for the `root` element.',
},
styleText: {
type: 'object',
required: false,
desc: 'This style object defines the styles for the `text` element.',
},
onClick: {
type: 'function',
required: false,
Expand Down

0 comments on commit ab2092f

Please sign in to comment.