Skip to content

Commit 6664301

Browse files
committed
feat(ui): add SocialShareButtons component
1 parent 62464be commit 6664301

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react';
2+
import { FaFacebook, FaTwitter, FaLinkedin, FaLink } from 'react-icons/fa';
3+
interface Props { url: string; title: string; className?: string; }
4+
const SocialShareButtons: React.FC<Props> = ({ url, title, className = '' }) => {
5+
const encodedUrl = encodeURIComponent(url);
6+
const encodedTitle = encodeURIComponent(title);
7+
const copyLink = () => { navigator.clipboard.writeText(url); };
8+
return (
9+
<div className={'flex items-center gap-2 ' + className}>
10+
<a href={'https://facebook.com/sharer/sharer.php?u=' + encodedUrl} target='_blank' rel='noopener noreferrer' className='w-9 h-9 flex items-center justify-center rounded-full bg-blue-600 text-white hover:bg-blue-700 transition-colors'><FaFacebook /></a>
11+
<a href={'https://twitter.com/intent/tweet?url=' + encodedUrl + '&text=' + encodedTitle} target='_blank' rel='noopener noreferrer' className='w-9 h-9 flex items-center justify-center rounded-full bg-sky-500 text-white hover:bg-sky-600 transition-colors'><FaTwitter /></a>
12+
<a href={'https://linkedin.com/shareArticle?mini=true&url=' + encodedUrl + '&title=' + encodedTitle} target='_blank' rel='noopener noreferrer' className='w-9 h-9 flex items-center justify-center rounded-full bg-blue-800 text-white hover:bg-blue-900 transition-colors'><FaLinkedin /></a>
13+
<button onClick={copyLink} className='w-9 h-9 flex items-center justify-center rounded-full bg-gray-600 text-white hover:bg-gray-700 transition-colors'><FaLink /></button>
14+
</div>
15+
);
16+
};
17+
export default SocialShareButtons;

0 commit comments

Comments
 (0)