Skip to content

Commit

Permalink
More styling for statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron committed Aug 24, 2016
1 parent bc0692d commit a541e93
Show file tree
Hide file tree
Showing 11 changed files with 135 additions and 379 deletions.
17 changes: 17 additions & 0 deletions app/assets/javascripts/components/components/avatar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const Avatar = React.createClass({

propTypes: {
src: React.PropTypes.string.isRequired
},

render () {
return (
<div style={{ width: '48px', height: '48px', flex: '0 0 auto' }}>
<img src={this.props.src} width={48} height={48} alt='' style={{ display: 'block', borderRadius: '4px' }} />
</div>
);
}

});

export default Avatar;
22 changes: 22 additions & 0 deletions app/assets/javascripts/components/components/display_name.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import ImmutablePropTypes from 'react-immutable-proptypes';

const DisplayName = React.createClass({
propTypes: {
account: ImmutablePropTypes.map.isRequired
},

render () {
var displayName = this.props.account.get('display_name', this.props.account.get('username'));
var acct = this.props.account.get('acct');
var url = this.props.account.get('url');

return (
<a href={url} style={{ color: '#616b86', textDecoration: 'none' }}>
<strong style={{ fontWeight: 'bold', color: '#fff' }}>{displayName}</strong> <span>{acct}</span>
</a>
);
}

});

export default DisplayName;
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import moment from 'moment';

moment.updateLocale('en', {
relativeTime : {
future: "in %s",
past: "%s ago",
s: "s",
m: "a minute",
mm: "%dm",
h: "an hour",
hh: "%dh",
d: "a day",
dd: "%dd",
M: "a month",
MM: "%dm",
y: "a year",
yy: "%dy"
}
});

const RelativeTimestamp = React.createClass({
getInitialState () {
return {
text: ''
};
},

propTypes: {
timestamp: React.PropTypes.string.isRequired
},

componentWillMount () {
this._updateMomentText();
this.interval = setInterval(this._updateMomentText, 6000);
},

componentWillUnmount () {
clearInterval(this.interval);
},

_updateMomentText () {
this.setState({ text: moment(this.props.timestamp).fromNow() });
},

render () {
return (
<span style={{ color: '#616b86' }}>
{this.state.text}
</span>
);
}

});

export default RelativeTimestamp;
23 changes: 19 additions & 4 deletions app/assets/javascripts/components/components/status.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
import ImmutablePropTypes from 'react-immutable-proptypes';
import Avatar from './avatar';
import DisplayName from './display_name';
import RelativeTimestamp from './relative_timestamp';

const Status = React.createClass({
propTypes: {
status: ImmutablePropTypes.map.isRequired
},

render: function() {
render () {
var content = { __html: this.props.status.get('content') };
var status = this.props.status;

return (
<div style={{ padding: '5px' }}>
<div><strong>{this.props.status.getIn(['account', 'username'])}</strong></div>
<div dangerouslySetInnerHTML={content} />
<div style={{ padding: '8px 10px', display: 'flex', flexDirection: 'row', borderBottom: '1px solid #363c4b' }}>
<Avatar src={status.getIn(['account', 'avatar'])} />

<div style={{ flex: '1 1 auto', marginLeft: '10px' }}>
<div style={{ overflow: 'hidden' }}>
<div style={{ float: 'right' }}>
<a href={status.get('url')} style={{ textDecoration: 'none' }}><RelativeTimestamp timestamp={status.get('created_at')} /></a>
</div>

<DisplayName account={status.get('account')} />
</div>

<div className='status__content' dangerouslySetInnerHTML={content} style={{ fontSize: '14px' }} />
</div>
</div>
);
}
Expand Down
3 changes: 1 addition & 2 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ body {
}
}

@import 'home';
@import 'accounts';
@import 'stream_entries';
@import 'dashboard'
@import 'components'
20 changes: 20 additions & 0 deletions app/assets/stylesheets/components.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.status__content {
a {
color: #2b90d9;
text-decoration: none;

&:hover {
text-decoration: underline;
}

&.mention {
&:hover {
text-decoration: none;

span {
text-decoration: underline;
}
}
}
}
}
Loading

0 comments on commit a541e93

Please sign in to comment.