/**
* External dependencies
*/
import { Text, Button, useBreakpointMatch } from '@automattic/jetpack-components';
import { Dropdown } from '@wordpress/components';
import { gmdateI18n } from '@wordpress/date';
import { __ } from '@wordpress/i18n';
import { Icon, edit, captureVideo, cloud, image, media, video } from '@wordpress/icons';
import classnames from 'classnames';
/**
* Internal dependencies
*/
import styles from './style.module.scss';
/**
* Types
*/
import { VideoThumbnailDropdownProps, VideoThumbnailProps } from './types';
import type React from 'react';
export const VideoThumbnailDropdownButtons = ( {
onUseDefaultThumbnail,
onSelectFromVideo,
onUploadImage,
onClose,
isUpdatingPoster = false,
} ) => {
return (
<>
>
);
};
export const VideoThumbnailDropdown = ( {
onUseDefaultThumbnail,
onSelectFromVideo,
onUploadImage,
}: VideoThumbnailDropdownProps ) => {
return (
(
) }
renderContent={ ( { onClose } ) => (
) }
/>
);
};
/**
* React component to display video thumbnail.
*
* @param {VideoThumbnailProps} props - Component props.
* @returns {React.ReactNode} - VideoThumbnail react component.
*/
const VideoThumbnail = ( {
className,
thumbnail,
duration,
editable,
blankIconSize = 96,
isPrivate,
onUseDefaultThumbnail,
onSelectFromVideo,
onUploadImage,
}: VideoThumbnailProps ) => {
const [ isSmall ] = useBreakpointMatch( 'sm' );
thumbnail =
typeof thumbnail === 'string' && thumbnail !== '' ? (
) : (
thumbnail
);
/** Use a different icon for private videos */
const blankIcon = isPrivate ? captureVideo : video;
/** If the thumbnail is not set, use the placeholder with an icon */
thumbnail = thumbnail ? (
thumbnail
) : (
);
return (
{ Boolean( thumbnail ) && editable && (
) }
{ Number.isFinite( duration ) && (
{ duration >= 3600 * 1000
? gmdateI18n( 'H:i:s', duration )
: gmdateI18n( 'i:s', duration ) }
) }
{ thumbnail }
);
};
export default VideoThumbnail;