Skip to content

Commit fb1462f

Browse files
committed
Folder リストに articleの数をだす
1 parent 41e1630 commit fb1462f

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

browser/main/HomePage.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class HomePage extends React.Component {
9898
}
9999

100100
render () {
101-
let { dispatch, status, articles, activeArticle, folders, filters } = this.props
101+
let { dispatch, status, articles, allArticles, activeArticle, folders, filters } = this.props
102102

103103
return (
104104
<div className='HomePage'>
@@ -107,6 +107,7 @@ class HomePage extends React.Component {
107107
dispatch={dispatch}
108108
folders={folders}
109109
status={status}
110+
allArticles={allArticles}
110111
/>
111112
<ArticleTopBar
112113
ref='top'
@@ -141,6 +142,7 @@ function remap (state) {
141142
articles.sort((a, b) => {
142143
return new Date(b.updatedAt) - new Date(a.updatedAt)
143144
})
145+
let allArticles = articles.slice()
144146

145147
// Filter articles
146148
let filters = status.search.split(' ').map(key => key.trim()).filter(key => key.length > 0 && !key.match(/^\/$/) && !key.match(/^#$/)).map(key => {
@@ -229,6 +231,7 @@ function remap (state) {
229231
return {
230232
folders,
231233
status,
234+
allArticles,
232235
articles,
233236
activeArticle,
234237
filters: {
@@ -247,6 +250,7 @@ HomePage.propTypes = {
247250
userId: PropTypes.string
248251
}),
249252
articles: PropTypes.array,
253+
allArticles: PropTypes.array,
250254
activeArticle: PropTypes.shape(),
251255
dispatch: PropTypes.func,
252256
folders: PropTypes.array,

browser/main/HomePage/ArticleNavigator.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,17 @@ export default class ArticleNavigator extends React.Component {
8888
}
8989

9090
render () {
91-
let { status, folders } = this.props
91+
let { status, folders, allArticles } = this.props
9292
let { targetFolders } = status
9393
if (targetFolders == null) targetFolders = []
9494

9595
let folderElememts = folders.map((folder, index) => {
9696
let isActive = findWhere(targetFolders, {key: folder.key})
97+
let articleCount = allArticles.filter(article => article.FolderKey === folder.key).length
9798

9899
return (
99100
<button onClick={e => this.handleFolderButtonClick(folder.name)(e)} key={'folder-' + folder.key} className={isActive ? 'active' : ''}>
100-
<FolderMark color={folder.color}/> {folder.name}
101+
<FolderMark color={folder.color}/> {folder.name} <span className='articleCount'>{articleCount}</span>
101102
</button>
102103
)
103104
})
@@ -150,6 +151,7 @@ export default class ArticleNavigator extends React.Component {
150151
ArticleNavigator.propTypes = {
151152
activeUser: PropTypes.object,
152153
folders: PropTypes.array,
154+
allArticles: PropTypes.array,
153155
status: PropTypes.shape({
154156
folderId: PropTypes.number
155157
}),

browser/styles/main/HomeContainer/components/ArticleNavigator.styl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
articleNavBgColor = #353535
2+
articleCount = #999
23

34
.ArticleNavigator
45
background-color articleNavBgColor
@@ -150,6 +151,9 @@ articleNavBgColor = #353535
150151
background-color transparentify(white, 5%)
151152
&.active, &:active
152153
background-color brandColor
154+
.articleCount
155+
color articleCount
156+
font-size 12px
153157
.members
154158
.memberList>div
155159
height 33px

0 commit comments

Comments
 (0)