Skip to content

Commit

Permalink
Add aria-label to Preview component (#1705)
Browse files Browse the repository at this point in the history
Co-authored-by: Schmith Daniel <[email protected]>
  • Loading branch information
schdaniel20 and danielschmith authored Feb 21, 2024
1 parent 132a9d3 commit 08240af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion src/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Preview
url={url}
light={light}
playIcon={playIcon}
previewTabIndex={previewTabIndex}
previewAriaLabel={previewAriaLabel}
oEmbedUrl={oEmbedUrl}
onClick={this.handleClickPreview}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const propTypes = {
light: oneOfType([bool, string, object]),
playIcon: node,
previewTabIndex: number,
previewAriaLabel: string,
fallback: node,
oEmbedUrl: string,
wrapper: oneOfType([
Expand Down Expand Up @@ -118,6 +119,7 @@ export const defaultProps = {
fallback: null,
wrapper: 'div',
previewTabIndex: 0,
previewAriaLabel: '',
oEmbedUrl: 'https://noembed.com/embed?url={url}',
config: {
soundcloud: {
Expand Down

0 comments on commit 08240af

Please sign in to comment.