Skip to content

Commit

Permalink
Frontend: Enable project search
Browse files Browse the repository at this point in the history
  • Loading branch information
xuhcc committed Jan 2, 2021
1 parent a8c15ac commit 4b177dc
Showing 1 changed file with 44 additions and 13 deletions.
57 changes: 44 additions & 13 deletions vue-app/src/views/ProjectList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,20 @@
<div class="round-info-value">{{ contribution | formatAmount }} {{ currentRound.nativeTokenSymbol }}</div>
</div>
</div>
<div v-if="projects.length > 0" class="project-search">
<input
v-model="search"
class="input"
name="search"
placeholder="Search projects..."
autocomplete="off"
>
</div>
<div class="project-list">
<project-list-item
v-for="project in projects"
v-bind:project="project"
v-bind:key="project.id"
v-for="project in filteredProjects"
:project="project"
:key="project.id"
>
</project-list-item>
</div>
Expand Down Expand Up @@ -97,6 +106,7 @@ function shuffleArray(array: any[]) {
export default class ProjectList extends Vue {
projects: Project[] = []
search = ''
roundWatcherStop?: Function
Expand Down Expand Up @@ -131,11 +141,11 @@ export default class ProjectList extends Vue {
this.currentRound?.startBlock,
this.currentRound?.endBlock,
)
const filtered = projects.filter(project => {
const visibleProjects = projects.filter(project => {
return (!project.isHidden && !project.isLocked)
})
shuffleArray(filtered)
this.projects = filtered
shuffleArray(visibleProjects)
this.projects = visibleProjects
}
get contribution(): FixedNumber {
Expand All @@ -162,6 +172,15 @@ export default class ProjectList extends Vue {
},
)
}
get filteredProjects(): Project[] {
return this.projects.filter((project: Project) => {
if (!this.search) {
return true
}
return project.name.toLowerCase().includes(this.search.toLowerCase())
})
}
}
</script>

Expand All @@ -172,7 +191,6 @@ export default class ProjectList extends Vue {
display: flex;
flex-wrap: wrap;
font-size: 12px;
margin-bottom: $content-space;
}
.round-info-item {
Expand Down Expand Up @@ -201,12 +219,6 @@ export default class ProjectList extends Vue {
text-overflow: ellipsis;
}
.project-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: $content-space;
}
.add-matching-funds-btn {
display: inline-block;
line-height: 1;
Expand All @@ -218,6 +230,25 @@ export default class ProjectList extends Vue {
}
}
.project-search {
margin: 20px 0;
input {
background-color: $bg-secondary-color;
border: none;
border-radius: 20px;
font-size: 14px;
padding: 2px 10px;
width: 100%;
}
}
.project-list {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: $content-space;
}
@media (max-width: 1150px) {
.round-info-item {
flex: 0 0 50%;
Expand Down

0 comments on commit 4b177dc

Please sign in to comment.