Skip to content

Instantly share code, notes, and snippets.

View Bestra's full-sized avatar
😃

Chris Westra Bestra

😃
  • GitHub
  • Columbus, OH
  • 01:36 (UTC -05:00)
  • X @_Bestra
View GitHub Profile
import Ember from 'ember';
export default Ember.Component.extend({
people: Ember.A(),
actions: {
add() {
this.get('people').pushObject("Phil K.S.")
}
}

Showing Flash-style Messages in Ember

Flash messages are ubiquitous on the web. Update your credit card info on any given site and you'll see the friendly "Your information has been updated" message when the page reloads. Having a consitent notification area on the page that users can glean status and errors from can also be very convenient from a development standpoint, for better or worse. The flash in a Rails application acts like a global hash that is cleared out after each request. It's a pattern that's not too difficult to mimic in Ember.

We'll need a few pieces in our app in order to display the flash.

  • A place to store the flash
  • A way to clear the flash after transitions
  • A place to display the flash message(s)
@Bestra
Bestra / README.md
Created February 4, 2014 11:55 — forked from mbostock/.block

This choropleth encodes unemployment rates from 2008 with a quantize scale ranging from 0 to 15%. A threshold scale is a useful alternative for coloring arbitrary ranges.

@Bestra
Bestra / README.md
Last active December 22, 2015 05:58 — forked from mbostock/.block

By adding transitions, we can more easily follow the elements as they are entered, updated and exited. Separate transitions are defined for each of the three states.

Note that no transition is applied to the merged enter + update selection; this is because it would supersede the transition already scheduled on entering and updating elements. It's possible to schedule concurrent elements by using transition.transition or by setting transition.id, but it's simpler here to only transition the x-position on update; for entering elements, the x-position is assigned statically.

Want to read more? Try these tutorials:

@Bestra
Bestra / index.html
Last active December 17, 2015 01:30 — forked from mbostock/.block
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.node {
stroke: #fff;
stroke-width: 1.5px;
}
.node text {
font: 10px sans-serif;
pointer-events: none;