react-toolbox/components/list/ListItemActions.js

35 lines
980 B
JavaScript
Raw Normal View History

2016-05-29 22:11:04 +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';
import InjectListItemAction from './ListItemAction.js';
2016-05-29 21:59:54 +03:00
const factory = (ListItemAction) => {
const ListItemActions = ({type, children, theme}) => {
const validChildren = React.Children.toArray(children).filter(c => (
React.isValidElement(c)
));
2016-05-29 21:59:54 +03:00
return (
<span className={theme[type]}>
{validChildren.map((action, i) => <ListItemAction key={i} theme={theme} action={action} />)}
2016-05-29 21:59:54 +03:00
</span>
);
};
ListItemActions.propTypes = {
2016-05-29 22:11:04 +03:00
children: PropTypes.any,
theme: PropTypes.shape({
left: PropTypes.string,
right: PropTypes.string
2016-05-29 21:59:54 +03:00
}),
2016-05-29 22:11:04 +03:00
type: PropTypes.oneOf(['left', 'right'])
2016-05-29 21:59:54 +03:00
};
2016-05-29 21:59:54 +03:00
return ListItemActions;
};
2016-05-29 21:59:54 +03:00
const ListItemActions = factory(InjectListItemAction);
export default themr(LIST)(ListItemActions);
export { factory as listItemActionsFactory };
export { ListItemActions };