Skip to content
This repository has been archived by the owner on Aug 13, 2023. It is now read-only.

Add story for Media Message component & remove border #3666

Merged
merged 6 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/components/psammead-media-player/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- prettier-ignore -->
| Version | Description |
| ------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| 2.9.0 | [PR#3666](https://github.com/bbc/psammead/pull/3666) Adding story for media message and removing bottom border from strong el |
| 2.8.2 | [PR#3641](https://github.com/bbc/psammead/pull/3641) Version bump & fixing PR link |
| 2.8.1 | [PR#3640](https://github.com/bbc/psammead/pull/3640) Make z-index styling be conditional based on whether loadingImage is used |
| 2.8.0 | [PR#3600](https://github.com/bbc/psammead/pull/3600) Implementing dark mode compatible placeholder with media player |
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/components/psammead-media-player/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead-media-player",
"version": "2.8.2",
"version": "2.9.0",
"description": "Provides a media player with optional placeholder",
"main": "dist/index.js",
"module": "esm/index.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Media Message matches media message snapshot 1`] = `
.c0 {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.c1 {
font-family: Helmet,Freesans,Helvetica,Arial,sans-serif;
font-weight: 400;
font-style: normal;
font-size: 0.9375rem;
line-height: 1.125rem;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
border: 0.0625rem solid transparent;
color: #FFFFFF;
background-color: rgba(34,34,34,0.75);
}

.c2 {
display: block;
font-weight: normal;
bottom: 0;
position: absolute;
padding: 0.5rem;
}

@media (min-width:37.5rem) {
.c1 {
font-size: 0.875rem;
}
}

@media screen and (-ms-high-contrast:active) {
.c1 {
background-color: transparent;
}
}

@media screen and (-ms-high-contrast:active) {
.c2 {
background-color: window;
}
}

@media (min-width:25rem) {
.c2 {
padding: 1rem;
}
}

<div
class="c0"
>

<div
class="c1"
>
<strong
class="c2"
>
Контент більше не доступний
</strong>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const StyledMessage = styled.strong`
bottom: 0;
position: absolute;
padding: ${GEL_SPACING};
border-bottom: 0.0625rem solid transparent;
@media screen and (-ms-high-contrast: active) {
background-color: window;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import React from 'react';
import { render } from '@testing-library/react';
import { shouldMatchSnapshot } from '@bbc/psammead-test-helpers';
import Message from './index';
import '@testing-library/jest-dom/extend-expect';

it('should display the media message', () => {
const { getByText } = render(
<Message
service="news"
message="Please enable Javascript or try a different browser"
placeholderSrc="http://foo.bar/placeholder.png"
placeholderSrcset="http://foo.bar/placeholder.png"
/>,
);
const message = getByText(
'Please enable Javascript or try a different browser',
describe('Media Message', () => {
it('should display the media message', () => {
const { getByText } = render(
<Message
service="news"
message="Please enable Javascript or try a different browser"
placeholderSrc="http://foo.bar/placeholder.png"
placeholderSrcset="http://foo.bar/placeholder.png"
/>,
);
const message = getByText(
'Please enable Javascript or try a different browser',
);
expect(message).toBeInTheDocument();
});

shouldMatchSnapshot(
'matches media message snapshot',
<Message message="Контент більше не доступний" service="ukrainian" />,
);
expect(message).toBeInTheDocument();
});
28 changes: 27 additions & 1 deletion packages/components/psammead-media-player/src/index.stories.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { boolean, withKnobs } from '@storybook/addon-knobs';
import { boolean, text, withKnobs } from '@storybook/addon-knobs';
import styled from 'styled-components';
import { withServicesKnob } from '@bbc/psammead-storybook-helpers';
import { CanonicalMediaPlayer, AmpMediaPlayer } from '.';
import MediaMessage from './Message';
import { ampDecorator } from '../../../../.storybook/config';
import notes from '../README.md';

Expand All @@ -11,6 +14,12 @@ const withDuration = {
datetime: 'PT2M30S',
};

const StyledMessageContainer = styled.div`
padding-top: 56.25%;
Copy link
Contributor

@greenc05 greenc05 Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering what 56.25% is for? This value seems unsual? Did we use this before this PR?

Copy link
Contributor Author

@RichardPK RichardPK Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a means of applying a 16:9 ratio to the container's padding. Where 16 is the width, 56.26% of that (9) is the height.

We use it in Simorgh as a means of pushing the other page content below the player - I'm just mocking that in the story to emulate the styling.

Screenshot 2020-08-18 at 12 28 18

Frankly it seems like a mad way to manage layout but I'm sure there's good reason for doing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intersting, ok thanks for the explanation @RichardPK

position: relative;
overflow: hidden;
`;

storiesOf('Components|Media Player', module)
.add(
'Articles Canonical',
Expand Down Expand Up @@ -97,6 +106,23 @@ storiesOf('Components|Media Player', module)
/>
),
{ notes, knobs: { escapeHTML: false } },
)
.addDecorator(withKnobs)
.addDecorator(withServicesKnob({ defaultService: 'ukrainian' }))
.add(
'Media Message',
({ service }) => {
const id = text('Message', 'Контент більше не доступний');
return (
<StyledMessageContainer>
<MediaMessage service={service} message={id} />
</StyledMessageContainer>
);
},
{
notes,
knobs: { escapeHTML: false },
},
);

storiesOf('Components|Media Player', module)
Expand Down