Files
talk/client/coral-framework/components/IfSlotIsNotEmpty.js
T

23 lines
651 B
JavaScript

import React from 'react';
import {connect} from 'react-redux';
import {isSlotEmpty} from 'coral-framework/helpers/plugins';
import PropTypes from 'prop-types';
function IfSlotIsNotEmpty({slot, className, pluginConfig, component: Component = 'div', children, ...rest}) {
return (
<Component className={className}>
{!isSlotEmpty(slot, pluginConfig, rest) ? children : null}
</Component>
);
}
IfSlotIsNotEmpty.propTypes = {
slot: PropTypes.string,
className: PropTypes.string,
};
const mapStateToProps = (state) => ({pluginConfig: state.config.plugin_config});
export default connect(mapStateToProps, null)(IfSlotIsNotEmpty);