Options.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <SmartModal
  3. v-if="show"
  4. dialog
  5. :title="t('app.options')"
  6. max-width="sm:max-w-md"
  7. class="text-sm"
  8. @close="$emit('hide-modal')"
  9. >
  10. <template #body>
  11. <div class="flex flex-col space-y-2">
  12. <h2 class="p-2 font-semibold font-bold text-secondaryDark">
  13. {{ t("layout.name") }}
  14. </h2>
  15. <SmartItem
  16. svg="sidebar"
  17. :label="EXPAND_NAVIGATION ? t('hide.sidebar') : t('show.sidebar')"
  18. :description="t('layout.collapse_sidebar')"
  19. info-icon="chevron_right"
  20. active
  21. @click.native="expandNavigation"
  22. />
  23. <SmartItem
  24. svg="sidebar-open"
  25. :label="SIDEBAR ? t('hide.collection') : t('show.collection')"
  26. :description="t('layout.collapse_collection')"
  27. info-icon="chevron_right"
  28. active
  29. @click.native="expandCollection"
  30. />
  31. <h2 class="p-2 font-semibold font-bold text-secondaryDark">
  32. {{ t("support.title") }}
  33. </h2>
  34. <SmartItem
  35. svg="book"
  36. :label="t('app.documentation')"
  37. to="https://docs.hoppscotch.io"
  38. :description="t('support.documentation')"
  39. info-icon="chevron_right"
  40. active
  41. blank
  42. @click.native="hideModal()"
  43. />
  44. <SmartItem
  45. svg="gift"
  46. :label="t('app.whats_new')"
  47. to="https://docs.hoppscotch.io/changelog"
  48. :description="t('support.changelog')"
  49. info-icon="chevron_right"
  50. active
  51. blank
  52. @click.native="hideModal()"
  53. />
  54. <SmartItem
  55. svg="activity"
  56. :label="t('app.status')"
  57. to="https://status.hoppscotch.io"
  58. blank
  59. :description="t('app.status_description')"
  60. info-icon="chevron_right"
  61. active
  62. @click.native="hideModal()"
  63. />
  64. <SmartItem
  65. svg="lock"
  66. :label="`${t('app.terms_and_privacy')}`"
  67. to="https://docs.hoppscotch.io/privacy"
  68. blank
  69. :description="t('app.terms_and_privacy')"
  70. info-icon="chevron_right"
  71. active
  72. @click.native="hideModal()"
  73. />
  74. <h2 class="p-2 font-semibold font-bold text-secondaryDark">
  75. {{ t("settings.follow") }}
  76. </h2>
  77. <SmartItem
  78. svg="brands/discord"
  79. :label="t('app.discord')"
  80. to="https://hoppscotch.io/discord"
  81. blank
  82. :description="t('app.join_discord_community')"
  83. info-icon="chevron_right"
  84. active
  85. @click.native="hideModal()"
  86. />
  87. <SmartItem
  88. svg="brands/twitter"
  89. :label="t('app.twitter')"
  90. to="https://hoppscotch.io/twitter"
  91. blank
  92. :description="t('support.twitter')"
  93. info-icon="chevron_right"
  94. active
  95. @click.native="hideModal()"
  96. />
  97. <SmartItem
  98. svg="github"
  99. :label="`${t('app.github')}`"
  100. to="https://github.com/hoppscotch/hoppscotch"
  101. blank
  102. :description="t('support.github')"
  103. info-icon="chevron_right"
  104. active
  105. @click.native="hideModal()"
  106. />
  107. <SmartItem
  108. svg="message-circle"
  109. :label="t('app.chat_with_us')"
  110. :description="t('support.chat')"
  111. info-icon="chevron_right"
  112. active
  113. @click.native="chatWithUs()"
  114. />
  115. <SmartItem
  116. svg="user-plus"
  117. :label="`${t('app.invite')}`"
  118. :description="t('shortcut.miscellaneous.invite')"
  119. info-icon="chevron_right"
  120. active
  121. @click.native="expandInvite()"
  122. />
  123. <SmartItem
  124. v-if="navigatorShare"
  125. v-tippy="{ theme: 'tooltip' }"
  126. svg="share-2"
  127. :label="`${t('request.share')}`"
  128. :description="t('request.share_description')"
  129. info-icon="chevron_right"
  130. active
  131. @click.native="nativeShare()"
  132. />
  133. </div>
  134. <AppShare :show="showShare" @hide-modal="showShare = false" />
  135. </template>
  136. </SmartModal>
  137. </template>
  138. <script setup lang="ts">
  139. import { ref, watch } from "@nuxtjs/composition-api"
  140. import { useSetting } from "~/newstore/settings"
  141. import { defineActionHandler } from "~/helpers/actions"
  142. import { showChat } from "~/helpers/support"
  143. import { useI18n } from "~/helpers/utils/composables"
  144. const t = useI18n()
  145. const navigatorShare = !!navigator.share
  146. const showShare = ref(false)
  147. const ZEN_MODE = useSetting("ZEN_MODE")
  148. const EXPAND_NAVIGATION = useSetting("EXPAND_NAVIGATION")
  149. const SIDEBAR = useSetting("SIDEBAR")
  150. watch(
  151. () => ZEN_MODE.value,
  152. () => {
  153. EXPAND_NAVIGATION.value = !ZEN_MODE.value
  154. }
  155. )
  156. defineProps<{
  157. show: Boolean
  158. }>()
  159. defineActionHandler("modals.share.toggle", () => {
  160. showShare.value = !showShare.value
  161. })
  162. const emit = defineEmits<{
  163. (e: "hide-modal"): void
  164. }>()
  165. const chatWithUs = () => {
  166. showChat()
  167. hideModal()
  168. }
  169. const expandNavigation = () => {
  170. EXPAND_NAVIGATION.value = !EXPAND_NAVIGATION.value
  171. hideModal()
  172. }
  173. const expandCollection = () => {
  174. SIDEBAR.value = !SIDEBAR.value
  175. hideModal()
  176. }
  177. const expandInvite = () => {
  178. showShare.value = true
  179. }
  180. const nativeShare = () => {
  181. if (navigator.share) {
  182. navigator
  183. .share({
  184. title: "Hoppscotch",
  185. text: "Hoppscotch • Open source API development ecosystem - Helps you create requests faster, saving precious time on development.",
  186. url: "https://hoppscotch.io",
  187. })
  188. .then(() => {})
  189. .catch(console.error)
  190. } else {
  191. // fallback
  192. }
  193. }
  194. const hideModal = () => {
  195. emit("hide-modal")
  196. }
  197. </script>