From c95cce04393080a52a54191cff7be8fec68af4b0 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Sun, 15 May 2022 17:45:41 +0200 Subject: chore: add Article pages --- .../organisms/layout/comment.stories.tsx | 39 +++++++++++++++++----- src/components/organisms/layout/comment.test.tsx | 6 ++-- src/components/organisms/layout/comment.tsx | 14 ++++---- .../organisms/layout/comments-list.stories.tsx | 30 +++++++++++------ .../organisms/layout/comments-list.test.tsx | 6 +++- src/components/organisms/layout/comments-list.tsx | 10 +++--- 6 files changed, 71 insertions(+), 34 deletions(-) (limited to 'src/components/organisms/layout') diff --git a/src/components/organisms/layout/comment.stories.tsx b/src/components/organisms/layout/comment.stories.tsx index 3794b06..c31b77a 100644 --- a/src/components/organisms/layout/comment.stories.tsx +++ b/src/components/organisms/layout/comment.stories.tsx @@ -1,13 +1,19 @@ import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import CommentComponent from './comment'; +const saveComment = async () => { + /** Do nothing. */ +}; + /** * Comment - Storybook Meta */ export default { title: 'Organisms/Layout', component: CommentComponent, + args: { + saveComment, + }, argTypes: { author: { description: 'The author data.', @@ -51,6 +57,29 @@ export default { required: true, }, }, + Notice: { + control: { + type: null, + }, + description: 'A component to display a success or error message.', + table: { + category: 'Options', + }, + type: { + name: 'function', + required: false, + }, + }, + parentId: { + control: { + type: null, + }, + description: 'The parent id if it is a reply.', + type: { + name: 'number', + required: false, + }, + }, publication: { description: 'The publication date.', type: { @@ -73,13 +102,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - - - - ), - ], } as ComponentMeta; const Template: ComponentStory = (args) => ( @@ -100,7 +122,6 @@ Comment.args = { 'Harum aut cumque iure fugit neque sequi cupiditate repudiandae laudantium. Ratione aut assumenda qui illum voluptas accusamus quis officiis exercitationem. Consectetur est harum eius perspiciatis officiis nihil. Aut corporis minima debitis adipisci possimus debitis et.', id: 2, publication: '2021-04-03 23:04:24', - saveComment: () => null, // @ts-ignore - Needed because of the placeholder image. unoptimized: true, }; diff --git a/src/components/organisms/layout/comment.test.tsx b/src/components/organisms/layout/comment.test.tsx index 4961722..02a51dc 100644 --- a/src/components/organisms/layout/comment.test.tsx +++ b/src/components/organisms/layout/comment.test.tsx @@ -11,13 +11,15 @@ const content = 'Harum aut cumque iure fugit neque sequi cupiditate repudiandae laudantium. Ratione aut assumenda qui illum voluptas accusamus quis officiis exercitationem. Consectetur est harum eius perspiciatis officiis nihil. Aut corporis minima debitis adipisci possimus debitis et.'; const publication = '2021-04-03 23:04:24'; const id = 5; - +const saveComment = async () => { + /** Do nothing. */ +}; const data = { author, content, id, publication, - saveComment: () => null, + saveComment, }; const formattedDate = getFormattedDate(publication); diff --git a/src/components/organisms/layout/comment.tsx b/src/components/organisms/layout/comment.tsx index 248efc2..6df393b 100644 --- a/src/components/organisms/layout/comment.tsx +++ b/src/components/organisms/layout/comment.tsx @@ -25,7 +25,7 @@ export type CommentAuthor = { url?: string; }; -export type CommentProps = { +export type CommentProps = Pick & { /** * The comment author data. */ @@ -50,10 +50,6 @@ export type CommentProps = { * The comment date and time separated with a space. */ publication: string; - /** - * A callback function to save comment form data. - */ - saveComment: CommentFormProps['saveComment']; }; /** @@ -66,6 +62,7 @@ const Comment: FC = ({ canReply = true, content, id, + Notice, parentId, publication, saveComment, @@ -169,7 +166,10 @@ const Comment: FC = ({ className={styles.date} groupClassName={styles.date__item} /> -
{content}
+