Skip to content

Instantly share code, notes, and snippets.

@mattmcmanus
Last active April 8, 2016 18:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattmcmanus/d23d9bc3167cfb5297ef0b293d4b0704 to your computer and use it in GitHub Desktop.
Save mattmcmanus/d23d9bc3167cfb5297ef0b293d4b0704 to your computer and use it in GitHub Desktop.
Using ember-derred-content with ember-in-viewport
import Ember from 'ember';
const {
get,
computed
} = Ember;
import InViewportMixin from 'ember-in-viewport';
export default Ember.Component.extend(
InViewportMixin,
{
classNames: ['panel'],
stats: computed('groupMembership', function() {
return get(this, 'groupMembership').tallyupStats(); // Using ember-api-actions (https://github.com/mike-north/ember-api-actions)
})
});
{{user-avatar user=groupMembership.user}}
{{#if viewportEntered}}
{{#deferred-content promise=stats as |d|}}
{{#if d.isPending}}
<div class="loading spinner"></div>
{{/if}}
{{#if d.isFulfilled}}
{{progress-bar
current=d.content.stats.tallyup_stats.current_month.amount
max=groupMembership.monthlyGoalAmount}}
<div class="big-stats-row">
{{bigStat (numberToK d.content.stats.tallyup_stats.monthly_average) "Monthly Average"}}
{{bigStat (numberToK d.content.stats.tallyup_stats.highest_month.amount) (concat "Highest Month" "<br/>" "(" d.content.stats.tallyup_stats.highest_month.month ")")}}
{{bigStat (numberToK d.content.stats.tallyup_stats.ytd_total) "YTD Total"}}
</div>
{{/if}}
{{/deferred-content}}
{{/if}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment