Updates on search design
Former-commit-id: c9c64b4157f8209bce5c62bbfd18d088f3795c15 [formerly 736ba83f466e3ef31dd802940c8cb55fb625f4f6] [formerly ff79dd1704e46ee9cd93e6d92bb36a1efb0d3477 [formerly 990cadd744
]]
Former-commit-id: b9d20239e9c35076c8233712e2ae50840459ec2e [formerly e236a1977d22c04a5f89515f7a50c335c62d87d3]
Former-commit-id: 90f9aa3f1291626649eae83f7e42e1df9d51a0fb
pull/726/head
parent
a97c581562
commit
8dc1f2d407
|
@ -1,15 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="search" v-on:mouseleave="hover = false" v-on:click="click" v-bind:class="{ active: focus || hover, ongoing }">
|
<div id="search" @click="active = true" v-bind:class="{ active , ongoing }">
|
||||||
<i class="material-icons" title="Search">search</i>
|
<div id="input">
|
||||||
|
<button v-if="active" class="action" @click="close" >
|
||||||
|
<i class="material-icons">arrow_back</i>
|
||||||
|
</button>
|
||||||
|
<i v-else class="material-icons">search</i>
|
||||||
<input type="text"
|
<input type="text"
|
||||||
v-model.trim="value"
|
v-model.trim="value"
|
||||||
v-on:focus="focus = true"
|
@keyup="keyup"
|
||||||
v-on:blur="focus = false"
|
@keyup.enter="submit"
|
||||||
v-on:keyup="keyup"
|
|
||||||
v-on:keyup.enter="submit"
|
|
||||||
aria-label="Write here to search"
|
aria-label="Write here to search"
|
||||||
:placeholder="placeholder()">
|
:placeholder="placeholder()">
|
||||||
<div v-on:mouseover="hover = true">
|
</div>
|
||||||
|
<div id="result">
|
||||||
<div>
|
<div>
|
||||||
<span v-if="search.length === 0 && commands.length === 0">{{ text() }}</span>
|
<span v-if="search.length === 0 && commands.length === 0">{{ text() }}</span>
|
||||||
<ul v-else-if="search.length > 0">
|
<ul v-else-if="search.length > 0">
|
||||||
|
@ -34,8 +37,7 @@ export default {
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
value: '',
|
value: '',
|
||||||
hover: false,
|
active: false,
|
||||||
focus: false,
|
|
||||||
ongoing: false,
|
ongoing: false,
|
||||||
scrollable: null,
|
scrollable: null,
|
||||||
search: [],
|
search: [],
|
||||||
|
@ -44,9 +46,21 @@ export default {
|
||||||
},
|
},
|
||||||
computed: mapState(['user']),
|
computed: mapState(['user']),
|
||||||
mounted: function () {
|
mounted: function () {
|
||||||
this.scrollable = document.querySelector('#search > div')
|
this.scrollable = document.querySelector('#search #result')
|
||||||
|
|
||||||
|
window.addEventListener('keydown', (event) => {
|
||||||
|
// Esc!
|
||||||
|
if (event.keyCode === 27) {
|
||||||
|
this.active = false
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
close: function (event) {
|
||||||
|
event.stopPropagation()
|
||||||
|
event.preventDefault()
|
||||||
|
this.active = false
|
||||||
|
},
|
||||||
placeholder: function () {
|
placeholder: function () {
|
||||||
if (this.user.allowCommands && this.user.commands.length > 0) {
|
if (this.user.allowCommands && this.user.commands.length > 0) {
|
||||||
return 'Search or execute a command...'
|
return 'Search or execute a command...'
|
||||||
|
@ -55,6 +69,10 @@ export default {
|
||||||
return 'Search...'
|
return 'Search...'
|
||||||
},
|
},
|
||||||
text: function () {
|
text: function () {
|
||||||
|
if (this.ongoing) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
if (this.value.length === 0) {
|
if (this.value.length === 0) {
|
||||||
if (this.user.allowCommands && this.user.commands.length > 0) {
|
if (this.user.allowCommands && this.user.commands.length > 0) {
|
||||||
return `Search or use one of your supported commands: ${this.user.commands.join(', ')}.`
|
return `Search or use one of your supported commands: ${this.user.commands.join(', ')}.`
|
||||||
|
@ -69,7 +87,13 @@ export default {
|
||||||
return 'Press enter to execute.'
|
return 'Press enter to execute.'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
keyup: function () {
|
keyup: function (event) {
|
||||||
|
if (event.keyCode === 27) {
|
||||||
|
this.active = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.active = true
|
||||||
this.search.length = 0
|
this.search.length = 0
|
||||||
this.commands.length = 0
|
this.commands.length = 0
|
||||||
},
|
},
|
||||||
|
|
|
@ -85,22 +85,40 @@ header > div:last-child {
|
||||||
|
|
||||||
#search {
|
#search {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0.75em;
|
|
||||||
vertical-align: middle;
|
|
||||||
border-radius: 0.3em;
|
|
||||||
background-color: #f5f5f5;
|
|
||||||
transition: .1s ease all;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 25em;
|
max-width: 25em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search.active {
|
#search.active {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search #input {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
display: flex;
|
||||||
|
padding: 0.75em;
|
||||||
|
border-radius: 0.3em;
|
||||||
|
transition: .1s ease all;
|
||||||
|
align-items: center;
|
||||||
|
z-index: 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search.active #input {
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.075);
|
||||||
|
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
border-bottom-left-radius: 0;
|
height: 4em;
|
||||||
border-bottom-right-radius: 0;
|
}
|
||||||
box-shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .12);
|
|
||||||
|
#search.active > div {
|
||||||
|
border-radius: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search.active i,
|
#search.active i,
|
||||||
|
@ -108,12 +126,8 @@ header > div:last-child {
|
||||||
color: #212121;
|
color: #212121;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search i,
|
#search #input > .action,
|
||||||
#search input {
|
#search #input > i {
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
#search i {
|
|
||||||
margin-right: 0.3em;
|
margin-right: 0.3em;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
@ -125,10 +139,23 @@ header > div:last-child {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search.active div {
|
#search #result {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
opacity: 1;
|
max-height: none;
|
||||||
top: 100%;
|
background-color: #fff;
|
||||||
|
text-align: left;
|
||||||
|
color: #ccc;
|
||||||
|
padding: 0;
|
||||||
|
height: 0;
|
||||||
|
transition: .1s ease height, .1s ease padding;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overflow-y: auto;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#search.active #result {
|
||||||
|
padding: .5em;
|
||||||
|
height: calc(100% - 4em);
|
||||||
}
|
}
|
||||||
|
|
||||||
#search ul {
|
#search ul {
|
||||||
|
@ -141,28 +168,7 @@ header > div:last-child {
|
||||||
margin-bottom: .5em;
|
margin-bottom: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search>div {
|
#search #result div {
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
left: 0;
|
|
||||||
z-index: 999999;
|
|
||||||
background-color: #fff;
|
|
||||||
text-align: left;
|
|
||||||
color: #ccc;
|
|
||||||
box-shadow: 0 2px 3px rgba(0, 0, 0, .06), 0 2px 2px rgba(0, 0, 0, .12);
|
|
||||||
padding: .5em;
|
|
||||||
border-bottom-left-radius: .3em;
|
|
||||||
border-bottom-right-radius: .3em;
|
|
||||||
transition: .1s ease all;
|
|
||||||
visibility: hidden;
|
|
||||||
opacity: 0;
|
|
||||||
overflow-x: hidden;
|
|
||||||
overflow-y: auto;
|
|
||||||
max-height: 50vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
#search>div div {
|
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
white-space: -moz-pre-wrap;
|
white-space: -moz-pre-wrap;
|
||||||
white-space: -pre-wrap;
|
white-space: -pre-wrap;
|
||||||
|
@ -170,7 +176,7 @@ header > div:last-child {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search>div p {
|
#search #result p {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -178,12 +184,11 @@ header > div:last-child {
|
||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search.ongoing p {
|
#search.ongoing #result p {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
#search.active div i,
|
#search.active #result i {
|
||||||
#sidebar #search.active div i {
|
|
||||||
color: #ccc;
|
color: #ccc;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
|
Loading…
Reference in New Issue