From 15f51dbf8c19d1072d873c3b92b5a638035728a1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 25 Sep 2016 14:20:29 +0200 Subject: [PATCH] Better styling for selected status in detailed view --- .../components/components/status.jsx | 2 +- .../features/status/components/action_bar.jsx | 30 +++++++++++ .../status/components/detailed_status.jsx | 52 +++++++++++++++++++ .../components/features/status/index.jsx | 23 ++++---- app/assets/stylesheets/components.scss | 27 ++++++++-- app/models/user.rb | 3 +- 6 files changed, 122 insertions(+), 15 deletions(-) create mode 100644 app/assets/javascripts/components/features/status/components/action_bar.jsx create mode 100644 app/assets/javascripts/components/features/status/components/detailed_status.jsx diff --git a/app/assets/javascripts/components/components/status.jsx b/app/assets/javascripts/components/components/status.jsx index 9f9e877e6..a1ab60ae1 100644 --- a/app/assets/javascripts/components/components/status.jsx +++ b/app/assets/javascripts/components/components/status.jsx @@ -80,7 +80,7 @@ const Status = React.createClass({
- +
diff --git a/app/assets/javascripts/components/features/status/components/action_bar.jsx b/app/assets/javascripts/components/features/status/components/action_bar.jsx new file mode 100644 index 000000000..51332dc95 --- /dev/null +++ b/app/assets/javascripts/components/features/status/components/action_bar.jsx @@ -0,0 +1,30 @@ +import PureRenderMixin from 'react-addons-pure-render-mixin'; +import IconButton from '../../../components/icon_button'; +import ImmutablePropTypes from 'react-immutable-proptypes'; + +const ActionBar = React.createClass({ + + propTypes: { + status: ImmutablePropTypes.map.isRequired, + onReply: React.PropTypes.func.isRequired, + onReblog: React.PropTypes.func.isRequired, + onFavourite: React.PropTypes.func.isRequired + }, + + mixins: [PureRenderMixin], + + render () { + const { status } = this.props; + + return ( +
+
+
+
+
+ ); + } + +}); + +export default ActionBar; diff --git a/app/assets/javascripts/components/features/status/components/detailed_status.jsx b/app/assets/javascripts/components/features/status/components/detailed_status.jsx new file mode 100644 index 000000000..fbc9cb69b --- /dev/null +++ b/app/assets/javascripts/components/features/status/components/detailed_status.jsx @@ -0,0 +1,52 @@ +import PureRenderMixin from 'react-addons-pure-render-mixin'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import Avatar from '../../../components/avatar'; +import DisplayName from '../../../components/display_name'; +import StatusContent from '../../../components/status_content'; +import MediaGallery from '../../../components/media_gallery'; +import VideoPlayer from '../../../components/video_player'; +import moment from 'moment'; + +const DetailedStatus = React.createClass({ + + contextTypes: { + router: React.PropTypes.object + }, + + propTypes: { + status: ImmutablePropTypes.map.isRequired + }, + + mixins: [PureRenderMixin], + + handleAccountClick (e) { + if (e.button === 0) { + e.preventDefault(); + this.context.router.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`); + } + + e.stopPropagation(); + }, + + render () { + const status = this.props.status.get('reblog') ? this.props.status.get('reblog') : this.props.status; + + return ( +
+ +
+ +
+ + + +
+ {moment(status.get('created_at')).format('HH:mm, DD MMM Y')} · {status.get('reblogs_count')} · {status.get('favourites_count')} +
+
+ ); + } + +}); + +export default DetailedStatus; diff --git a/app/assets/javascripts/components/features/status/index.jsx b/app/assets/javascripts/components/features/status/index.jsx index 7a810d474..167864a1c 100644 --- a/app/assets/javascripts/components/features/status/index.jsx +++ b/app/assets/javascripts/components/features/status/index.jsx @@ -1,12 +1,14 @@ -import { connect } from 'react-redux'; -import PureRenderMixin from 'react-addons-pure-render-mixin'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import { fetchStatus } from '../../actions/statuses'; -import Immutable from 'immutable'; -import EmbeddedStatus from '../../components/status'; -import { favourite, reblog } from '../../actions/interactions'; -import { replyCompose } from '../../actions/compose'; -import { selectStatus } from '../../reducers/timelines'; +import { connect } from 'react-redux'; +import PureRenderMixin from 'react-addons-pure-render-mixin'; +import ImmutablePropTypes from 'react-immutable-proptypes'; +import { fetchStatus } from '../../actions/statuses'; +import Immutable from 'immutable'; +import EmbeddedStatus from '../../components/status'; +import DetailedStatus from './components/detailed_status'; +import ActionBar from './components/action_bar'; +import { favourite, reblog } from '../../actions/interactions'; +import { replyCompose } from '../../actions/compose'; +import { selectStatus } from '../../reducers/timelines'; function selectStatuses(state, ids) { return ids.map(id => selectStatus(state, id)).filterNot(status => status === null); @@ -69,7 +71,8 @@ const Status = React.createClass({
{this.renderChildren(ancestors)}
- + +
{this.renderChildren(descendants)}
diff --git a/app/assets/stylesheets/components.scss b/app/assets/stylesheets/components.scss index 409ba31f8..cf3dc8397 100644 --- a/app/assets/stylesheets/components.scss +++ b/app/assets/stylesheets/components.scss @@ -82,6 +82,13 @@ } } +.detailed-status { + .status__content { + font-size: 19px; + line-height: 24px; + } +} + .reply-indicator__content { color: #282c37; font-size: 14px; @@ -91,7 +98,7 @@ } } -.status__display-name, .status__relative-time { +.status__display-name, .status__relative-time, .detailed-status__display-name, .detailed-status__datetime { text-decoration: none; } @@ -101,7 +108,7 @@ } } -.status__display-name, .reply-indicator__display-name { +.status__display-name, .reply-indicator__display-name, .detailed-status__display-name { &:hover { strong { text-decoration: underline; @@ -109,7 +116,21 @@ } } -.status__relative-time { +.detailed-status__display-name { + color: #d9e1e8; + line-height: 24px; + + strong, span { + display: block; + } + + strong { + font-size: 16px; + color: #fff; + } +} + +.status__relative-time, .detailed-status__datetime { &:hover { text-decoration: underline; } diff --git a/app/models/user.rb b/app/models/user.rb index 066e376f4..d4361ffa1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -10,7 +10,8 @@ class User < ApplicationRecord scope :prolific, -> { joins('inner join statuses on statuses.account_id = users.account_id').select('users.*, count(statuses.id) as statuses_count').group('users.id').order('statuses_count desc') } scope :recent, -> { order('created_at desc') } - + scope :admins, -> { where(admin: true) } + def admin? self.admin end