This is the summary text
diff --git a/packages/components/psammead-grid/src/index.stories.jsx b/packages/components/psammead-grid/src/index.stories.jsx
index 2b40eb0cc3..0a5466c70d 100644
--- a/packages/components/psammead-grid/src/index.stories.jsx
+++ b/packages/components/psammead-grid/src/index.stories.jsx
@@ -5,7 +5,6 @@ import {
withServicesKnob,
buildRTLSubstories,
} from '@bbc/psammead-storybook-helpers';
-import Image from '@bbc/psammead-image';
import StoryPromo, { Headline, Summary, Link } from '@bbc/psammead-story-promo';
import Grid from '.';
import {
@@ -1275,17 +1274,9 @@ storiesOf(STORY_KIND, module)
>
);
- const Img = (
-
- );
-
return (
}
info={Info}
promoType={promoType}
dir={dir}
@@ -1473,11 +1464,7 @@ storiesOf(STORY_KIND, module)
group5: 6,
}}
>
-
+
-
+
-
+
-
+
-
+
));
diff --git a/packages/components/psammead-grid/src/testHelpers.jsx b/packages/components/psammead-grid/src/testHelpers.jsx
index b4e5c283c7..d67aba975a 100644
--- a/packages/components/psammead-grid/src/testHelpers.jsx
+++ b/packages/components/psammead-grid/src/testHelpers.jsx
@@ -29,15 +29,27 @@ const ImageSpacing = styled.div`
padding: 0 0 ${GEL_SPACING} 0;
`;
-export const ExampleImage = () => (
-
-
-
-);
+export const ExampleImage = () => {
+ const imageSizes = [300, 450, 600, 1024];
+ const imageSrc =
+ 'https://ichef.bbci.co.uk/news/[WIDTH]/cpsprodpb/11897/production/_106613817_999_al_.jpg';
+
+ return (
+
+ `${imageSrc.replace('[WIDTH]', size)}.webp ${size}w`)
+ .join(', ')}
+ fallbackSrcset={imageSizes
+ .map(size => `${imageSrc.replace('[WIDTH]', size)} ${size}w`)
+ .join(', ')}
+ />
+
+ );
+};
export const ExampleMediaIndicator = styled(MediaIndicator)``;
diff --git a/packages/components/psammead-image/CHANGELOG.md b/packages/components/psammead-image/CHANGELOG.md
index cff00c0e01..8755973a1b 100644
--- a/packages/components/psammead-image/CHANGELOG.md
+++ b/packages/components/psammead-image/CHANGELOG.md
@@ -3,6 +3,7 @@
| Version | Description |
|---------|-------------|
+| 3.0.0 | [PR#4606](https://github.com/bbc/psammead/pull/4606) Add support for WebP |
| 2.0.8 | [PR#4486](https://github.com/bbc/psammead/pull/4486) upgrade minor/patch dependencies |
| 2.0.7 | [PR#4420](https://github.com/bbc/psammead/pull/4420) bumps 3rd-party dependencies |
| 2.0.6 | [PR#4368](https://github.com/bbc/psammead/pull/4368) use Yarn Workspaces |
diff --git a/packages/components/psammead-image/README.md b/packages/components/psammead-image/README.md
index e095f6048a..80b73775da 100644
--- a/packages/components/psammead-image/README.md
+++ b/packages/components/psammead-image/README.md
@@ -56,6 +56,7 @@ const WrappingContainer = ({ alt, src, height, width, sizes }) => (
## Props
### Img
+
| Prop | Type | Required | Default | Example |
|:-----|:-----|:---------|:--------|:--------|
@@ -63,7 +64,8 @@ const WrappingContainer = ({ alt, src, height, width, sizes }) => (
| `height` | number/string | No | null | 450 |
| `sizes` | string | No | null | "100vw" |
| `src` | string | Yes | - | "https://bbc.com/300/cat.jpg" |
-| `srcset` | string | No | null | "https://bbc.com/300/cat.jpg 300w, https://bbc.com/450/cat.jpg 450w, https://bbc.com/600/cat.jpg 600w" |
+| `srcset` | string | No | null | "https://bbc.com/300/cat.jpg.webp 300w, https://bbc.com/450/cat.jpg.webp 450w, https://bbc.com/600/cat.jpg.webp 600w" |
+| `fallbackSrcset` | string | No | null | "https://bbc.com/300/cat.jpg 300w, https://bbc.com/450/cat.jpg 450w, https://bbc.com/600/cat.jpg 600w" |
| `width` | number/string | No | null | 600 |
| `fade` | boolean | No | false | true |
@@ -80,6 +82,7 @@ The `sizes` prop is optional since some projects might not want to use the sizes
The `fade` prop is optional and set to `false` by default. It's been used to apply a fade-in animation effect on the `Img` component.
### AmpImg
+
| Prop | Type | Required | Default | Example |
|:-----|:-----|:---------|:--------|:--------|
@@ -89,7 +92,8 @@ The `fade` prop is optional and set to `false` by default. It's been used to app
| `layout` | string | Yes | - | "responsive" |
| `sizes` | string | No | null | "100vw" |
| `src` | string | Yes | - | "https://bbc.com/300/cat.jpg" |
-| `srcset` | string | No | null | "https://bbc.com/300/cat.jpg 300w, https://bbc.com/450/cat.jpg 450w, https://bbc.com/600/cat.jpg 600w" |
+| `srcset` | string | No | null | "https://bbc.com/300/cat.jpg.webp 300w, https://bbc.com/450/cat.jpg.webp 450w, https://bbc.com/600/cat.jpg.webp 600w" |
+| `fallbackSrcset` | string | No | null | "https://bbc.com/300/cat.jpg 300w, https://bbc.com/450/cat.jpg 450w, https://bbc.com/600/cat.jpg 600w" |
| `width` | number/string | Yes | - | 600 |
The `attribution` prop is available to pass in strings to include the image source. [For further details, please refer to the `amp-img` attribute docs](https://www.ampproject.org/docs/reference/components/amp-img#attributes).
diff --git a/packages/components/psammead-image/package.json b/packages/components/psammead-image/package.json
index 7061a46245..c89db06d87 100644
--- a/packages/components/psammead-image/package.json
+++ b/packages/components/psammead-image/package.json
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead-image",
- "version": "2.0.8",
+ "version": "3.0.0",
"main": "dist/index.js",
"module": "esm/index.js",
"sideEffects": false,
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
index 8f5738fdfc..bbfd51229e 100644
--- a/packages/components/psammead-image/src/__snapshots__/index.amp.test.jsx.snap
+++ b/packages/components/psammead-image/src/__snapshots__/index.amp.test.jsx.snap
@@ -14,7 +14,7 @@ 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 image with only srcset correctly 1`] = `
`;
+exports[`Image - AmpImg should render image with srcset and fallbackSrcset correctly 1`] = `
+
+`;
+
exports[`Image - AmpImg should render landscape image correctly 1`] = `
-
+ >
+
+
+
+
`;
@@ -26,35 +40,90 @@ exports[`Image - imported as '{ Img }' should render image with custom dimension
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![By Elisa Decker, from her series \\](https://ichef.bbci.co.uk/news/300/cpsprodpb/164BB/production/_104032319_03270dcc-9dda-4bd4-96a0-db89f6b915ae.jpg)
+ >
+
+
![By Elisa Decker, from her series \\](https://ichef.bbci.co.uk/news/300/cpsprodpb/164BB/production/_104032319_03270dcc-9dda-4bd4-96a0-db89f6b915ae.jpg)
+
`;
-exports[`Image - imported as '{ Img }' should render image with srcset correctly 1`] = `
+exports[`Image - imported as '{ Img }' should render image with only srcset correctly 1`] = `
.emotion-0 {
display: block;
width: 100%;
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+ >
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
+
+`;
+
+exports[`Image - imported as '{ Img }' should render image with srcset and fallbackSrcset correctly 1`] = `
+.emotion-0 {
+ display: block;
+ width: 100%;
+ visibility: visible;
+}
+
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
+
+
+
+
+
+
`;
@@ -65,15 +134,25 @@ exports[`Image - imported as '{ Img }' should render landscape image correctly 1
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+ >
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
`;
@@ -84,15 +163,25 @@ exports[`Image - imported as '{ Img }' should render portrait image correctly 1`
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.](https://ichef.bbci.co.uk/news/300/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png)
+ >
+
+
![Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.](https://ichef.bbci.co.uk/news/300/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png)
+
`;
@@ -103,15 +192,25 @@ exports[`Image - imported as '{ Img }' should render square image correctly 1`]
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Tracks through the snow](https://ichef.bbci.co.uk/news/300/cpsprodpb/114FE/production/_104801907_79010.jpg)
+ >
+
+
![Tracks through the snow](https://ichef.bbci.co.uk/news/300/cpsprodpb/114FE/production/_104801907_79010.jpg)
+
`;
@@ -122,15 +221,29 @@ exports[`Image - imported as default 'Image' should render image correctly witho
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+ >
+
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
`;
@@ -141,35 +254,90 @@ exports[`Image - imported as default 'Image' should render image with custom dim
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
+
+
+
+
+
+
+`;
+
+exports[`Image - imported as default 'Image' should render image with only srcset correctly 1`] = `
+.emotion-0 {
+ display: block;
+ width: 100%;
+ visibility: visible;
+}
+
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![By Elisa Decker, from her series \\](https://ichef.bbci.co.uk/news/300/cpsprodpb/164BB/production/_104032319_03270dcc-9dda-4bd4-96a0-db89f6b915ae.jpg)
+ >
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
`;
-exports[`Image - imported as default 'Image' should render image with srcset correctly 1`] = `
+exports[`Image - imported as default 'Image' should render image with srcset and fallbackSrcset correctly 1`] = `
.emotion-0 {
display: block;
width: 100%;
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+ >
+
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
`;
@@ -180,15 +348,25 @@ exports[`Image - imported as default 'Image' should render landscape image corre
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+ >
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
`;
@@ -199,15 +377,25 @@ exports[`Image - imported as default 'Image' should render portrait image correc
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.](https://ichef.bbci.co.uk/news/300/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png)
+ >
+
+
![Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.](https://ichef.bbci.co.uk/news/300/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png)
+
`;
@@ -218,87 +406,152 @@ exports[`Image - imported as default 'Image' should render square image correctl
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Tracks through the snow](https://ichef.bbci.co.uk/news/300/cpsprodpb/114FE/production/_104801907_79010.jpg)
+ >
+
+
![Tracks through the snow](https://ichef.bbci.co.uk/news/300/cpsprodpb/114FE/production/_104801907_79010.jpg)
+
`;
exports[`Image - with Fade-in effect' should render image correctly without width 1`] = `
-@keyframes animation-0 {
- from {
- opacity: 0;
- }
+.emotion-0 {
+ display: block;
+ width: 100%;
+ visibility: visible;
+}
- to {
- opacity: 1;
- }
+.emotion-2 {
+ display: block;
+ width: 100%;
}
+
+
+
+
+
+
+
+`;
+
+exports[`Image - with Fade-in effect' should render image with custom dimensions correctly 1`] = `
.emotion-0 {
display: block;
width: 100%;
visibility: visible;
- -webkit-animation: animation-0 0.2s linear;
- animation: animation-0 0.2s linear;
- -webkit-transition: visibility 0.2s linear;
- transition: visibility 0.2s linear;
+}
+
+.emotion-2 {
+ display: block;
+ width: 100%;
}
-
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+ >
+
+
![By Elisa Decker, from her series \\](https://ichef.bbci.co.uk/news/300/cpsprodpb/164BB/production/_104032319_03270dcc-9dda-4bd4-96a0-db89f6b915ae.jpg)
+
`;
-exports[`Image - with Fade-in effect' should render image with custom dimensions correctly 1`] = `
+exports[`Image - with Fade-in effect' should render image with only srcset correctly 1`] = `
.emotion-0 {
display: block;
width: 100%;
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![By Elisa Decker, from her series \\](https://ichef.bbci.co.uk/news/300/cpsprodpb/164BB/production/_104032319_03270dcc-9dda-4bd4-96a0-db89f6b915ae.jpg)
+ >
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
`;
-exports[`Image - with Fade-in effect' should render image with srcset correctly 1`] = `
+exports[`Image - with Fade-in effect' should render image with srcset and fallbackSrcset correctly 1`] = `
.emotion-0 {
display: block;
width: 100%;
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+ >
+
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
`;
@@ -309,15 +562,25 @@ exports[`Image - with Fade-in effect' should render landscape image correctly 1`
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+ >
+
+
![Student sitting an exam](https://ichef.bbci.co.uk/news/300/cpsprodpb/7098/production/_104842882_students.jpg)
+
`;
@@ -328,15 +591,25 @@ exports[`Image - with Fade-in effect' should render portrait image correctly 1`]
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.](https://ichef.bbci.co.uk/news/300/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png)
+ >
+
+
![Map of the UK displaying Syrian refugees and asylum seekers per 10000 population. Ranges from 0 to 17.](https://ichef.bbci.co.uk/news/300/cpsprodpb/439A/production/_100960371_syrians_and_asylum_v2-nc.png)
+
`;
@@ -347,14 +620,24 @@ exports[`Image - with Fade-in effect' should render square image correctly 1`] =
visibility: visible;
}
+.emotion-2 {
+ display: block;
+ width: 100%;
+}
+
-
![Tracks through the snow](https://ichef.bbci.co.uk/news/300/cpsprodpb/114FE/production/_104801907_79010.jpg)
+ >
+
+
![Tracks through the snow](https://ichef.bbci.co.uk/news/300/cpsprodpb/114FE/production/_104801907_79010.jpg)
+
`;
diff --git a/packages/components/psammead-image/src/index.amp.jsx b/packages/components/psammead-image/src/index.amp.jsx
index 1dae61b55f..4457ce5e80 100644
--- a/packages/components/psammead-image/src/index.amp.jsx
+++ b/packages/components/psammead-image/src/index.amp.jsx
@@ -6,9 +6,19 @@ import { number, string } from 'prop-types';
const omitInvalidProps = omit(['classname']);
const AmpImg = props => {
- const { srcset, ...otherProps } = props;
+ const { srcset, fallbackSrcset, ...otherProps } = props;
- return
;
+ return (
+
+ {fallbackSrcset && (
+
+ )}
+
+ );
};
AmpImg.propTypes = {
@@ -19,6 +29,7 @@ AmpImg.propTypes = {
sizes: string,
src: string.isRequired,
srcset: string,
+ fallbackSrcset: string,
width: number.isRequired,
};
@@ -26,6 +37,7 @@ AmpImg.defaultProps = {
attribution: '',
sizes: null,
srcset: null,
+ fallbackSrcset: 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
index eddbabae75..f7a56ebd44 100644
--- a/packages/components/psammead-image/src/index.amp.stories.jsx
+++ b/packages/components/psammead-image/src/index.amp.stories.jsx
@@ -6,10 +6,10 @@ const additionalProps = {
layout: 'responsive',
};
-stories(
- AmpImg,
- 'Components/Images/Image - AmpImg',
- true,
+stories({
+ Component: AmpImg,
+ title: 'Components/Images/Image - AmpImg',
+ includeHeight: true,
additionalProps,
- ampDecorator,
-);
+ styleDecorator: ampDecorator,
+});
diff --git a/packages/components/psammead-image/src/index.jsx b/packages/components/psammead-image/src/index.jsx
index 5e1ec1a74c..50ce12933c 100644
--- a/packages/components/psammead-image/src/index.jsx
+++ b/packages/components/psammead-image/src/index.jsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { number, oneOfType, string, bool } from 'prop-types';
+import { number, oneOfType, string, bool, func } from 'prop-types';
import styled from '@emotion/styled';
import { keyframes, css } from '@emotion/react';
@@ -20,17 +20,28 @@ const fadeIn = css`
transition: visibility 0.2s linear;
`;
-const StyledImg = styled.img`
+const StyledPicture = styled.picture`
display: block;
width: 100%;
visibility: visible;
${props => props.fade && fadeIn};
`;
+const StyledImg = styled.img`
+ display: block;
+ width: 100%;
+`;
+
export const Img = props => {
- const { srcset, ...otherProps } = props;
+ const { src, srcset, fallbackSrcset, onLoad, ...otherProps } = props;
- return
;
+ return (
+
+
+ {fallbackSrcset && }
+
+
+ );
};
Img.propTypes = {
@@ -40,7 +51,9 @@ Img.propTypes = {
sizes: string,
src: string.isRequired,
srcset: string,
+ fallbackSrcset: string,
width: oneOfType([string, number]),
+ onLoad: func,
};
Img.defaultProps = {
@@ -48,7 +61,9 @@ Img.defaultProps = {
height: null,
sizes: null,
srcset: null,
+ fallbackSrcset: null,
width: null,
+ onLoad: () => {},
};
export default Img;
diff --git a/packages/components/psammead-image/src/index.stories.jsx b/packages/components/psammead-image/src/index.stories.jsx
index bb45b93b35..c95246ab17 100644
--- a/packages/components/psammead-image/src/index.stories.jsx
+++ b/packages/components/psammead-image/src/index.stories.jsx
@@ -1,21 +1,15 @@
-import React from 'react';
import { withKnobs } from '@storybook/addon-knobs';
import { Img } from '.';
-import { stories, getProps } from './testHelpers/stories';
-import { landscape } from './testHelpers/fixtureData';
-import notes from '../README.md';
+import { stories } from './testHelpers/stories';
const type = 'Img';
-stories(
- Img,
- 'Components/Images/Image - Img',
- false,
- {},
- withKnobs,
+stories({
+ Component: Img,
+ title: 'Components/Images/Image - Img',
+ includeHeight: false,
+ additionalProps: {},
+ styleDecorator: withKnobs,
type,
-).add(
- 'image without width',
- () =>
![]()
,
- { notes },
-);
+ isCanonical: true,
+});
diff --git a/packages/components/psammead-image/src/testHelpers/fixtureData.js b/packages/components/psammead-image/src/testHelpers/fixtureData.js
index 51e68585c7..57d0b4b18f 100644
--- a/packages/components/psammead-image/src/testHelpers/fixtureData.js
+++ b/packages/components/psammead-image/src/testHelpers/fixtureData.js
@@ -10,6 +10,9 @@ export const landscape = {
sizes: '100vw',
src: landscapeImageUrl.replace('[WIDTH]', sizes[0]),
srcset: sizes
+ .map(size => `${landscapeImageUrl.replace('[WIDTH]', size)}.webp ${size}w`)
+ .join(', '),
+ fallbackSrcset: sizes
.map(size => `${landscapeImageUrl.replace('[WIDTH]', size)} ${size}w`)
.join(', '),
width: 1024,
@@ -23,6 +26,9 @@ export const portrait = {
sizes: '100vw',
src: portraitImageUrl.replace('[WIDTH]', sizes[0]),
srcset: sizes
+ .map(size => `${portraitImageUrl.replace('[WIDTH]', size)}.webp ${size}w`)
+ .join(', '),
+ fallbackSrcset: sizes
.map(size => `${portraitImageUrl.replace('[WIDTH]', size)} ${size}w`)
.join(', '),
width: 1024,
@@ -35,6 +41,9 @@ export const square = {
sizes: '100vw',
src: squareImageUrl.replace('[WIDTH]', sizes[0]),
srcset: sizes
+ .map(size => `${squareImageUrl.replace('[WIDTH]', size)}.webp ${size}w`)
+ .join(', '),
+ fallbackSrcset: sizes
.map(size => `${squareImageUrl.replace('[WIDTH]', size)} ${size}w`)
.join(', '),
width: 1024,
@@ -47,6 +56,9 @@ export const custom = {
sizes: '100vw',
src: customImageUrl.replace('[WIDTH]', sizes[0]),
srcset: sizes
+ .map(size => `${customImageUrl.replace('[WIDTH]', size)}.webp ${size}w`)
+ .join(', '),
+ fallbackSrcset: sizes
.map(size => `${customImageUrl.replace('[WIDTH]', size)} ${size}w`)
.join(', '),
width: 445,
diff --git a/packages/components/psammead-image/src/testHelpers/snapshotTests.jsx b/packages/components/psammead-image/src/testHelpers/snapshotTests.jsx
index 92507b5128..d7fd3a3ac6 100644
--- a/packages/components/psammead-image/src/testHelpers/snapshotTests.jsx
+++ b/packages/components/psammead-image/src/testHelpers/snapshotTests.jsx
@@ -52,7 +52,21 @@ const snapshotTests = (Component, additionalProps) => {
/>,
);
shouldMatchSnapshot(
- 'should render image with srcset correctly',
+ 'should render image with srcset and fallbackSrcset correctly',
+
,
+ );
+ shouldMatchSnapshot(
+ 'should render image with only srcset correctly',
storyFn(),
type,
-) =>
+ isCanonical = false,
+}) =>
storiesOf(title, module)
.addDecorator(styleDecorator)
.add(
@@ -78,4 +80,9 @@ export const stories = (
/>
),
{ notes },
+ )
+ .add(
+ isCanonical && 'image without width',
+ () => ,
+ { notes },
);
diff --git a/packages/components/psammead-media-player/CHANGELOG.md b/packages/components/psammead-media-player/CHANGELOG.md
index 6be6e0f419..6b1fba0d75 100644
--- a/packages/components/psammead-media-player/CHANGELOG.md
+++ b/packages/components/psammead-media-player/CHANGELOG.md
@@ -3,6 +3,7 @@
| Version | Description |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
+| 6.0.0| [PR#4606](https://github.com/bbc/psammead/pull/4606) Adds support for WebP |
| 5.1.13 | [PR#4601](https://github.com/bbc/psammead/pull/4601) Bumps dependencies |
| 5.1.13 | [PR#4574](https://github.com/bbc/psammead/pull/4574) Bumps psammead-styles transitive packages |
| 5.1.12 | [PR#4568](https://github.com/bbc/psammead/pull/4568) Bump from psammead-styles |
diff --git a/packages/components/psammead-media-player/package.json b/packages/components/psammead-media-player/package.json
index 2a7d585836..4424968d10 100644
--- a/packages/components/psammead-media-player/package.json
+++ b/packages/components/psammead-media-player/package.json
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead-media-player",
- "version": "5.1.14",
+ "version": "6.0.0",
"description": "Provides a media player with optional placeholder",
"main": "dist/index.js",
"module": "esm/index.js",
@@ -30,7 +30,7 @@
},
"dependencies": {
"@bbc/psammead-assets": "3.1.10",
- "@bbc/psammead-image": "2.0.8",
+ "@bbc/psammead-image": "3.0.0",
"@bbc/psammead-image-placeholder": "3.4.10",
"@bbc/psammead-play-button": "3.0.32"
},
diff --git a/packages/components/psammead-media-player/src/Placeholder/__snapshots__/index.test.jsx.snap b/packages/components/psammead-media-player/src/Placeholder/__snapshots__/index.test.jsx.snap
index d710a3b80b..1dbd743101 100644
--- a/packages/components/psammead-media-player/src/Placeholder/__snapshots__/index.test.jsx.snap
+++ b/packages/components/psammead-media-player/src/Placeholder/__snapshots__/index.test.jsx.snap
@@ -106,6 +106,11 @@ exports[`Media Player: Placeholder should render a video placeholder 1`] = `
visibility: visible;
}
+.emotion-19 {
+ display: block;
+ width: 100%;
+}
+
-
![](http://foo.bar/placeholder.png)
+ >
+
+
![](http://foo.bar/placeholder.png)
+
`;
@@ -293,6 +303,11 @@ exports[`Media Player: Placeholder should render a video placeholder with guidan
visibility: visible;
}
+.emotion-21 {
+ display: block;
+ width: 100%;
+}
+
-
![](http://foo.bar/placeholder.png)
+ >
+
+
![](http://foo.bar/placeholder.png)
+
`;
@@ -454,6 +474,11 @@ exports[`Media Player: Placeholder should render a video placeholder without dur
visibility: visible;
}
+.emotion-17 {
+ display: block;
+ width: 100%;
+}
+
-
![](http://foo.bar/placeholder.png)
+ >
+
+
![](http://foo.bar/placeholder.png)
+
`;
@@ -608,6 +638,11 @@ exports[`Media Player: Placeholder should render an audio placeholder 1`] = `
visibility: visible;
}
+.emotion-19 {
+ display: block;
+ width: 100%;
+}
+