Vulcan/packages/nova-base-components/lib/posts/PostsList.jsx

40 lines
1.3 KiB
React
Raw Normal View History

2016-08-08 11:18:21 +09:00
import Telescope from 'meteor/nova:lib';
2016-04-14 10:12:35 +09:00
import React from 'react';
const PostsList = ({results, currentUser, hasMore, ready, count, totalCount, loadMore, refetchQuery, showHeader = true}) => {
2016-04-14 10:12:35 +09:00
if (!!results.length) {
return (
<div className="posts-list">
{showHeader ? <Telescope.components.PostsListHeader/> : null}
<div className="posts-list-content">
{results.map(post => <Telescope.components.PostsItem post={post} key={post._id} refetchQuery={refetchQuery} />)}
2016-04-14 10:12:35 +09:00
</div>
{hasMore ? (ready ? <Telescope.components.PostsLoadMore loadMore={loadMore} count={count} totalCount={totalCount} /> : <Telescope.components.PostsLoading/>) : <Telescope.components.PostsNoMore/>}
2016-04-14 10:12:35 +09:00
</div>
)
} else if (!ready) {
return (
<div className="posts-list">
{showHeader ? <Telescope.components.PostsListHeader /> : null}
<div className="posts-list-content">
<Telescope.components.PostsLoading/>
2016-04-14 10:12:35 +09:00
</div>
</div>
)
} else {
return (
<div className="posts-list">
{showHeader ? <Telescope.components.PostsListHeader /> : null}
<div className="posts-list-content">
<Telescope.components.PostsNoResults/>
2016-04-14 10:12:35 +09:00
</div>
</div>
)
}
};
PostsList.displayName = "PostsList";
2016-04-14 10:12:35 +09:00
module.exports = PostsList;