From 16b9a2b06e603754bb86e3dcf2bf47996001f2c2 Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Sat, 28 Aug 2021 23:23:16 +0530 Subject: [PATCH 1/8] feat: search --- components/app/Header.vue | 16 +-- components/app/Lunr.vue | 229 +++++++++++++++++++++++++++++++++++ components/app/Search.vue | 34 +++--- components/app/Shortcuts.vue | 6 +- helpers/shortcuts.js | 147 +++++++++++++--------- package-lock.json | 15 ++- package.json | 1 + 7 files changed, 358 insertions(+), 90 deletions(-) create mode 100644 components/app/Lunr.vue diff --git a/components/app/Header.vue b/components/app/Header.vue index 8be8e3f4f..927ba78e9 100644 --- a/components/app/Header.vue +++ b/components/app/Header.vue @@ -20,13 +20,13 @@ class="rounded" @click.native="showInstallPrompt()" /> - + /> - + @@ -98,19 +98,19 @@ import { defineActionHandler } from "~/helpers/actions" export default defineComponent({ setup() { const showSupport = ref(false) - // const showSearch = ref(false) + const showSearch = ref(false) defineActionHandler("modals.support.toggle", () => { showSupport.value = !showSupport.value }) - // defineActionHandler("modals.search.toggle", () => { - // showSearch.value = !showSearch.value - // }) + defineActionHandler("modals.search.toggle", () => { + showSearch.value = !showSearch.value + }) return { currentUser: useReadonlyStream(currentUser$, null), showSupport, - // showSearch, + showSearch, } }, data() { diff --git a/components/app/Lunr.vue b/components/app/Lunr.vue new file mode 100644 index 000000000..3c9eee180 --- /dev/null +++ b/components/app/Lunr.vue @@ -0,0 +1,229 @@ + + + + + diff --git a/components/app/Search.vue b/components/app/Search.vue index 9f7d5a51b..dfe9425b7 100644 --- a/components/app/Search.vue +++ b/components/app/Search.vue @@ -18,7 +18,15 @@ pb-6 " /> +
-
+
{{ $t(map.section) }}
@@ -49,10 +54,7 @@ group hover:bg-primaryLight " - @click=" - runAction(shortcut.action) - hideModal() - " + @click="runAction(shortcut.action)" > {{ shortcut.icon }} @@ -77,7 +79,7 @@ - - diff --git a/components/app/Search.vue b/components/app/Search.vue index e51c9a1b9..f3964d27f 100644 --- a/components/app/Search.vue +++ b/components/app/Search.vue @@ -13,9 +13,7 @@ border-b border-dividerLight flex flex-shrink-0 text-secondaryDark text-base - leading-normal - py-4 - px-6 + p-6 " /> {{ $t(map.section) }} -
- - - {{ $t(shortcut.label) }} - - - {{ key }} - -
+ :shortcut="shortcut" + @action="runAction" + />
- - - diff --git a/components/app/SearchEntry.vue b/components/app/SearchEntry.vue new file mode 100644 index 000000000..12275c0c6 --- /dev/null +++ b/components/app/SearchEntry.vue @@ -0,0 +1,47 @@ + + + + + From ebd8f43219f8f3a4a420b0053d63cf2556796000 Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Sun, 29 Aug 2021 13:25:01 +0530 Subject: [PATCH 5/8] refactor: minor ui improvements --- README.md | 2 ++ components/app/SearchEntry.vue | 23 +++++++++++++++++++++-- nuxt.config.js | 2 +- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 87e4787cb..838d11da8 100644 --- a/README.md +++ b/README.md @@ -197,6 +197,8 @@ _Official proxy server is hosted by Hoppscotch - **[GitHub](https://github.com/h 🌎 **i18n:** Experience the app in your own language. +Help us to translate Hoppscotch. Please read [`TRANSLATIONS`](TRANSLATIONS.md) for details on our [`CODE OF CONDUCT`](CODE_OF_CONDUCT.md), and the process for submitting pull requests to us. + 📦 **Add-ons:** Official add-ons for hoppscotch. - **[Proxy](https://github.com/hoppscotch/proxyscotch)** - A simple proxy server created for Hoppscotch diff --git a/components/app/SearchEntry.vue b/components/app/SearchEntry.vue index 12275c0c6..2b25f9eff 100644 --- a/components/app/SearchEntry.vue +++ b/components/app/SearchEntry.vue @@ -9,14 +9,33 @@ items-center group hover:bg-primaryLight + focus:outline-none + focus-visible:bg-primaryLight " + tabindex="0" @click="$emit('action', shortcut.action)" + @keydown.enter="$emit('action', shortcut.action)" > - + {{ $t(shortcut.label) }} Date: Sun, 29 Aug 2021 16:44:18 +0530 Subject: [PATCH 6/8] feat: disable autocomplete on inputs + keyboard navigation focus --- components/app/Lunr.vue | 26 +++++++++++++++++++ components/app/Search.vue | 1 + components/app/Shortcuts.vue | 2 +- components/collections/Add.vue | 1 + components/collections/AddFolder.vue | 1 + components/collections/ChooseType.vue | 1 + components/collections/Edit.vue | 1 + components/collections/EditFolder.vue | 1 + components/collections/EditRequest.vue | 1 + components/collections/ImportExport.vue | 1 + components/collections/SaveRequest.vue | 1 + components/collections/graphql/Add.vue | 1 + components/collections/graphql/AddFolder.vue | 1 + components/collections/graphql/Edit.vue | 1 + components/collections/graphql/EditFolder.vue | 1 + .../collections/graphql/EditRequest.vue | 1 + components/collections/graphql/index.vue | 1 + components/collections/index.vue | 1 + components/environments/Add.vue | 1 + components/environments/Edit.vue | 1 + components/firebase/Login.vue | 2 +- components/graphql/Request.vue | 1 + components/graphql/Sidebar.vue | 1 + components/history/index.vue | 1 + components/http/Request.vue | 2 ++ components/realtime/Mqtt.vue | 4 +++ components/realtime/Socketio.vue | 3 +++ components/realtime/Sse.vue | 1 + components/realtime/Websocket.vue | 3 +++ components/smart/AutoComplete.vue | 1 + components/teams/Add.vue | 1 + components/teams/Edit.vue | 1 + pages/settings.vue | 1 + 33 files changed, 66 insertions(+), 2 deletions(-) diff --git a/components/app/Lunr.vue b/components/app/Lunr.vue index 19e8ec7a3..d7014a0aa 100644 --- a/components/app/Lunr.vue +++ b/components/app/Lunr.vue @@ -3,6 +3,7 @@ @@ -62,6 +63,7 @@ export default { outputHash: "", theOutput: [], cache: {}, + currentItem: -1, } }, computed: { @@ -119,6 +121,12 @@ export default { immediate: true, }, }, + mounted() { + document.addEventListener("keydown", this.nextItem) + }, + destroyed() { + document.removeEventListener("keydown", this.nextItem) + }, methods: { async output(search) { const that = this @@ -196,6 +204,24 @@ export default { const hex = val.toString(16).toUpperCase() return `00000000${hex}`.slice(-8) }, + nextItem(e) { + if (e.keyCode === 38 && this.currentItem > 0) { + e.preventDefault() + this.currentItem-- + this.$nextTick().then(() => { + this.$refs[`item-${this.currentItem}`][0].$el.focus() + }) + } else if ( + e.keyCode === 40 && + this.currentItem < this.theOutput.length - 1 + ) { + e.preventDefault() + this.currentItem++ + this.$nextTick().then(() => { + this.$refs[`item-${this.currentItem}`][0].$el.focus() + }) + } + }, }, } diff --git a/components/app/Search.vue b/components/app/Search.vue index f3964d27f..2a9048bfe 100644 --- a/components/app/Search.vue +++ b/components/app/Search.vue @@ -6,6 +6,7 @@ v-model="search" v-focus type="text" + autocomplete="off" name="command" :placeholder="$t('app.type_a_command_search')" class=" diff --git a/components/app/Shortcuts.vue b/components/app/Shortcuts.vue index 23d9ae372..1a27f422f 100644 --- a/components/app/Shortcuts.vue +++ b/components/app/Shortcuts.vue @@ -23,7 +23,7 @@
@@ -83,6 +85,7 @@ v-model="msg" class="input" type="text" + autocomplete="off" :placeholder="$t('mqtt.message')" spellcheck="false" /> @@ -112,6 +115,7 @@ id="sub_topic" v-model="sub_topic" type="text" + autocomplete="off" :placeholder="$t('mqtt.topic_name')" spellcheck="false" class="input" diff --git a/components/realtime/Socketio.vue b/components/realtime/Socketio.vue index b8be272a8..87adacc2c 100644 --- a/components/realtime/Socketio.vue +++ b/components/realtime/Socketio.vue @@ -12,6 +12,7 @@ v-model="url" v-focus type="url" + autocomplete="off" spellcheck="false" :class="{ error: !urlValid }" class=" @@ -94,6 +95,7 @@ name="event_name" :placeholder="$t('socketio.event_name')" type="text" + autocomplete="off" :disabled="!connectionState" />
@@ -123,6 +125,7 @@ name="message" :placeholder="$t('count.message', { count: index + 1 })" type="text" + autocomplete="off" :disabled="!connectionState" @keyup.enter="connectionState ? sendMessage() : null" /> diff --git a/components/realtime/Sse.vue b/components/realtime/Sse.vue index 8cb614712..3d230dc38 100644 --- a/components/realtime/Sse.vue +++ b/components/realtime/Sse.vue @@ -9,6 +9,7 @@ v-model="server" v-focus type="url" + autocomplete="off" :class="{ error: !serverValid }" class=" bg-primaryLight diff --git a/components/realtime/Websocket.vue b/components/realtime/Websocket.vue index cc36db7c2..121165902 100644 --- a/components/realtime/Websocket.vue +++ b/components/realtime/Websocket.vue @@ -23,6 +23,7 @@ focus-visible:border-dividerDark " type="url" + autocomplete="off" spellcheck="false" :class="{ error: !urlValid }" :placeholder="$t('websocket.url')" @@ -89,6 +90,7 @@ :placeholder="$t('count.protocol', { count: index + 1 })" name="message" type="text" + autocomplete="off" />