react-toolbox/components/list/ListItemAction.js

26 lines
671 B
JavaScript
Raw Permalink Normal View History

import React from 'react';
import PropTypes from 'prop-types';
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 };