Increment an existing reaction

This allows you to increment an existing reaction below a message by clicking on
it.

At the moment, this is not linked to the action bar, so they each are using
local state. We'll likely want to add some mechanism so that we can local echo
to both of these UI areas at the same time, but that can be done separately.

Fixes https://github.com/vector-im/riot-web/issues/9486
This commit is contained in:
J. Ryan Stinnett 2019-05-02 11:48:32 +01:00
parent 15c5893278
commit 87f737b8a3
4 changed files with 44 additions and 2 deletions

View file

@ -23,8 +23,14 @@ limitations under the License.
border: 1px solid $reaction-row-button-border-color; border: 1px solid $reaction-row-button-border-color;
border-radius: 10px; border-radius: 10px;
background-color: $reaction-row-button-bg-color; background-color: $reaction-row-button-bg-color;
cursor: pointer;
&:hover { &:hover {
border-color: $reaction-row-button-hover-border-color; border-color: $reaction-row-button-hover-border-color;
} }
&.mx_ReactionsRowButton_selected {
background-color: $reaction-row-button-selected-bg-color;
border-color: $reaction-row-button-selected-border-color;
}
} }

View file

@ -154,6 +154,8 @@ $message-action-bar-hover-border-color: $header-panel-text-primary-color;
$reaction-row-button-bg-color: $header-panel-bg-color; $reaction-row-button-bg-color: $header-panel-bg-color;
$reaction-row-button-border-color: #616b7f; $reaction-row-button-border-color: #616b7f;
$reaction-row-button-hover-border-color: $header-panel-text-primary-color; $reaction-row-button-hover-border-color: $header-panel-text-primary-color;
$reaction-row-button-selected-bg-color: #1f6954;
$reaction-row-button-selected-border-color: $accent-color;
// ***** Mixins! ***** // ***** Mixins! *****

View file

@ -262,6 +262,8 @@ $message-action-bar-hover-border-color: #b8c1d2;
$reaction-row-button-bg-color: $header-panel-bg-color; $reaction-row-button-bg-color: $header-panel-bg-color;
$reaction-row-button-border-color: #e9edf1; $reaction-row-button-border-color: #e9edf1;
$reaction-row-button-hover-border-color: #bebebe; $reaction-row-button-hover-border-color: #bebebe;
$reaction-row-button-selected-bg-color: #e9fff9;
$reaction-row-button-selected-border-color: $accent-color;
// ***** Mixins! ***** // ***** Mixins! *****

View file

@ -16,6 +16,7 @@ limitations under the License.
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import classNames from 'classnames';
export default class ReactionsRowButton extends React.PureComponent { export default class ReactionsRowButton extends React.PureComponent {
static propTypes = { static propTypes = {
@ -23,11 +24,42 @@ export default class ReactionsRowButton extends React.PureComponent {
count: PropTypes.number.isRequired, count: PropTypes.number.isRequired,
} }
constructor(props) {
super(props);
// TODO: This should be derived from actual reactions you may have sent
// once we have some API to read them.
this.state = {
selected: false,
};
}
onClick = (ev) => {
const state = this.state.selected;
this.setState({
selected: !state,
});
// TODO: Send the reaction event
};
render() { render() {
const { content, count } = this.props; const { content, count } = this.props;
const { selected } = this.state;
return <span className="mx_ReactionsRowButton"> const classes = classNames({
{content} {count} mx_ReactionsRowButton: true,
mx_ReactionsRowButton_selected: selected,
});
let adjustedCount = count;
if (selected) {
adjustedCount++;
}
return <span className={classes}
onClick={this.onClick}
>
{content} {adjustedCount}
</span>; </span>;
} }
} }