This repository has been archived by the owner on Aug 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
preview.js
117 lines (110 loc) · 3.74 KB
/
preview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import React, { Fragment } from 'react';
import { configure, addDecorator, addParameters } from '@storybook/react';
import { create } from '@storybook/theming';
import { withA11y } from '@storybook/addon-a11y';
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks';
import {
AMP_SCRIPT,
AMP_NO_SCRIPT,
} from '@bbc/psammead-assets/amp-boilerplate';
import * as fontFaces from '@bbc/psammead-styles/fonts';
import { themes } from '@bbc/psammead-storybook-helpers';
import GlobalStyles from '@bbc/psammead-styles/global-styles';
import './storybook.css';
// New locales
import '@bbc/psammead-locales/moment/am';
import '@bbc/psammead-locales/moment/ha';
import '@bbc/psammead-locales/moment/ig';
import '@bbc/psammead-locales/moment/om';
import '@bbc/psammead-locales/moment/pcm';
import '@bbc/psammead-locales/moment/ps';
import '@bbc/psammead-locales/moment/rw';
import '@bbc/psammead-locales/moment/so';
import '@bbc/psammead-locales/moment/ti';
// Updated locales
import '@bbc/psammead-locales/moment/ar';
import '@bbc/psammead-locales/moment/az';
import '@bbc/psammead-locales/moment/bn';
import '@bbc/psammead-locales/moment/es';
import '@bbc/psammead-locales/moment/gu';
import '@bbc/psammead-locales/moment/hi';
import '@bbc/psammead-locales/moment/ky';
import '@bbc/psammead-locales/moment/mr';
import '@bbc/psammead-locales/moment/ne';
import '@bbc/psammead-locales/moment/pa-in';
import '@bbc/psammead-locales/moment/pt-br';
import '@bbc/psammead-locales/moment/ru';
import '@bbc/psammead-locales/moment/si';
import '@bbc/psammead-locales/moment/sr';
import '@bbc/psammead-locales/moment/sr-cyrl';
import '@bbc/psammead-locales/moment/sw';
import '@bbc/psammead-locales/moment/ta';
import '@bbc/psammead-locales/moment/th';
import '@bbc/psammead-locales/moment/uk';
import '@bbc/psammead-locales/moment/ur';
import '@bbc/psammead-locales/moment/uz';
import '@bbc/psammead-locales/moment/yo';
import { Helmet } from 'react-helmet';
export const parameters = {
passArgsFirst: false,
options: {
panelPosition: 'right',
sidebarAnimations: true,
theme: themes.light,
},
a11y: {
options: {
runOnly: {
type: 'tag',
values: ['wcag2a', 'wcag2aa', 'wcag21aa'],
},
iframes: true,
},
},
docs: {
container: DocsContainer,
page: DocsPage,
extractComponentDescription: (component, { notes }) => {
if (notes) {
return typeof notes === 'string' ? notes : notes.markdown || notes.text;
}
return null;
},
},
};
const fontPathMap = [
{ prefix: 'F_REITH', path: 'fonts/Reith/' },
{ prefix: 'F_ISKOOLA_POTA_BBC', path: 'fonts/IskoolaPota/' },
{ prefix: 'F_LATHA', path: 'fonts/Latha/' },
{ prefix: 'F_MALLANNA', path: 'fonts/Mallanna/' },
{ prefix: 'F_NOTO_SANS_ETHIOPIC', path: 'fonts/NotoSansEthiopic/' },
{ prefix: 'F_PADAUK', path: 'fonts/Padauk/' },
{ prefix: 'F_SHONAR_BANGLA', path: 'fonts/ShonarBangla/' },
{ prefix: 'F_QALAM', path: 'fonts/ReithQalam/' },
];
addDecorator(story => (
<Fragment>
<GlobalStyles
fonts={Object.values(fontFaces).map(fontFace => {
const fontMap =
fontPathMap.find(map => fontFace.name.includes(map.prefix)) ||
fontPathMap[0];
return fontFace(fontMap.path);
})}
/>
{story()}
</Fragment>
));
export const ampDecorator = story => (
<Fragment>
<Helmet htmlAttributes={{ amp: '' }}>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,minimum-scale=1" />
<link rel="canonical" href="https://bbc.com" />
<style amp-boilerplate="">{AMP_SCRIPT}</style>
<noscript>{`<style amp-boilerplate="">${AMP_NO_SCRIPT}</style>`}</noscript>
<script async src="https://cdn.ampproject.org/v0.js" />
</Helmet>
{story()}
</Fragment>
);