react-toolbox/components/list/ListItemAction.js

25 lines
650 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';
2017-01-26 20:05:32 +03:00
import { LIST } from '../identifiers';
2017-01-26 20:05:32 +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 = {
2017-01-26 20:05:32 +03:00
action: PropTypes.node,
2016-05-22 20:08:47 +03:00
theme: PropTypes.shape({
2017-01-26 20:05:32 +03:00
itemAction: PropTypes.string,
}),
};
2016-05-29 21:59:54 +03:00
export default themr(LIST)(ListItemAction);
export { ListItemAction };