From 34a863424bf0c96236a9f29e33d7c129b40e02c5 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Tue, 19 Feb 2019 10:37:31 +0100 Subject: [PATCH] Show search results while typing --- components/SearchInput.vue | 338 ++++++++++++------ locales/de.json | 4 +- locales/en.json | 4 +- pages/post/_slug/index.vue | 8 +- .../components/data-input/Select/Select.vue | 50 ++- 5 files changed, 282 insertions(+), 122 deletions(-) diff --git a/components/SearchInput.vue b/components/SearchInput.vue index 5dab89177..6fa761b1e 100644 --- a/components/SearchInput.vue +++ b/components/SearchInput.vue @@ -3,11 +3,21 @@ class="search" aria-label="search" role="search" - :class="{ 'is-active': isActive }" + :class="{ + 'is-active': isActive, + 'is-open': isOpen + }" >
- +   + + + @keypress.enter.prevent.stop.self="onEnter" + @focus.capture.native="onFocus" + @blur.capture.native="onBlur" + @keyup.delete.native="onDelete" + @keyup.esc.native="clear" + @input.native="handleInput" + @click.capture.native="isOpen = true" + > + +
- diff --git a/locales/de.json b/locales/de.json index ae7cb46da..976b39906 100644 --- a/locales/de.json +++ b/locales/de.json @@ -26,7 +26,9 @@ "commented": "Kommentiert" }, "search": { - "placeholder": "Suchen" + "placeholder": "Suchen", + "hint": "Wonach suchst du?", + "failed": "Nichts gefunden" }, "settings": { "name": "Einstellungen", diff --git a/locales/en.json b/locales/en.json index 2bf0affc2..f4261de61 100644 --- a/locales/en.json +++ b/locales/en.json @@ -26,7 +26,9 @@ "commented": "Commented" }, "search": { - "placeholder": "Search" + "placeholder": "Search", + "hint": "What are you searching for?", + "failed": "Nothing found" }, "settings": { "name": "Settings", diff --git a/pages/post/_slug/index.vue b/pages/post/_slug/index.vue index 200a9f472..330d2e38b 100644 --- a/pages/post/_slug/index.vue +++ b/pages/post/_slug/index.vue @@ -156,7 +156,10 @@ export default { }, watch: { Post(post) { - this.post = post[0] + this.post = post[0] || {} + // if (!this.post.title) { + // throw new Error('404') + // } this.title = this.post.title } }, @@ -194,7 +197,7 @@ export default { name } commentsCount - comments(orderBy: createdAt_desc) { + comments(first: 20, orderBy: createdAt_desc) { id contentExcerpt createdAt @@ -233,6 +236,7 @@ export default { slug: this.$route.params.slug } }, + prefetch: true, fetchPolicy: 'cache-and-network' } } diff --git a/styleguide/src/system/components/data-input/Select/Select.vue b/styleguide/src/system/components/data-input/Select/Select.vue index 382e328d1..11753031a 100755 --- a/styleguide/src/system/components/data-input/Select/Select.vue +++ b/styleguide/src/system/components/data-input/Select/Select.vue @@ -111,8 +111,9 @@ v-else-if="!filteredOptions.length"> {{ noOptionsFound }} "{{ searchString }}" -