Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] add edit and delete dropdown in comments #243

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
81 changes: 72 additions & 9 deletions client/src/components/Comments/CommentListItem.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,84 @@
import React, { Component } from 'react';
import { Col, Row } from 'reactstrap';
import {
Col,
Row,
ButtonDropdown,
DropdownToggle,
DropdownMenu,
DropdownItem,
} from 'reactstrap';
import moment from 'moment';
import avatar from '../../../src/avatar.jpg';

class CommentListItem extends Component {
constructor(props) {
super(props);

this.state = {
dropdownOpen: false,
};
}

toggle = () => {
this.setState({
dropdownOpen: !this.state.dropdownOpen,
});
};
render() {
const comment = this.props.comment;
return (
<li key={comment.id}>
<button
type="button"
className="close"
title="delete"
aria-hidden="true"
>
&times;
</button>
<div className="settings-btn">
<ButtonDropdown
isOpen={this.state.dropdownOpen}
toggle={this.toggle}
className="comment-options"
>
<DropdownToggle className="dots-btn">
<i className="fa fa-ellipsis-v" aria-hidden="true" />
</DropdownToggle>
<DropdownMenu right>
<DropdownItem>
<i className="fa fa-pencil fa-fw" /> Edit
</DropdownItem>
<DropdownItem divider />
<DropdownItem>
<i className="fa fa-trash-o fa-fw" /> Delete
</DropdownItem>
</DropdownMenu>
</ButtonDropdown>
</div>
{/* <div className="btn-group open">
<a
className="btn btn-primary dropdown-toggle"
data-toggle="dropdown"
href="#"
>
k </a>
<ul className="dropdown-menu">
<li>
<a href="#">
<i className="fa fa-pencil fa-fw" /> Edit
</a>
</li>
<li>
<a href="#">
<i className="fa fa-trash-o fa-fw" /> Delete
</a>
</li>
<li>
<a href="#">
<i className="fa fa-ban fa-fw" /> Ban
</a>
</li>
<li className="divider" />
<li>
<a href="#">
<i className="fa fa-unlock" /> Make admin
</a>
</li>
</ul>
</div> */}
<Row>
<Col sm="4" md="2" xs="4" lg="2">
<img
Expand Down
14 changes: 14 additions & 0 deletions client/src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,17 @@ body {
border-top: 1px solid #f5f5f5;
padding: 10px;
}
.settings-btn {
Copy link
Collaborator

@QaseemLodhi QaseemLodhi Jan 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@taleymirza can we create a separate css file related to comment section and move all these changes into this one.
This is because if we put all css in index.css then in future it will be messy.

float: right;
}
.comment-options .btn-group {
float: right;
}
.comment-options .dots-btn {
background: none;
color: #545b62;
border: none;
}
.comment-options .dropdown-menu {
min-width: 8rem;
}