diff --git a/src/components/AutocompleteDropdown.vue b/src/components/AutocompleteDropdown.vue index 933c550..d3c30cf 100644 --- a/src/components/AutocompleteDropdown.vue +++ b/src/components/AutocompleteDropdown.vue @@ -3,6 +3,7 @@ @@ -50,7 +58,8 @@ export default { data() { return { searchResults: [], - keyboardNavigationIndex: 0 + keyboardNavigationIndex: 0, + numberOfResults: 10 }; }, methods: { @@ -61,33 +70,37 @@ export default { }, fetchAutocompleteResults() { this.keyboardNavigationIndex = 0; + this.searchResults = []; - elasticSearchMoviesAndShows(this.query).then(resp => { - const data = resp.hits.hits; + elasticSearchMoviesAndShows(this.query, this.numberOfResults).then( + resp => { + const data = resp.hits.hits; - let results = data.map(item => { - let index = null; - if (item._source.log.file.path.includes("movie")) index = "movie"; - if (item._source.log.file.path.includes("series")) index = "show"; + let results = data.map(item => { + let index = null; + if (item._source.log.file.path.includes("movie")) index = "movie"; + if (item._source.log.file.path.includes("series")) index = "show"; - if (index === "movie" || index === "show") { - return { - title: item._source.original_name || item._source.original_title, - id: item._source.id, - adult: item._source.adult, - type: index - }; - } - }); + if (index === "movie" || index === "show") { + return { + title: + item._source.original_name || item._source.original_title, + id: item._source.id, + adult: item._source.adult, + type: index + }; + } + }); - results = this.removeDuplicates(results); - results = results.map((el, index) => { - return { ...el, index }; - }); + results = this.removeDuplicates(results); + results = results.map((el, index) => { + return { ...el, index }; + }); - this.$emit("update:results", results); - this.searchResults = results.slice(0, 10); - }); + this.$emit("update:results", results); + this.searchResults = results; + } + ); }, removeDuplicates(searchResults) { let filteredResults = []; @@ -112,7 +125,7 @@ export default { } }, created() { - this.fetchAutocompleteResults(); + if (this.query) this.fetchAutocompleteResults(); } }; @@ -179,14 +192,17 @@ $sizes: 22; } li.result { + background-color: var(--background-95); + color: var(--text-color-50); + padding: 0.5rem 2rem; + list-style: none; + opacity: 0; height: 56px; width: 100%; visibility: hidden; display: flex; align-items: center; - background-color: var(--background-95); - color: var(--text-color-50); padding: 0.5rem 2rem; font-size: 1.4rem; @@ -195,7 +211,7 @@ li.result { cursor: pointer; white-space: nowrap; - transition: color 0.1s ease, stroke 0.4s ease; + transition: color 0.1s ease, fill 0.4s ease; span { overflow-x: hidden; @@ -211,17 +227,33 @@ li.result { border-bottom: 2px solid var(--color-green); .type-icon { - stroke: var(--text-color); + fill: var(--text-color); } } .type-icon { + width: 28px; + height: 28px; margin-right: 1rem; transition: inherit; - stroke: var(--text-color-50); + fill: var(--text-color-50); } } +li.info { + visibility: hidden; + opacity: 0; + display: flex; + justify-content: center; + padding: 0 1rem; + color: var(--text-color-50); + background-color: var(--background-95); + color: var(--text-color-50); + font-size: 0.6rem; + height: 16px; + width: 100%; +} + .shut-leave-to { height: 0px; transition: height 0.4s ease; diff --git a/src/components/SearchInput.vue b/src/components/SearchInput.vue index e5ed224..217988b 100644 --- a/src/components/SearchInput.vue +++ b/src/components/SearchInput.vue @@ -13,7 +13,7 @@ tabindex="0" v-model="query" @input="handleInput" - @click="focus = true" + @click="focusingInput = true" @keydown.escape="handleEscape" @keyup.enter="handleSubmit" @keydown.up="navigateUp" @@ -177,7 +177,8 @@ export default { .fade-leave-active { transition: opacity 0.2s; } -.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ { +.fade-enter, +.fade-leave-to { opacity: 0; } @@ -215,12 +216,14 @@ hr { } .search.active { + transition: border-color 0.3s ease, fill 0.3s ease; + input { border-color: var(--color-green); } .search-icon { - stroke: var(--color-green); + fill: var(--color-green); } } @@ -255,10 +258,11 @@ hr { font-weight: 300; font-size: 18px; color: $text-color; - // border-bottom: 1px solid transparent; + border-bottom: 1px solid transparent; &:focus { - border-color: var(--text-color); + // border-bottom: 1px solid var(--color-green); + border-color: var(--color-green); } @include tablet-min { @@ -270,8 +274,7 @@ hr { &-icon { width: 20px; height: 20px; - stroke: var(--text-color-50); - transition: stroke 0.5s ease; + fill: var(--text-color-50); pointer-events: none; position: absolute; left: 15px;