react-toolbox/components/list/ListItemAction.js

25 lines
649 B
JavaScript
Raw Normal View History

2016-04-09 21:34:34 +03:00
import React, { PropTypes } from 'react';
2016-05-22 20:08:47 +03:00
import { themr } from 'react-css-themr';
2016-05-29 21:59:54 +03:00
import { LIST } from '../identifiers.js';
2016-05-22 20:08:47 +03:00
const ListItemAction = ({action, theme}) => {
const {onClick, onMouseDown} = action.props;
const stopRipple = onClick && !onMouseDown;
const stop = e => e.stopPropagation();
return (
2016-05-22 20:08:47 +03:00
<span className={theme.itemAction} onMouseDown={stopRipple && stop} onClick={onClick && stop}>
{action}
</span>
);
};
ListItemAction.propTypes = {
2016-05-22 20:08:47 +03:00
action: PropTypes.object,
theme: PropTypes.shape({
itemAction: PropTypes.string
2016-05-22 20:08:47 +03:00
})
};
2016-05-29 21:59:54 +03:00
export default themr(LIST)(ListItemAction);
export { ListItemAction };