refactor: embeds preview theme (#3657)

This commit is contained in:
Nivedin
2023-12-15 17:08:02 +05:30
committed by GitHub
parent d66537ac34
commit 93082c3816

View File

@@ -1,65 +1,50 @@
<template> <template>
<div <div
class="flex flex-col p-4 border rounded border-dividerDark" class="flex flex-col p-4 border rounded border-dividerDark"
:class="{ :class="[embedColours]"
'bg-accentContrast': isEmbedThemeLight,
}"
> >
<div <div class="flex items-stretch space-x-2" :class="[embedColours]">
class="flex items-stretch space-x-2"
:class="{
'bg-accentContrast': isEmbedThemeLight,
}"
>
<span <span
class="flex items-center flex-1 min-w-0 border rounded border-divider" class="flex items-center flex-1 min-w-0 border rounded"
:class="[embedColours]"
> >
<span <span
class="flex max-w-[4rem] rounded-l h-full items-center justify-center border-r border-divider text-tiny" class="flex max-w-[4rem] rounded-l h-full items-center justify-center border-r text-tiny"
:class="{ :class="[embedColours]"
'!border-dividerLight bg-accentContrast text-primary':
isEmbedThemeLight,
}"
> >
<span class="px-3 truncate"> <span class="px-3 truncate text-xs">
{{ method }} {{ method }}
</span> </span>
</span> </span>
<span <span class="px-3 truncate" :class="[embedColours]">
class="px-3 truncate"
:class="{
'text-primary': isEmbedThemeLight,
}"
>
{{ endpoint }} {{ endpoint }}
</span> </span>
</span> </span>
<button <button
class="flex items-center justify-center flex-shrink-0 px-3 py-2 font-semibold border rounded border-dividerDark bg-primaryDark text-secondary" class="flex items-center justify-center flex-shrink-0 px-3 py-2 font-semibold border rounded"
:class="{ :class="[embedColours]"
'!bg-accentContrast text-primaryLight': isEmbedThemeLight,
}"
> >
{{ t("action.send") }} {{ t("action.send") }}
</button> </button>
</div> </div>
<div <div
class="flex" class="flex"
:class="{ :class="[{ 'border-b pt-2 ': !noActiveTab }, embedColours]"
'bg-accentContrast text-primary': isEmbedThemeLight,
'border-b border-divider pt-2': !noActiveTab,
}"
> >
<span <span
v-for="option in embedOptions.tabs" v-for="option in embedOptions.tabs"
v-show="option.enabled" v-show="option.enabled"
:key="option.value" :key="option.value"
class="px-2 py-2" class="p-2"
:class="{ :class="[
'border-b border-dividerDark': {
embedOptions.tabs.filter((tab) => tab.enabled)[0]?.value === embedColours,
option.value, 'border-b ':
}" embedOptions.tabs.filter((tab) => tab.enabled)[0]?.value ===
option.value,
},
embedColours,
]"
> >
{{ option.label }} {{ option.label }}
</span> </span>
@@ -71,6 +56,7 @@
import { useVModel } from "@vueuse/core" import { useVModel } from "@vueuse/core"
import { computed } from "vue" import { computed } from "vue"
import { useI18n } from "~/composables/i18n" import { useI18n } from "~/composables/i18n"
import { useSetting } from "~/composables/settings"
type Tabs = "parameters" | "body" | "headers" | "authorization" type Tabs = "parameters" | "body" | "headers" | "authorization"
@@ -98,5 +84,19 @@ const noActiveTab = computed(() => {
return embedOptions.value.tabs.every((tab) => !tab.enabled) return embedOptions.value.tabs.every((tab) => !tab.enabled)
}) })
const isEmbedThemeLight = computed(() => embedOptions.value.theme === "light") const systemTheme = useSetting("BG_COLOR")
const embedColours = computed(() => {
const theme = embedOptions.value.theme
const darkThemeColours = "bg-dark-800 text-white !border-dark-50"
const lightThemeColours = "bg-white text-black !border-white-50"
if (theme === "dark") {
return darkThemeColours
} else if (theme === "light") {
return lightThemeColours
}
return systemTheme.value === "light" ? lightThemeColours : darkThemeColours
})
</script> </script>