Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Grid example to Storybook #3693

Merged
merged 28 commits into from
Sep 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
690d62b
Refactor front-page story
EinsteinNjoroge Sep 10, 2019
7946149
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 10, 2019
95ca44d
Expose front pages main without analytics
EinsteinNjoroge Sep 10, 2019
4078097
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 10, 2019
a3ae4b0
Fix exported name not defined as default
EinsteinNjoroge Sep 10, 2019
b678f9d
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 10, 2019
e36fc16
Add grid layout to articles main story
EinsteinNjoroge Sep 10, 2019
10774fb
Merge branch 'latest' into add-grid-example-to-storybook
Sep 11, 2019
a80cc08
Merge branch 'latest' into add-grid-example-to-storybook
sareh Sep 11, 2019
07f0bd0
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 12, 2019
eda109e
Revert FrontPagesMain without analytics
EinsteinNjoroge Sep 12, 2019
8ee0af6
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 12, 2019
1312a20
merge latest
EinsteinNjoroge Sep 12, 2019
a4124bc
Group main containers in storybook
EinsteinNjoroge Sep 12, 2019
f92e817
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 12, 2019
6a6e822
merge latest
EinsteinNjoroge Sep 12, 2019
57ebc3b
Update snapshot
EinsteinNjoroge Sep 12, 2019
5638d84
Merge branch 'latest' into add-grid-example-to-storybook
sareh Sep 12, 2019
81e2d7a
Add services to grid example
EinsteinNjoroge Sep 12, 2019
b86c0d7
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 12, 2019
7dadd70
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 12, 2019
6e967c3
Merge branch 'latest' into add-grid-example-to-storybook
sareh Sep 13, 2019
b43208e
Update src/app/containers/ArticleMain/index.stories.jsx
EinsteinNjoroge Sep 13, 2019
bb1bba7
Update src/app/containers/FrontPageMain/index.stories.jsx
EinsteinNjoroge Sep 13, 2019
d0a9cbb
Update src/app/containers/ArticleMain/index.stories.jsx
EinsteinNjoroge Sep 13, 2019
e302c65
Update src/app/containers/FrontPageMain/index.stories.jsx
EinsteinNjoroge Sep 13, 2019
9bd123e
Merge branch 'latest' into add-grid-example-to-storybook
EinsteinNjoroge Sep 13, 2019
c9b25c4
Add punjabi to storybook tests
EinsteinNjoroge Sep 16, 2019
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
44 changes: 14 additions & 30 deletions src/app/containers/ArticleMain/index.stories.jsx
Original file line number Diff line number Diff line change
@@ -1,42 +1,26 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import { inputProvider } from '@bbc/psammead-storybook-helpers';
import { withKnobs } from '@storybook/addon-knobs';
import { ServiceContextProvider } from '../../contexts/ServiceContext';
import { ToggleContextProvider } from '../../contexts/ToggleContext';
import { RequestContextProvider } from '../../contexts/RequestContext';

import ArticleMain from '.';
import { articleDataNews, articleDataPersian } from '../Article/fixtureData';

// article c5jje4ejkqvo contains a Headline, a Paragraph, a timestamp
// a Portrait Image with Caption, a Landscape Image with Caption and Square Image with Caption.
import articleData from '../../../../data/news/articles/c5jje4ejkqvo';

// Not all services have fixtures for article data yet
// the service selector will be constrained to services that have article fixtures:
const availableFixtures = {
news: articleDataNews,
persian: articleDataPersian,
};

storiesOf('Containers|Article/Article Main', module)
storiesOf('Main|Article', module)
.addDecorator(withKnobs)
.add(
'default',
inputProvider({
// eslint-disable-next-line react/prop-types
componentFunction: ({ service }) => {
return (
<ToggleContextProvider>
<ServiceContextProvider service={service}>
<RequestContextProvider
isAmp={false}
pageType="article"
service={service}
>
<ArticleMain articleData={availableFixtures[service]} />
</RequestContextProvider>
</ServiceContextProvider>
</ToggleContextProvider>
);
},
services: Object.keys(availableFixtures),
}),
);
.add('Articles', () => (
<ToggleContextProvider>
<ServiceContextProvider service="news">
<RequestContextProvider isAmp={false} pageType="article" service="news">
<ArticleMain articleData={articleData} />
</RequestContextProvider>
</ServiceContextProvider>
</ToggleContextProvider>
));
82 changes: 19 additions & 63 deletions src/app/containers/FrontPage/index.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import pidginData from '../../../../data/pidgin/frontpage';
import addIdsToItems from '../../lib/utilities/preprocessor/rules/addIdsToItems';
import thaiData from '../../../../data/thai/frontpage';
import yorubaData from '../../../../data/yoruba/frontpage';

import punjabiData from '../../../../data/punjabi/frontpage';
import filterUnknownContentTypes from '../../lib/utilities/preprocessor/rules/filterContentType';
import filterEmptyGroupItems from '../../lib/utilities/preprocessor/rules/filterEmptyGroupItems';
import applySquashTopstories from '../../lib/utilities/preprocessor/rules/topstories';
Expand All @@ -19,80 +19,36 @@ const preprocessorRules = [
applySquashTopstories,
];

storiesOf('Pages|Front Page', module)
.add('Igbo', () => {
const igboFrontPageData = preprocess(igboData, preprocessorRules);

const data = {
pageData: igboFrontPageData,
status: 200,
};

return (
<FrontPage
data={data}
service="igbo"
isAmp={false}
loading={false}
error=""
pageType="frontPage"
/>
);
})
.add('Yoruba', () => {
const yorubaFrontPageData = preprocess(yorubaData, preprocessorRules);

const data = {
pageData: yorubaFrontPageData,
status: 200,
};

return (
<FrontPage
data={data}
service="yoruba"
isAmp={false}
loading={false}
error=""
pageType="frontPage"
/>
);
})
.add('Pidgin', () => {
const pidginFrontPageData = preprocess(pidginData, preprocessorRules);

const data = {
pageData: pidginFrontPageData,
status: 200,
};

return (
<FrontPage
data={data}
service="pidgin"
isAmp={false}
loading={false}
error=""
pageType="frontPage"
/>
const serviceDatasets = {
igbo: igboData,
yoruba: yorubaData,
pidgin: pidginData,
thai: thaiData,
EinsteinNjoroge marked this conversation as resolved.
Show resolved Hide resolved
punjabi: punjabiData,
};

const stories = storiesOf('Pages|Front Page', module);
Object.keys(serviceDatasets).forEach(service => {
EinsteinNjoroge marked this conversation as resolved.
Show resolved Hide resolved
stories.add(service, () => {
const frontPageData = preprocess(
serviceDatasets[service],
preprocessorRules,
);
})
.add('Thai', () => {
const thaiFrontPageData = preprocess(thaiData, preprocessorRules);

const data = {
pageData: thaiFrontPageData,
pageData: frontPageData,
status: 200,
};

return (
<FrontPage
data={data}
service="thai"
service={service}
isAmp={false}
loading={false}
error=""
error={null}
pageType="frontPage"
/>
);
});
});
39 changes: 39 additions & 0 deletions src/app/containers/FrontPageMain/index.stories.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import newsData from '../../../../data/news/frontpage';
import igboData from '../../../../data/igbo/frontpage';
import pidginData from '../../../../data/pidgin/frontpage';
import thaiData from '../../../../data/thai/frontpage';
import yorubaData from '../../../../data/yoruba/frontpage';
import punjabiData from '../../../../data/punjabi/frontpage';
import FrontPageMain from '.';
import { ServiceContextProvider } from '../../contexts/ServiceContext';
import { ToggleContextProvider } from '../../contexts/ToggleContext';
import { RequestContextProvider } from '../../contexts/RequestContext';

const serviceDataSets = {
news: newsData,
igbo: igboData,
yoruba: yorubaData,
pidgin: pidginData,
thai: thaiData,
punjabi: punjabiData,
};

const stories = storiesOf('Main|Front Page', module);

Object.keys(serviceDataSets).forEach(service => {
stories.add(`Front Page - ${service}`, () => (
<ToggleContextProvider>
<ServiceContextProvider service={service}>
<RequestContextProvider
isAmp={false}
pageType="frontPage"
service={service}
>
<FrontPageMain frontPageData={serviceDataSets[service]} />
</RequestContextProvider>
</ServiceContextProvider>
</ToggleContextProvider>
));
});