Footer.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <div>
  3. <div class="flex justify-between bg-primary">
  4. <div class="flex">
  5. <ButtonSecondary
  6. v-tippy="{ theme: 'tooltip' }"
  7. :title="EXPAND_NAVIGATION ? t('hide.sidebar') : t('show.sidebar')"
  8. svg="sidebar"
  9. class="transform"
  10. :class="{ '-rotate-180': !EXPAND_NAVIGATION }"
  11. @click.native="EXPAND_NAVIGATION = !EXPAND_NAVIGATION"
  12. />
  13. <ButtonSecondary
  14. v-tippy="{ theme: 'tooltip' }"
  15. :title="`${ZEN_MODE ? t('action.turn_off') : t('action.turn_on')} ${t(
  16. 'layout.zen_mode'
  17. )}`"
  18. :svg="ZEN_MODE ? 'minimize' : 'maximize'"
  19. :class="{
  20. '!text-accent !focus-visible:text-accentDark !hover:text-accentDark':
  21. ZEN_MODE,
  22. }"
  23. @click.native="ZEN_MODE = !ZEN_MODE"
  24. />
  25. <tippy
  26. ref="interceptorOptions"
  27. interactive
  28. trigger="click"
  29. theme="popover"
  30. arrow
  31. >
  32. <template #trigger>
  33. <ButtonSecondary
  34. v-tippy="{ theme: 'tooltip' }"
  35. :title="t('settings.interceptor')"
  36. svg="shield-check"
  37. />
  38. </template>
  39. <AppInterceptor />
  40. </tippy>
  41. </div>
  42. <div class="flex">
  43. <tippy
  44. ref="options"
  45. interactive
  46. trigger="click"
  47. theme="popover"
  48. arrow
  49. :on-shown="() => tippyActions.focus()"
  50. >
  51. <template #trigger>
  52. <ButtonSecondary
  53. svg="help-circle"
  54. class="!rounded-none"
  55. :label="`${t('app.help')}`"
  56. />
  57. </template>
  58. <div
  59. ref="tippyActions"
  60. class="flex flex-col focus:outline-none"
  61. tabindex="0"
  62. role="menu"
  63. @keyup.d="documentation.$el.click()"
  64. @keyup.s="shortcuts.$el.click()"
  65. @keyup.c="chat.$el.click()"
  66. @keyup.escape="options.tippy().hide()"
  67. >
  68. <SmartItem
  69. ref="documentation"
  70. svg="book"
  71. :label="`${t('app.documentation')}`"
  72. to="https://docs.hoppscotch.io"
  73. blank
  74. :shortcut="['D']"
  75. @click.native="options.tippy().hide()"
  76. />
  77. <SmartItem
  78. ref="shortcuts"
  79. svg="zap"
  80. :label="`${t('app.keyboard_shortcuts')}`"
  81. :shortcut="['S']"
  82. @click.native="
  83. () => {
  84. showShortcuts = true
  85. options.tippy().hide()
  86. }
  87. "
  88. />
  89. <SmartItem
  90. ref="chat"
  91. svg="message-circle"
  92. :label="`${t('app.chat_with_us')}`"
  93. :shortcut="['C']"
  94. @click.native="
  95. () => {
  96. chatWithUs()
  97. options.tippy().hide()
  98. }
  99. "
  100. />
  101. <SmartItem
  102. svg="gift"
  103. :label="`${t('app.whats_new')}`"
  104. to="https://docs.hoppscotch.io/changelog"
  105. blank
  106. @click.native="options.tippy().hide()"
  107. />
  108. <SmartItem
  109. svg="activity"
  110. :label="t('app.status')"
  111. to="https://status.hoppscotch.io"
  112. blank
  113. @click.native="options.tippy().hide()"
  114. />
  115. <hr />
  116. <SmartItem
  117. svg="github"
  118. :label="`${t('app.github')}`"
  119. to="https://github.com/hoppscotch/hoppscotch"
  120. blank
  121. @click.native="options.tippy().hide()"
  122. />
  123. <SmartItem
  124. svg="twitter"
  125. :label="`${t('app.twitter')}`"
  126. to="https://hoppscotch.io/twitter"
  127. blank
  128. @click.native="options.tippy().hide()"
  129. />
  130. <SmartItem
  131. svg="user-plus"
  132. :label="`${t('app.invite')}`"
  133. @click.native="
  134. () => {
  135. showShare = true
  136. options.tippy().hide()
  137. }
  138. "
  139. />
  140. <SmartItem
  141. svg="lock"
  142. :label="`${t('app.terms_and_privacy')}`"
  143. to="https://docs.hoppscotch.io/privacy"
  144. blank
  145. @click.native="options.tippy().hide()"
  146. />
  147. <div
  148. class="flex px-4 py-2 opacity-50"
  149. @dblclick="showDeveloperOptionModal()"
  150. >
  151. {{ `${t("app.name")} v${$config.clientVersion}` }}
  152. </div>
  153. </div>
  154. </tippy>
  155. <ButtonSecondary
  156. v-tippy="{ theme: 'tooltip' }"
  157. svg="zap"
  158. :title="t('app.shortcuts')"
  159. @click.native="showShortcuts = true"
  160. />
  161. <ButtonSecondary
  162. v-if="navigatorShare"
  163. v-tippy="{ theme: 'tooltip' }"
  164. svg="share-2"
  165. :title="t('request.share')"
  166. @click.native="nativeShare()"
  167. />
  168. <ButtonSecondary
  169. v-tippy="{ theme: 'tooltip' }"
  170. :title="COLUMN_LAYOUT ? t('layout.row') : t('layout.column')"
  171. svg="columns"
  172. class="transform"
  173. :class="{ 'rotate-90': !COLUMN_LAYOUT }"
  174. @click.native="COLUMN_LAYOUT = !COLUMN_LAYOUT"
  175. />
  176. <span
  177. class="transition transform"
  178. :class="{
  179. 'rotate-180': SIDEBAR_ON_LEFT,
  180. }"
  181. >
  182. <ButtonSecondary
  183. v-tippy="{ theme: 'tooltip' }"
  184. :title="SIDEBAR ? t('hide.sidebar') : t('show.sidebar')"
  185. svg="sidebar-open"
  186. class="transform"
  187. :class="{ 'rotate-180': !SIDEBAR }"
  188. @click.native="SIDEBAR = !SIDEBAR"
  189. />
  190. </span>
  191. </div>
  192. </div>
  193. <AppShortcuts :show="showShortcuts" @close="showShortcuts = false" />
  194. <AppShare :show="showShare" @hide-modal="showShare = false" />
  195. <AppDeveloperOptions
  196. :show="showDeveloperOptions"
  197. @hide-modal="showDeveloperOptions = false"
  198. />
  199. </div>
  200. </template>
  201. <script setup lang="ts">
  202. import { ref, watch } from "@nuxtjs/composition-api"
  203. import { defineActionHandler } from "~/helpers/actions"
  204. import { showChat } from "~/helpers/support"
  205. import { useSetting } from "~/newstore/settings"
  206. import { useI18n, useReadonlyStream } from "~/helpers/utils/composables"
  207. import { currentUser$ } from "~/helpers/fb/auth"
  208. const t = useI18n()
  209. const showShortcuts = ref(false)
  210. const showShare = ref(false)
  211. const showDeveloperOptions = ref(false)
  212. defineActionHandler("flyouts.keybinds.toggle", () => {
  213. showShortcuts.value = !showShortcuts.value
  214. })
  215. defineActionHandler("modals.share.toggle", () => {
  216. showShare.value = !showShare.value
  217. })
  218. const EXPAND_NAVIGATION = useSetting("EXPAND_NAVIGATION")
  219. const SIDEBAR = useSetting("SIDEBAR")
  220. const ZEN_MODE = useSetting("ZEN_MODE")
  221. const COLUMN_LAYOUT = useSetting("COLUMN_LAYOUT")
  222. const SIDEBAR_ON_LEFT = useSetting("SIDEBAR_ON_LEFT")
  223. const navigatorShare = !!navigator.share
  224. const currentUser = useReadonlyStream(currentUser$, null)
  225. watch(
  226. () => ZEN_MODE.value,
  227. () => {
  228. EXPAND_NAVIGATION.value = !ZEN_MODE.value
  229. }
  230. )
  231. const nativeShare = () => {
  232. if (navigator.share) {
  233. navigator
  234. .share({
  235. title: "Hoppscotch",
  236. text: "Hoppscotch • Open source API development ecosystem - Helps you create requests faster, saving precious time on development.",
  237. url: "https://hoppscotch.io",
  238. })
  239. .then(() => {})
  240. .catch(console.error)
  241. } else {
  242. // fallback
  243. }
  244. }
  245. const chatWithUs = () => {
  246. showChat()
  247. }
  248. const showDeveloperOptionModal = () => {
  249. if (currentUser.value) {
  250. showDeveloperOptions.value = true
  251. options.value.tippy().hide()
  252. }
  253. }
  254. // Template refs
  255. const tippyActions = ref<any | null>(null)
  256. const documentation = ref<any | null>(null)
  257. const shortcuts = ref<any | null>(null)
  258. const chat = ref<any | null>(null)
  259. const options = ref<any | null>(null)
  260. </script>