From 0618304ddc961f8c20a4c34051d186b89ac5b820 Mon Sep 17 00:00:00 2001 From: Nonimart Date: Tue, 21 Oct 2025 10:24:13 +0200 Subject: [PATCH] FEATURE Handling the share copy link and removing twitter --- includes/utilities.php | 3 ++- resources/css/components/post-header.css | 21 +++++++++++++++++++++ resources/js/singles/share-button.ts | 23 +++++++++++++++++++++++ template-parts/post-header.php | 16 ++++++---------- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/includes/utilities.php b/includes/utilities.php index de2b559..2b6f1a4 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -325,7 +325,8 @@ function build_share_urls() return array( 'Facebook' => $facebookUrl, 'Twitter-X' => $twitterUrl, - 'Linkedin' => $linkedInUrl + 'Linkedin' => $linkedInUrl, + 'postUrl' => $postUrl ); } diff --git a/resources/css/components/post-header.css b/resources/css/components/post-header.css index 2eca17d..21c019b 100644 --- a/resources/css/components/post-header.css +++ b/resources/css/components/post-header.css @@ -181,6 +181,7 @@ transform: scale(1.02) !important; } + .copy-link, .share-link { @apply block w-7 h-7; @@ -212,9 +213,29 @@ img { @apply w-7 h-7 filter-none; } + + &--copy-link { + @apply relative bg-transparent border-0 p-0 cursor-pointer; + + .copy-feedback { + @apply absolute left-1/2 -translate-x-1/2 -bottom-8 bg-white text-primary px-3 py-1 rounded-md text-sm font-medium whitespace-nowrap z-50; + animation: fadeIn 0.3s ease-in-out; + } + } } } } + +@keyframes fadeIn { + from { + opacity: 0; + transform: translate(-50%, -5px); + } + to { + opacity: 1; + transform: translate(-50%, 0); + } +} .article-meta__related-revue { flex-shrink: 1; } diff --git a/resources/js/singles/share-button.ts b/resources/js/singles/share-button.ts index 1146d1b..cc03b61 100644 --- a/resources/js/singles/share-button.ts +++ b/resources/js/singles/share-button.ts @@ -10,4 +10,27 @@ export default function handleShareButton() { shareButton.classList.remove('is-open'); } }); + handleCopyLinkButton(); +} + +function handleCopyLinkButton() { + const copyLinkButton = document.querySelector('.share-button--copy-link a'); + if (!copyLinkButton) return; + + copyLinkButton.addEventListener('click', (e) => { + e.preventDefault(); + const url = copyLinkButton.getAttribute('data-url'); + if (!url) return; + navigator.clipboard.writeText(url); + const notyf = new Notyf({ + duration: 4000, + ripple: false, + dismissible: true, + position: { + x: 'right', + y: 'top', + }, + }); + notyf.success('Lien copiƩ !'); + }); } diff --git a/template-parts/post-header.php b/template-parts/post-header.php index 0b1febc..189ae4d 100644 --- a/template-parts/post-header.php +++ b/template-parts/post-header.php @@ -89,28 +89,24 @@ $likes_count = get_post_likes_count($post_id);