-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathinteractive-instrument-example.js
41 lines (40 loc) · 1.55 KB
/
interactive-instrument-example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import { Instrument, Note } from '../../../src/';
class InteractiveInstrument extends React.Component {
constructor(props) {
super(props);
this.state = {
};
this.onStartPlaying.bind(this);
this.onStopPlaying.bind(this);
}
// eslint-disable-next-line class-methods-use-this
onStartPlaying(noteName) {
console.warn(`Note played ${noteName}. Use this function if you want to sync your state with the instrument, dispatch redux action or alter mobx observable or just setting state inside your component`);
}
// eslint-disable-next-line class-methods-use-this
onStopPlaying(noteName) {
console.warn(`Stopped playing ${noteName}. Use this function if you want to sync your state with the instrument, dispatch redux action or alter mobx observable or just setting state inside your component`);
}
render() {
return (
<Instrument name={'acoustic_grand_piano'} onStartPlaying={this.onStartPlaying} onStopPlaying={this.onStopPlaying} interactive>
<Note name={'A3'} className={'animated bounce'}>
<div className="control">
<div className={`button ${this.state.playA ? 'is-primary' : ''}`}>
Click me to play A3
</div>
</div>
</Note>
<Note name={'C3'}>
<div className="control">
<button className={`button ${this.state.playC ? 'is-primary' : ''}`}>
Click me to play C3
</button>
</div>
</Note>
</Instrument>
);
}
}
export default InteractiveInstrument;