Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
chore: introduce platform object for platform specific code
Andrew Bastin1e5dd1cc5365
diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.tsindex ab5070ecb..380ed83be 100644--- a/packages/hoppscotch-common/src/components.d.ts+++ b/packages/hoppscotch-common/src/components.d.ts@@ -102,7 +102,6 @@ declare module '@vue/runtime-core' {IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default']IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default']IconLucideGlobe: typeof import('~icons/lucide/globe')['default']- IconLucideHelpCircle: typeof import('~icons/lucide/help-circle')['default']IconLucideInbox: typeof import('~icons/lucide/inbox')['default']IconLucideInfo: typeof import('~icons/lucide/info')['default']IconLucideLayers: typeof import('~icons/lucide/layers')['default']@@ -111,7 +110,6 @@ declare module '@vue/runtime-core' {IconLucideSearch: typeof import('~icons/lucide/search')['default']IconLucideUser: typeof import('~icons/lucide/user')['default']IconLucideUsers: typeof import('~icons/lucide/users')['default']- IconLucideVerified: typeof import('~icons/lucide/verified')['default']LensesHeadersRenderer: typeof import('./components/lenses/HeadersRenderer.vue')['default']LensesHeadersRendererEntry: typeof import('./components/lenses/HeadersRendererEntry.vue')['default']LensesRenderersHTMLLensRenderer: typeof import('./components/lenses/renderers/HTMLLensRenderer.vue')['default']diff --git a/packages/hoppscotch-common/src/components/app/Header.vue b/packages/hoppscotch-common/src/components/app/Header.vueindex ba4c40d20..b89c23bad 100644--- a/packages/hoppscotch-common/src/components/app/Header.vue+++ b/packages/hoppscotch-common/src/components/app/Header.vue@@ -3,7 +3,13 @@<headerclass="flex items-center justify-between flex-1 flex-shrink-0 px-2 py-2 space-x-2 overflow-x-auto overflow-y-hidden">- <div class="inline-flex items-center space-x-2">+ <div+ class="inline-flex items-center space-x-2"+ :style="{+ paddingTop: platform.ui?.appHeader?.paddingTop?.value,+ paddingLeft: platform.ui?.appHeader?.paddingLeft?.value,+ }"+ ><ButtonSecondaryclass="tracking-wide !font-bold !text-secondaryDark hover:bg-primaryDark focus-visible:bg-primaryDark uppercase":label="t('app.name')"@@ -169,6 +175,7 @@ import { probableUser$ } from "@helpers/fb/auth"import { useI18n } from "@composables/i18n"import { useReadonlyStream } from "@composables/stream"import { invokeAction } from "@helpers/actions"+import { platform } from "~/index"const t = useI18n()diff --git a/packages/hoppscotch-common/src/index.ts b/packages/hoppscotch-common/src/index.tsindex 69c3548af..59e621dc8 100644--- a/packages/hoppscotch-common/src/index.ts+++ b/packages/hoppscotch-common/src/index.ts@@ -1,4 +1,4 @@-import { createApp } from "vue"+import { createApp, Ref } from "vue"import { setupLocalPersistence } from "./newstore/localpersistence"import { performMigrations } from "./helpers/migrations"import { initializeFirebase } from "./helpers/fb"@@ -12,7 +12,26 @@ import "nprogress/nprogress.css"import App from "./App.vue"-export function createHoppApp(el: string | Element) {+export type PlatformDef = {+ ui?: {+ appHeader?: {+ paddingTop?: Ref<string>+ paddingLeft?: Ref<string>+ }+ }+}++/**+ * Defines the fields, functions and properties that will be+ * filled in by the individual platforms.+ *+ * This value is populated upon calling `createHoppApp`+ */+export let platform: PlatformDef++export function createHoppApp(el: string | Element, platformDef: PlatformDef) {+ platform = platformDef+const app = createApp(App)// Some basic work that needs to be done before module inits evendiff --git a/packages/hoppscotch-web/src/main.ts b/packages/hoppscotch-web/src/main.tsindex 18dcfea16..70b880b27 100644--- a/packages/hoppscotch-web/src/main.ts+++ b/packages/hoppscotch-web/src/main.ts@@ -1,3 +1,3 @@import { createHoppApp } from "@hoppscotch/common"-createHoppApp("#app")+createHoppApp("#app", {})