Skip to content

Commit

Permalink
Adds previewTabIndex property to light mode (#1169)
Browse files Browse the repository at this point in the history
Co-authored-by: failcake <failcake.work@gmail.com>
  • Loading branch information
edunad and failcake authored Feb 8, 2021
1 parent 53e4aed commit 994820e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Prop | Description | Default
`fallback` | Element or component to use as a fallback if you are using lazy loading | `null`
`wrapper` | Element or component to use as the container element | `div`
`playIcon` | Element or component to use as the play icon in light mode
`previewTabIndex` | Set the tab index to be used on light mode | 0
`config` | Override options for the various players, see [config prop](#config-prop)

#### Callback props
Expand Down
4 changes: 2 additions & 2 deletions src/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default class Preview extends Component {
}

render () {
const { onClick, playIcon } = this.props
const { onClick, playIcon, previewTabIndex } = this.props
const { image } = this.state
const flexCenter = {
display: 'flex',
Expand Down Expand Up @@ -95,7 +95,7 @@ export default class Preview extends Component {
style={styles.preview}
className='react-player__preview'
onClick={onClick}
tabIndex={0}
tabIndex={previewTabIndex}
onKeyPress={this.handleKeyPress}
>
{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 @@ -134,12 +134,13 @@ export const createReactPlayer = (players, fallback) => {

renderPreview (url) {
if (!url) return null
const { light, playIcon } = this.props
const { light, playIcon, previewTabIndex } = this.props
return (
<Preview
url={url}
light={light}
playIcon={playIcon}
previewTabIndex={previewTabIndex}
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 @@ -19,6 +19,7 @@ export const propTypes = {
stopOnUnmount: bool,
light: oneOfType([bool, string]),
playIcon: node,
previewTabIndex: number,
fallback: node,
wrapper: oneOfType([
string,
Expand Down Expand Up @@ -110,6 +111,7 @@ export const defaultProps = {
light: false,
fallback: null,
wrapper: 'div',
previewTabIndex: 0,
config: {
soundcloud: {
options: {
Expand Down
1 change: 1 addition & 0 deletions types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface BaseReactPlayerProps {
progressInterval?: number
playsinline?: boolean
playIcon?: ReactElement
previewTabIndex?: number
pip?: boolean
stopOnUnmount?: boolean
light?: boolean | string
Expand Down

0 comments on commit 994820e

Please sign in to comment.