Dater; Basic grid responsive; Local formatting

This commit is contained in:
James Barnsley
2016-11-02 16:51:00 +13:00
parent 4fdbef2b4e
commit 1920e69e60
133 changed files with 18350 additions and 5599 deletions

View File

@ -7,15 +7,44 @@ export default class Dater extends React.Component{
super(props);
}
formatDuration( milliseconds = false ){
if( !milliseconds ) return null
var string, total_hours, total_minutes, total_seconds, minutes, seconds;
// get total values for each
total_seconds = Math.floor( milliseconds / 1000 )
total_minutes = Math.floor( milliseconds / (1000 * 60) )
total_hours = Math.floor(milliseconds / (1000 * 60 * 60))
// get left-over number of seconds
seconds = total_seconds - ( total_minutes * 60 )
if( seconds <= 9 ) seconds = '0'+ seconds
minutes = total_minutes - ( total_hours * 60 )
if( minutes <= 9 ) minutes = '0'+ minutes
if( total_hours ) string = total_hours+':'
string += minutes+':'+seconds;
return string
}
calculate(){
switch(this.props.type){
case 'total-time':
var duration = 0;
var tracks = this.props.data
for( var i = 0; i < tracks.length; i++ ){
if( tracks[i].duration_ms ) duration += parseInt(tracks[i].duration_ms);
if( tracks[i].length ) duration += parseInt(tracks[i].length);
}
return this.formatDuration(duration)
break
case 'length':
var time = new Date( this.props.data );
var min = time.getMinutes();
var sec = time.getSeconds();
if( sec < 10 ) sec = '0'+sec;
return min+':'+sec;
return this.formatDuration(this.props.data)
break
case 'date':

View File

@ -11,7 +11,7 @@ export default class Icon extends React.Component{
render(){
var className = 'icon';
if( this.props.className ) className += ' '+this.props.className;
var src = require('../../images/icons/'+this.props.name+'.svg');
var src = require('../../assets/icons/'+this.props.name+'.svg');
return <img className={className} src={src} />;
}
}

View File

@ -28,10 +28,10 @@ export default class Thumbnail extends React.Component{
if( images.length <= 0 ){
state = {
small: require('../../images/no-image.svg'),
medium: require('../../images/no-image.svg'),
large: require('../../images/no-image.svg'),
huge: require('../../images/no-image.svg')
small: require('../../assets/no-image.svg'),
medium: require('../../assets/no-image.svg'),
large: require('../../assets/no-image.svg'),
huge: require('../../assets/no-image.svg')
}
}else{
state = helpers.sizedImages( images );