2020-02-26 03:07:35 +00:00
|
|
|
<template>
|
2020-05-17 23:22:56 +00:00
|
|
|
<form
|
|
|
|
class="search"
|
|
|
|
@submit.prevent="search"
|
|
|
|
>
|
|
|
|
<input
|
|
|
|
ref="search"
|
|
|
|
v-model="query"
|
|
|
|
type="search"
|
|
|
|
class="search-input"
|
|
|
|
placeholder="Search..."
|
|
|
|
>
|
|
|
|
<button
|
|
|
|
type="submit"
|
|
|
|
class="search-button"
|
|
|
|
><Icon
|
|
|
|
icon="search"
|
|
|
|
/></button>
|
|
|
|
</form>
|
2020-02-26 03:07:35 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
async function search() {
|
2020-05-17 23:22:56 +00:00
|
|
|
this.$router.push({ name: 'search', query: { q: this.query } });
|
|
|
|
this.$emit('search');
|
2020-02-29 23:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function searching(to) {
|
2020-05-17 23:22:56 +00:00
|
|
|
if (to) {
|
2020-12-28 23:42:02 +00:00
|
|
|
this.$refs.search.focus();
|
2020-05-17 23:22:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function route(to) {
|
|
|
|
if (to.name !== 'search') {
|
|
|
|
this.query = null;
|
|
|
|
}
|
2020-02-26 03:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default {
|
2020-05-17 23:22:56 +00:00
|
|
|
props: {
|
|
|
|
searching: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
query: this.$route.query ? this.$route.query.q : null,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
$route: route,
|
|
|
|
searching,
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
search,
|
|
|
|
},
|
2020-02-26 03:07:35 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
@import 'theme';
|
|
|
|
|
|
|
|
.search {
|
|
|
|
height: 100%;
|
|
|
|
max-width: 20rem;
|
|
|
|
display: flex;
|
|
|
|
flex-grow: 1;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-end;
|
|
|
|
padding: 0 1rem 0 0;
|
2020-03-23 00:43:49 +00:00
|
|
|
border-left: solid 1px var(--shadow-hint);
|
2020-02-26 03:07:35 +00:00
|
|
|
|
|
|
|
&.compact {
|
|
|
|
padding: 0;
|
|
|
|
border: none;
|
|
|
|
|
2020-12-28 23:42:02 +00:00
|
|
|
.search-input {
|
|
|
|
padding: .75rem .5rem .75rem .75rem;
|
|
|
|
}
|
2020-02-26 03:07:35 +00:00
|
|
|
|
|
|
|
.search-button {
|
2020-12-28 23:42:02 +00:00
|
|
|
padding: 1rem 1rem .75rem .25rem;
|
2020-02-26 03:07:35 +00:00
|
|
|
margin: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
2020-09-11 20:45:44 +00:00
|
|
|
padding: .5rem 0 .5rem .5rem;
|
2020-02-26 03:07:35 +00:00
|
|
|
border: none;
|
2020-03-23 00:43:49 +00:00
|
|
|
color: var(--text);
|
|
|
|
background: var(--background);
|
2020-02-26 03:07:35 +00:00
|
|
|
outline: none;
|
|
|
|
font-size: 1rem;
|
|
|
|
outline: none;
|
|
|
|
|
|
|
|
&::placeholder {
|
2020-03-23 00:43:49 +00:00
|
|
|
color: var(--shadow);
|
2020-02-26 03:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&::-webkit-search-cancel-button {
|
|
|
|
-webkit-appearance: none;
|
|
|
|
padding: .5rem;
|
|
|
|
position: relative;
|
|
|
|
right: 0;
|
2020-03-23 00:43:49 +00:00
|
|
|
color: var(--text);
|
2020-02-26 03:07:35 +00:00
|
|
|
background: url('/img/cancel-circle2.svg');
|
|
|
|
opacity: .25;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
opacity: .5;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&:focus::placeholder {
|
2020-03-23 00:43:49 +00:00
|
|
|
color: var(--shadow-weak);
|
2020-02-26 03:07:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.search-button {
|
|
|
|
height: 100%;
|
|
|
|
padding: 0 1rem;
|
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
margin: .3rem 0 0 0;
|
|
|
|
outline: none;
|
|
|
|
|
|
|
|
.icon {
|
2020-03-23 00:43:49 +00:00
|
|
|
fill: var(--shadow-weak);
|
2020-02-26 03:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
.icon {
|
2020-03-23 00:43:49 +00:00
|
|
|
fill: var(--shadow);
|
2020-02-26 03:07:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|