Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add share modal to articles #131

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/assets/css/fonts.css
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@24,400,1,0');
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@100;200;300;400;500;600;700;800;900&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css');
124 changes: 124 additions & 0 deletions src/components/ShareModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
<template>
<div
class="flex fixed top-0 left-0 justify-center items-center z-40 size-full"
>
<div
class="flex absolute top-0 left-0 size-full bg-gray-400 dark:bg-black opacity-50 backdrop-blur-xl z-40"
@click="$emit('close')"
></div>
<div
class="relative shadow-lg rounded-xl bg-gray-100 dark:bg-gray-900 w-[30%] h-max z-50"
>
<div class="grid gap-4 p-6">
<div class="flex justify-between items-center">
<h2 class="text-xl font-semibold text-gray-900 dark:text-neutral-50">
Share
</h2>
<button
@click="$emit('close')"
class="text-gray-900 dark:text-neutral-50 hover:text-gray-600 dark:hover:text-neutral-300"
>
</button>
</div>
<div class="grid grid-cols-3 gap-3">
<a
:href="mastodonLink"
target="_blank"
class="p-4 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-50 rounded-full flex items-center justify-center hover:bg-gray-600 dark:hover:bg-gray-600"
>
<i class="fa-brands fa-mastodon text-gray-900 dark:text-white"></i>
</a>
<a
:href="twitterLink"
target="_blank"
class="p-4 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-50 rounded-full flex items-center justify-center hover:bg-gray-600 dark:hover:bg-gray-600"
>
<i class="fa-brands fa-twitter text-gray-900 dark:text-white"></i>
</a>
<a
:href="telegramLink"
target="_blank"
class="p-4 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-50 rounded-full flex items-center justify-center hover:bg-gray-600 dark:hover:bg-gray-600"
>
<i class="fa-brands fa-telegram text-gray-900 dark:text-white"></i>
</a>
<a
:href="facebookLink"
target="_blank"
class="p-4 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-50 rounded-full flex items-center justify-center hover:bg-gray-600 dark:hover:bg-gray-600"
>
<i class="fa-brands fa-facebook text-gray-900 dark:text-white"></i>
</a>
<a
:href="whatsappLink"
target="_blank"
class="p-4 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-50 rounded-full flex items-center justify-center hover:bg-gray-600 dark:hover:bg-gray-600"
>
<i class="fa-brands fa-whatsapp text-gray-900 dark:text-white"></i>
</a>
<a
:href="linkedinLink"
target="_blank"
class="p-4 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-50 rounded-full flex items-center justify-center hover:bg-gray-600 dark:hover:bg-gray-600"
>
<i class="fa-brands fa-linkedin text-gray-900 dark:text-white"></i>
</a>
<div
@click="sendEmail"
class="p-4 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-50 rounded-full flex items-center justify-center hover:bg-gray-600 dark:hover:bg-gray-600 cursor-pointer"
>
<i class="fa-regular fa-envelope text-gray-900 dark:text-white"></i>
</div>
<div
@click="copyLink"
class="p-4 bg-gray-100 dark:bg-gray-800 dark:bg-opacity-50 rounded-full flex items-center justify-center hover:bg-gray-600 dark:hover:bg-gray-600 col-span-3 cursor-pointer"
>
<i class="fa-regular fa-copy text-gray-900 dark:text-white"></i>
<span class="ml-2 text-gray-900 dark:text-white">
{{ copied ? "Copied!" : "Copy to Clipboard" }}
</span>
</div>
</div>
</div>
</div>
</div>
</template>

<script setup lang="ts">
import { ref } from "vue";

const copied = ref(false);

const copyLink = () => {
navigator.clipboard.writeText(window.location.href);
copied.value = true;
setTimeout(() => {
copied.value = false;
}, 2000);
};

const sendEmail = () => {
const subject = "Check out this article";
const body = `I thought
you might like this article: ${window.location.href}`;
window.location.href = `mailto:?subject=${subject}&body=${body}`;
};

const mastodonLink = ref(
`https://shareopenly.org/share/?title=${document.title}&url=${window.location.href}`,
);
const twitterLink = ref(
`https://twitter.com/intent/tweet?text=${window.location.href}`,
);
const telegramLink = ref(`https://t.me/share/url?url=${window.location.href}`);
const facebookLink = ref(
`https://www.facebook.com/sharer/sharer.php?u=${window.location.href}`,
);
const whatsappLink = ref(
`https://api.whatsapp.com/send?text=${window.location.href}`,
);
const linkedinLink = ref(
`https://www.linkedin.com/shareArticle?mini=true&url=${window.location.href}`,
);
</script>
Loading