it-tools/components/SearchBar.vue

63 lines
1.5 KiB
Vue
Raw Normal View History

2021-02-13 19:55:45 +01:00
<template>
<v-autocomplete
label="Search..."
single-line
2021-03-14 20:11:39 +01:00
append-icon="mdi-magnify"
2021-02-13 19:55:45 +01:00
color="white"
hide-details
2021-05-28 19:44:27 +02:00
:items="$toolListFlat"
:item-text="item => item.title"
2021-02-13 19:55:45 +01:00
item-value="path"
solo-inverted
2021-03-14 20:11:39 +01:00
dense
:filter="filterItems"
2021-02-13 19:55:45 +01:00
clearable
cache-items
@change="choose"
>
2021-05-22 00:45:00 +02:00
<template #no-data>
2021-02-13 19:55:45 +01:00
<v-list-item>
<v-list-item-title>
Search for the <strong>tool</strong> you need!
</v-list-item-title>
</v-list-item>
</template>
</v-autocomplete>
</template>
2021-03-14 20:11:39 +01:00
<script lang="ts">
2021-05-28 19:44:27 +02:00
import {Component, Vue} from 'nuxt-property-decorator'
2021-03-14 20:11:39 +01:00
import {ToolRouteConfig} from '~/types/ToolConfig'
2021-02-13 19:55:45 +01:00
2021-03-14 20:11:39 +01:00
@Component
2021-05-28 19:44:27 +02:00
export default class SearchBar extends Vue {
2021-03-14 20:11:39 +01:00
choose(path:string) {
this.$router.push({path})
}
filterItems(item:ToolRouteConfig, queryText:string, itemText:string) {
const query = queryText.trim().toLowerCase()
const nameContainsText = itemText.toLowerCase().includes(query)
2021-05-28 19:44:27 +02:00
const keywordContainsText = item?.keywords.join(' ').toLowerCase().includes(query) ?? false
2021-03-14 20:11:39 +01:00
return nameContainsText || keywordContainsText
}
2021-02-13 19:55:45 +01:00
}
</script>
<style scoped lang="less">
2021-03-14 20:11:39 +01:00
::v-deep {
.v-input__slot{
background: var(--v-primary-base) !important;
background: linear-gradient(90deg, rgba(37,99,108,1) 0%, rgba(59,149,111,1) 60%, rgba(71,177,113,1) 100%) !important;
input {
color: #ffffff !important;
}
}
}
.v-list{
background: var(--v-foreground-base) !important;
2021-02-13 19:55:45 +01:00
}
</style>