diff --git a/packages/hoppscotch-common/src/components/collections/ImportExport.vue b/packages/hoppscotch-common/src/components/collections/ImportExport.vue index 90badc53f..7aa864c15 100644 --- a/packages/hoppscotch-common/src/components/collections/ImportExport.vue +++ b/packages/hoppscotch-common/src/components/collections/ImportExport.vue @@ -131,6 +131,7 @@ @click="emit('export-json-collection')" />
+ +
@@ -110,7 +126,8 @@ import { pipe } from "fp-ts/function" import { not } from "fp-ts/Predicate" import * as A from "fp-ts/Array" import * as O from "fp-ts/Option" -import { ref, ComputedRef, computed, provide, inject } from "vue" +import { ref, ComputedRef, computed, provide, inject, watch } from "vue" +import { useElementSize } from "@vueuse/core" import type { Slot } from "vue" import draggable from "vuedraggable-es" import { HoppUIPluginOptions, HOPP_UI_OPTIONS } from "./../../index" @@ -135,32 +152,24 @@ export type TabProvider = { const { t } = inject(HOPP_UI_OPTIONS) ?? {} -const props = defineProps({ - styles: { - type: String, - default: "", - }, - modelValue: { - type: String, - required: true, - }, - renderInactiveTabs: { - type: Boolean, - default: false, - }, - canAddNewTab: { - type: Boolean, - default: true, - }, - newText: { - type: String, - default: null, - }, - closeText: { - type: String, - default: null, - }, -}) +const props = withDefaults( + defineProps<{ + styles: string + modelValue: string + renderInactiveTabs: boolean + canAddNewTab: boolean + newText: string | null + closeText: string | null + }>(), + { + styles: "", + renderInactiveTabs: false, + canAddNewTab: true, + newText: null, + closeText: null, + } +) + const emit = defineEmits<{ (e: "update:modelValue", newTabID: string): void (e: "sort", body: { oldIndex: number; newIndex: number }): void @@ -241,12 +250,46 @@ const addTab = () => { emit("addTab") } -const scrollContainer = ref(null) +/** + * Scroll related properties + */ +const MAX_SCROLL_VALUE = 500 +const scrollContainer = ref() +const { width: scrollContainerWidth } = useElementSize(scrollContainer) +const thumbPosition = ref(0) + +const scrollThumb = computed(() => { + const clientWidth = scrollContainerWidth.value ?? 0 + const scrollWidth = tabEntries.value.length * 184 + + return { + width: (clientWidth / scrollWidth) * clientWidth || 300, + show: clientWidth ? scrollWidth > clientWidth : false, + } +}) + +/* + * Scroll with mouse wheel + */ const scroll = (e: WheelEvent) => { scrollContainer.value!.scrollLeft += e.deltaY scrollContainer.value!.scrollLeft += e.deltaX + + const { scrollWidth, clientWidth, scrollLeft } = scrollContainer.value! + const maxScroll = scrollWidth - clientWidth + thumbPosition.value = (scrollLeft / maxScroll) * MAX_SCROLL_VALUE } + +/* + * Scroll with scrollbar/slider + * when scroll thumb is dragged or clicked on the scrollbar + */ +watch(thumbPosition, (newVal) => { + const { scrollWidth, clientWidth } = scrollContainer.value! + const maxScroll = scrollWidth - clientWidth + scrollContainer.value!.scrollLeft = maxScroll * (newVal / MAX_SCROLL_VALUE) +}) diff --git a/packages/hoppscotch-web/src/main.ts b/packages/hoppscotch-web/src/main.ts index 5e2108199..672f331cb 100644 --- a/packages/hoppscotch-web/src/main.ts +++ b/packages/hoppscotch-web/src/main.ts @@ -20,4 +20,7 @@ createHoppApp("#app", { history: historyDef, tabState: tabStateDef, }, + platformFeatureFlags: { + exportAsGIST: true, + }, })