-
Notifications
You must be signed in to change notification settings - Fork 0
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
Modal audio #29
base: master
Are you sure you want to change the base?
Modal audio #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple small comments :)
src/components/Modal.jsx
Outdated
@@ -195,6 +248,8 @@ Modal.defaultProps = { | |||
title: 'Please give me a title :)', | |||
content: 'Please give me some content :)', | |||
image: '', | |||
sound: '', | |||
volume: '10', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can likely be a number :)
@@ -195,6 +248,8 @@ Modal.defaultProps = { | |||
title: 'Please give me a title :)', | |||
content: 'Please give me some content :)', | |||
image: '', | |||
sound: '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this exists conditionally, I'd make this a boolean, and instead of having a hasSound()
method, just check if (this.props.sound) { // do stuff }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patrickocoffeyo so in the case that this has a sound, the value for this property would be the sound file (i.e. a string). For example it would be defined in the modal like so:
<Modal
id="modal__upstairs"
title="Upstairs Playroom"
position={{ x: -26.15, y: 5.70, z: -10.41 }}
image={require('../../assets/images/jpg/upstairs.jpg')}
sound={require('../../assets/sounds/upstairs.mp3')}
volume={5}
/>
Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, that makes sense, and if no sound property is specified, it'll default to the value you set here. If that value is just false
, it'll make checking for the existence of the sound a bit easier :) I should probably do that for image as well. I think that will work..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nope, I'm wrong. You can't default a string to a boolean, it does do typing on defaults. I coulda sworn that wasn't true! Oh well. Sorry about that!
* @returns {boolean} | ||
* Returns true if a sound is set, otherwise returns false. | ||
*/ | ||
hasSound() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment below about defaulting this to false
. II think it should work if we type check this to string
, and default it to false
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was totes wrong on this, you defaults are type checked. 🛑 This is good to go!
@patrickocoffeyo I made the change to the volume propType. I had actually done this in a more recent version of this for Meredith. Incidentally some more recent work on that project also breaks out the sound playback methods into a separate class that can be shared across multiple components (like the existing Sound component). I've been meaning to PR that work here as well. Up to you if you think this PR is useful as is or if you want to wait for the additional enhancements. |
Modal audio
This PR introduces the following changes:
Steps to Test
yarn
ornpm i
in this repo's root.npm run start
in this repo's root.