Added placeholder loaders to multiple components

• Added:
- placeholder loaders to multiple components
- status, panels, comment, lists, group items, notifications
This commit is contained in:
mgabdev
2020-07-28 15:11:51 -05:00
parent a38d9f6133
commit bc6cf0e624
12 changed files with 141 additions and 68 deletions

View File

@@ -1,3 +1,4 @@
import { Fragment } from 'react'
import throttle from 'lodash.throttle'
import { List as ImmutableList } from 'immutable'
import IntersectionObserverArticle from './intersection_observer_article'
@@ -28,6 +29,8 @@ export default class ScrollableList extends PureComponent {
children: PropTypes.node,
onScrollToTop: PropTypes.func,
onScroll: PropTypes.func,
placeholderComponent: PropTypes.node,
placeholderCount: PropTypes.node,
}
state = {
@@ -220,13 +223,34 @@ export default class ScrollableList extends PureComponent {
hasMore,
emptyMessage,
onLoadMore,
placeholderComponent: Placeholder,
placeholderCount,
} = this.props
const childrenCount = React.Children.count(children);
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null
if (showLoading) {
return <ColumnIndicator type='loading' />
if (Placeholder) {
return (
<Fragment>
{
Array.apply(null, {
length: placeholderCount
}).map((_, i) => (
<Placeholder
key={`${scrollKey}-placeholder-${i}`}
isLast={i === placeholderCount - 1}
/>
))
}
</Fragment>
)
}
return (
<ColumnIndicator type='loading' />
)
} else if (isLoading || childrenCount > 0 || hasMore || !emptyMessage) {
return (
<div onMouseMove={this.handleMouseMove}>