-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial commit of the custom search widget
- Loading branch information
root
committed
Jun 4, 2023
1 parent
ff5b2d5
commit e1d4adb
Showing
3 changed files
with
127 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<template> | ||
<div class="custom-search"> | ||
<input type="text" v-model="query" | ||
@keyup.enter="search(defaultEngine)" | ||
@keyup.stop @keydown.stop | ||
:placeholder="placeholder"> | ||
<div class="buttons"> | ||
<button | ||
v-for="(engine, key) in engines" :key="key" | ||
v-on:click="search(engine)"> | ||
{{ engine.title }} | ||
</button> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import WidgetMixin from '@/mixins/WidgetMixin'; | ||
export default { | ||
mixins: [WidgetMixin], | ||
components: {}, | ||
data() { | ||
return { | ||
query: '', | ||
}; | ||
}, | ||
computed: { | ||
placeholder() { | ||
return this.options.placeholder || ''; | ||
}, | ||
engines() { | ||
return this.options.engines || []; | ||
}, | ||
defaultEngine() { | ||
return this.engines[0]; | ||
}, | ||
}, | ||
methods: { | ||
search(engine) { | ||
if (engine !== undefined && this.query !== '') { | ||
window.open(engine.url + this.query, '_blank'); | ||
} | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.custom-search { | ||
font-size: 1.2rem; | ||
input { | ||
width: 80%; | ||
margin: 1rem 10%; | ||
padding: 0.5rem; | ||
font-size: 1.2rem; | ||
} | ||
.buttons { | ||
text-align:center; | ||
button{ | ||
margin: 0.5rem; | ||
padding: 0.5rem; | ||
border: none; | ||
color: var(--item-text-color); | ||
background: var(--item-background); | ||
font-size: 1.2rem; | ||
} | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters