builder block: add search
This commit is contained in:
parent
d4ba8dc619
commit
1120c20f05
|
@ -39,6 +39,10 @@
|
||||||
background: #eee;
|
background: #eee;
|
||||||
border: 1px solid #1e2430;
|
border: 1px solid #1e2430;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.search {
|
||||||
|
max-width: 300px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -72,9 +76,13 @@
|
||||||
:class="{'d-none': activeCategory !== key}"
|
:class="{'d-none': activeCategory !== key}"
|
||||||
>
|
>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
<div class="col-12 mb-4">
|
||||||
|
<input v-model="search" placeholder="Type to search..." class="form-control search">
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="(widget, name) in category.widgets"
|
v-for="(widget, name) in category.widgets"
|
||||||
v-on:click="add(name, widget)"
|
v-on:click="add(name, widget)"
|
||||||
|
v-if="matchSearch(name)"
|
||||||
class="widget col-auto"
|
class="widget col-auto"
|
||||||
>
|
>
|
||||||
<span class="widget-icon" v-if="widget.icon" v-html="widget.icon"></span>
|
<span class="widget-icon" v-if="widget.icon" v-html="widget.icon"></span>
|
||||||
|
@ -116,6 +124,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
showPicker: false,
|
showPicker: false,
|
||||||
activeCategory: 'all',
|
activeCategory: 'all',
|
||||||
|
search: '',
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -154,6 +163,13 @@ export default {
|
||||||
|
|
||||||
return `block-${result}`
|
return `block-${result}`
|
||||||
},
|
},
|
||||||
|
matchSearch(name) {
|
||||||
|
if (!this.search.trim().length) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return name.toLowerCase().includes(this.search.toLowerCase())
|
||||||
|
},
|
||||||
togglePicker() {
|
togglePicker() {
|
||||||
this.showPicker = !this.showPicker
|
this.showPicker = !this.showPicker
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue