-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reaction: support reacting with an existing reaction
package.json: use github.com/arpith/zulip-js#new-reactions zulip-js branch yarn.lock: update yarn.lock constants: add ADD_REACTION actions: add support for adding reaction actions: new reactions api requires emoji_code message: pass message_id to reactions reactions: start using emoji_code reactions: 1. use emoji_code as internal keys (instead of emoji_name) 2. store emoji_code -> emoji_name mapping in a separate object 3. pass emoji_code to Reaction :) reaction: 1. change background color on hover 2. use emojiCode in increment call
- Loading branch information
Showing
8 changed files
with
436 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,32 @@ | ||
import React from 'react'; | ||
import React, { Component } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import { replaceColons } from '../emoji'; | ||
import style from '../styles/reaction'; | ||
import { addReaction } from '../actions'; | ||
import { style, hover } from '../styles/reaction'; | ||
|
||
export default ({ emojiName, onHover }) => { | ||
const reactionEmoji = replaceColons(`:${emojiName}:`); | ||
return <button style={style} onMouseEnter={onHover} onMouseLeave={onHover}> | ||
{reactionEmoji} | ||
</button>; | ||
class Reaction extends Component { | ||
state = { style }; | ||
|
||
onHover = (shouldHighlight) => { | ||
if (shouldHighlight) { | ||
this.setState({ style: hover }); | ||
} else { | ||
this.setState({ style }); | ||
} | ||
this.props.onHover(); | ||
}; | ||
|
||
render() { | ||
const reactionEmoji = replaceColons(`:${this.props.emojiName}:`); | ||
return <button style={this.state.style} | ||
onClick={this.props.increment} | ||
onMouseEnter={() => this.onHover(true)} | ||
onMouseLeave={() => this.onHover(false)}> | ||
{reactionEmoji} | ||
</button>; | ||
} | ||
} | ||
|
||
export default connect(null, (dispatch, { emojiName, messageID, emojiCode }) => ({ | ||
increment: () => dispatch(addReaction(messageID, emojiName, emojiCode)), | ||
}))(Reaction); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.