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

Social Share in movie player #19

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
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
27 changes: 24 additions & 3 deletions src/components/watch/embed-player.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
'use client';
import React from 'react';
import {
FacebookShareButton,
TwitterShareButton,
LinkedinShareButton,
FacebookIcon,
TwitterIcon,
LinkedinIcon,
} from 'react-share';

Check failure on line 10 in src/components/watch/embed-player.tsx

View workflow job for this annotation

GitHub Actions / build

Cannot find module 'react-share' or its corresponding type declarations.

interface EmbedPlayerProps {
url: string;
}

function EmbedPlayer(props: EmbedPlayerProps) {
const ref = React.useRef<HTMLIFrameElement>(null);
const currentUrl = typeof window !== 'undefined' ? window.location.href : '';

React.useEffect(() => {
if (ref.current) {
ref.current.src = props.url;
Expand All @@ -16,9 +27,7 @@
return () => {
iframe?.removeEventListener('load', handleIframeLoaded);
};
}, []);

const ref = React.useRef<HTMLIFrameElement>(null);
}, [props.url]);

const handleIframeLoaded = () => {
if (!ref.current) {
Expand All @@ -44,8 +53,20 @@
style={{ opacity: 0 }}
referrerPolicy="no-referrer-when-downgrade"
/>
<div style={{ position: 'absolute', bottom: 10, left: 10, zIndex: 1000 }}>
<FacebookShareButton url={currentUrl}>
<FacebookIcon size={32} round />
</FacebookShareButton>
<TwitterShareButton url={currentUrl}>
<TwitterIcon size={32} round />
</TwitterShareButton>
<LinkedinShareButton url={currentUrl}>
<LinkedinIcon size={32} round />
</LinkedinShareButton>
</div>
</div>
);
}

export default EmbedPlayer;

Loading