From ad9e9646d46f8df0115253752a096c2271c1f7b2 Mon Sep 17 00:00:00 2001 From: Sareh Heidari Date: Thu, 20 Dec 2018 14:08:29 +0000 Subject: [PATCH 01/25] Add AmpImg, update Image to include srcset prop --- .../psammead-brand/src/svgs/news.jsx | 0 .../psammead-brand/src/svgs/persian.jsx | 0 .../components/psammead-image/CHANGELOG.md | 11 +- packages/components/psammead-image/README.md | 52 ++++++- .../psammead-image/package-lock.json | 8 +- .../components/psammead-image/package.json | 3 +- .../src/__snapshots__/index.amp.test.jsx.snap | 51 +++++++ .../src/__snapshots__/index.test.jsx.snap | 143 +++++++++++++++++- .../psammead-image/src/index.amp.jsx | 35 +++++ .../psammead-image/src/index.amp.stories.jsx | 8 + .../psammead-image/src/index.amp.test.jsx | 10 ++ .../components/psammead-image/src/index.jsx | 32 +++- .../psammead-image/src/index.stories.jsx | 19 +-- .../psammead-image/src/index.test.jsx | 26 +--- .../src/testHelpers/fixtureData.js | 36 +++++ .../src/testHelpers/snapshotTests.jsx | 58 +++++++ .../src/testHelpers/stories.jsx | 52 +++++++ 17 files changed, 489 insertions(+), 55 deletions(-) create mode 100644 packages/components/psammead-brand/src/svgs/news.jsx create mode 100644 packages/components/psammead-brand/src/svgs/persian.jsx create mode 100644 packages/components/psammead-image/src/__snapshots__/index.amp.test.jsx.snap create mode 100644 packages/components/psammead-image/src/index.amp.jsx create mode 100644 packages/components/psammead-image/src/index.amp.stories.jsx create mode 100644 packages/components/psammead-image/src/index.amp.test.jsx create mode 100644 packages/components/psammead-image/src/testHelpers/fixtureData.js create mode 100644 packages/components/psammead-image/src/testHelpers/snapshotTests.jsx create mode 100644 packages/components/psammead-image/src/testHelpers/stories.jsx diff --git a/packages/components/psammead-brand/src/svgs/news.jsx b/packages/components/psammead-brand/src/svgs/news.jsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/components/psammead-brand/src/svgs/persian.jsx b/packages/components/psammead-brand/src/svgs/persian.jsx new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/components/psammead-image/CHANGELOG.md b/packages/components/psammead-image/CHANGELOG.md index 8ba2c34b05..dee47fb293 100644 --- a/packages/components/psammead-image/CHANGELOG.md +++ b/packages/components/psammead-image/CHANGELOG.md @@ -1,7 +1,8 @@ # Psammead Image Changelog -| Version | Description | -|---------|-------------| -| 0.2.0 | [PR#234](https://github.com/BBC-News/psammead/pull/234) Change height prop to be optional. Update the storybook example. | -| 0.1.1 | [PR#230](https://github.com/BBC-News/psammead/pull/230) Add README to Storybook | -| 0.1.0 | [PR#225](https://github.com/BBC-News/psammead/pull/225) Create initial package, pulled in from [Simorgh](https://github.com/BBC-News/simorgh). | +| Version | Description | +| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| 0.3.0 | [PR#](https://github.com/BBC-News/psammead/pull/) Add AmpImg component. Update Image to have optional srcset prop. | +| 0.2.0 | [PR#234](https://github.com/BBC-News/psammead/pull/234) Change height prop to be optional. Update the storybook example. | +| 0.1.1 | [PR#230](https://github.com/BBC-News/psammead/pull/230) Add README to Storybook | +| 0.1.0 | [PR#225](https://github.com/BBC-News/psammead/pull/225) Create initial package, pulled in from [Simorgh](https://github.com/BBC-News/simorgh). | diff --git a/packages/components/psammead-image/README.md b/packages/components/psammead-image/README.md index 3b48008bc1..8e8545d431 100644 --- a/packages/components/psammead-image/README.md +++ b/packages/components/psammead-image/README.md @@ -1,26 +1,68 @@ # psammead-image · [![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/BBC-News/psammead/blob/latest/LICENSE) [![npm version](https://img.shields.io/npm/v/@bbc/psammead-image.svg)](https://www.npmjs.com/package/@bbc/psammead-image) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/BBC-News/psammead/blob/latest/CONTRIBUTING.md) ## Description -The `psammead-image` component is a styled `img` element. + +The `psammead-image` component has two images available. The default is a styled `img` element that uses Styled Components. + +There is an alternative AMP Image which can be used. It is a React component returning an `amp-img` element. ## Usage +### Img + +Importing the standard Image component, which renders an `` tag. + ```jsx -import Image from '@bbc/psammead-image'; +import Image from '../components/Image'; -const Wrapper = (src, alt, width, height) => ( - {alt} +const WrappingContainer = ({ alt, src, height, width }) => ( + {alt} ); ``` | Prop | Type | Required | -|:---------|:--------------|:---------| +| :------- | :------------ | :------- | | `alt` | string | Yes | | `height` | number/string | No | | `src` | string | Yes | +| `srcset` | string | No | | `width` | number/string | Yes | The `height` prop is optional, since in some cases to preserve the image ratio we only want to specify the width and let the browser scale the image accordingly. However, in other cases the height might need to be specified. +The `srcset` prop is optional since some projects might not want to use the srcset attribute on images. + +### AmpImg + +If you're to use the `AmpImg` component, [please read the AMP documentation here](https://www.ampproject.org/docs/reference/components/amp-img) for further details. + +Importing an Amp Image component, which renders an `` tag. + +```jsx +import { AmpImg } from '../components/Image'; + +const WrappingContainer = ({ alt, src, height, width }) => ( + +); +``` + +| Prop | Type | Required | +| :------------ | :------------ | :------- | +| `alt` | string | Yes | +| `attribution` | string | Yes | +| `height` | number/string | Yes | +| `layout` | string | Yes | +| `src` | string | Yes | +| `srcset` | string | No | +| `width` | number/string | Yes | + +The `attribution` prop is available to pass in strings to include the image source. +The `layout` prop can be one of several, including `responsive`, `fixed`, `intrinsic` etc. We recommend using `responsive` for most use-cases, with `height` and `width` props passed in, so the AMP can use the correct ratio for scaling the image. [For further details, please refer to the AMP docs](https://www.ampproject.org/docs/reference/components/amp-img). ## Accessibility notes diff --git a/packages/components/psammead-image/package-lock.json b/packages/components/psammead-image/package-lock.json index df24da83a9..aad0612b4f 100644 --- a/packages/components/psammead-image/package-lock.json +++ b/packages/components/psammead-image/package-lock.json @@ -1,6 +1,6 @@ { "name": "@bbc/psammead-image", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -30,6 +30,12 @@ "to-fast-properties": "^2.0.0" } }, + "@bbc/psammead-assets": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@bbc/psammead-assets/-/psammead-assets-0.1.3.tgz", + "integrity": "sha512-qrXcpzV/RhzII0HVNgh3WSYYKRoUfXupmKYqy450j6YV0h5/f2bKxpvmWnM+CR4BAaZNqoq3mjBAxRp2iLwK7A==", + "dev": true + }, "@bbc/psammead-test-helpers": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@bbc/psammead-test-helpers/-/psammead-test-helpers-0.1.0.tgz", diff --git a/packages/components/psammead-image/package.json b/packages/components/psammead-image/package.json index 92a60ec75a..98af9b8c99 100644 --- a/packages/components/psammead-image/package.json +++ b/packages/components/psammead-image/package.json @@ -1,6 +1,6 @@ { "name": "@bbc/psammead-image", - "version": "0.2.0", + "version": "0.3.0", "main": "dist/index.js", "description": "React styled components for an Image", "repository": { @@ -21,6 +21,7 @@ "styled-components": "^4.1.2" }, "devDependencies": { + "@bbc/psammead-assets": "^0.1.3", "@bbc/psammead-test-helpers": "^0.1.0", "react": "^16.6.3" }, diff --git a/packages/components/psammead-image/src/__snapshots__/index.amp.test.jsx.snap b/packages/components/psammead-image/src/__snapshots__/index.amp.test.jsx.snap new file mode 100644 index 0000000000..b97bf984a9 --- /dev/null +++ b/packages/components/psammead-image/src/__snapshots__/index.amp.test.jsx.snap @@ -0,0 +1,51 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Image - AmpImg should render image with custom dimensions correctly 1`] = ` + +`; + +exports[`Image - AmpImg should render image with srcset correctly 1`] = ` + +`; + +exports[`Image - AmpImg should render landscape image correctly 1`] = ` + +`; + +exports[`Image - AmpImg should render portrait image correctly 1`] = ` + +`; + +exports[`Image - AmpImg should render square image correctly 1`] = ` + +`; diff --git a/packages/components/psammead-image/src/__snapshots__/index.test.jsx.snap b/packages/components/psammead-image/src/__snapshots__/index.test.jsx.snap index 1409652561..aa327cf3c0 100644 --- a/packages/components/psammead-image/src/__snapshots__/index.test.jsx.snap +++ b/packages/components/psammead-image/src/__snapshots__/index.test.jsx.snap @@ -1,6 +1,128 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Image should render correctly 1`] = ` +exports[`Image - imported as '{ Img }' should render image with custom dimensions correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +By Elisa Decker, from her series \\ +`; + +exports[`Image - imported as '{ Img }' should render image with srcset correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +Student sitting an exam +`; + +exports[`Image - imported as '{ Img }' should render landscape image correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +Student sitting an exam +`; + +exports[`Image - imported as '{ Img }' should render portrait image correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17. +`; + +exports[`Image - imported as '{ Img }' should render square image correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +Tracks through the snow +`; + +exports[`Image - imported as default 'Image' should render image with custom dimensions correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +By Elisa Decker, from her series \\ +`; + +exports[`Image - imported as default 'Image' should render image with srcset correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +Student sitting an exam +`; + +exports[`Image - imported as default 'Image' should render landscape image correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +Student sitting an exam +`; + +exports[`Image - imported as default 'Image' should render portrait image correctly 1`] = ` .c0 { display: block; width: 100%; @@ -9,8 +131,23 @@ exports[`Image should render correctly 1`] = ` Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17. +`; + +exports[`Image - imported as default 'Image' should render square image correctly 1`] = ` +.c0 { + display: block; + width: 100%; +} + +Tracks through the snow `; diff --git a/packages/components/psammead-image/src/index.amp.jsx b/packages/components/psammead-image/src/index.amp.jsx new file mode 100644 index 0000000000..30322d2537 --- /dev/null +++ b/packages/components/psammead-image/src/index.amp.jsx @@ -0,0 +1,35 @@ +import React from 'react'; +import { number, string } from 'prop-types'; + +const AmpImg = ({ alt, attribution, layout, src, srcset, height, width }) => { + const props = { + alt, + attribution, + layout, + src, + height, + width, + }; + + if (srcset) { + props.srcSet = srcset; + } + + return ; +}; + +AmpImg.propTypes = { + alt: string.isRequired, + attribution: string.isRequired, + layout: string.isRequired, + src: string.isRequired, + srcset: string, + height: number.isRequired, + width: number.isRequired, +}; + +AmpImg.defaultProps = { + srcset: null, +}; + +export default AmpImg; diff --git a/packages/components/psammead-image/src/index.amp.stories.jsx b/packages/components/psammead-image/src/index.amp.stories.jsx new file mode 100644 index 0000000000..8c6fd842d2 --- /dev/null +++ b/packages/components/psammead-image/src/index.amp.stories.jsx @@ -0,0 +1,8 @@ +import AmpImg from './index.amp'; +import stories from './testHelpers/stories'; + +const additionalProps = { + layout: 'responsive', +}; + +stories(AmpImg, 'Image - AmpImg', additionalProps); diff --git a/packages/components/psammead-image/src/index.amp.test.jsx b/packages/components/psammead-image/src/index.amp.test.jsx new file mode 100644 index 0000000000..32f13b789c --- /dev/null +++ b/packages/components/psammead-image/src/index.amp.test.jsx @@ -0,0 +1,10 @@ +import AmpImg from './index.amp'; +import snapshotTests from './testHelpers/snapshotTests'; + +describe('Image - AmpImg', () => { + const additionalProps = { + layout: 'responsive', + }; + + snapshotTests(AmpImg, additionalProps); +}); diff --git a/packages/components/psammead-image/src/index.jsx b/packages/components/psammead-image/src/index.jsx index d9775b2ad4..ea8ea854bf 100644 --- a/packages/components/psammead-image/src/index.jsx +++ b/packages/components/psammead-image/src/index.jsx @@ -1,16 +1,38 @@ -import styled from 'styled-components'; +import React from 'react'; import { number, oneOfType, string } from 'prop-types'; +import styled from 'styled-components'; + +export { default as AmpImg } from './index.amp'; -const Image = styled.img` +const StyledImg = styled.img` display: block; width: 100%; `; -Image.propTypes = { +export const Img = ({ alt, src, srcset, height, width }) => { + const props = { alt, src, height, width }; + + if (height) { + props.height = height; + } + if (srcset) { + props.srcSet = srcset; + } + + return ; +}; + +Img.propTypes = { alt: string.isRequired, - height: oneOfType([string, number]), src: string.isRequired, + srcset: string, + height: oneOfType([string, number]), width: oneOfType([string, number]).isRequired, }; -export default Image; +Img.defaultProps = { + height: null, + srcset: null, +}; + +export default Img; diff --git a/packages/components/psammead-image/src/index.stories.jsx b/packages/components/psammead-image/src/index.stories.jsx index 8990f61c39..d6cd796e8e 100644 --- a/packages/components/psammead-image/src/index.stories.jsx +++ b/packages/components/psammead-image/src/index.stories.jsx @@ -1,17 +1,4 @@ -import React from 'react'; -import { storiesOf } from '@storybook/react'; -import { withReadme } from 'storybook-readme'; -import Readme from '../README.md'; -import Image from './index'; +import { Img } from '.'; +import stories from './testHelpers/stories'; -const imageAlt = - 'Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.'; -const imageSrc = - 'https://ichef.bbci.co.uk/news/640/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png'; -const imageWidth = 853; - -storiesOf('Image', module) - .addDecorator(withReadme(Readme)) - .add('default', () => ( - {imageAlt} - )); +stories(Img, 'Image - Img'); diff --git a/packages/components/psammead-image/src/index.test.jsx b/packages/components/psammead-image/src/index.test.jsx index c90be99cff..e8392bd5d1 100644 --- a/packages/components/psammead-image/src/index.test.jsx +++ b/packages/components/psammead-image/src/index.test.jsx @@ -1,22 +1,10 @@ -import React from 'react'; -import { shouldMatchSnapshot } from '@bbc/psammead-test-helpers'; -import Image from '.'; +import Image, { Img } from '.'; +import snapshotTests from './testHelpers/snapshotTests'; -const imageAlt = - 'Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.'; -const imageSrc = - 'https://ichef.bbci.co.uk/news/640/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png'; -const imageWidth = 853; -const imageHeight = 1067; +describe("Image - imported as '{ Img }'", () => { + snapshotTests(Img); +}); -describe('Image', () => { - shouldMatchSnapshot( - 'should render correctly', - {imageAlt}, - ); +describe("Image - imported as default 'Image'", () => { + snapshotTests(Image); }); diff --git a/packages/components/psammead-image/src/testHelpers/fixtureData.js b/packages/components/psammead-image/src/testHelpers/fixtureData.js new file mode 100644 index 0000000000..bee4be41c2 --- /dev/null +++ b/packages/components/psammead-image/src/testHelpers/fixtureData.js @@ -0,0 +1,36 @@ +export const landscape = { + alt: 'Student sitting an exam', + src: + 'https://ichef.bbci.co.uk/news/1024/cpsprodpb/7098/production/_104842882_students.jpg', + srcset: + 'https://ichef.bbci.co.uk/news/1024/cpsprodpb/7098/production/_104842882_students.jpg 1024w, https://ichef.bbci.co.uk/news/1024/cpsprodpb/7098/production/_104842882_students.jpg 1024w, https://ichef.bbci.co.uk/news/1024/cpsprodpb/7098/production/_104842882_students.jpg 1024w, https://ichef.bbci.co.uk/news/1024/cpsprodpb/7098/production/_104842882_students.jpg 1024w, https://ichef.bbci.co.uk/news/1024/cpsprodpb/7098/production/_104842882_students.jpg 1024w', + + width: 1024, + height: 576, +}; + +export const portrait = { + alt: + 'Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.', + src: + 'https://ichef.bbci.co.uk/news/640/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png', + width: 640, + height: 1138, +}; + +export const square = { + alt: 'Tracks through the snow', + src: + 'https://ichef.bbci.co.uk/news/1024/cpsprodpb/114FE/production/_104801907_79010.jpg', + width: 1024, + height: 1024, +}; + +export const custom = { + alt: 'By Elisa Decker, from her series "Sidewalk"', + src: + 'https://ichef.bbci.co.uk/news/445/cpsprodpb/164BB/production/_104032319_03270dcc-9dda-4bd4-96a0-db89f6b915ae.jpg', + + width: 445, + height: 547, +}; diff --git a/packages/components/psammead-image/src/testHelpers/snapshotTests.jsx b/packages/components/psammead-image/src/testHelpers/snapshotTests.jsx new file mode 100644 index 0000000000..e9fb6d5c1a --- /dev/null +++ b/packages/components/psammead-image/src/testHelpers/snapshotTests.jsx @@ -0,0 +1,58 @@ +import React from 'react'; +import { shouldMatchSnapshot } from '@bbc/psammead-test-helpers'; +import { custom, landscape, portrait, square } from './fixtureData'; + +const snapshotTests = (Component, additionalProps) => { + shouldMatchSnapshot( + 'should render landscape image correctly', + , + ); + shouldMatchSnapshot( + 'should render portrait image correctly', + , + ); + shouldMatchSnapshot( + 'should render square image correctly', + , + ); + shouldMatchSnapshot( + 'should render image with custom dimensions correctly', + , + ); + shouldMatchSnapshot( + 'should render image with srcset correctly', + , + ); +}; + +export default snapshotTests; diff --git a/packages/components/psammead-image/src/testHelpers/stories.jsx b/packages/components/psammead-image/src/testHelpers/stories.jsx new file mode 100644 index 0000000000..9b94ef5d63 --- /dev/null +++ b/packages/components/psammead-image/src/testHelpers/stories.jsx @@ -0,0 +1,52 @@ +import React from 'react'; +import { storiesOf } from '@storybook/react'; +import { withReadme } from 'storybook-readme'; +import Readme from '../../README.md'; +import { custom, landscape, portrait, square } from './fixtureData'; + +const stories = (Component, title, additionalProps) => + storiesOf(title, module) + .addDecorator(withReadme(Readme)) + .add('16:9 landscape image', () => ( + + )) + .add('9:16 portrait image', () => ( + + )) + .add('1:1 square image', () => ( + + )) + .add('custom ratio image', () => ( + + )) + .add('image with srcset', () => ( + + )); + +export default stories; From 7c9c70744580e150a04b77e7121615d00f818998 Mon Sep 17 00:00:00 2001 From: Sareh Heidari Date: Thu, 20 Dec 2018 14:17:54 +0000 Subject: [PATCH 02/25] Update Changelog --- packages/components/psammead-brand/src/svgs/news.jsx | 0 .../components/psammead-brand/src/svgs/persian.jsx | 0 packages/components/psammead-image/CHANGELOG.md | 12 ++++++------ 3 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 packages/components/psammead-brand/src/svgs/news.jsx delete mode 100644 packages/components/psammead-brand/src/svgs/persian.jsx diff --git a/packages/components/psammead-brand/src/svgs/news.jsx b/packages/components/psammead-brand/src/svgs/news.jsx deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/components/psammead-brand/src/svgs/persian.jsx b/packages/components/psammead-brand/src/svgs/persian.jsx deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/components/psammead-image/CHANGELOG.md b/packages/components/psammead-image/CHANGELOG.md index dee47fb293..eeec03b1f9 100644 --- a/packages/components/psammead-image/CHANGELOG.md +++ b/packages/components/psammead-image/CHANGELOG.md @@ -1,8 +1,8 @@ # Psammead Image Changelog -| Version | Description | -| ------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| 0.3.0 | [PR#](https://github.com/BBC-News/psammead/pull/) Add AmpImg component. Update Image to have optional srcset prop. | -| 0.2.0 | [PR#234](https://github.com/BBC-News/psammead/pull/234) Change height prop to be optional. Update the storybook example. | -| 0.1.1 | [PR#230](https://github.com/BBC-News/psammead/pull/230) Add README to Storybook | -| 0.1.0 | [PR#225](https://github.com/BBC-News/psammead/pull/225) Create initial package, pulled in from [Simorgh](https://github.com/BBC-News/simorgh). | +| Version | Description | +|---------|-------------| +| 0.3.0 | [PR#241](https://github.com/BBC-News/psammead/pull/241) Add AmpImg component. Update Image to have optional srcset prop. | +| 0.2.0 | [PR#234](https://github.com/BBC-News/psammead/pull/234) Change height prop to be optional. Update the storybook example. | +| 0.1.1 | [PR#230](https://github.com/BBC-News/psammead/pull/230) Add README to Storybook | +| 0.1.0 | [PR#225](https://github.com/BBC-News/psammead/pull/225) Create initial package, pulled in from [Simorgh](https://github.com/BBC-News/simorgh). | From 943b21971e54b8344591a0f77c1d7a7e91655c4d Mon Sep 17 00:00:00 2001 From: Sareh Heidari Date: Thu, 20 Dec 2018 16:07:34 +0000 Subject: [PATCH 03/25] Create AMP Storybook decorator --- .storybook/config.js | 21 +++++++++++++++++++-- package-lock.json | 6 ++++++ package.json | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.storybook/config.js b/.storybook/config.js index 2698d02326..2c7b03a463 100644 --- a/.storybook/config.js +++ b/.storybook/config.js @@ -3,6 +3,10 @@ import { configure, addDecorator } from '@storybook/react'; import { setOptions } from '@storybook/addon-options'; import styledNormalize from 'styled-normalize'; import { createGlobalStyle } from 'styled-components'; +import { + AMP_SCRIPT, + AMP_NO_SCRIPT, +} from '@bbc/psammead-assets/amp-boilerplate'; // Option defaults: setOptions({ @@ -44,11 +48,24 @@ const GlobalStyle = createGlobalStyle` } `; -addDecorator(story => ( +const canonicalDecorator = story => ( {story()} -)); +); + +const ampDecorator = story => ( + + + +