ConceptPortal-public/rsconcept/frontend/src/components/ui/EmbedYoutube.tsx

38 lines
913 B
TypeScript
Raw Normal View History

2023-08-27 23:04:57 +03:00
interface EmbedYoutubeProps {
2023-12-28 14:04:44 +03:00
videoID: string;
pxHeight: number;
pxWidth?: number;
2023-08-27 23:04:57 +03:00
}
function EmbedYoutube({ videoID, pxHeight, pxWidth }: EmbedYoutubeProps) {
if (!pxWidth) {
2023-12-28 14:04:44 +03:00
pxWidth = (pxHeight * 16) / 9;
2023-08-27 23:04:57 +03:00
}
return (
2023-12-28 14:04:44 +03:00
<div
className='relative'
style={{
2023-12-28 14:04:44 +03:00
height: 0,
paddingBottom: `${pxHeight}px`,
paddingLeft: `${pxWidth}px`
}}
2023-12-28 14:04:44 +03:00
>
<iframe
allowFullScreen
title='Встроенное видео Youtube'
allow='accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture'
className='absolute top-0 left-0 border'
style={{
minHeight: `${pxHeight}px`,
minWidth: `${pxWidth}px`
}}
width={`${pxWidth}px`}
height={`${pxHeight}px`}
src={`https://www.youtube.com/embed/${videoID}`}
/>
</div>
);
2023-08-27 23:04:57 +03:00
}
2023-12-28 14:04:44 +03:00
export default EmbedYoutube;