Skip to content

Commit 6ad77d6

Browse files
committed
Dynamic heading display
1 parent 7bccd39 commit 6ad77d6

1 file changed

Lines changed: 23 additions & 12 deletions

File tree

src/dashboard/category-results-screen.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,31 +47,42 @@ export default function CategoryResultsScreen ({ store }) {
4747
const weekPapers = findRelativeDate(selectedPapers, 'week');
4848
const monthPapers = findRelativeDate(selectedPapers, 'month');
4949

50-
return h('div', { class: 'category-results-screen' }, [
51-
h(Link, { href: '/', class: 'category-results-reset link' }, '< Select a different topic'), // TODO: < should be a nice SVG icon
50+
const resultsScreenElements = [
51+
h(Link, { href: '/', class: 'category-results-reset link' }, '< Select a different topic'),
5252
h('div', { class: 'category-results-info' }, [ // TODO: better css for mobile
5353
CategoryCard({ category: selectedCategory, store, selectable: false, includeName: false }),
5454
h('div', { class: 'category-results-details' }, [
5555
h('div', { class: 'category-results-title' }, `${selectedCategory.name}`),
5656
h('div', { class: 'category-results-date' }, 'Updated yesterday'),
5757
h('div', { class: 'category-results-description' }, selectedCategory.description)
5858
])
59-
]),
60-
h('div', { class: 'papers-today' }, [
59+
])
60+
];
61+
62+
if (todayPapers.length !== 0) {
63+
resultsScreenElements.push(h('div', { class: 'papers-today' }, [
6164
h('h2', { class: 'papers-today-title' }, 'New papers today'),
6265
h('div', { class: 'papers' }, todayPapers.map(paper => h(Paper, { paper })))
63-
]),
64-
h('div', { class: 'papers-last-few-days' }, [
66+
]));
67+
}
68+
if (fewDaysPapers.length !== 0) {
69+
resultsScreenElements.push(h('div', { class: 'papers-last-few-days' }, [
6570
h('h2', { class: 'papers-last-few-days-title' }, 'Papers in the last few days'),
6671
h('div', { class: 'papers' }, fewDaysPapers.map(paper => h(Paper, { paper })))
67-
]),
68-
h('div', { class: 'papers-last-week' }, [
72+
]));
73+
}
74+
if (weekPapers.length !== 0) {
75+
resultsScreenElements.push(h('div', { class: 'papers-last-week' }, [
6976
h('h2', { class: 'papers-last-week-title' }, 'Papers in the last week'),
7077
h('div', { class: 'papers' }, weekPapers.map(paper => h(Paper, { paper })))
71-
]),
72-
h('div', { class: 'papers-this-month' }, [
78+
]));
79+
}
80+
if (monthPapers.length !== 0) {
81+
resultsScreenElements.push(h('div', { class: 'category-results-papers-this-month' }, [
7382
h('h2', { class: 'papers-this-month-title' }, 'Papers in the past month'),
7483
h('div', { class: 'papers' }, monthPapers.map(paper => h(Paper, { paper })))
75-
])
76-
]);
84+
]));
85+
}
86+
87+
return h('div', { class: 'category-results-screen' }, resultsScreenElements);
7788
}

0 commit comments

Comments
 (0)