From 37234d77ebea968a5524ef56249a3d82be11facf Mon Sep 17 00:00:00 2001 From: Schmith Daniel Date: Fri, 27 Oct 2023 14:52:06 +0300 Subject: [PATCH] Add aria-label to Preview component --- src/Preview.js | 3 ++- src/ReactPlayer.js | 3 ++- src/props.js | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Preview.js b/src/Preview.js index 1b66a4a2..b24f6b64 100644 --- a/src/Preview.js +++ b/src/Preview.js @@ -57,7 +57,7 @@ export default class Preview extends Component { } render () { - const { light, onClick, playIcon, previewTabIndex } = this.props + const { light, onClick, playIcon, previewTabIndex, previewAriaLabel } = this.props const { image } = this.state const isElement = React.isValidElement(light) const flexCenter = { @@ -102,6 +102,7 @@ export default class Preview extends Component { onClick={onClick} tabIndex={previewTabIndex} onKeyPress={this.handleKeyPress} + {...(previewAriaLabel ? { 'aria-label': previewAriaLabel } : {})} > {isElement ? light : null} {playIcon || defaultPlayIcon} diff --git a/src/ReactPlayer.js b/src/ReactPlayer.js index 4770e604..11768bc3 100644 --- a/src/ReactPlayer.js +++ b/src/ReactPlayer.js @@ -135,13 +135,14 @@ export const createReactPlayer = (players, fallback) => { renderPreview (url) { if (!url) return null - const { light, playIcon, previewTabIndex, oEmbedUrl } = this.props + const { light, playIcon, previewTabIndex, oEmbedUrl, previewAriaLabel } = this.props return ( diff --git a/src/props.js b/src/props.js index b0874fd7..a029e293 100644 --- a/src/props.js +++ b/src/props.js @@ -20,6 +20,7 @@ export const propTypes = { light: oneOfType([bool, string, object]), playIcon: node, previewTabIndex: number, + previewAriaLabel: string, fallback: node, oEmbedUrl: string, wrapper: oneOfType([ @@ -118,6 +119,7 @@ export const defaultProps = { fallback: null, wrapper: 'div', previewTabIndex: 0, + previewAriaLabel: '', oEmbedUrl: 'https://noembed.com/embed?url={url}', config: { soundcloud: {