Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
salemokey committed Oct 14, 2024
1 parent cef8984 commit 7fd87d9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/components/comments-form/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from 'react';
import './style.css';

const CommentsForm = ({ submitLabel, onSubmit, ...props }) => {
const [text, setText] = useState('');
Expand All @@ -7,13 +8,14 @@ const CommentsForm = ({ submitLabel, onSubmit, ...props }) => {
onSubmit({ text, parent: { _id: props.id, _type: props.type }, name: props.name });
};
return (
<form action="" onSubmit={onSubmitForm}>
<form className="Comments-form" action="" onSubmit={onSubmitForm}>
{props.type === 'comment' && <div className="Comments-form-title">Новый ответ</div>}
<textarea
className="comment-form-textarea"
className="Comments-form-textarea"
value={text}
onChange={e => setText(e.target.value)}
/>
<button className="comment-form-button">отправить</button>
<button className="Сommentы-form-button">отправить</button>
</form>
);
};
Expand Down
7 changes: 7 additions & 0 deletions src/components/comments-form/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.Comments-form {
width: 100%;
}
.Comments-form-textarea {
width: 100%;
height: 76px;
}
10 changes: 5 additions & 5 deletions src/components/comments-item/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const CommentsItem = props => {


return (
<div className={cn('')}>
<div className={cn('container')} style={indentStyle}>
<div className={cn('')} style={indentStyle}>
<div className={cn('container')} >
<div className={cn('author-date')}>
<span className="author">{props.comment.author?.profile?.name || 'Имя не указано'}</span>{' '}
<span className="date">{date}</span>
Expand All @@ -45,8 +45,8 @@ const CommentsItem = props => {
) : (
`Войдите чтобы ответить`
)}
</div>
{isReplying && <CommentsForm onSubmit={callbacks.onSubmit} id={props.id} type="comment" />}

{isReplying && <CommentsForm onSubmit={callbacks.onSubmit} id={props.id} type="comment" />}</div>
{props.replies.length > 0 && (
<div className={cn('replies-list')}>
{props.replies.map(reply => (
Expand All @@ -60,7 +60,7 @@ const CommentsItem = props => {
onSubmit={callbacks.onSubmit}
onReply={callbacks.onReply}
comment={reply}
replies={props.getReplies(reply._id)}
replies={[]}
/>
</div>
))}
Expand Down
1 change: 0 additions & 1 deletion src/containers/comments/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const Comments = props => {
onSubmit={props.onSubmit}
id={rootComment._id}
type="comment"
getReplies={getReplies}
/>
))}
</div>
Expand Down

0 comments on commit 7fd87d9

Please sign in to comment.