Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

feat: make smart url feild the default input

liyasthomase2fc0564884d
diff --git a/components/button/Primary.vue b/components/button/Primary.vue
index 7f141fab4..4f459a910 100644
--- a/components/button/Primary.vue
+++ b/components/button/Primary.vue
@@ -15,7 +15,7 @@
:class="[
color
? `text-${color}-800 bg-${color}-200 hover:text-${color}-900 hover:bg-${color}-300 focus:text-${color}-900 focus:bg-${color}-300`
- : `text-primary bg-accent hover:bg-accentDark focus:bg-accentDark`,
+ : `text-white bg-accent hover:bg-accentDark focus:bg-accentDark`,
label ? 'px-4' : 'px-2',
rounded ? 'rounded-full' : 'rounded',
{ 'opacity-75 cursor-not-allowed': disabled },
diff --git a/components/http/Request.vue b/components/http/Request.vue
index 2903ccf23..4e789cd4f 100644
--- a/components/http/Request.vue
+++ b/components/http/Request.vue
@@ -30,7 +30,6 @@
focus:outline-none focus:border-accent
"
:value="newMethod"
- autofocus
readonly
/>
</template>
@@ -45,7 +44,13 @@
</span>
</div>
<div class="flex-1 inline-flex">
+ <SmartUrlField
+ v-if="EXPERIMENTAL_URL_BAR_ENABLED"
+ v-model="newEndpoint"
+ @enter="newSendRequest()"
+ />
<input
+ v-else
id="url"
v-model="newEndpoint"
class="
@@ -65,10 +70,10 @@
type="text"
spellcheck="false"
:placeholder="$t('url')"
+ autofocus
@keyup.enter="newSendRequest()"
/>
</div>
- <!-- <SmartUrlField v-else v-model="uri" /> -->
<div class="flex">
<ButtonPrimary
id="send"
@@ -200,6 +205,7 @@ import { runRESTRequest$ } from "~/helpers/RequestRunner"
import { useStreamSubscriber, useStream } from "~/helpers/utils/composables"
import { defineActionHandler } from "~/helpers/actions"
import { copyToClipboard } from "~/helpers/utils/clipboard"
+import { getSettingSubject } from "~/newstore/settings"
const methods = [
"GET",
@@ -356,5 +362,12 @@ export default defineComponent({
;(this.$refs.options as any).tippy().hide()
},
},
+ subscriptions() {
+ return {
+ EXPERIMENTAL_URL_BAR_ENABLED: getSettingSubject(
+ "EXPERIMENTAL_URL_BAR_ENABLED"
+ ),
+ }
+ },
})
</script>
diff --git a/components/smart/UrlField.vue b/components/smart/UrlField.vue
index f6b3959d8..160d63959 100644
--- a/components/smart/UrlField.vue
+++ b/components/smart/UrlField.vue
@@ -5,7 +5,13 @@
<template>
<div class="url-field-container">
- <div ref="editor" class="url-field" contenteditable="true"></div>
+ <div
+ ref="editor"
+ :placeholder="$t('url')"
+ class="url-field"
+ contenteditable="true"
+ @keyup.enter="$emit('enter')"
+ ></div>
</div>
</template>
@@ -35,7 +41,7 @@ export default {
highlight: [
{
text: /(<<\w+>>)/g,
- style: "VAR",
+ style: "text-white bg-accentDark rounded px-1.5 py-0.5 mx-0.5",
},
],
highlightEnabled: true,
@@ -389,18 +395,45 @@ export default {
}
</script>
-<style scoped lang="scss">
-.VAR {
- @apply font-bold;
- @apply text-accent;
+<style lang="scss" scoped>
+[contenteditable="true"]:empty {
+ @apply h-8;
+
+ line-height: 1.9;
+
+ &::before {
+ @apply text-secondary;
+ @apply opacity-75;
+ @apply pointer-events-none;
+ @apply block;
+
+ content: attr(placeholder);
+ }
}
.url-field-container {
@apply inline-grid;
+ @apply w-full;
}
.url-field {
- @apply border-dashed border-divider;
+ @apply flex;
+ @apply items-center;
+ @apply justify-items-start;
+ @apply bg-primaryLight;
+ @apply border;
+ @apply border-divider;
+ @apply font-semibold;
+ @apply font-mono;
+ @apply flex-1;
+ @apply text-secondaryDark;
+ @apply py-1;
+ @apply px-4;
+ @apply transition;
+ @apply truncate;
+ @apply focus:outline-none;
+ @apply focus:border-accent;
+ @apply truncate;
@apply whitespace-nowrap;
@apply overflow-x-auto;
@apply resize-none;
diff --git a/newstore/settings.ts b/newstore/settings.ts
index 14c34d81a..0071040a3 100644
--- a/newstore/settings.ts
+++ b/newstore/settings.ts
@@ -60,7 +60,7 @@ export const defaultSettings: SettingsType = {
PROXY_URL: "https://proxy.hoppscotch.io/",
PROXY_KEY: "",
EXTENSIONS_ENABLED: true,
- EXPERIMENTAL_URL_BAR_ENABLED: false,
+ EXPERIMENTAL_URL_BAR_ENABLED: true,
URL_EXCLUDES: {
auth: true,
httpUser: true,