Skip to content
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

Adds previewTabIndex property to light mode #1169

Merged
merged 1 commit into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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