@times-components/ts-components 1.35.1 → 1.35.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/components/article-flag/ArticleFlag.js +2 -2
  3. package/dist/components/article-flag/styles.js +2 -2
  4. package/dist/components/article-header/styles.js +2 -2
  5. package/dist/components/carousel/styles.js +2 -2
  6. package/dist/components/common-styles.js +2 -2
  7. package/dist/components/in-article-big-numbers/styles.js +2 -2
  8. package/dist/components/in-article-info-card/InfoCard.js +2 -2
  9. package/dist/components/in-article-info-card/styles.js +2 -2
  10. package/dist/components/in-article-info-card-bulletpoints/InfoCardBulletPoints.js +2 -2
  11. package/dist/components/in-article-info-card-bulletpoints/styles.js +2 -2
  12. package/dist/components/in-article-link/styles.js +2 -2
  13. package/dist/components/in-article-puff/styles.js +2 -2
  14. package/dist/components/in-article-related-articles/InArticleRelatedArticles.stories.js +3 -2
  15. package/dist/components/in-article-related-articles/SingleRelatedArticle.styles.js +2 -2
  16. package/dist/components/in-article-related-articles/styles.js +2 -2
  17. package/dist/components/in-article-timelines/styles.js +2 -2
  18. package/dist/components/inline-dialog/styles.js +2 -2
  19. package/dist/components/inline-message/styles.js +2 -2
  20. package/dist/components/newsletter-puff/NewsletterPuffLink.js +2 -2
  21. package/dist/components/newsletter-puff/styles.js +2 -2
  22. package/dist/components/olympics/medal-table/styles.js +3 -3
  23. package/dist/components/olympics/schedule/styles.js +2 -2
  24. package/dist/components/olympics/shared-styles.js +2 -2
  25. package/dist/components/opta/football/fixtures/styles.js +2 -2
  26. package/dist/components/opta/football/match-stats/styles.js +2 -2
  27. package/dist/components/opta/football/shared-styles.js +2 -2
  28. package/dist/components/opta/football/standings/styles.js +2 -2
  29. package/dist/components/opta/football/summary/styles.js +2 -2
  30. package/dist/components/opta/rugby/fixtures/styles.js +2 -2
  31. package/dist/components/opta/rugby/match-stats/styles.js +2 -2
  32. package/dist/components/opta/rugby/shared-styles.js +2 -2
  33. package/dist/components/opta/rugby/standings/styles.js +2 -2
  34. package/dist/components/opta/rugby/summary/styles.js +2 -2
  35. package/dist/components/related-article-slice/styles.js +2 -2
  36. package/dist/components/updated-timestamp/styles.js +2 -2
  37. package/dist/fixtures/article-harness/styles.js +2 -2
  38. package/dist/index.d.ts +0 -1
  39. package/dist/index.js +1 -3
  40. package/package.json +13 -13
  41. package/rnw.js +1 -1
  42. package/src/components/article-flag/ArticleFlag.tsx +1 -1
  43. package/src/components/article-flag/styles.ts +1 -1
  44. package/src/components/article-header/styles.ts +1 -1
  45. package/src/components/carousel/styles.ts +1 -1
  46. package/src/components/common-styles.ts +1 -1
  47. package/src/components/in-article-big-numbers/styles.ts +1 -1
  48. package/src/components/in-article-info-card/InfoCard.tsx +1 -1
  49. package/src/components/in-article-info-card/styles.ts +1 -1
  50. package/src/components/in-article-info-card-bulletpoints/InfoCardBulletPoints.tsx +1 -1
  51. package/src/components/in-article-info-card-bulletpoints/styles.ts +1 -1
  52. package/src/components/in-article-link/styles.ts +1 -1
  53. package/src/components/in-article-puff/styles.ts +1 -1
  54. package/src/components/in-article-related-articles/InArticleRelatedArticles.stories.tsx +2 -1
  55. package/src/components/in-article-related-articles/SingleRelatedArticle.styles.ts +1 -1
  56. package/src/components/in-article-related-articles/styles.ts +1 -1
  57. package/src/components/in-article-timelines/styles.ts +1 -1
  58. package/src/components/inline-dialog/styles.ts +1 -1
  59. package/src/components/inline-message/styles.ts +1 -1
  60. package/src/components/newsletter-puff/NewsletterPuffLink.tsx +1 -1
  61. package/src/components/newsletter-puff/styles.ts +1 -1
  62. package/src/components/olympics/__tests__/__snapshots__/OlympicsMedalTable.test.tsx.snap +4 -0
  63. package/src/components/olympics/medal-table/styles.ts +2 -2
  64. package/src/components/olympics/schedule/styles.ts +1 -1
  65. package/src/components/olympics/shared-styles.ts +1 -1
  66. package/src/components/opta/football/fixtures/styles.ts +1 -1
  67. package/src/components/opta/football/match-stats/styles.ts +1 -1
  68. package/src/components/opta/football/shared-styles.ts +1 -1
  69. package/src/components/opta/football/standings/styles.ts +1 -1
  70. package/src/components/opta/football/summary/styles.ts +1 -1
  71. package/src/components/opta/rugby/fixtures/styles.ts +1 -1
  72. package/src/components/opta/rugby/match-stats/styles.ts +1 -1
  73. package/src/components/opta/rugby/shared-styles.ts +1 -1
  74. package/src/components/opta/rugby/standings/styles.ts +1 -1
  75. package/src/components/opta/rugby/summary/styles.ts +1 -1
  76. package/src/components/related-article-slice/styles.ts +1 -1
  77. package/src/components/updated-timestamp/styles.ts +1 -1
  78. package/src/fixtures/article-harness/styles.ts +1 -1
  79. package/src/index.ts +0 -22
  80. package/src/types/externs.d.ts +69 -39
  81. package/dist/components/styleguide/Styleguide.d.ts +0 -193
  82. package/dist/components/styleguide/Styleguide.js +0 -24
  83. package/dist/components/styleguide/__tests__/breakpoints.test.d.ts +0 -1
  84. package/dist/components/styleguide/__tests__/breakpoints.test.js +0 -46
  85. package/dist/components/styleguide/__tests__/styleguide.test.d.ts +0 -1
  86. package/dist/components/styleguide/__tests__/styleguide.test.js +0 -48
  87. package/dist/components/styleguide/__tests__/themeFactory.test.d.ts +0 -1
  88. package/dist/components/styleguide/__tests__/themeFactory.test.js +0 -41
  89. package/dist/components/styleguide/breakpoints.d.ts +0 -37
  90. package/dist/components/styleguide/breakpoints.js +0 -42
  91. package/dist/components/styleguide/colours/colours.d.ts +0 -103
  92. package/dist/components/styleguide/colours/colours.js +0 -8
  93. package/dist/components/styleguide/colours/functional.d.ts +0 -32
  94. package/dist/components/styleguide/colours/functional.js +0 -33
  95. package/dist/components/styleguide/colours/section.d.ts +0 -68
  96. package/dist/components/styleguide/colours/section.js +0 -78
  97. package/dist/components/styleguide/components/Animations.d.ts +0 -6
  98. package/dist/components/styleguide/components/Animations.js +0 -19
  99. package/dist/components/styleguide/components/TcText.d.ts +0 -6
  100. package/dist/components/styleguide/components/TcText.js +0 -22
  101. package/dist/components/styleguide/components/TcView.d.ts +0 -6
  102. package/dist/components/styleguide/components/TcView.js +0 -21
  103. package/dist/components/styleguide/components/index.d.ts +0 -4
  104. package/dist/components/styleguide/components/index.js +0 -5
  105. package/dist/components/styleguide/fonts/font-factory.d.ts +0 -10
  106. package/dist/components/styleguide/fonts/font-factory.js +0 -12
  107. package/dist/components/styleguide/fonts/font-sizes.d.ts +0 -47
  108. package/dist/components/styleguide/fonts/font-sizes.js +0 -47
  109. package/dist/components/styleguide/fonts/font-styles.d.ts +0 -13
  110. package/dist/components/styleguide/fonts/font-styles.js +0 -13
  111. package/dist/components/styleguide/fonts/fonts.d.ts +0 -4
  112. package/dist/components/styleguide/fonts/fonts.js +0 -5
  113. package/dist/components/styleguide/helpers/storybookStyles.d.ts +0 -2
  114. package/dist/components/styleguide/helpers/storybookStyles.js +0 -54
  115. package/dist/components/styleguide/lineHeight.d.ts +0 -7
  116. package/dist/components/styleguide/lineHeight.js +0 -65
  117. package/dist/components/styleguide/scales.d.ts +0 -6
  118. package/dist/components/styleguide/scales.js +0 -6
  119. package/dist/components/styleguide/spacing.d.ts +0 -11
  120. package/dist/components/styleguide/spacing.js +0 -17
  121. package/dist/components/styleguide/styleguide.stories.d.ts +0 -1
  122. package/dist/components/styleguide/styleguide.stories.js +0 -71
  123. package/dist/components/styleguide/themeFactory.d.ts +0 -8
  124. package/dist/components/styleguide/themeFactory.js +0 -59
  125. package/src/components/styleguide/Styleguide.tsx +0 -54
  126. package/src/components/styleguide/__tests__/breakpoints.test.ts +0 -67
  127. package/src/components/styleguide/__tests__/styleguide.test.tsx +0 -68
  128. package/src/components/styleguide/__tests__/themeFactory.test.ts +0 -44
  129. package/src/components/styleguide/breakpoints.tsx +0 -52
  130. package/src/components/styleguide/colours/colours.tsx +0 -8
  131. package/src/components/styleguide/colours/functional.tsx +0 -32
  132. package/src/components/styleguide/colours/section.tsx +0 -81
  133. package/src/components/styleguide/components/Animations.tsx +0 -22
  134. package/src/components/styleguide/components/TcText.tsx +0 -32
  135. package/src/components/styleguide/components/TcView.tsx +0 -27
  136. package/src/components/styleguide/components/index.tsx +0 -5
  137. package/src/components/styleguide/fonts/font-factory.tsx +0 -18
  138. package/src/components/styleguide/fonts/font-sizes.tsx +0 -46
  139. package/src/components/styleguide/fonts/font-styles.tsx +0 -12
  140. package/src/components/styleguide/fonts/fonts.tsx +0 -5
  141. package/src/components/styleguide/helpers/storybookStyles.ts +0 -55
  142. package/src/components/styleguide/lineHeight.tsx +0 -73
  143. package/src/components/styleguide/scales.tsx +0 -5
  144. package/src/components/styleguide/spacing.tsx +0 -19
  145. package/src/components/styleguide/styleguide.stories.tsx +0 -143
  146. package/src/components/styleguide/themeFactory.tsx +0 -82
@@ -1,18 +0,0 @@
1
- import styleguide from '../Styleguide';
2
- import { timesFontSizes, fontStyles } from './fonts';
3
- import lineHeight from '../lineHeight';
4
-
5
- export default ({
6
- font,
7
- fontSize
8
- }: {
9
- font: keyof typeof fontStyles;
10
- fontSize: keyof typeof timesFontSizes;
11
- }) => {
12
- const styles = styleguide();
13
- return {
14
- fontFamily: styles.fonts[font],
15
- fontSize: timesFontSizes[fontSize],
16
- lineHeight: lineHeight({ font, fontSize })
17
- };
18
- };
@@ -1,46 +0,0 @@
1
- export default {
2
- articleHeadline: 45,
3
- articleMeta: 15,
4
- body: 18,
5
- bodyMobile: 17,
6
- button: 16,
7
- caption: 13,
8
- cardHeadline: 27,
9
- cardMeta: 13,
10
- cardMetaMobile: 12,
11
- commentsGuidelines: 13,
12
- commentsHeadline: 27,
13
- credits: 9,
14
- headline: 30,
15
- imageOverlayTextSmall: 11,
16
- infoTitle: 22,
17
- keyFactsTitle: 24,
18
- leadHeadline: 26,
19
- link: 13,
20
- meta: 14,
21
- newsletterPuffLabel: 12,
22
- newsletterPuffHeadline: 28,
23
- newsletterPuffCopy: 15,
24
- pageComponentHeadline: 25,
25
- pageHeadline: 40,
26
- pageHeadlineLarge: 50,
27
- pagingMeta: 15,
28
- puffLink: 11,
29
- secondary: 16,
30
- sliceHeadline: 32,
31
- smallestHeadline: 20,
32
- smallHeadline: 22,
33
- strapline: 22,
34
- teaser: 14,
35
- tertiary: 15,
36
- tileLeadHeadline: 35,
37
- heading2Mobile: 25,
38
- heading3Mobile: 22,
39
- heading4Mobile: 19,
40
- heading5Mobile: 17,
41
- infoSubText: 18,
42
- heading2: 28,
43
- heading3: 24,
44
- heading4: 20,
45
- heading5: 19
46
- };
@@ -1,12 +0,0 @@
1
- export default {
2
- body: 'TimesDigitalW04',
3
- bodyRegular: 'TimesDigitalW04-Regular',
4
- bodyRegularSmallCaps: 'TimesDigitalW04-RegularSC',
5
- cultureMagazine: 'Flama-Bold',
6
- dropCap: 'TimesModern-Regular',
7
- headline: 'TimesModern-Bold',
8
- headlineRegular: 'TimesModern-Regular',
9
- stMagazine: 'Tiempos-Headline-Bold',
10
- styleMagazine: 'CenturyGothic-Bold',
11
- supporting: 'GillSansMTStd-Medium'
12
- };
@@ -1,5 +0,0 @@
1
- import fontStyles from './font-styles';
2
- import timesFontFactory from './font-factory';
3
- import timesFontSizes from './font-sizes';
4
-
5
- export { fontStyles, timesFontSizes, timesFontFactory };
@@ -1,55 +0,0 @@
1
- import { fonts } from '../Styleguide';
2
- import { timesFontSizes as fontSizes } from '../fonts/fonts';
3
-
4
- const styles: Record<string, Record<string, number | string>> = {
5
- animationBox: {
6
- backgroundColor: '#CCCCCC',
7
- margin: 50,
8
- padding: 100
9
- },
10
- box: {
11
- height: 100,
12
- marginBottom: 10
13
- },
14
- container: {
15
- borderColor: '#DBDBDB',
16
- borderWidth: 1,
17
- margin: 20,
18
- paddingBottom: 10,
19
- width: 250
20
- },
21
- display: {
22
- flexDirection: 'row',
23
- flexWrap: 'wrap'
24
- },
25
- headline: {
26
- fontSize: fontSizes.body,
27
- fontWeight: 'bold',
28
- marginBottom: 10
29
- },
30
- showoffFonts: {
31
- fontSize: fontSizes.headline,
32
- marginBottom: 20,
33
- marginLeft: 20,
34
- marginTop: 10
35
- },
36
- showoffFontsContainer: {
37
- borderBottomColor: '#CCCCCC',
38
- borderBottomWidth: 1,
39
- margin: 20
40
- },
41
- subHeadline: {
42
- fontSize: fontSizes.meta,
43
- fontWeight: 'bold',
44
- marginLeft: 10,
45
- marginTop: 10
46
- },
47
- text: {
48
- color: '#333333',
49
- fontFamily: fonts.body,
50
- fontSize: fontSizes.caption,
51
- textAlign: 'center'
52
- }
53
- };
54
-
55
- export default styles;
@@ -1,73 +0,0 @@
1
- const mapping: Record<string, Record<string, {}>> = {
2
- body: {
3
- bodyMobile: 30,
4
- puffLink: 15,
5
- secondary: 27,
6
- teaser: 20,
7
- tertiary: 26
8
- },
9
- bodyRegular: {
10
- infoSubText: 23,
11
- infoTitle: 30,
12
- pageComponentHeadline: 25
13
- },
14
- bodyRegularSmallCaps: {
15
- cardMetaMobile: 12,
16
- meta: 14
17
- },
18
- cultureMagazine: {
19
- headline: 35,
20
- pageHeadline: 42
21
- },
22
- headline: {
23
- articleHeadline: 45,
24
- commentsHeadline: 29,
25
- headline: 33,
26
- infoTitle: 22,
27
- leadHeadline: 26,
28
- pageComponentHeadline: 27,
29
- pageHeadline: 40,
30
- smallHeadline: 27,
31
- tileLeadHeadline: 35,
32
- heading2Mobile: 26,
33
- heading3Mobile: 26,
34
- heading4Mobile: 26,
35
- heading5Mobile: 26
36
- },
37
- headlineRegular: {
38
- pageComponentHeadline: 30,
39
- smallestHeadline: 26,
40
- strapline: 24
41
- },
42
- stMagazine: {
43
- headline: 35,
44
- pageHeadline: 42
45
- },
46
- styleMagazine: {
47
- headline: 35,
48
- pageHeadline: 42
49
- },
50
- supporting: {
51
- button: 16,
52
- caption: 13,
53
- cardMeta: 15,
54
- cardMetaMobile: 14,
55
- keyFactsTitle: 18,
56
- link: 13,
57
- meta: 14,
58
- pagingMeta: 15,
59
- tertiary: 17
60
- }
61
- };
62
-
63
- type ValueOf<T> = T[keyof T];
64
-
65
- export default ({
66
- font,
67
- fontSize
68
- }: {
69
- font: keyof typeof mapping;
70
- fontSize: keyof ValueOf<typeof mapping>;
71
- }) => {
72
- return mapping[font][fontSize];
73
- };
@@ -1,5 +0,0 @@
1
- export default Object.freeze({
2
- large: 'large',
3
- medium: 'medium',
4
- xlarge: 'xlarge'
5
- });
@@ -1,19 +0,0 @@
1
- const spacingBase = 5;
2
-
3
- const spacing = (multiple: number) => {
4
- return spacingBase * multiple;
5
- };
6
-
7
- const globalSpacingStyles = {
8
- tabletHeadline: {
9
- marginBottom: spacingBase * 1
10
- },
11
- tabletTeaser: {
12
- marginTop: spacingBase * 1
13
- }
14
- };
15
-
16
- export default (multiple: number) => {
17
- return `${spacing(multiple)}px`;
18
- };
19
- export { globalSpacingStyles };
@@ -1,143 +0,0 @@
1
- import React, { Fragment } from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { TcScrollView } from '@times-components/utils';
4
- import { TcText, TcView } from './components';
5
-
6
- import timesStyleguide, { Animations, colours, fonts } from './Styleguide';
7
- import styles from './helpers/storybookStyles';
8
-
9
- const getStories = (colourMap: Record<string, string>) => {
10
- const colourBoxes = Object.keys(colourMap).map(colourName => (
11
- <TcView style={styles.container}>
12
- <TcView
13
- style={{ ...styles.box, backgroundColor: colourMap[colourName] }}
14
- />
15
- <TcText style={styles.text}>
16
- {colourName} - {colourMap[colourName]}
17
- </TcText>
18
- </TcView>
19
- ));
20
-
21
- return <TcView style={styles.display}>{colourBoxes}</TcView>;
22
- };
23
-
24
- const fontDisplayer = (
25
- fontFamily: string,
26
- phrase: any,
27
- fontSizes: Record<string, number>
28
- ) =>
29
- Object.keys(fontSizes).map(fontSize => (
30
- <Fragment key={fontSize}>
31
- <TcText style={styles.subHeadline}>{fontSize}</TcText>
32
- <TcText
33
- style={{
34
- ...styles.showoffFonts,
35
- fontFamily,
36
- fontSize: fontSizes[fontSize]
37
- }}
38
- >
39
- {phrase}
40
- </TcText>
41
- </Fragment>
42
- ));
43
-
44
- const fontFixture = () => {
45
- const styleguide = timesStyleguide();
46
- const phrase = 'The Quick Brown Fox Jumps Over the Lazy Dog';
47
- return (
48
- <TcScrollView>
49
- <TcView style={styles.showoffFontsContainer}>
50
- <TcText style={styles.headline}>Body</TcText>
51
- {fontDisplayer(fonts.body, phrase, styleguide.fontSizes)}
52
- </TcView>
53
- <TcView style={styles.showoffFontsContainer}>
54
- <TcText style={styles.headline}>Body Regular</TcText>
55
- <TcText>
56
- Used for the body copy of articles or as the teaser copy on article
57
- links.
58
- </TcText>
59
- {fontDisplayer(fonts.bodyRegular, phrase, styleguide.fontSizes)}
60
- </TcView>
61
- <TcView style={styles.showoffFontsContainer}>
62
- <TcText style={styles.headline}>Body Regular Small Caps</TcText>
63
- <TcText>
64
- Always used as a lowercase font, it is typically used to support the
65
- headline font. It’s used in various different places e.g. Journalist
66
- pages for the Journalist job title, article flags and show more
67
- buttons on the homepage.
68
- </TcText>
69
- {fontDisplayer(
70
- fonts.bodyRegularSmallCaps,
71
- phrase.toLowerCase(),
72
- styleguide.fontSizes
73
- )}
74
- </TcView>
75
- <TcView style={styles.showoffFontsContainer}>
76
- <TcText style={styles.headline}>Headline</TcText>
77
- <TcText>
78
- Used as the headline for components and articles across the site.
79
- </TcText>
80
- {fontDisplayer(fonts.headline, phrase, styleguide.fontSizes)}
81
- </TcView>
82
- <TcView style={styles.showoffFontsContainer}>
83
- <TcText style={styles.headline}>Headline Regular</TcText>
84
- <TcText>
85
- Used primarily to style subheadings for components and stand firsts on
86
- the homepage and articles.
87
- </TcText>
88
- {fontDisplayer(fonts.headlineRegular, phrase, styleguide.fontSizes)}
89
- </TcView>
90
- <TcView style={styles.showoffFontsContainer}>
91
- <TcText style={styles.headline}>Supporting</TcText>
92
- <TcText>
93
- Used as a supporting typeface in a variety of places including
94
- messaging banners, buttons, links, homepage labels and tags.
95
- </TcText>
96
- {fontDisplayer(fonts.supporting, phrase, styleguide.fontSizes)}
97
- </TcView>
98
- <TcView style={styles.showoffFontsContainer}>
99
- <TcText style={styles.headline}>
100
- Style Magazine (Century Gothic Bold)
101
- </TcText>
102
- <TcText>
103
- Used for theme specific headlines, drop caps and pull-quotes in the
104
- Style magazine
105
- </TcText>
106
- {fontDisplayer(fonts.styleMagazine, phrase, styleguide.fontSizes)}
107
- </TcView>
108
- <TcView style={styles.showoffFontsContainer}>
109
- <TcText style={styles.headline}>Culture Magazine (Flama Bold)</TcText>
110
- <TcText>
111
- Used for theme specific headlines, drop caps and pull-quotes in the
112
- Culture magazine
113
- </TcText>
114
- {fontDisplayer(fonts.cultureMagazine, phrase, styleguide.fontSizes)}
115
- </TcView>
116
- <TcView style={styles.showoffFontsContainer}>
117
- <TcText style={styles.headline}>
118
- Sunday Times Magazine (Tiempos Headline Bold)
119
- </TcText>
120
- <TcText>
121
- Used for theme specific headlines, drop caps and pull-quotes in the
122
- Sunday Times Magazine
123
- </TcText>
124
- {fontDisplayer(fonts.stMagazine, phrase, styleguide.fontSizes)}
125
- </TcView>
126
- </TcScrollView>
127
- );
128
- };
129
-
130
- storiesOf('Typescript Component/styleguide', module)
131
- .add('Fonts', () => fontFixture())
132
- .add('Animations', () => (
133
- <Animations.FadeIn>
134
- <TcView style={styles.animationBox}>
135
- <TcText style={styles.text}>Fade In</TcText>
136
- </TcView>
137
- </Animations.FadeIn>
138
- ))
139
- .add('Section Colours', () => getStories(colours.section))
140
- .add('Functional colours', () => getStories(colours.functional))
141
- .add('Secondary Section Colours', () =>
142
- getStories(colours.secondarySectionColours)
143
- );
@@ -1,82 +0,0 @@
1
- import { sectionColours, secondarySectionColours } from './colours/section';
2
-
3
- const sectionColourPickerConfig: Record<string, Record<string, string>> = {
4
- indepth: {},
5
- magazinecomment: {
6
- ...sectionColours,
7
- ...secondarySectionColours
8
- },
9
- magazinestandard: {
10
- ...sectionColours,
11
- ...secondarySectionColours
12
- },
13
- maincomment: {
14
- ...sectionColours
15
- },
16
- mainstandard: {
17
- ...sectionColours
18
- },
19
- takeoverpage: {}
20
- };
21
-
22
- const magazineSections: Record<string, string> = {
23
- culture: 'cultureMagazine',
24
- Culture: 'cultureMagazine',
25
- style: 'styleMagazine',
26
- Style: 'styleMagazine',
27
- 'The Sunday Times Magazine': 'stMagazine',
28
- thesundaytimesmagazine: 'stMagazine',
29
- 'the sunday times magazine': 'stMagazine'
30
- };
31
-
32
- const magazineSectionsConfig: Record<string, Record<string, string>> = {
33
- indepth: magazineSections,
34
- magazinecomment: magazineSections,
35
- magazinestandard: magazineSections,
36
- maincomment: {},
37
- mainstandard: {},
38
- takeoverpage: {}
39
- };
40
-
41
- type ValueOf<T> = T[keyof T];
42
-
43
- const sectionColourPicker = (
44
- section: keyof ValueOf<typeof sectionColourPickerConfig>,
45
- template: keyof typeof sectionColourPickerConfig
46
- ) => {
47
- return sectionColourPickerConfig[template][section];
48
- };
49
-
50
- const magazineFontPicker = (
51
- defaultFont: string,
52
- section: keyof ValueOf<typeof sectionColourPickerConfig>,
53
- template: keyof typeof magazineSectionsConfig
54
- ) => {
55
- return magazineSectionsConfig[template][section] || defaultFont;
56
- };
57
-
58
- const headlineCasePicker = (
59
- section: keyof typeof magazineSectionsConfig,
60
- template: keyof typeof magazineSectionsConfig
61
- ) =>
62
- section &&
63
- section.toLowerCase() === 'style' &&
64
- ['indepth', 'magazinestandard', 'magazinecomment'].includes(template)
65
- ? 'uppercase'
66
- : null;
67
-
68
- export default (
69
- sectionParam?: keyof typeof magazineSectionsConfig,
70
- templateParam?: keyof typeof magazineSectionsConfig
71
- ) => {
72
- const section = sectionParam || 'default';
73
- const template = templateParam || 'mainstandard';
74
-
75
- return {
76
- dropCapFont: magazineFontPicker('dropCap', section, template),
77
- headlineFont: magazineFontPicker('headline', section, template),
78
- pullQuoteFont: magazineFontPicker('headlineRegular', section, template),
79
- sectionColour: sectionColourPicker(section, template),
80
- headlineCase: headlineCasePicker(section, template)
81
- };
82
- };