forked from jzoldak/edx-eng-dashboard
-
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.
- Loading branch information
Jay Zoldak
committed
Mar 3, 2014
1 parent
df172d0
commit 1526f50
Showing
6 changed files
with
103 additions
and
6 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
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 @@ | ||
Adapted from https://gist.github.com/munkius/9209839 |
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,34 @@ | ||
class Dashing.Hotness extends Dashing.Widget | ||
|
||
@accessor 'value', Dashing.AnimatedValue | ||
|
||
constructor: -> | ||
super | ||
|
||
buckets: -> | ||
buckets = [0, 1, 2, 3, 4] | ||
buckets.reverse() if @cool > @warm | ||
buckets | ||
|
||
onData: (data) -> | ||
node = $(@node) | ||
value = parseInt data.value | ||
@cool = parseInt node.data "cool" | ||
@warm = parseInt node.data "warm" | ||
|
||
low = Math.min(@cool, @warm) | ||
high = Math.max(@cool, @warm) | ||
|
||
level = switch | ||
when value <= low then 0 | ||
when value >= high then 4 | ||
else | ||
bucketSize = (high - low) / 3 # Total # of colours in middle | ||
Math.ceil (value - low) / bucketSize | ||
|
||
accurate_level = @buckets()[level] | ||
|
||
backgroundClass = "hotness#{accurate_level}" | ||
lastClass = @get "lastClass" | ||
node.toggleClass "#{lastClass} #{backgroundClass}" | ||
@set "lastClass", backgroundClass |
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 @@ | ||
<h1 class="title" data-bind="title"></h1> | ||
|
||
<h2 class="value" data-bind="value | prepend prefix | append suffix"></h2> | ||
|
||
<p class="updated-at" data-bind="updatedAtMessage"></p> |
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,52 @@ | ||
// ---------------------------------------------------------------------------- | ||
// Mixins | ||
// ---------------------------------------------------------------------------- | ||
@mixin transition($transition-property, $transition-time, $method) { | ||
-webkit-transition: $transition-property $transition-time $method; | ||
-moz-transition: $transition-property $transition-time $method; | ||
-o-transition: $transition-property $transition-time $method; | ||
transition: $transition-property $transition-time $method; | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Sass declarations | ||
// ---------------------------------------------------------------------------- | ||
$background-color: #000000; | ||
$value-color: #FFFFFF; | ||
$title-color: rgba(255, 255, 255, 0.7); | ||
$updated-at-color: rgba(0, 0, 0, 0.3); | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Widget-hotness styles | ||
// ---------------------------------------------------------------------------- | ||
.widget-hotness { | ||
|
||
background-color: $background-color; | ||
@include transition(background-color, 1s, linear); | ||
|
||
.title { | ||
color: $title-color; | ||
} | ||
|
||
.value { | ||
color: $value-color; | ||
} | ||
|
||
.updated-at { | ||
color: $updated-at-color; | ||
} | ||
|
||
} | ||
|
||
.hotness0 { background-color: #00C176; } | ||
.hotness1 { background-color: #88C100; } | ||
.hotness2 { background-color: #FABE28; } | ||
.hotness3 { background-color: #FF8A00; } | ||
.hotness4 { background-color: #FF003C; } | ||
|
||
// // More colour-blind friendly palette | ||
// .hotness0 { background-color: #046D8B; } | ||
// .hotness1 { background-color: #309292; } | ||
// .hotness2 { background-color: #2FB8AC; } | ||
// .hotness3 { background-color: #93A42A; } | ||
// .hotness4 { background-color: #ECBE13; } |