replaced singleSlot with slotSize

This commit is contained in:
Wyatt Johnson
2018-02-23 14:48:57 -07:00
parent 105ed1454d
commit 894940cd0b
3 changed files with 8 additions and 15 deletions
@@ -604,7 +604,7 @@ export default class Comment extends React.Component {
defaultComponent={CommentContent}
{...slotProps}
queryData={queryData}
singleSlot
slotSize={1}
/>
</div>
)}
+5 -5
View File
@@ -38,7 +38,7 @@ class Slot extends React.Component {
'inline',
'className',
'reduxState',
'singleSlot',
'slotSize',
'defaultComponent_',
'queryData',
'childFactory',
@@ -47,7 +47,7 @@ class Slot extends React.Component {
}
getChildren(props = this.props) {
const { singleSlot = false } = props;
const { slotSize = 0 } = props;
const { plugins } = this.context;
return plugins.getSlotElements(
@@ -55,7 +55,7 @@ class Slot extends React.Component {
props.reduxState,
this.getSlotProps(props),
props.queryData,
{ singleSlot }
{ slotSize }
);
}
@@ -113,9 +113,9 @@ Slot.propTypes = {
defaultComponent: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
/**
* When true, only the first plugin will take the slot.
* Specifies the number of children that can fill the slot.
*/
singleSlot: PropTypes.bool,
slotSize: PropTypes.number,
/**
* You may specify the component to use as the root wrapper.
+2 -9
View File
@@ -94,19 +94,12 @@ class PluginsService {
};
}
getSlotElement(slot, reduxState, props = {}, queryData = {}, options = {}) {
return this.getSlotElements(slot, reduxState, props, queryData, {
...options,
singleSlot: true,
});
}
/**
* Returns React Elements for given slot.
*/
getSlotElements(slot, reduxState, props = {}, queryData = {}, options = {}) {
const pluginConfig = get(reduxState, 'config.plugin_config') || emptyConfig;
const { singleSlot = false } = options;
const { slotSize = 0 } = options;
const isDisabled = component => {
if (
@@ -143,7 +136,7 @@ class PluginsService {
.map(o => o.module.slots[slot])
);
return (singleSlot ? slots.slice(0, 1) : slots)
return (slotSize > 0 ? slots.slice(0, slotSize) : slots)
.map((component, i) => ({
component,
disabled: isDisabled(component),