Share.vue 3.3 KB

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