-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from brancusi/dev
Study wip
- Loading branch information
Showing
15 changed files
with
184 additions
and
31 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
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,50 @@ | ||
import Ember from 'ember'; | ||
import firebase from 'firebase'; | ||
|
||
const { | ||
isPresent, | ||
computed: { notEmpty } | ||
} = Ember; | ||
|
||
export default Ember.Component.extend({ | ||
classNames: ['row'], | ||
hifi: Ember.inject.service(), | ||
|
||
hasAudio: notEmpty('audioUrl'), | ||
|
||
init() { | ||
try { | ||
this.set("fbRef", firebase.app().storage().ref()); | ||
} catch(_) { | ||
this.set("fbRef", undefined); | ||
} | ||
this._super(...arguments); | ||
}, | ||
|
||
didReceiveAttrs() { | ||
if(isPresent(this.get('fbRef'))) { | ||
this.set('audioUrl', undefined); | ||
const cloudUrl = this.get('model'); | ||
|
||
if(isPresent(cloudUrl)) { | ||
this.get("fbRef") | ||
.child(cloudUrl) | ||
.getDownloadURL() | ||
.then(url => { | ||
this.set('audioUrl', url) | ||
}) | ||
.catch(() => { | ||
this.set('audioUrl', undefined); | ||
}) | ||
} else { | ||
this.set('audioUrl', undefined); | ||
} | ||
} | ||
}, | ||
|
||
actions: { | ||
play() { | ||
this.get('hifi').play(this.get('audioUrl')); | ||
} | ||
} | ||
}); |
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,15 @@ | ||
& | ||
border: none | ||
|
||
.btn | ||
margin: 0.25em | ||
display: block | ||
border-radius: 50% | ||
padding: 0.5em | ||
background: rgba(off-white, 0.8) | ||
height: 30px | ||
width: 30px | ||
transition: all 0.2s ease-in-out | ||
|
||
.btn:hover | ||
background: rgba(off-white, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{{#if hasAudio}} | ||
{{ui/icon-button | ||
click=(action "play") | ||
leftIcon="play"}} | ||
{{/if}} |
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 |
---|---|---|
|
@@ -6,6 +6,9 @@ | |
&:active | ||
opacity: 0.5 | ||
|
||
.space | ||
margin: 0.25em | ||
|
||
.label | ||
font-size: 1rem | ||
|
||
|
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
|
||
.right | ||
align-items: flex-end | ||
justify-content: flex-end | ||
|
||
.bottom | ||
align-items: flex-end | ||
|
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,13 @@ | ||
const STRIP_PUNCTUATION = /[.,\/#!$%\^&\*;:{}=\-_?`~()]/g; | ||
|
||
const trimStripLower = str => | ||
str | ||
.replace(STRIP_PUNCTUATION, "") | ||
.toLowerCase() | ||
.trim(); | ||
|
||
const isCorrectAnswer = (submission, answer) => trimStripLower(submission) === trimStripLower(answer) | ||
|
||
export { | ||
isCorrectAnswer | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/integration/components/media/audio-player/component-test.js
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,16 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
import hbs from 'htmlbars-inline-precompile'; | ||
|
||
moduleForComponent('media/audio-player', 'Integration | Component | media/audio player', { | ||
integration: true | ||
}); | ||
|
||
test('it renders', function(assert) { | ||
|
||
// Set any properties with this.set('myProperty', 'value'); | ||
// Handle any actions with this.on('myAction', function(val) { ... }); | ||
|
||
this.render(hbs`{{media/audio-player}}`); | ||
|
||
assert.equal(this.$().text().trim(), ''); | ||
}); |
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