summaryrefslogtreecommitdiff
path: root/src/client/app/desktop/views/components/ui.header.search.vue
blob: d22efbf84f65bbf0500880ba292f12862bd0de06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<template>
<form class="search" @submit.prevent="onSubmit">
	%fa:search%
	<input v-model="q" type="search" placeholder="%i18n:@placeholder%"/>
	<div class="result"></div>
</form>
</template>

<script lang="ts">
import Vue from 'vue';

export default Vue.extend({
	data() {
		return {
			q: ''
		};
	},
	methods: {
		onSubmit() {
			if (this.q.startsWith('#')) {
				this.$router.push(`/tags/${encodeURIComponent(this.q.substr(1))}`);
			} else {
				this.$router.push(`/search?q=${encodeURIComponent(this.q)}`);
			}
		}
	}
});
</script>

<style lang="stylus" scoped>
.search
	> [data-fa]
		display block
		position absolute
		top 0
		left 0
		width 48px
		text-align center
		line-height 48px
		color var(--desktopHeaderFg)
		pointer-events none

		> *
			vertical-align middle

	> input
		user-select text
		cursor auto
		margin 8px 0 0 0
		padding 6px 18px 6px 36px
		width 14em
		height 32px
		font-size 1em
		background var(--desktopHeaderSearchBg)
		outline none
		border none
		border-radius 16px
		transition color 0.5s ease, border 0.5s ease
		color var(--desktopHeaderSearchFg)

		&::placeholder
			color var(--desktopHeaderFg)

		&:hover
			background var(--desktopHeaderSearchHoverBg)

		&:focus
			box-shadow 0 0 0 2px var(--primaryAlpha05) !important

</style>