1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 06:28:42 +01:00
Files
dozzle/assets/components/Search.vue
Amir Raminfar 412a10256d Vue3 (#1594)
* WIP vue3

* WIP vue3

* WIP vue3

* Migrates to vitejs

* Fixes js tests and removes not needed modules

* Fixes unmount

* Updates to use css instead for space

* Fixes tests and rebases one more time

* Uses orgua

* Fixes migrations bugs with oruga and fixes scroll

* Fixes v-deep

* Fixes icons to prod

* Fixes icons to prod

* Adds favicon back

* Transitions some to composition api

* Updates another component to comp api

* Cleans defineProps

* Updates log messages

* Moves more to compose api

* Cleans up styles and rewrites event source

* Tries to fix DOMPurify

* Removes postcss

* WIP typescript

* Improves importing

* Converts all to ts

* Converts main to ts

* Makes changes for tsconfig

* Moves more to ts

* Adds typing to store

* More typing

* Updates to ts

* Updates the rest to ts

* Fixes computes

* Fixes unmount

* Adds cypress with custom base fixed

* Fixes jest tests

* Fixes golang tests

* Adds gitignore for cypress

* Removes int in favor of e2e with cypress

* Tries to fix int tests again

* Adds title

* Updates e2e tests

* Uses vue for isMobile

* Removes app spec

* Cleans up docker

* Adds drop down for settings

* Fixes bug with restart

* Fixes scroll up bug

* Adds tests for light mode
2021-11-16 10:55:44 -08:00

111 lines
2.2 KiB
Vue

<template>
<div class="search columns is-gapless is-vcentered" v-show="showSearch" v-if="settings.search">
<div class="column">
<p class="control has-icons-left">
<input
class="input"
type="text"
placeholder="Find / RegEx"
ref="filter"
v-model="filter"
@keyup.esc="resetSearch()"
/>
<span class="icon is-left">
<mdi-light-magnify />
</span>
</p>
</div>
<div class="column is-1 has-text-centered">
<button class="delete is-medium" @click="resetSearch()"></button>
</div>
</div>
</template>
<script lang="ts">
import { mapActions, mapState } from "vuex";
import hotkeys from "hotkeys-js";
export default {
props: [],
name: "Search",
data() {
return {
showSearch: false,
};
},
mounted() {
hotkeys("command+f, ctrl+f", (event, handler) => {
this.showSearch = true;
this.$nextTick(() => this.$refs.filter.focus() || this.$refs.filter.select());
event.preventDefault();
});
hotkeys("esc", (event, handler) => {
this.resetSearch();
});
},
beforeUnmount() {
this.updateSearchFilter("");
hotkeys.unbind("command+f, ctrl+f, esc");
},
methods: {
...mapActions({
updateSearchFilter: "SET_SEARCH",
}),
resetSearch() {
this.showSearch = false;
this.filter = "";
},
},
computed: {
...mapState(["searchFilter", "settings"]),
filter: {
get() {
return this.searchFilter;
},
set(value) {
this.updateSearchFilter(value);
},
},
},
};
</script>
<style lang="scss" scoped>
.search {
width: 350px;
position: fixed;
padding: 10px;
background: var(--scheme-main-ter);
top: 0;
right: 0;
border-radius: 0 0 0 5px;
z-index: 10;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
button.delete {
margin-left: 1em;
background-color: var(--scheme-main-ter);
opacity: 0.6;
&:after,
&:before {
background-color: var(--text-color);
}
&:hover {
opacity: 1;
}
}
.icon {
padding: 10px 3px;
}
.input {
color: var(--body-color);
&::placeholder {
color: var(--border-color);
}
}
}
</style>