mirror of
https://github.com/gosticks/dash-player.git
synced 2026-12-06 12:01:50 +00:00
Removed ExampleComponent, renamed PlayerComponent, improved prop doc
Also removed useless lines
This commit is contained in:
+3
-7
@@ -1,5 +1,5 @@
|
||||
import React, {Component} from 'react';
|
||||
import {ExampleComponent} from '../src';
|
||||
import {Player} from '../src';
|
||||
|
||||
class Demo extends Component {
|
||||
constructor() {
|
||||
@@ -15,12 +15,8 @@ class Demo extends Component {
|
||||
<h1>dash-player Demo</h1>
|
||||
|
||||
<hr/>
|
||||
<h2>ExampleComponent</h2>
|
||||
<ExampleComponent
|
||||
label="This is an example label"
|
||||
value={this.state.value}
|
||||
setProps={newProps => this.setState({value: newProps.value})}
|
||||
/>
|
||||
<h2>Player</h2>
|
||||
<Player />
|
||||
<hr/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
import React, {Component} from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
/**
|
||||
* ExampleComponent is an example component.
|
||||
* It takes a property, `label`, and
|
||||
* displays it.
|
||||
* It renders an input with the property `value`
|
||||
* which is editable by the user.
|
||||
*/
|
||||
export default class ExampleComponent extends Component {
|
||||
render() {
|
||||
const {id, label, setProps, value} = this.props;
|
||||
|
||||
return (
|
||||
<div id={id}>
|
||||
ExampleComponent: {label}
|
||||
<input
|
||||
value={value}
|
||||
onChange={e => {
|
||||
/*
|
||||
* Send the new value to the parent component.
|
||||
* In a Dash app, this will send the data back to the
|
||||
* Python Dash app server.
|
||||
*/
|
||||
if (setProps) {
|
||||
setProps({
|
||||
value: e.target.value
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ExampleComponent.propTypes = {
|
||||
/**
|
||||
* The ID used to identify this compnent in Dash callbacks
|
||||
*/
|
||||
id: PropTypes.string,
|
||||
|
||||
/**
|
||||
* A label that will be printed when this component is rendered.
|
||||
*/
|
||||
label: PropTypes.string.isRequired,
|
||||
|
||||
/**
|
||||
* The value displayed in the input
|
||||
*/
|
||||
value: PropTypes.string,
|
||||
|
||||
/**
|
||||
* Dash-assigned callback that should be called whenever any of the
|
||||
* properties change
|
||||
*/
|
||||
setProps: PropTypes.func
|
||||
};
|
||||
@@ -7,10 +7,9 @@ import PropTypes from 'prop-types';
|
||||
* YouTube, Facebook, Twitch, SoundCloud, Streamable, Vimeo, Wistia, Mixcloud,
|
||||
* and DailyMotion.
|
||||
*/
|
||||
export default class PlayerComponent extends Component {
|
||||
export default class Player extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {value: props.value};
|
||||
|
||||
this.updateCurrentTime = this.updateCurrentTime.bind(this);
|
||||
this.updateInstanceMethods = this.updateInstanceMethods.bind(this);
|
||||
@@ -98,7 +97,7 @@ export default class PlayerComponent extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
PlayerComponent.propTypes = {
|
||||
Player.propTypes = {
|
||||
/**
|
||||
* The ID used to identify this compnent in Dash callbacks
|
||||
*/
|
||||
@@ -171,7 +170,9 @@ PlayerComponent.propTypes = {
|
||||
progressInterval: PropTypes.string,
|
||||
|
||||
/**
|
||||
* Applies the playsinline attribute where supported
|
||||
* Applies the html5 playsinline attribute where supported, which allows
|
||||
* videos to be played inline and will not automatically enter fullscreen
|
||||
* mode when playback begins (for iOS).
|
||||
*/
|
||||
playsinline: PropTypes.bool,
|
||||
|
||||
@@ -198,7 +199,7 @@ PlayerComponent.propTypes = {
|
||||
seekTo: PropTypes.number
|
||||
};
|
||||
|
||||
PlayerComponent.defaultProps = {
|
||||
Player.defaultProps = {
|
||||
playing: false,
|
||||
loop: false,
|
||||
controls: false,
|
||||
@@ -1,11 +1,10 @@
|
||||
import React from 'react';
|
||||
import {shallow} from 'enzyme';
|
||||
import ExampleComponent from '../ExampleComponent.react';
|
||||
|
||||
describe('ExampleComponent', () => {
|
||||
|
||||
it('renders', () => {
|
||||
const component = shallow(<ExampleComponent label="Test label"/>);
|
||||
const component = shallow(<div/>);
|
||||
expect(component).to.be.ok;
|
||||
});
|
||||
});
|
||||
});
|
||||
+2
-4
@@ -1,8 +1,6 @@
|
||||
/* eslint-disable import/prefer-default-export */
|
||||
import ExampleComponent from './components/ExampleComponent.react';
|
||||
import PlayerComponent from './components/PlayerComponent.react';
|
||||
import Player from './components/Player.react';
|
||||
|
||||
export {
|
||||
ExampleComponent,
|
||||
PlayerComponent
|
||||
Player
|
||||
};
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ app.layout = html.Div([
|
||||
'margin': '0% 5% 1% 5%'
|
||||
},
|
||||
children=[
|
||||
dash_player.PlayerComponent(
|
||||
dash_player.Player(
|
||||
id='video-player',
|
||||
url='http://media.w3.org/2010/05/bunny/movie.mp4',
|
||||
controls=True,
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ app.scripts.config.serve_locally = True
|
||||
|
||||
|
||||
app.layout = html.Div([
|
||||
dash_player.PlayerComponent(
|
||||
dash_player.Player(
|
||||
id='video-player',
|
||||
url='http://media.w3.org/2010/05/bunny/movie.mp4',
|
||||
controls=True
|
||||
|
||||
Reference in New Issue
Block a user