Share.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <SmartModal
  3. v-if="show"
  4. :title="$t('app.invite_your_friends')"
  5. @close="$emit('hide-modal')"
  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>
  37. import { defineComponent } from "@nuxtjs/composition-api"
  38. import { copyToClipboard } from "~/helpers/utils/clipboard"
  39. export default defineComponent({
  40. props: {
  41. show: Boolean,
  42. },
  43. data() {
  44. const url = "https://hoppscotch.io"
  45. const text = "Hoppscotch - Open source API development ecosystem."
  46. const description =
  47. "Helps you create requests faster, saving precious time on development."
  48. const subject =
  49. "Checkout Hoppscotch - an open source API development ecosystem"
  50. 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`
  51. const twitter = "hoppscotch_io"
  52. return {
  53. url: "https://hoppscotch.io",
  54. copyIcon: "copy",
  55. platforms: [
  56. {
  57. name: "Email",
  58. icon: "mail",
  59. link: `mailto:?subject=${subject}&body=${summary}`,
  60. },
  61. {
  62. name: "Twitter",
  63. icon: "brands/twitter",
  64. link: `https://twitter.com/intent/tweet?text=${text} ${description}&url=${url}&via=${twitter}`,
  65. },
  66. {
  67. name: "Facebook",
  68. icon: "brands/facebook",
  69. link: `https://www.facebook.com/sharer/sharer.php?u=${url}`,
  70. },
  71. {
  72. name: "Reddit",
  73. icon: "brands/reddit",
  74. link: `https://www.reddit.com/submit?url=${url}&title=${text}`,
  75. },
  76. {
  77. name: "LinkedIn",
  78. icon: "brands/linkedin",
  79. link: `https://www.linkedin.com/sharing/share-offsite/?url=${url}`,
  80. },
  81. ],
  82. }
  83. },
  84. methods: {
  85. copyAppLink() {
  86. copyToClipboard(this.url)
  87. this.copyIcon = "check"
  88. this.$toast.success(this.$t("state.copied_to_clipboard").toString(), {
  89. icon: "content_paste",
  90. })
  91. setTimeout(() => (this.copyIcon = "copy"), 1000)
  92. },
  93. hideModal() {
  94. this.$emit("hide-modal")
  95. },
  96. },
  97. })
  98. </script>
  99. <style lang="scss" scoped>
  100. .share-link {
  101. @apply border border-dividerLight;
  102. @apply rounded;
  103. @apply flex-col flex;
  104. @apply p-4;
  105. @apply items-center;
  106. @apply justify-center;
  107. @apply hover:(bg-primaryLight text-secondaryDark);
  108. @apply focus:outline-none;
  109. @apply focus-visible:border-divider;
  110. svg {
  111. @apply opacity-80;
  112. }
  113. &:hover {
  114. svg {
  115. @apply opacity-100;
  116. }
  117. }
  118. }
  119. </style>