Skip to content

Commit

Permalink
replaced the demo text with a project count
Browse files Browse the repository at this point in the history
  • Loading branch information
lunarcloud committed Jan 30, 2024
1 parent fb8dfcc commit 89d930b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions controllers/projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,23 @@ export default class ProjectsPageController {
// Sort the projects by newest
this.projectEls = this.projectEls.sort(ProjectDisplayElement.compareDate).reverse()

let shownProjects = 0

// Add the sorted & filtered projects to the page
for (const projEl of this.projectEls) {
this.allProjectsEl.appendChild(projEl)
const hasFilterTags = this.pageFilters.length === 0 || this.pageFilters.every(i => projEl.tags.includes(i))
projEl.toggleAttribute('hidden', !hasFilterTags)
if (hasFilterTags)
shownProjects++
projEl.addEventListener('projectfilterselected',
// @ts-ignore
event => this.updateFilter(event.detail.tag, event.detail.active)
)
}

document.getElementById('projects-count').textContent =
`(${shownProjects}${(shownProjects !== this.projectEls.length ? ` of ${this.projectEls.length}` : '')})`
}

/**
Expand Down
2 changes: 1 addition & 1 deletion project-list-view.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</nav-header>
<main id="main" class="page-fade">
<h1>
Projects <together>List Demo</together>
Projects <span id="projects-count"></span>
</h1>

<div id="filters-list">
Expand Down

0 comments on commit 89d930b

Please sign in to comment.