From 0d59a6d2995b4119865271ed1908ede0bb96497c Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 9 May 2022 18:19:38 +0200 Subject: refactor: rewrite DescriptionList and Meta components The meta can have different layout. The previous implementation was not enough to easily change the layout. Also, I prefer to restrict the meta types and it prevents me to repeat myself for the labels. --- .../templates/page/page-layout.stories.tsx | 107 ++++++++------------- src/components/templates/page/page-layout.tsx | 14 ++- 2 files changed, 50 insertions(+), 71 deletions(-) (limited to 'src/components/templates/page') diff --git a/src/components/templates/page/page-layout.stories.tsx b/src/components/templates/page/page-layout.stories.tsx index 1f72cb0..b4b0d68 100644 --- a/src/components/templates/page/page-layout.stories.tsx +++ b/src/components/templates/page/page-layout.stories.tsx @@ -6,7 +6,6 @@ import PostsList from '@components/organisms/layout/posts-list'; import LinksListWidget from '@components/organisms/widgets/links-list-widget'; import Sharing from '@components/organisms/widgets/sharing'; import { ComponentMeta, ComponentStory } from '@storybook/react'; -import { IntlProvider } from 'react-intl'; import PageLayoutComponent from './page-layout'; /** @@ -157,15 +156,6 @@ export default { }, }, }, - decorators: [ - (Story) => ( - -
- -
-
- ), - ], parameters: { layout: 'fullscreen', }, @@ -231,7 +221,6 @@ SinglePage.args = { 'linkedin', 'twitter', ]} - title="Share" level={2} expanded={true} />, @@ -320,22 +309,19 @@ Post.args = { title: pageTitle, intro: pageIntro, headerMeta: { - publication: { name: 'Published on:', value: 'March 14th 2020' }, - categories: { - name: 'Categories:', - value: [ - - Cat 1 - , - - Cat 2 - , - ], - }, + publication: { date: '2020-03-14' }, + thematics: [ + + Cat 1 + , + + Cat 2 + , + ], }, footerMeta: { - tags: { - name: 'Read more about:', + custom: { + label: 'Read more about:', value: Topic 1, }, }, @@ -379,7 +365,6 @@ Post.args = { 'linkedin', 'twitter', ]} - title="Share" level={2} expanded={true} />, @@ -400,23 +385,17 @@ const posts = [ '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' }, + publication: { date: '2022-02-26' }, + readingTime: '5 minutes', + categories: [ + + Cat 1 + , + + Cat 2 + , + ], + commentsCount: '1 comment', }, title: 'Ratione velit fuga', url: '#', @@ -435,19 +414,15 @@ const posts = [ id: 'post-2', meta: { publication: { - name: 'Published on:', - value: '2022-02-20T10:40:00', + date: '2022-02-20', }, - readingTime: { name: 'Reading time:', value: '8 minutes' }, - categories: { - name: 'Categories:', - value: [ - - Cat 2 - , - ], - }, - comments: { name: 'Comments:', value: '0 comments' }, + readingTime: '8 minutes', + categories: [ + + Cat 2 + , + ], + comments: '0 comments', }, title: 'Debitis laudantium laudantium', url: '#', @@ -458,19 +433,15 @@ const posts = [ 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 - , - ], + date: '2021-12-20', }, - comments: { name: 'Comments:', value: '3 comments' }, + readingTime: '3 minutes', + categories: [ + + Cat 1 + , + ], + comments: '3 comments', }, title: 'Quaerat ut corporis', url: '#', @@ -502,7 +473,7 @@ export const Blog = Template.bind({}); Blog.args = { breadcrumb: postsListBreadcrumb, title: 'Blog', - headerMeta: { total: { name: 'Total:', value: `${posts.length} posts` } }, + headerMeta: { total: `${posts.length} posts` }, children: ( <> diff --git a/src/components/templates/page/page-layout.tsx b/src/components/templates/page/page-layout.tsx index 24c4e50..ac021ba 100644 --- a/src/components/templates/page/page-layout.tsx +++ b/src/components/templates/page/page-layout.tsx @@ -133,9 +133,17 @@ const PageLayout: FC = ({ )} )} -
- {children} -
+ {typeof children === 'string' ? ( +
+ ) : ( +
+ {children} +
+ )} {widgets} -- cgit v1.2.3