Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Increment an existing reaction
Browse files Browse the repository at this point in the history
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 element-hq/element-web#9486
  • Loading branch information
jryans committed May 2, 2019
1 parent 15c5893 commit 87f737b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
6 changes: 6 additions & 0 deletions res/css/views/messages/_ReactionsRowButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ limitations under the License.
border: 1px solid $reaction-row-button-border-color;
border-radius: 10px;
background-color: $reaction-row-button-bg-color;
cursor: pointer;

&:hover {
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;
}
}
2 changes: 2 additions & 0 deletions res/themes/dark/css/_dark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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-border-color: #616b7f;
$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! *****

Expand Down
2 changes: 2 additions & 0 deletions res/themes/light/css/_light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ $message-action-bar-hover-border-color: #b8c1d2;
$reaction-row-button-bg-color: $header-panel-bg-color;
$reaction-row-button-border-color: #e9edf1;
$reaction-row-button-hover-border-color: #bebebe;
$reaction-row-button-selected-bg-color: #e9fff9;
$reaction-row-button-selected-border-color: $accent-color;

// ***** Mixins! *****

Expand Down
36 changes: 34 additions & 2 deletions src/components/views/messages/ReactionsRowButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,50 @@ limitations under the License.

import React from 'react';
import PropTypes from 'prop-types';
import classNames from 'classnames';

export default class ReactionsRowButton extends React.PureComponent {
static propTypes = {
content: PropTypes.string.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() {
const { content, count } = this.props;
const { selected } = this.state;

const classes = classNames({
mx_ReactionsRowButton: true,
mx_ReactionsRowButton_selected: selected,
});

let adjustedCount = count;
if (selected) {
adjustedCount++;
}

return <span className="mx_ReactionsRowButton">
{content} {count}
return <span className={classes}
onClick={this.onClick}
>
{content} {adjustedCount}
</span>;
}
}

0 comments on commit 87f737b

Please sign in to comment.