diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-05-22 15:09:39 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-05-22 15:09:39 +0200 |
| commit | 321dae4a47594af83269fa560b375965d7f35763 (patch) | |
| tree | 28392e486bb8c99c231e767d1532935c5ebc1b94 /src | |
| parent | 70bd37fe14d4e0c1538291fa97b0522ab6d20941 (diff) | |
fix: render all images unoptimized in Storybook
There is a bug with next/image and Storybook. I was manually adding
`unoptimized` to images. Instead we can use a workaround by adding an
extra config in Storybook `preview.js` file.
Diffstat (limited to 'src')
17 files changed, 62 insertions, 74 deletions
diff --git a/src/components/molecules/images/flipping-logo.stories.tsx b/src/components/molecules/images/flipping-logo.stories.tsx index 40a4c49..9d09293 100644 --- a/src/components/molecules/images/flipping-logo.stories.tsx +++ b/src/components/molecules/images/flipping-logo.stories.tsx @@ -54,7 +54,6 @@ export default { required: true, }, }, - unoptimized: { table: { disable: true } }, }, } as ComponentMeta<typeof FlippingLogoComponent>; @@ -70,6 +69,4 @@ FlippingLogo.args = { altText: 'Website picture', logoTitle: 'Website logo', photo: 'http://placeimg.com/640/480', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }; diff --git a/src/components/molecules/images/responsive-image.stories.tsx b/src/components/molecules/images/responsive-image.stories.tsx index ca69d4f..4917cde 100644 --- a/src/components/molecules/images/responsive-image.stories.tsx +++ b/src/components/molecules/images/responsive-image.stories.tsx @@ -80,7 +80,6 @@ export default { required: false, }, }, - unoptimized: { table: { disable: true } }, width: { control: { type: 'number', @@ -121,7 +120,18 @@ Default.args = { src: 'http://placeimg.com/640/480/transport', width: 640, height: 480, - unoptimized: true, +}; + +/** + * Responsive Image Stories - With borders + */ +export const WithBorders = Template.bind({}); +WithBorders.args = { + alt: 'An example', + src: 'http://placeimg.com/640/480/transport', + width: 640, + height: 480, + withBorders: true, }; /** @@ -133,11 +143,23 @@ WithLink.args = { src: 'http://placeimg.com/640/480/transport', width: 640, height: 480, - unoptimized: true, target: '#', }; /** + * Responsive Image Stories - With link and borders + */ +export const WithLinkAndBorders = Template.bind({}); +WithLinkAndBorders.args = { + alt: 'An example', + src: 'http://placeimg.com/640/480/transport', + width: 640, + height: 480, + target: '#', + withBorders: true, +}; + +/** * Responsive Image Stories - With caption */ export const WithCaption = Template.bind({}); @@ -147,7 +169,19 @@ WithCaption.args = { width: 640, height: 480, caption: 'Omnis nulla labore', - unoptimized: true, +}; + +/** + * Responsive Image Stories - With caption and borders + */ +export const WithCaptionAndBorders = Template.bind({}); +WithCaptionAndBorders.args = { + alt: 'An example', + src: 'http://placeimg.com/640/480/transport', + width: 640, + height: 480, + caption: 'Omnis nulla labore', + withBorders: true, }; /** @@ -161,5 +195,18 @@ WithCaptionAndLink.args = { height: 480, caption: 'Omnis nulla labore', target: '#', - unoptimized: true, +}; + +/** + * Responsive Image Stories - With caption, link and borders + */ +export const WithCaptionLinkAndBorders = Template.bind({}); +WithCaptionLinkAndBorders.args = { + alt: 'An example', + src: 'http://placeimg.com/640/480/transport', + width: 640, + height: 480, + caption: 'Omnis nulla labore', + target: '#', + withBorders: true, }; diff --git a/src/components/molecules/layout/branding.stories.tsx b/src/components/molecules/layout/branding.stories.tsx index d2e0694..94bb166 100644 --- a/src/components/molecules/layout/branding.stories.tsx +++ b/src/components/molecules/layout/branding.stories.tsx @@ -56,7 +56,6 @@ export default { required: true, }, }, - unoptimized: { table: { disable: true } }, withLink: { control: { type: 'boolean', @@ -85,8 +84,6 @@ export const Default = Template.bind({}); Default.args = { title: 'Website title', photo: 'http://placeimg.com/640/480', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }; /** @@ -97,6 +94,4 @@ WithBaseline.args = { title: 'Website title', baseline: 'Maiores corporis qui', photo: 'http://placeimg.com/640/480', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }; diff --git a/src/components/molecules/layout/card.stories.tsx b/src/components/molecules/layout/card.stories.tsx index 2e99bbb..0ad42c0 100644 --- a/src/components/molecules/layout/card.stories.tsx +++ b/src/components/molecules/layout/card.stories.tsx @@ -113,7 +113,6 @@ const cover = { height: 480, src: 'http://placeimg.com/640/480', width: 640, - unoptimized: true, }; const meta = { diff --git a/src/components/organisms/images/gallery.stories.tsx b/src/components/organisms/images/gallery.stories.tsx index 786cfff..6fc278f 100644 --- a/src/components/organisms/images/gallery.stories.tsx +++ b/src/components/organisms/images/gallery.stories.tsx @@ -43,10 +43,10 @@ const image = { const Template: ComponentStory<typeof Gallery> = (args) => ( <Gallery {...args}> - <ResponsiveImage unoptimized {...image} /> - <ResponsiveImage unoptimized {...image} /> - <ResponsiveImage unoptimized {...image} /> - <ResponsiveImage unoptimized {...image} /> + <ResponsiveImage {...image} /> + <ResponsiveImage {...image} /> + <ResponsiveImage {...image} /> + <ResponsiveImage {...image} /> </Gallery> ); diff --git a/src/components/organisms/layout/cards-list.stories.tsx b/src/components/organisms/layout/cards-list.stories.tsx index 522d068..c19220a 100644 --- a/src/components/organisms/layout/cards-list.stories.tsx +++ b/src/components/organisms/layout/cards-list.stories.tsx @@ -90,8 +90,6 @@ const items: CardsListItem[] = [ src: 'http://placeimg.com/640/480', width: 640, height: 480, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, meta: { thematics: ['Velit', 'Ex', 'Alias'] }, tagline: 'Molestias ut error', @@ -105,8 +103,6 @@ const items: CardsListItem[] = [ src: 'http://placeimg.com/640/480', width: 640, height: 480, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, meta: { thematics: ['Voluptas'] }, tagline: 'Quod vel accusamus', @@ -120,8 +116,6 @@ const items: CardsListItem[] = [ src: 'http://placeimg.com/640/480', width: 640, height: 480, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, meta: { thematics: ['Quisquam', 'Quia', 'Sapiente', 'Perspiciatis'], diff --git a/src/components/organisms/layout/cards-list.test.tsx b/src/components/organisms/layout/cards-list.test.tsx index 7d98844..8558fa6 100644 --- a/src/components/organisms/layout/cards-list.test.tsx +++ b/src/components/organisms/layout/cards-list.test.tsx @@ -9,8 +9,6 @@ const items: CardsListItem[] = [ src: 'http://placeimg.com/640/480', width: 640, height: 480, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, meta: { thematics: ['Velit', 'Ex', 'Alias'] }, tagline: 'Molestias ut error', @@ -24,8 +22,6 @@ const items: CardsListItem[] = [ src: 'http://placeimg.com/640/480', width: 640, height: 480, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, meta: { thematics: ['Voluptas'] }, tagline: 'Quod vel accusamus', @@ -39,8 +35,6 @@ const items: CardsListItem[] = [ src: 'http://placeimg.com/640/480', width: 640, height: 480, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, meta: { thematics: ['Quisquam', 'Quia', 'Sapiente', 'Perspiciatis'], diff --git a/src/components/organisms/layout/comment.stories.tsx b/src/components/organisms/layout/comment.stories.tsx index c7649ab..fa4bba9 100644 --- a/src/components/organisms/layout/comment.stories.tsx +++ b/src/components/organisms/layout/comment.stories.tsx @@ -123,6 +123,4 @@ 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', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }; diff --git a/src/components/organisms/layout/comments-list.stories.tsx b/src/components/organisms/layout/comments-list.stories.tsx index 1ed159a..22cc9d9 100644 --- a/src/components/organisms/layout/comments-list.stories.tsx +++ b/src/components/organisms/layout/comments-list.stories.tsx @@ -81,8 +81,6 @@ const comments: Comment[] = [ 'Voluptas ducimus inventore. Libero ut et doloribus. Earum nostrum ab. Aliquam rem dolores omnis voluptate. Sunt aut ut et.', id: 1, publication: '2021-04-03 18:04:11', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, { child: [ @@ -95,8 +93,6 @@ const comments: Comment[] = [ 'Vel ullam in porro tempore. Maiores quos quia magnam beatae nemo libero velit numquam. Sapiente aliquid cumque. Velit neque in adipisci aut assumenda voluptates earum. Autem esse autem provident in tempore. Aut distinctio dolor qui repellat et et adipisci velit aspernatur.', id: 4, publication: '2021-04-03 23:04:24', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, { author: { @@ -107,8 +103,6 @@ const comments: Comment[] = [ 'Sed non omnis. Quam porro est. Quae tempore quae. Exercitationem eos non velit voluptatem velit voluptas iusto. Sit debitis qui ipsam quo asperiores numquam veniam praesentium ut.', id: 5, publication: '2021-04-04 08:05:14', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, ], author: { @@ -120,8 +114,6 @@ const comments: Comment[] = [ 'Sit sed error quasi voluptatem velit voluptas aut. Aut debitis eveniet. Praesentium dolores quia voluptate vero quis dicta quasi vel. Aut voluptas accusantium ut aut quidem consectetur itaque laboriosam occaecati.', id: 2, publication: '2021-04-03 23:30:20', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, { author: { @@ -132,8 +124,6 @@ const comments: Comment[] = [ 'Natus consequatur maiores aperiam dolore eius nesciunt ut qui et. Ab ea nobis est. Eaque dolor corrupti id aut. Impedit architecto autem qui neque rerum ab dicta dignissimos voluptates.', id: 3, publication: '2021-09-13 13:24:54', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, ]; diff --git a/src/components/organisms/layout/header.stories.tsx b/src/components/organisms/layout/header.stories.tsx index a5233ea..0507e89 100644 --- a/src/components/organisms/layout/header.stories.tsx +++ b/src/components/organisms/layout/header.stories.tsx @@ -112,7 +112,6 @@ export default { required: true, }, }, - unoptimized: { table: { disable: true } }, withLink: { control: { type: 'boolean', @@ -151,6 +150,4 @@ Header.args = { nav, photo: 'http://placeimg.com/640/480/people', title: 'Website title', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }; diff --git a/src/components/organisms/layout/overview.stories.tsx b/src/components/organisms/layout/overview.stories.tsx index 1139350..26f7ba0 100644 --- a/src/components/organisms/layout/overview.stories.tsx +++ b/src/components/organisms/layout/overview.stories.tsx @@ -52,7 +52,6 @@ const cover = { height: 480, src: 'http://placeimg.com/640/480/cats', width: 640, - unoptimized: true, }; const meta: OverviewMeta = { diff --git a/src/components/organisms/layout/posts-list.stories.tsx b/src/components/organisms/layout/posts-list.stories.tsx index 96fb2f0..360d441 100644 --- a/src/components/organisms/layout/posts-list.stories.tsx +++ b/src/components/organisms/layout/posts-list.stories.tsx @@ -181,8 +181,6 @@ const posts: Post[] = [ height: 480, src: 'http://placeimg.com/640/480', width: 640, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, }, { @@ -213,8 +211,6 @@ const posts: Post[] = [ height: 480, src: 'http://placeimg.com/640/480', width: 640, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, }, ]; diff --git a/src/components/organisms/layout/posts-list.test.tsx b/src/components/organisms/layout/posts-list.test.tsx index 7429cbd..dfb9825 100644 --- a/src/components/organisms/layout/posts-list.test.tsx +++ b/src/components/organisms/layout/posts-list.test.tsx @@ -28,8 +28,6 @@ const posts: Post[] = [ height: 480, src: 'http://placeimg.com/640/480', width: 640, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, }, { @@ -60,8 +58,6 @@ const posts: Post[] = [ height: 480, src: 'http://placeimg.com/640/480', width: 640, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, }, ]; diff --git a/src/components/organisms/layout/summary.stories.tsx b/src/components/organisms/layout/summary.stories.tsx index 92736b8..2512051 100644 --- a/src/components/organisms/layout/summary.stories.tsx +++ b/src/components/organisms/layout/summary.stories.tsx @@ -88,7 +88,6 @@ const cover = { height: 480, src: 'http://placeimg.com/640/480', width: 640, - unoptimized: true, }; const excerpt = diff --git a/src/components/organisms/widgets/image-widget.stories.tsx b/src/components/organisms/widgets/image-widget.stories.tsx index fa39745..2271c03 100644 --- a/src/components/organisms/widgets/image-widget.stories.tsx +++ b/src/components/organisms/widgets/image-widget.stories.tsx @@ -130,7 +130,6 @@ const image = { height: 480, src: 'http://placeimg.com/640/480/nature', width: 640, - unoptimized: true, }; /** diff --git a/src/components/templates/page/page-layout.stories.tsx b/src/components/templates/page/page-layout.stories.tsx index 12fe26a..bc1d7b6 100644 --- a/src/components/templates/page/page-layout.stories.tsx +++ b/src/components/templates/page/page-layout.stories.tsx @@ -179,8 +179,12 @@ export default { }, }, decorators: [ - (Story) => ( - <LayoutBase {...LayoutBase.args}> + (Story, context) => ( + <LayoutBase + useGrid={true} + withExtraPadding={!context.args.allowComments && !context.args.comments} + {...LayoutBase.args} + > <Story /> </LayoutBase> ), @@ -273,8 +277,6 @@ const comments = [ 'Voluptas ducimus inventore. Libero ut et doloribus. Earum nostrum ab. Aliquam rem dolores omnis voluptate. Sunt aut ut et.', id: 1, publication: '2021-04-03 18:04:11', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, { child: [ @@ -287,8 +289,6 @@ const comments = [ 'Vel ullam in porro tempore. Maiores quos quia magnam beatae nemo libero velit numquam. Sapiente aliquid cumque. Velit neque in adipisci aut assumenda voluptates earum. Autem esse autem provident in tempore. Aut distinctio dolor qui repellat et et adipisci velit aspernatur.', id: 4, publication: '2021-04-03 23:04:24', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, { author: { @@ -299,8 +299,6 @@ const comments = [ 'Sed non omnis. Quam porro est. Quae tempore quae. Exercitationem eos non velit voluptatem velit voluptas iusto. Sit debitis qui ipsam quo asperiores numquam veniam praesentium ut.', id: 5, publication: '2021-04-04 08:05:14', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, ], author: { @@ -312,8 +310,6 @@ const comments = [ 'Sit sed error quasi voluptatem velit voluptas aut. Aut debitis eveniet. Praesentium dolores quia voluptate vero quis dicta quasi vel. Aut voluptas accusantium ut aut quidem consectetur itaque laboriosam occaecati.', id: 2, publication: '2021-04-03 23:30:20', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, { author: { @@ -324,8 +320,6 @@ const comments = [ 'Natus consequatur maiores aperiam dolore eius nesciunt ut qui et. Ab ea nobis est. Eaque dolor corrupti id aut. Impedit architecto autem qui neque rerum ab dicta dignissimos voluptates.', id: 3, publication: '2021-09-13 13:24:54', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, ]; @@ -435,8 +429,6 @@ const posts = [ height: 480, src: 'http://placeimg.com/640/480', width: 640, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, }, { @@ -467,8 +459,6 @@ const posts = [ height: 480, src: 'http://placeimg.com/640/480', width: 640, - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, }, ]; diff --git a/src/components/templates/page/page-layout.test.tsx b/src/components/templates/page/page-layout.test.tsx index a414e14..a0c8923 100644 --- a/src/components/templates/page/page-layout.test.tsx +++ b/src/components/templates/page/page-layout.test.tsx @@ -98,8 +98,6 @@ describe('PageLayout', () => { 'Voluptas ducimus inventore. Libero ut et doloribus. Earum nostrum ab. Aliquam rem dolores omnis voluptate. Sunt aut ut et.', id: 1, publication: '2021-04-03 18:04:11', - // @ts-ignore - Needed because of the placeholder image. - unoptimized: true, }, ]; render( |
