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

Commit

Permalink
Merge pull request #3291 from bbc/fix-stories-broken-for-variants
Browse files Browse the repository at this point in the history
Use `selectedService` prop in psammead-radio-schedules & psammead-most-read stories
  • Loading branch information
Ruth Bochere authored Mar 25, 2020
2 parents f2f0eb5 + dc9bf16 commit 8640807
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- prettier-ignore -->
| Version | Description |
|---------|-------------|
| 2.0.111 | [PR#3291](https://github.com/bbc/psammead/pull/3291) Bump `@psammead-storybook-helpers` |
| 2.0.110 | [PR#3264](https://github.com/bbc/psammead/pull/3264) Add @bbc/psammead-live-label to dependencies |
| 2.0.109 | [PR#3292](https://github.com/bbc/psammead/pull/3292) Talos - Bump Dependencies - @bbc/psammead-navigation, @bbc/psammead-section-label |
| 2.0.108 | [PR#3217](https://github.com/bbc/psammead/pull/3217) Add @loadable/component to devDependencies for @bbc/psammead-social-embed. |
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead",
"version": "2.0.110",
"version": "2.0.111",
"description": "Core Components Library Developed & Maintained By The Articles and Reach & Languages Team",
"main": "index.js",
"private": true,
Expand Down Expand Up @@ -83,7 +83,7 @@
"@bbc/psammead-sitewide-links": "^4.0.10",
"@bbc/psammead-story-promo": "^5.1.0",
"@bbc/psammead-story-promo-list": "^4.0.5",
"@bbc/psammead-storybook-helpers": "^8.2.5",
"@bbc/psammead-storybook-helpers": "^8.2.6",
"@bbc/psammead-styles": "^4.3.0",
"@bbc/psammead-test-helpers": "^3.1.3",
"@bbc/psammead-timestamp": "^2.2.26",
Expand Down
1 change: 1 addition & 0 deletions packages/components/psammead-most-read/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- prettier-ignore -->
| Version | Description |
|---------|-------------|
| 4.0.3 | [PR#3291](https://github.com/bbc/psammead/pull/3291) Use withServicesKnob `selectedService` prop |
| 4.0.2 | [PR#3243](https://github.com/bbc/psammead/pull/3243) Fixes most-read IE11 `oneColumn` layout bugs |
| 4.0.1 | [PR#3237](https://github.com/bbc/psammead/pull/3237) Fixed most-read IE layout bug |
| 4.0.0 | [PR#3201](https://github.com/bbc/psammead/pull/3201) Refactor RankWrapper in MostRead |
Expand Down
2 changes: 1 addition & 1 deletion packages/components/psammead-most-read/package-lock.json

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-most-read/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead-most-read",
"version": "4.0.2",
"version": "4.0.3",
"description": "A component for the most read item",
"main": "dist/index.js",
"module": "esm/index.js",
Expand Down
18 changes: 11 additions & 7 deletions packages/components/psammead-most-read/src/index.stories.jsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
/* eslint-disable react/prop-types */
import React from 'react';
import { storiesOf } from '@storybook/react';
import { select, boolean, text, withKnobs } from '@storybook/addon-knobs';
import { select, boolean, number, withKnobs } from '@storybook/addon-knobs';
import { withServicesKnob } from '@bbc/psammead-storybook-helpers';
import { getItem, getItemWrapperArray, getServiceVariant } from './utilities';
import { getItem, getItemWrapperArray } from './utilities';
import { MostReadRank, MostReadLink, MostReadList } from './index';
import notes from '../README.md';

const newsServiceDecorator = withServicesKnob({
defaultService: 'news',
});
const listIndexRange = {
min: 1,
max: 10,
};

const pageTypes = ['oneColumn', 'twoColumn', 'multiColumn'];

Expand Down Expand Up @@ -79,7 +83,7 @@ storiesOf('Components|MostRead/Rank', module)
dir,
service,
script,
listIndex: text('Number (1 - 10)', '5'),
listIndex: number('Number (1 - 10)', 5, listIndexRange),
numberOfItems: 10,
}),
{
Expand All @@ -93,11 +97,11 @@ storiesOf('Components|MostRead/Item', module)
.addDecorator(withServicesKnob())
.add(
`default`,
({ dir, script, service, variant }) =>
({ dir, script, selectedService }) =>
renderLink({
dir,
script,
service: getServiceVariant({ service, variant }),
service: selectedService,
withTimestamp: boolean('Timestamp', false),
}),
{
Expand All @@ -110,12 +114,12 @@ storiesOf('Components|MostRead/List', module)
.add(
`default`,
() =>
newsServiceDecorator(({ dir, script, service, variant }) =>
newsServiceDecorator(({ dir, script, selectedService }) =>
renderList({
numberOfItems: 10,
columnLayout: select('Page Type (columns)', pageTypes, 'multiColumn'),
withTimestamp: boolean('Timestamp', false),
service: getServiceVariant({ service, variant }),
service: selectedService,
dir,
script,
}),
Expand Down
10 changes: 0 additions & 10 deletions packages/components/psammead-most-read/src/utilities/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ const lastUpdated = ({ script, service }) => (
</Timestamp>
);

export const getServiceVariant = ({ service, variant = '' }) => {
if (variant !== 'default') {
const variantOverride =
variant.charAt(0).toUpperCase() + variant.substring(1);
return service + variantOverride;
}

return service;
};

export const getItem = ({ service, withTimestamp = false }) => {
const baseUrl = 'https://www.bbc.com';
const { text, articlePath } = TEXT_VARIANTS[service];
Expand Down
1 change: 1 addition & 0 deletions packages/components/psammead-radio-schedule/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- prettier-ignore -->
| Version | Description |
|---------|-------------|
| 0.1.0-alpha.24 | [PR#3291](https://github.com/bbc/psammead/pull/3291) Use withServicesKnob `selectedService` prop |
| 0.1.0-alpha.23 | [PR#3297](https://github.com/bbc/psammead/pull/3297) Use LiveLabel, and pass in translations for next and live |
| 0.1.0-alpha.22 | [PR#3274](https://github.com/bbc/psammead/pull/3274) Talos - Bump Dependencies - @bbc/psammead-timestamp-container |
| 0.1.0-alpha.21 | [PR#3272](https://github.com/bbc/psammead/pull/3272) Talos - Bump Dependencies - @bbc/psammead-timestamp-container |
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-radio-schedule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bbc/psammead-radio-schedule",
"version": "0.1.0-alpha.23",
"version": "0.1.0-alpha.24",
"main": "dist/index.js",
"module": "esm/index.js",
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ describe('RadioSchedule', () => {
script: arabic,
dir: 'rtl',
locale: 'fa',
selectedService: 'arabic',
}),
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ export const renderRadioSchedule = ({
script = latin,
dir = 'ltr',
withLongSummary = false,
selectedService = 'news',
}) => {
const nextLabel = dir === 'rtl' ? 'مباشر' : 'NEXT';
const liveLabel = dir === 'rtl' ? 'مباشر' : 'LIVE';

return (
<RadioSchedule
schedules={getSchedule(service, withLongSummary)}
schedules={getSchedule(selectedService, withLongSummary)}
locale={locale}
timezone={timezone}
script={script}
Expand Down

0 comments on commit 8640807

Please sign in to comment.