Share.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <SmartModal
  3. v-if="show"
  4. dialog
  5. :title="t('app.invite_your_friends')"
  6. @close="hideModal"
  7. >
  8. <template #body>
  9. <p class="px-2 mb-8 text-secondaryLight">
  10. {{ t("app.invite_description") }}
  11. </p>
  12. <div class="flex flex-col px-2 space-y-2">
  13. <div class="grid grid-cols-3 gap-4">
  14. <a
  15. v-for="(platform, index) in platforms"
  16. :key="`platform-${index}`"
  17. :href="platform.link"
  18. target="_blank"
  19. class="share-link"
  20. >
  21. <SmartIcon :name="platform.icon" class="w-6 h-6" />
  22. <span class="mt-3">
  23. {{ platform.name }}
  24. </span>
  25. </a>
  26. <button class="share-link" @click="copyAppLink">
  27. <SmartIcon class="w-6 h-6 text-xl" :name="copyIcon" />
  28. <span class="mt-3">
  29. {{ t("app.copy") }}
  30. </span>
  31. </button>
  32. </div>
  33. </div>
  34. </template>
  35. </SmartModal>
  36. </template>
  37. <script setup lang="ts">
  38. import { ref } from "@nuxtjs/composition-api"
  39. import { copyToClipboard } from "~/helpers/utils/clipboard"
  40. import { useI18n, useToast } from "~/helpers/utils/composables"
  41. const t = useI18n()
  42. const toast = useToast()
  43. defineProps<{
  44. show: Boolean
  45. }>()
  46. const emit = defineEmits<{
  47. (e: "hide-modal"): void
  48. }>()
  49. const url = "https://hoppscotch.io"
  50. const text = "Hoppscotch - Open source API development ecosystem."
  51. const description =
  52. "Helps you create requests faster, saving precious time on development."
  53. const subject = "Checkout Hoppscotch - an open source API development ecosystem"
  54. const summary = `Hi there!%0D%0A%0D%0AI thought you'll like this new platform that I joined called Hoppscotch - https://hoppscotch.io.%0D%0AIt is a simple and intuitive interface for creating and managing your APIs. You can build, test, document, and share your APIs.%0D%0A%0D%0AThe best part about Hoppscotch is that it is open source and free to get started.%0D%0A%0D%0A`
  55. const twitter = "hoppscotch_io"
  56. const copyIcon = ref("copy")
  57. const platforms = [
  58. {
  59. name: "Email",
  60. icon: "mail",
  61. link: `mailto:?subject=${subject}&body=${summary}`,
  62. },
  63. {
  64. name: "Twitter",
  65. icon: "brands/twitter",
  66. link: `https://twitter.com/intent/tweet?text=${text} ${description}&url=${url}&via=${twitter}`,
  67. },
  68. {
  69. name: "Facebook",
  70. icon: "brands/facebook",
  71. link: `https://www.facebook.com/sharer/sharer.php?u=${url}`,
  72. },
  73. {
  74. name: "Reddit",
  75. icon: "brands/reddit",
  76. link: `https://www.reddit.com/submit?url=${url}&title=${text}`,
  77. },
  78. {
  79. name: "LinkedIn",
  80. icon: "brands/linkedin",
  81. link: `https://www.linkedin.com/sharing/share-offsite/?url=${url}`,
  82. },
  83. ]
  84. const copyAppLink = () => {
  85. copyToClipboard(url)
  86. copyIcon.value = "check"
  87. toast.success(`${t("state.copied_to_clipboard")}`)
  88. setTimeout(() => (copyIcon.value = "copy"), 1000)
  89. }
  90. const hideModal = () => {
  91. emit("hide-modal")
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .share-link {
  96. @apply border border-dividerLight;
  97. @apply rounded;
  98. @apply flex-col flex;
  99. @apply p-4;
  100. @apply items-center;
  101. @apply justify-center;
  102. @apply font-semibold;
  103. @apply hover:(bg-primaryLight text-secondaryDark);
  104. @apply focus:outline-none;
  105. @apply focus-visible:border-divider;
  106. svg {
  107. @apply opacity-80;
  108. }
  109. &:hover {
  110. svg {
  111. @apply opacity-100;
  112. }
  113. }
  114. }
  115. </style>