Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Mention #96

Merged
merged 47 commits into from
Jul 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
74c226c
Emoji picker working in custom contentDiv
tahnik Jul 24, 2017
8f7f6ba
shit's broken
tahnik Jul 24, 2017
2bf3053
Merge branch 'master' into mention
tahnik Jul 25, 2017
3436e64
initial version of stacked textarea
tahnik Jul 25, 2017
d3a2ee8
fixed cursor movent in div
tahnik Jul 25, 2017
df2a7bb
Fixed caret positioning using arrow keys
Jul 25, 2017
ebfc865
: syntax bois
Jul 26, 2017
b1d16d5
Added @mention syntax
Jul 26, 2017
e3abaae
added padding to textarea
Jul 26, 2017
446ad63
Initial version of mention
tahnik Jul 26, 2017
9393aa0
fix for unstable div movement
tahnik Jul 26, 2017
80f54b6
forgot px
tahnik Jul 26, 2017
a05428b
Changed to bottom
tahnik Jul 26, 2017
fe7c77a
Testing mention
tahnik Jul 26, 2017
0c706b1
mention now is more stable
tahnik Jul 26, 2017
f286b64
Some inital styling
Jul 26, 2017
44055ca
added mention
tahnik Jul 27, 2017
3ae6f45
Added tags to rant cards
Jul 27, 2017
05e32e3
Fixed bug
Jul 27, 2017
489c673
Time since
Jul 27, 2017
cd9a26b
Time badge in comments
Jul 27, 2017
427e7e1
Mention fully working
tahnik Jul 27, 2017
88b37a8
Merge branch 'mention' of https://github.com/tahnik/devRantron into m…
tahnik Jul 27, 2017
2fbc270
Added padding to tags
Jul 27, 2017
b3c77a0
Added confirmation to logout
Jul 27, 2017
4887cc0
Fixed console error. @rekkyrek watch out
tahnik Jul 28, 2017
a25c065
Merge branch 'mention' of https://github.com/tahnik/devRantron into m…
tahnik Jul 28, 2017
5524d87
Recursive emoji search. Needs to be improved
tahnik Jul 29, 2017
e648221
optimized emoji search
tahnik Jul 29, 2017
0698b99
emoji parsing is working great! Next is searching the emojis in file
tahnik Jul 29, 2017
14c1436
Emoji picker is fully working 👏 Optmization incoming
tahnik Jul 29, 2017
78c76f3
moved some code to domfunctions as they are static and doesn't depend…
tahnik Jul 29, 2017
4b69785
Renamed contenteditable to smart area. Thanks @rekkyrek
tahnik Jul 29, 2017
4ac9e63
Added ability to close modal in compact item column
tahnik Jul 29, 2017
628e3e4
fixed scroll to bottom after posting
tahnik Jul 29, 2017
6c2b2eb
Should work now (update rantscript to 1.2.4)
hex2f Jul 29, 2017
6b9953d
upvote and downvote disabled for own rants #108
tahnik Jul 29, 2017
cfbb347
Merge branch 'mention' of https://github.com/tahnik/devRantron into m…
tahnik Jul 29, 2017
040a14c
added rantscript, fixed no images in comments #72
tahnik Jul 29, 2017
59f2c54
disabled button if the text is invalid
tahnik Jul 29, 2017
a32faae
fixed post_rant
tahnik Jul 30, 2017
9db2ea3
Added placeholder
tahnik Jul 30, 2017
a702161
fixed linting errors
tahnik Jul 30, 2017
c177a57
Emojipicker shadow
hex2f Jul 30, 2017
d24e33d
Merge branch 'mention' of https://github.com/tahnik/devRantron into m…
hex2f Jul 30, 2017
d245d73
added placeholder in tags
tahnik Jul 30, 2017
7e89db7
Increased version number
tahnik Jul 30, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/src/main/js/components/comments/comment_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,27 @@ import UserBadge from '../user/user_badge';
import BottomBar from '../utilities/bottom_bar';
import { ITEM } from '../../consts/types';

function timeSince(date) {
const seconds = Math.floor((new Date() - date) / 1000);
let interval = seconds / 2592000;
if (interval > 1) {
const nd = new Date(date);
return `${nd.getDate()}/${nd.getMonth()}/${nd.getYear().toString().substring(1)}`;
}
interval = seconds / 86400;
if (interval > 1) {
return `${Math.floor(interval)}d`;
}
interval = seconds / 3600;
if (interval > 1) {
return `${Math.floor(interval)}h`;
}
interval = seconds / 60;
if (interval > 1) {
return `${Math.floor(interval)}m`;
}
return `${Math.floor(seconds)}s`;
}

const CommentCard = (props) => {
const { item, theme, vote, auth, open } = props;
Expand All @@ -18,6 +39,7 @@ const CommentCard = (props) => {
if (auth.user) {
isUser = auth.user.authToken.user_id === item.user_id;
}
const image = item.attached_image;
return (
<div
className="comment_card"
Expand All @@ -30,7 +52,9 @@ const CommentCard = (props) => {
className="top_container"
>
<UserBadge user={user} theme={theme} open={open} />
<span className="timesince">{timeSince(item.created_time * 1000)}</span>
<Twemoji><p>{item.body}</p></Twemoji>
{ typeof image !== 'undefined' ? <img alt="" src={image.url} /> : null }
</div>
<BottomBar
score={item.score}
Expand Down
41 changes: 26 additions & 15 deletions app/src/main/js/components/comments/comment_post.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import rantscript from '../../consts/rantscript';
import SmartArea from '../utilities/smart_area';

class CommentPost extends Component {
constructor() {
super();
this.state = {
text: '',
disabled: false,
users: [],
content: '',
};
}
onPost() {
componentWillMount() {
const users = new Set();
const { comments } = this.props;
for (let i = 0; i < comments.length; i += 1) {
users.add(comments[i].user_username);
}
if (users.size !== 0) {
this.setState({ users: Array.from(users) });
}
}
onPost(text, image) {
const { auth, id, fetch } = this.props;
this.setState({ disabled: true });
rantscript
.postComment(this.state.text, id, auth.user.authToken)
.postComment(text, id, auth.user.authToken, image)
.then(() => {
this.setState({ text: '' });
this.setState({ content: '' });
this.setState({ disabled: false });
fetch();
const itemContainer = document.getElementsByClassName('item_compact_column')[0];
setTimeout(() => {
itemContainer.scrollTop = itemContainer.scrollHeight;
}, 200);
})
.catch(() => {
this.setState({ disabled: false });
Expand All @@ -35,24 +43,27 @@ class CommentPost extends Component {
className="post_comment"
style={{ width: `${theme.column.width - 17}px` }}
>
<textarea
value={this.state.text}
onChange={e => this.setState({ text: e.target.value })}
/>
<button
<SmartArea
id="post_comment_area"
users={this.state.users}
placeholder="Add a comment..."
onPost={(text, image) => this.onPost(text, image)}
disabled={this.state.disabled || auth.user === null}
onClick={() => this.onPost()}
>Add Comment</button>
value={this.state.content}
onChange={text => this.setState({ content: text })}
/>
</div>
);
}
}


CommentPost.propTypes = {
theme: PropTypes.object.isRequired,
auth: PropTypes.object.isRequired,
id: PropTypes.number.isRequired,
fetch: PropTypes.func.isRequired,
comments: PropTypes.array.isRequired,
};

export default CommentPost;
15 changes: 8 additions & 7 deletions app/src/main/js/components/emoji_picker/emoji_picker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import Twemoji from 'react-twemoji';
import emojiData from './emojis.json';
import emojiData from '../../consts/emojis.json';

const categoryImages = {
people: '😀',
Expand Down Expand Up @@ -34,16 +34,16 @@ class EmojiPicker extends Component {
}
});
}
pickEmoji(emojChar) {
pickEmoji(name) {
if (this.props.onPick === undefined) {
return false;
}
this.props.onPick(emojChar);
this.props.onPick(`:${name}:`);
return true;
}
render() {
return (
<div className="emoji_picker">
<div className="emoji_picker" style={this.props.style}>
<div className="emoji_top">
<div className="categories">
{emojiData.categories.map(object => (
Expand All @@ -62,10 +62,10 @@ class EmojiPicker extends Component {
{emojiData[this.state.activeTab].map(object => (
<Twemoji
className="emoji_wrapper"
key={object.character}
onClick={() => { this.pickEmoji(object.character); }}
key={object.icon}
onClick={() => { this.pickEmoji(object.name); }}
>
{object.character}
{object.icon}
</Twemoji>
))}
</div>
Expand All @@ -76,6 +76,7 @@ class EmojiPicker extends Component {

EmojiPicker.propTypes = {
onPick: PropTypes.func, //eslint-disable-line
style: PropTypes.object, //eslint-disable-line
};

export default EmojiPicker;
Loading