Skip to content

Commit

Permalink
Merge pull request #128 from stefanjudis/feature/109-better-loading-i…
Browse files Browse the repository at this point in the history
…ndication

#109 added loading indication
  • Loading branch information
stefanjudis committed Sep 5, 2014
2 parents c7f74db + 3321f8c commit 6b9ca50
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 9 deletions.
4 changes: 3 additions & 1 deletion tasks/assets/sass/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ $d-baseWidth : 98%;
$z-filmstrip-time : 5;
$z-header : 6;


/**
* Configs for _graphs.scss
*/
$description-height : 1.5em;
$description-width : 1.5em;


/**
* Table config stuff
*/

$t-colorBody : $c-white;
$t-colorBorder : $c-grayDarker;
$t-colorDate : $c-green;
Expand Down Expand Up @@ -88,6 +89,7 @@ $b-big : 1000px;
$header-bg-color : $c-grayDarker;
$header-headline-color : $c-green;


/**
* Stuff that fits nowhere else
*/
Expand Down
45 changes: 42 additions & 3 deletions tasks/assets/sass/components/_graphs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,56 @@
}
}

.p--graphs--loading {
display : none;

position : absolute;
z-index : $z-loading;

top : 0;
right : 0;
bottom : 0;
left : 0;

background : rgba( $c-black, 0.25 );

.spinner {
position : absolute;

top : 40%;
left : 50%;

margin-left : -2em;

height : 4em;
width : 4em;

border : 0.5em solid $c-green;
border-top: 0.5em solid adjust-lightness( $c-green, 20 );

border-radius : 100%;

@include animation( rotator 2s infinite linear );
}

&.is-active {
display : block;
}
}

.p--graphs--svg {
width : 100%;
height : 0;

padding-top : calc( 40% + 80px );
}

.p--graphs--svg__initialized {
padding : 0;
&.is-initialized {
height : auto;
padding : 0;
}
}


.p--lineChart--area {
fill: rgba( $c-gray, 0.5 );
}
Expand Down
9 changes: 9 additions & 0 deletions tasks/assets/sass/components/_keyframes.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@include keyframes( rotator ) {
from {
transform: rotate(0deg);
}

to {
transform: rotate(359deg);
}
}
1 change: 1 addition & 0 deletions tasks/assets/sass/phantomas.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@import "components/filmstrip";
@import "components/footer";
@import "components/graphs";
@import "components/keyframes";
@import "components/offenders";
@import "components/table";

Expand Down
16 changes: 13 additions & 3 deletions tasks/assets/scripts/phantomas.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@
detailWidth = 115,

container = d3.select( containerEl ),
svg = container.select( 'svg' )
svg = container.select( '.p--graphs--svg' )
.attr( 'width', width )
.attr( 'height', height + margin.top + margin.bottom )
.attr( 'class', 'p--graphs--svg__initialized' ),
.attr( 'class', 'p--graphs--svg is-initialized' ),

x = d3.time.scale().range( [ 0, width - detailWidth ] ),
xAxis = d3.svg.axis().scale( x )
Expand Down Expand Up @@ -297,6 +297,8 @@
.x( function( d ) { return x( d.date ) + detailWidth / 2; } )
.y( function( d ) { return y( d.value[ type ] ); } ),

loader = container.select( '.p--graphs--loading' ),

assertionGroup,
circleContainer,
zoom;
Expand All @@ -317,9 +319,12 @@
} )
] );

// hide loading spinner
loader.attr( 'class', 'p--graphs--loading' );

// clean up time... :)
if ( !svg.empty() ) {
svg.selectAll( 'g, path, line' ).remove();
svg.selectAll( 'g, path, rect, text, line' ).remove();
}

svg.append( 'g' )
Expand Down Expand Up @@ -709,6 +714,11 @@
*/
function drawLineCharts( data, type ) {
var lastMetric = data[ data.length - 1 ];
var loaders = document.querySelectorAll( '.p--graphs--loading' );

for ( var i = 0; i < loaders.length; ++i ) {
loaders[ i ].classList.add( 'is-active' );
}

type = type || 'median';

Expand Down
2 changes: 1 addition & 1 deletion tasks/public/scripts/phantomas.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tasks/public/styles/phantomas.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tasks/tpl/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<% _.each( group[ key ], function( metric ) { %>
<% if ( results[ results.length - 1 ].metrics[ metric ] ) { %>
<li id="graph--<%= metric %>" class="p--graphs--graph <%= ( _.indexOf( failedAssertions, metric ) !== -1 ) ? 'failed' : '' %>">
<div class="p--graphs--loading is-active">
<div class="spinner"></div>
</div>
<h4><%= metric %></h4>
<button class="p--graphs--button__expand js-expand" type="button" data-metric="<%= metric %>">Table</button>
<% if ( results[ results.length - 1 ].offenders[ metric ] ) { %>
Expand Down

0 comments on commit 6b9ca50

Please sign in to comment.