From 913f9a38268b46f6abe51810ed7eec4b56c0e9a7 Mon Sep 17 00:00:00 2001 From: Kochkina Ekaterina Date: Sat, 19 Apr 2025 10:12:16 +0200 Subject: [PATCH 01/16] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=D0=B0=20=D1=81=D1=82=D0=B8=D0=BB=D0=B8=20=D0=B8=20=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D0=B8=20=D1=81=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B2=D0=BE=D0=B4=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/button/style.css | 3 ++- src/global.css | 1 + src/i18n/translations/en.json | 7 ++++++- src/i18n/translations/ru.json | 7 ++++++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/button/style.css b/src/components/button/style.css index 0efc8a896..b0f2f607c 100644 --- a/src/components/button/style.css +++ b/src/components/button/style.css @@ -34,8 +34,9 @@ .Button_style_text { padding: 0; border: none; + color: var(--primary); &:hover { - color: var(--primary); + opacity: 0.6; } } diff --git a/src/global.css b/src/global.css index e81695d21..4e06a54ea 100644 --- a/src/global.css +++ b/src/global.css @@ -7,6 +7,7 @@ --primary-select: #6B4ACB1A; --main-text: #1A2028; --second-text: #FFFFFF; + --other-text: #666666; --overlay: #1A202866; --divider: #EFEFEF; --delete: #D43B3B; diff --git a/src/i18n/translations/en.json b/src/i18n/translations/en.json index 0ebbcf8f2..4690013b5 100644 --- a/src/i18n/translations/en.json +++ b/src/i18n/translations/en.json @@ -22,5 +22,10 @@ "auth.login-placeholder": "Enter login", "auth.password-placeholder": "Enter password", "session.signIn": "Sign In", - "session.signOut": "Sign Out" + "session.signOut": "Sign Out", + "comment.newReply": "New reply", + "comment.newComment": "New comment", + "comment.send": "Send", + "comment.cancel": "Cancel", + "comment.title": "Comments" } diff --git a/src/i18n/translations/ru.json b/src/i18n/translations/ru.json index a18fb845e..3ccd0118f 100644 --- a/src/i18n/translations/ru.json +++ b/src/i18n/translations/ru.json @@ -24,5 +24,10 @@ "auth.login-placeholder": "Введите логин", "auth.password-placeholder": "Введите пароль", "session.signIn": "Вход", - "session.signOut": "Выход" + "session.signOut": "Выход", + "comment.newReply": "Новый ответ", + "comment.newComment": "Новый комментарий", + "comment.send": "Отправить", + "comment.cancel": "Отмена", + "comment.title": "Комментарии" } From ca13722ee36b191dcbd356968f4962eca0eeaf81 Mon Sep 17 00:00:00 2001 From: Kochkina Ekaterina Date: Sat, 19 Apr 2025 11:34:56 +0200 Subject: [PATCH 02/16] =?UTF-8?q?=D0=97=D0=B0=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/article/index.js | 4 + src/components/article-card/style.css | 2 +- src/components/comment-action/index.js | 69 +++++++++++ src/components/comment-action/style.css | 42 +++++++ src/components/comment-item/index.js | 66 ++++++++++ src/components/comment-item/style.css | 37 ++++++ src/components/comments-layout/index.js | 17 +++ src/components/comments-layout/style.css | 12 ++ src/components/ladder-list/index.js | 27 ++++ src/components/ladder-list/style.css | 12 ++ src/components/list/index.js | 3 +- src/containers/article-comments/index.js | 143 ++++++++++++++++++++++ src/containers/article-comments/style.css | 38 ++++++ src/i18n/translations/en.json | 3 +- src/i18n/translations/ru.json | 3 +- src/store-redux/comments/actions.js | 58 +++++++++ src/store-redux/comments/reducer.js | 26 ++++ src/store-redux/exports.js | 1 + src/utils/format-pretty-date.js | 22 ++++ 19 files changed, 580 insertions(+), 5 deletions(-) create mode 100644 src/components/comment-action/index.js create mode 100644 src/components/comment-action/style.css create mode 100644 src/components/comment-item/index.js create mode 100644 src/components/comment-item/style.css create mode 100644 src/components/comments-layout/index.js create mode 100644 src/components/comments-layout/style.css create mode 100644 src/components/ladder-list/index.js create mode 100644 src/components/ladder-list/style.css create mode 100644 src/containers/article-comments/index.js create mode 100644 src/containers/article-comments/style.css create mode 100644 src/store-redux/comments/actions.js create mode 100644 src/store-redux/comments/reducer.js create mode 100644 src/utils/format-pretty-date.js diff --git a/src/app/article/index.js b/src/app/article/index.js index 54f037b64..d1560046c 100644 --- a/src/app/article/index.js +++ b/src/app/article/index.js @@ -13,7 +13,9 @@ import TopHead from '../../containers/top-head'; import { useDispatch, useSelector } from 'react-redux'; import shallowequal from 'shallowequal'; import articleActions from '../../store-redux/article/actions'; +import commentsActions from '../../store-redux/comments/actions'; import HeadLayout from '../../components/head-layout'; +import ArticleComments from '../../containers/article-comments'; function Article() { const store = useStore(); @@ -26,6 +28,7 @@ function Article() { useInit(() => { //store.actions.article.load(params.id); dispatch(articleActions.load(params.id)); + dispatch(commentsActions.load(params.id)); }, [params.id]); const select = useSelector( @@ -55,6 +58,7 @@ function Article() { + diff --git a/src/components/article-card/style.css b/src/components/article-card/style.css index c5ccceabd..51ef0eb74 100644 --- a/src/components/article-card/style.css +++ b/src/components/article-card/style.css @@ -2,7 +2,7 @@ display: flex; flex-direction: column; gap: 24px; - padding-block: 24px; + padding-top: 24px; } .ArticleCard-prop-wrapper { diff --git a/src/components/comment-action/index.js b/src/components/comment-action/index.js new file mode 100644 index 000000000..6c86c9502 --- /dev/null +++ b/src/components/comment-action/index.js @@ -0,0 +1,69 @@ +import { memo } from 'react'; +import PropTypes from 'prop-types'; +import { cn as bem } from '@bem-react/classname'; +import './style.css'; +import Button from '../button'; +import { Link } from 'react-router-dom'; + +function CommentAction(props) { + const { + t = text => text, + onAdd = () => { + }, + setValue = () => { + }, + cancel = () => { + }, + value = '', + isReply = false, + auth = false, + link = '/login', + backLink = '', + } = props; + const cn = bem('CommentAction'); + + const label = isReply ? t('comment.newReply') : t('comment.newComment'); + + const onChangeHandler = event => { + setValue(event.target.value); + }; + + if (!auth) { + return ( +
+ Войдите, чтобы иметь возможность комментировать +
+ ); + } + + + return ( +
+ +