Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a star icon for unsaved file name, added 'Saved: xx time ago' (#…
…177) * added a star icon for unsaved file name, added saved time ago * changed text * added timer component * clean extra styling in _editor.sass * customize momentjs fromnow function * clear 10s interval in componentWillUnmount * use space-between instead of float
- Loading branch information
1 parent
33582a1
commit e86e9a0
Showing
11 changed files
with
113 additions
and
14 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
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,46 @@ | ||
import React, { PropTypes } from 'react'; | ||
import moment from 'moment'; | ||
|
||
class Timer extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
this.showSavedTime = this.showSavedTime.bind(this); | ||
} | ||
|
||
componentDidMount() { | ||
this.interval = setInterval(() => this.forceUpdate(), 10000); | ||
} | ||
|
||
componentWillUnmount() { | ||
if (this.interval) { | ||
clearInterval(this.interval); | ||
} | ||
} | ||
|
||
showSavedTime() { | ||
if (Math.abs(moment().diff(this.props.projectSavedTime)) < 10000) { | ||
return 'Saved: just now'; | ||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 20000) { | ||
return 'Saved: 15 seconds ago'; | ||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 30000) { | ||
return 'Saved: 25 seconds ago'; | ||
} else if (Math.abs(moment().diff(this.props.projectSavedTime)) < 46000) { | ||
return 'Saved: 35 seconds ago'; | ||
} | ||
return `Saved: ${moment(this.props.projectSavedTime).fromNow()}`; | ||
} | ||
|
||
render() { | ||
return ( | ||
<span className="timer__saved-time"> | ||
{this.props.projectSavedTime !== '' ? this.showSavedTime() : null} | ||
</span> | ||
); | ||
} | ||
} | ||
|
||
Timer.propTypes = { | ||
projectSavedTime: PropTypes.string.isRequired | ||
}; | ||
|
||
export default Timer; |
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
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,7 @@ | ||
.timer__saved-time { | ||
@include themify() { | ||
color: getThemifyVariable('inactive-text-color'); | ||
} | ||
font-size: #{12 / $base-font-size}rem; | ||
padding-right: #{30 / $base-font-size}rem; | ||
} |
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