From 94a8e31f25ed3d92f9eb808e3264bd4ac8c039c7 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Thu, 21 Apr 2022 18:12:29 +0200 Subject: chore: add a PostsList component --- .../organisms/layout/posts-list.stories.tsx | 181 +++++++++++++++++++++ 1 file changed, 181 insertions(+) create mode 100644 src/components/organisms/layout/posts-list.stories.tsx (limited to 'src/components/organisms/layout/posts-list.stories.tsx') diff --git a/src/components/organisms/layout/posts-list.stories.tsx b/src/components/organisms/layout/posts-list.stories.tsx new file mode 100644 index 0000000..783d333 --- /dev/null +++ b/src/components/organisms/layout/posts-list.stories.tsx @@ -0,0 +1,181 @@ +import { ComponentMeta, ComponentStory } from '@storybook/react'; +import { IntlProvider } from 'react-intl'; +import PostsList, { type Post } from './posts-list'; + +/** + * PostsList - Storybook Meta + */ +export default { + title: 'Organisms/Layout/PostsList', + component: PostsList, + args: { + byYear: false, + }, + argTypes: { + byYear: { + control: { + type: 'boolean', + }, + description: 'True to display the posts by year.', + table: { + category: 'Options', + defaultValue: { summary: false }, + }, + type: { + name: 'boolean', + required: false, + }, + }, + posts: { + description: 'The posts data.', + type: { + name: 'object', + required: true, + value: {}, + }, + }, + titleLevel: { + control: { + type: 'number', + min: 1, + max: 6, + }, + description: 'The title level (hn).', + table: { + category: 'Options', + defaultValue: { summary: 2 }, + }, + type: { + name: 'number', + required: false, + }, + }, + }, + decorators: [ + (Story) => ( + + + + ), + ], +} as ComponentMeta; + +const Template: ComponentStory = (args) => ( + +); + +const posts: Post[] = [ + { + excerpt: + 'Esse et voluptas sapiente modi impedit unde et. Ducimus nulla ea impedit sit placeat nihil assumenda. Rem est fugiat amet quo hic. Corrupti fuga quod animi autem dolorem ullam corrupti vel aut.', + id: 'post-1', + meta: { + publication: { + name: 'Published on:', + value: '2022-02-26T00:42:02', + }, + readingTime: { name: 'Reading time:', value: '5 minutes' }, + categories: { + name: 'Categories:', + value: [ + + Cat 1 + , + + Cat 2 + , + ], + }, + comments: { name: 'Comments:', value: '1 comment' }, + }, + title: 'Ratione velit fuga', + url: '#', + cover: { + alt: 'cover', + height: 480, + src: 'http://placeimg.com/640/480', + width: 640, + // @ts-ignore - Needed because of the placeholder image. + unoptimized: true, + }, + }, + { + excerpt: + 'Illum quae asperiores quod aut necessitatibus itaque excepturi voluptas. Incidunt exercitationem ullam saepe alias consequatur sed. Quam veniam quaerat voluptatum earum quia quisquam fugiat sed perspiciatis. Et velit saepe est recusandae facilis eos eum ipsum.', + id: 'post-2', + meta: { + publication: { + name: 'Published on:', + value: '2022-02-20T10:40:00', + }, + readingTime: { name: 'Reading time:', value: '8 minutes' }, + categories: { + name: 'Categories:', + value: [ + + Cat 2 + , + ], + }, + comments: { name: 'Comments:', value: '0 comments' }, + }, + title: 'Debitis laudantium laudantium', + url: '#', + }, + { + excerpt: + 'Sunt aperiam ut rem impedit dolor id sit. Reprehenderit ipsum iusto fugiat. Quaerat laboriosam magnam facilis. Totam sint aliquam voluptatem in quis laborum sunt eum. Enim aut debitis officiis porro iure quia nihil voluptas ipsum. Praesentium quis necessitatibus cumque quia qui velit quos dolorem.', + id: 'post-3', + meta: { + publication: { + name: 'Published on:', + value: '2021-12-20T15:12:02', + }, + readingTime: { name: 'Reading time:', value: '3 minutes' }, + categories: { + name: 'Categories:', + value: [ + + Cat 1 + , + ], + }, + comments: { name: 'Comments:', value: '3 comments' }, + }, + title: 'Quaerat ut corporis', + url: '#', + cover: { + alt: 'cover', + height: 480, + src: 'http://placeimg.com/640/480', + width: 640, + // @ts-ignore - Needed because of the placeholder image. + unoptimized: true, + }, + }, +]; + +/** + * PostsList Stories - Default + */ +export const Default = Template.bind({}); +Default.args = { + posts, +}; + +/** + * PostsList Stories - By years + */ +export const ByYears = Template.bind({}); +ByYears.args = { + posts, + byYear: true, +}; + +/** + * PostsList Stories - No results + */ +export const NoResults = Template.bind({}); +NoResults.args = { + posts: [], +}; -- cgit v1.2.3