This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
102 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const AudioInput = ({ getInput, id }) => { | ||
return ( | ||
<div> | ||
<input id={id} type='file' accept='audio/*' capture onChange={getInput} /> | ||
</div> | ||
); | ||
}; | ||
|
||
AudioInput.propTypes = { | ||
id: PropTypes.string.isRequired, | ||
getInput: PropTypes.func.isRequired | ||
}; | ||
|
||
export default AudioInput; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { AudioInput } from 'components'; | ||
|
||
storiesOf('Audio', module) | ||
.add('default', () => ( | ||
<AudioInput id='recorder' /> | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import AudioInput from '.'; | ||
|
||
const wrap = (props = {}) => shallow(<AudioInput id='recorder' getInput={() => {}} {...props} />); | ||
|
||
it('renders props when passed in', () => { | ||
const wrapper = wrap({ id: 'foo' }); | ||
expect(wrapper.find({ id: 'foo' })).toHaveLength(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,30 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Audio } from 'components'; | ||
import { Audio, AudioInput } from 'components'; | ||
|
||
const Studio = ({ startRecording, stopRecording, info, recording, started, startFailed, stopped, stopFailed, ...props }) => { | ||
const Studio = ({ startRecording, stopRecording, info, recording, startFailed, stopFailed, clip, getInput, ...props }) => { | ||
return ( | ||
<div {...props}> | ||
In the stu-jo | ||
{stopped || <button onClick={started ? stopRecording : startRecording}> | ||
{started ? 'Stop' : 'Start'} | ||
</button>} | ||
{!stopped || <Audio src={recording.fileUrl} autoPlay />} | ||
<h2>In the stu-jo</h2> | ||
{!clip && <div> | ||
<button onClick={recording ? stopRecording : startRecording}> | ||
{recording ? 'Stop' : 'Start'} | ||
</button> | ||
<AudioInput id='recorder' getInput={getInput} /> | ||
</div>} | ||
{clip && <Audio src={clip.fileUrl} autoPlay />} | ||
</div> | ||
); | ||
}; | ||
|
||
Studio.propTypes = { | ||
info: PropTypes.object, | ||
recording: PropTypes.object, | ||
clip: PropTypes.object, | ||
startFailed: PropTypes.bool, | ||
stopFailed: PropTypes.bool, | ||
started: PropTypes.bool, | ||
stopped: PropTypes.bool | ||
recording: PropTypes.bool, | ||
startRecording: PropTypes.func.isRequired, | ||
stopRecording: PropTypes.func.isRequired | ||
}; | ||
|
||
export default Studio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
export const initialState = {}; | ||
|
||
export const initialStudioState = { | ||
info: null, | ||
recording: null | ||
clip: null, | ||
info: null | ||
}; | ||
|
||
export const getRecorderState = (state = initialState, studio) => state[studio] || initialStudioState; | ||
|
||
export const getRecording = (state = initialState, studio) => | ||
getRecorderState(state, studio).recording; | ||
export const getClip = (state = initialState, studio) => | ||
getRecorderState(state, studio).clip; | ||
|
||
export const getInfo = (state = initialState, studio) => | ||
getRecorderState(state, studio).info; |