Skip to content

Commit 05325e7

Browse files
committed
update design & refresh behavior
1 parent 0dde2eb commit 05325e7

10 files changed

Lines changed: 75 additions & 28 deletions

File tree

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"react": "~0.13.3",
55
"fontawesome": "~4.3.0",
66
"react-router": "~0.13.3",
7-
"reflux": "~0.2.8"
7+
"reflux": "~0.2.8",
8+
"moment": "~2.10.3"
89
}
910
}

browser/main/Containers/PlanetContainer.jsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
var React = require('react/addons')
22
var ReactRouter = require('react-router')
3+
var moment = require('moment')
4+
var ForceUpdate = require('../Mixins/ForceUpdate')
35
var ModalBase = require('../Components/ModalBase')
46
var LaunchModal = require('../Components/LaunchModal')
57
var CodeViewer = require('../Components/CodeViewer')
@@ -109,7 +111,7 @@ var PlanetNavigator = React.createClass({
109111
})
110112

111113
var PlanetArticleList = React.createClass({
112-
mixins: [ReactRouter.Navigation, ReactRouter.State],
114+
mixins: [ReactRouter.Navigation, ReactRouter.State, ForceUpdate(60000)],
113115
propTypes: {
114116
planet: React.PropTypes.shape({
115117
Snippets: React.PropTypes.array,
@@ -118,11 +120,13 @@ var PlanetArticleList = React.createClass({
118120
},
119121
render: function () {
120122
var articles = this.props.planet.Snippets.map(function (snippet) {
121-
var tags = snippet.Tags.map(function (tag) {
123+
var tags = snippet.Tags.length > 0 ? snippet.Tags.map(function (tag) {
122124
return (
123125
<a key={tag.id} href>#{tag.name}</a>
124126
)
125-
})
127+
}) : (
128+
<a className='noTag'>Not tagged yet</a>
129+
)
126130
var params = this.getParams()
127131

128132
var isActive = parseInt(params.localId, 10) === snippet.localId
@@ -138,9 +142,11 @@ var PlanetArticleList = React.createClass({
138142
return (
139143
<li onClick={handleClick} key={snippet.id}>
140144
<div className={isActive ? 'snippetItem active' : 'snippetItem'}>
141-
<div className='callSign'><i className='fa fa-code'></i> {snippet.callSign}</div>
142-
<div className='description'>{snippet.description}</div>
143-
<div className='updatedAt'>{snippet.updatedAt}</div>
145+
<div className='itemHeader'>
146+
<div className='callSign'><i className='fa fa-code'></i> {snippet.callSign}</div>
147+
<div className='updatedAt'>{moment(snippet.updatedAt).fromNow()}</div>
148+
</div>
149+
<div className='description'>{snippet.description.length > 50 ? snippet.description.substring(0, 50) + ' …' : snippet.description}</div>
144150
<div className='tags'><i className='fa fa-tags'/>{tags}</div>
145151
</div>
146152
<div className='divider'></div>
@@ -159,6 +165,7 @@ var PlanetArticleList = React.createClass({
159165
})
160166

161167
var PlanetArticleDetail = React.createClass({
168+
mixins: [ForceUpdate(60000)],
162169
propTypes: {
163170
snippet: React.PropTypes.object
164171
},
@@ -188,16 +195,18 @@ var PlanetArticleDetail = React.createClass({
188195
render: function () {
189196
var snippet = this.props.snippet
190197

191-
var tags = snippet.Tags.map(function (tag) {
198+
var tags = snippet.Tags.length > 0 ? snippet.Tags.map(function (tag) {
192199
return (
193200
<a key={tag.id} href>#{tag.name}</a>
194201
)
195-
})
202+
}) : (
203+
<a className='noTag'>Not tagged yet</a>
204+
)
196205

197206
return (
198207
<div className='PlanetArticleDetail'>
199208
<div className='viewer-header'>
200-
<i className='fa fa-code'></i> {snippet.callSign} <small className='updatedAt'>{snippet.updatedAt}</small>
209+
<i className='fa fa-code'></i> {snippet.callSign} <small className='updatedAt'>{moment(snippet.updatedAt).fromNow()}</small>
201210
<span className='control-group'>
202211
<button onClick={this.openEditModal} className='btn-default btn-square btn-sm'><i className='fa fa-edit fa-fw'></i></button>
203212
<button onClick={this.openDeleteModal} className='btn-default btn-square btn-sm'><i className='fa fa-trash fa-fw'></i></button>

browser/main/Mixins/ForceUpdate.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var ForceUpdate = function (interval) {
2+
return {
3+
componentDidMount: function () {
4+
this.refreshTimer = setInterval(function () {
5+
this.forceUpdate()
6+
}.bind(this), interval)
7+
},
8+
componentWillUnmount: function () {
9+
clearInterval(this.refreshTimer)
10+
}
11+
}
12+
}
13+
14+
module.exports = ForceUpdate

browser/main/Stores/PlanetStore.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ var PlanetStore = Reflux.createStore({
3636
}.bind(this))
3737
},
3838
createSnippet: function (planetName, input) {
39+
input.description = input.description.substring(0, 255)
3940
request
4041
.post('http://localhost:8000/' + planetName + '/snippets')
4142
.set({
@@ -51,6 +52,7 @@ var PlanetStore = Reflux.createStore({
5152
}.bind(this))
5253
},
5354
updateSnippet: function (id, input) {
55+
input.description = input.description.substring(0, 255)
5456
request
5557
.put('http://localhost:8000/snippets/id/' + id)
5658
.set({

browser/main/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
});
4040
}
4141
</script>
42-
42+
<script src="../vendor/moment/min/moment.min.js"></script>
4343
<script src="../vendor/react/react-with-addons.js"></script>
4444
<script src="../vendor/react-router/build/umd/ReactRouter.js"></script>
4545
<script src="../vendor/reflux/dist/reflux.js"></script>

browser/styles/main/containers/PlanetContainer.styl

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@
33
absolute top bottom right
44
left 50px
55
.tags
6+
white-space: nowrap;
7+
overflow-x: auto;
68
a
79
margin 0 2px
10+
&.noTag
11+
color inactiveTextColor
12+
font-size 0.8em
813

914
.PlanetHeader
1015
absolute left right top
@@ -134,15 +139,20 @@
134139
padding 10px
135140
cursor pointer
136141
transition 0.1s
137-
.callSign
142+
.itemHeader
143+
clearfix()
138144
margin-bottom 5px
145+
.callSign
146+
float left
139147
font-weight 600
140-
.description
141-
margin-bottom 5px
148+
font-size 1.1em
142149
.updatedAt
143-
margin-bottom 5px
150+
float right
151+
line-height 16px
144152
color lighten(textColor, 25%)
145153
font-size 0.8em
154+
.description
155+
margin 10px 0 15px
146156
&:hover, &.hover
147157
background-color hoverBackgroundColor
148158
&:active, &.active
@@ -160,24 +170,35 @@
160170
height 44px
161171
line-height 44px
162172
padding 0 15px
163-
border-bottom solid 1px borderColor
164173
box-sizing border-box
174+
font-size 1.2em
165175
small
166-
font-size 0.5em
176+
font-size 0.8em
177+
color lighten(textColor, 25%)
167178
.control-group
168179
float right
169180
button
170-
margin 0 2px
181+
margin 10px 3px
171182
.viewer-body
172183
absolute bottom right
173184
left 1px
174185
top 44px
175186
.viewer-detail
176187
border-bottom solid 1px borderColor
188+
height 150px
189+
box-sizing border-box
177190
padding 10px
178191
.description
179-
margin-bottom 15px
192+
height 100px
193+
line-height 1.4em
194+
overflow-y auto
195+
.tags
196+
position absolute
197+
left 15px
198+
right 15px
199+
top 120px
180200
.content
181-
padding 5px 0
182201
.ace_editor
183-
height 500px
202+
absolute left right
203+
top 155px
204+
bottom 5px

browser/styles/main/index.styl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ global-reset()
99
body
1010
font-family "Lato"
1111
color textColor
12+
font-size fontSize
1213

1314
h1
1415
font-size 2em

browser/styles/shared/modal.styl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
border-bottom-right-radius 10px
5151
textarea.snippetDescription
5252
height 75px
53+
font-size 0.9em
5354
.Select
5455
.Select-control
5556
border-color borderColor

browser/styles/vars.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ lightButtonColor = #898989
99

1010
hoverBackgroundColor= transparentify(#444, 3%)
1111

12-
1312
// v0.2.0
1413
inactiveTextColor = #888
1514
textColor = #4D4D4D
1615
backgroundColor= white
16+
fontSize= 16px
1717

1818
btnColor = #888
1919
btnHighlightenColor = #000

webpack.config.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@ module.exports = {
33
main: './browser/main/index.jsx'
44
},
55
output: {
6-
filename: '[name].js', //this is the default name, so you can skip it
6+
filename: '[name].js',
77
publicPath: 'http://localhost:8090/assets'
88
},
9-
devtool: "#inline-source-map", // Sourcemap
9+
devtool: '#inline-source-map',
1010
module: {
1111
loaders: [
1212
{
13-
//tell webpack to use jsx-loader for all *.jsx files
1413
test: /\.jsx$/,
1514
loader: 'jsx-loader?insertPragma=React.DOM&harmony'
1615
},
@@ -25,13 +24,12 @@ module.exports = {
2524
]
2625
},
2726
externals: {
28-
//don't bundle the 'react' npm package with our bundle.js
29-
//but get it from a global 'React' variable
3027
'react': 'React',
3128
'react/addons': 'React',
3229
'react-router': 'ReactRouter',
3330
'ace': 'ace',
34-
'reflux': 'Reflux'
31+
'reflux': 'Reflux',
32+
'moment': 'moment'
3533
},
3634
resolve: {
3735
extensions: ['', '.js', '.jsx']

0 commit comments

Comments
 (0)