-
-
Notifications
You must be signed in to change notification settings - Fork 110
feat: video preview type #450
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,8 @@ | |
} | ||
} | ||
|
||
&-img { | ||
&-img, | ||
&-video { | ||
max-width: 100%; | ||
max-height: 70%; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: previewvideo | ||
nav: | ||
title: Demo | ||
path: /demo | ||
--- | ||
|
||
<code src="../examples/previewvideo.tsx"></code> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Image from '@rc-component/image'; | ||
import * as React from 'react'; | ||
import '../../assets/index.less'; | ||
import { defaultIcons } from './common'; | ||
|
||
export default function PreviewVideo() { | ||
return ( | ||
<div> | ||
<Image | ||
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png?x-oss-process=image/auto-orient,1/resize,p_10/quality,q_10" | ||
preview={{ | ||
icons: defaultIcons, | ||
type: 'video', | ||
src: 'https://gw.alipayobjects.com/os/rmsportal/NTMlQdLIkPjOACXsdRrq.mp4', | ||
}} | ||
width={200} | ||
/> | ||
|
||
<br /> | ||
<h1>PreviewGroup</h1> | ||
<Image.PreviewGroup preview={{ icons: defaultIcons }}> | ||
<Image | ||
key={1} | ||
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" | ||
preview={{ | ||
src: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png', | ||
}} | ||
width={200} | ||
/> | ||
<Image | ||
key={2} | ||
src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" | ||
preview={{ | ||
type: 'video', | ||
src: 'https://gw.alipayobjects.com/os/rmsportal/NTMlQdLIkPjOACXsdRrq.mp4', | ||
}} | ||
width={200} | ||
/> | ||
</Image.PreviewGroup> | ||
</div> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -67,7 +67,7 @@ const Group: React.FC<PreviewGroupProps> = ({ | |||||||
const [keepOpenIndex, setKeepOpenIndex] = useState(false); | ||||||||
|
||||||||
// >>> Image | ||||||||
const { src, ...imgCommonProps } = mergedItems[current]?.data || {}; | ||||||||
const { src, type, ...imgCommonProps } = mergedItems[current]?.data || {}; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 从数据中额外取出 alt 与 videoCommonProps,避免属性丢失并完成视频接线 当前将除 - const { src, type, ...imgCommonProps } = mergedItems[current]?.data || {};
+ const { src, type, alt, videoCommonProps, ...imgCommonProps } =
+ mergedItems[current]?.data || {}; 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||
// >>> Visible | ||||||||
const [isShowPreview, setShowPreview] = useMergedState(!!previewOpen, { | ||||||||
value: previewOpen, | ||||||||
|
@@ -136,6 +136,7 @@ const Group: React.FC<PreviewGroupProps> = ({ | |||||||
mousePosition={mousePosition} | ||||||||
imgCommonProps={imgCommonProps} | ||||||||
src={src} | ||||||||
type={type} | ||||||||
fallback={fallback} | ||||||||
icons={icons} | ||||||||
current={current} | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
视频渲染未透传
videoCommonProps
且默认autoPlay
有 UX/兼容隐患videoCommonProps
,用户无法配置controls/poster/preload/事件
等;autoPlay
在多数浏览器会被静音门槛或策略阻断,建议默认不自动播放(或仅在muted
时启用);aria-label={alt}
;videoCommonProps.src
覆盖顶层src
。📝 Committable suggestion
🤖 Prompt for AI Agents