Default Components for Slots

This commit is contained in:
Belen Curcio
2017-06-14 13:02:51 -03:00
parent 00d1b0e6f5
commit 60905bb99d
2 changed files with 7 additions and 6 deletions
@@ -9,6 +9,7 @@ import FlagComment from 'coral-plugin-flags/FlagComment';
import {can} from 'coral-framework/services/perms';
import {TransitionGroup} from 'react-transition-group';
import cn from 'classnames';
import styles from './Comment.css';
import {
BestButton,
@@ -17,14 +18,14 @@ import {
commentIsBest,
BestIndicator
} from 'coral-plugin-best/BestButton';
import Slot from 'coral-framework/components/Slot';
import LoadMore from './LoadMore';
import {getEditableUntilDate} from './util';
import {TopRightMenu} from './TopRightMenu';
import CommentContent from './CommentContent';
import Slot from 'coral-framework/components/Slot';
import IgnoredCommentTombstone from './IgnoredCommentTombstone';
import {EditableCommentContent} from './EditableCommentContent';
import {getActionSummary, iPerformedThisAction} from 'coral-framework/utils';
import {getEditableUntilDate} from './util';
import styles from './Comment.css';
const isStaff = (tags) => !tags.every((t) => t.tag.name !== 'STAFF');
const hasTag = (tags, lookupTag) => !!tags.filter((t) => t.tag.name === lookupTag).length;
@@ -465,7 +466,7 @@ export default class Comment extends React.Component {
stopEditing={this.stopEditing}
/>
: <div>
<Slot fill="commentContent" comment={comment} />
<Slot fill="commentContent" comment={comment} defaultComponent={CommentContent} />
</div>
}
+2 -2
View File
@@ -4,10 +4,10 @@ import styles from './Slot.css';
import {connect} from 'react-redux';
import {getSlotElements} from 'coral-framework/helpers/plugins';
function Slot ({fill, inline = false, className, plugin_config: config, ...rest}) {
function Slot ({fill, inline = false, className, plugin_config: config, defaultComponent = () => {}, ...rest}) {
return (
<div className={cn({[styles.inline]: inline, [styles.debug]: config.debug}, className)}>
{getSlotElements(fill, {...rest, config})}
{getSlotElements(fill).length ? getSlotElements(fill, {...rest, config}) : defaultComponent({...rest})}
</div>
);
}