Skip to content

Commit 58ee762

Browse files
committed
feat: video preview type
1 parent 872e729 commit 58ee762

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

src/Preview/index.tsx

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ export interface PreviewProps extends InternalPreviewConfig {
121121
};
122122
fallback?: string;
123123

124-
// Preview image
124+
// Preview media
125+
type?: 'image' | 'video';
125126
imgCommonProps?: React.ImgHTMLAttributes<HTMLImageElement>;
127+
videoCommonProps?: React.VideoHTMLAttributes<HTMLVideoElement>;
126128
width?: string | number;
127129
height?: string | number;
128130

@@ -165,6 +167,7 @@ const Preview: React.FC<PreviewProps> = props => {
165167
const {
166168
prefixCls,
167169
rootClassName,
170+
type = 'image',
168171
src,
169172
alt,
170173
imageInfo,
@@ -425,13 +428,15 @@ const Preview: React.FC<PreviewProps> = props => {
425428
{/* Body */}
426429
<div className={classnames(`${prefixCls}-body`, classNames.body)} style={bodyStyle}>
427430
{/* Preview Image */}
428-
{imageRender
429-
? imageRender(imgNode, {
430-
transform,
431-
image,
432-
...(groupContext ? { current } : {}),
433-
})
434-
: imgNode}
431+
{type === 'image' &&
432+
(imageRender
433+
? imageRender(imgNode, {
434+
transform,
435+
image,
436+
...(groupContext ? { current } : {}),
437+
})
438+
: imgNode)}
439+
{type === 'video' && <video src={src} width={props.width} height={props.height} />}
435440
</div>
436441

437442
{/* Close Button */}
@@ -454,37 +459,38 @@ const Preview: React.FC<PreviewProps> = props => {
454459
/>
455460
)}
456461

457-
{/* Footer */}
458-
<Footer
459-
prefixCls={prefixCls}
460-
showProgress={showOperationsProgress}
461-
current={current}
462-
count={count}
463-
showSwitch={showLeftOrRightSwitches}
464-
// Style
465-
classNames={classNames}
466-
styles={styles}
467-
// Render
468-
image={image}
469-
transform={transform}
470-
icons={icons}
471-
countRender={countRender}
472-
actionsRender={actionsRender}
473-
// Scale
474-
scale={scale}
475-
minScale={minScale}
476-
maxScale={maxScale}
477-
// Actions
478-
onActive={onActive}
479-
onFlipY={onFlipY}
480-
onFlipX={onFlipX}
481-
onRotateLeft={onRotateLeft}
482-
onRotateRight={onRotateRight}
483-
onZoomOut={onZoomOut}
484-
onZoomIn={onZoomIn}
485-
onClose={onClose}
486-
onReset={onReset}
487-
/>
462+
{type === 'image' && (
463+
<Footer
464+
prefixCls={prefixCls}
465+
showProgress={showOperationsProgress}
466+
current={current}
467+
count={count}
468+
showSwitch={showLeftOrRightSwitches}
469+
// Style
470+
classNames={classNames}
471+
styles={styles}
472+
// Render
473+
image={image}
474+
transform={transform}
475+
icons={icons}
476+
countRender={countRender}
477+
actionsRender={actionsRender}
478+
// Scale
479+
scale={scale}
480+
minScale={minScale}
481+
maxScale={maxScale}
482+
// Actions
483+
onActive={onActive}
484+
onFlipY={onFlipY}
485+
onFlipX={onFlipX}
486+
onRotateLeft={onRotateLeft}
487+
onRotateRight={onRotateRight}
488+
onZoomOut={onZoomOut}
489+
onZoomIn={onZoomIn}
490+
onClose={onClose}
491+
onReset={onReset}
492+
/>
493+
)}
488494
</div>
489495
);
490496
}}

0 commit comments

Comments
 (0)