@times-components/ts-components 1.73.0 → 1.75.0
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.
- package/CHANGELOG.md +22 -0
- package/dist/components/opta/cricket/scorecard/OptaCricketScorecard.js +2 -2
- package/dist/components/opta/cricket/scorecard/OptaCricketScorecard.stories.js +6 -1
- package/dist/components/opta/cricket/scorecard/styles.js +128 -130
- package/dist/components/welcome-banner/WelcomeBanner.d.ts +2 -0
- package/dist/components/welcome-banner/WelcomeBanner.js +15 -0
- package/dist/components/welcome-banner/WelcomeBanner.stories.d.ts +1 -0
- package/dist/components/welcome-banner/WelcomeBanner.stories.js +8 -0
- package/dist/components/welcome-banner/__tests__/WelcomeBanner.test.d.ts +1 -0
- package/dist/components/welcome-banner/__tests__/WelcomeBanner.test.js +26 -0
- package/dist/components/welcome-banner/styles.d.ts +3 -0
- package/dist/components/welcome-banner/styles.js +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +11 -11
- package/rnw.js +1 -1
- package/src/components/opta/cricket/scorecard/OptaCricketScorecard.stories.tsx +7 -0
- package/src/components/opta/cricket/scorecard/OptaCricketScorecard.tsx +1 -1
- package/src/components/opta/cricket/scorecard/__tests__/__snapshots__/OptaCricketScorecard.test.tsx.snap +2 -2
- package/src/components/opta/cricket/scorecard/styles.ts +127 -129
- package/src/components/welcome-banner/WelcomeBanner.stories.tsx +12 -0
- package/src/components/welcome-banner/WelcomeBanner.tsx +23 -0
- package/src/components/welcome-banner/__tests__/WelcomeBanner.test.tsx +30 -0
- package/src/components/welcome-banner/styles.ts +26 -0
- package/src/index.ts +1 -0
|
@@ -18,6 +18,13 @@ const showcase = {
|
|
|
18
18
|
),
|
|
19
19
|
name: 'Scorecard',
|
|
20
20
|
type: 'story'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
component: () => (
|
|
24
|
+
<OptaCricketScorecard competition="3071" match="55391" />
|
|
25
|
+
),
|
|
26
|
+
name: 'Scorecard (1st inns)',
|
|
27
|
+
type: 'story'
|
|
21
28
|
}
|
|
22
29
|
],
|
|
23
30
|
name: 'Typescript Component/In Article/Cricket/Scorecard'
|
|
@@ -6,7 +6,7 @@ exports[`OptaCricketScorecard should render correctly 1`] = `
|
|
|
6
6
|
class="sc-bdVaJa giUBsz"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
|
-
class="sc-htpNat sc-bxivhb
|
|
9
|
+
class="sc-htpNat sc-bxivhb FnNeB"
|
|
10
10
|
/>
|
|
11
11
|
<div
|
|
12
12
|
class="sc-bwzfXH kVYHKf"
|
|
@@ -23,7 +23,7 @@ exports[`OptaCricketScorecard should render correctly 2`] = `
|
|
|
23
23
|
class="sc-bdVaJa hGXeaj"
|
|
24
24
|
>
|
|
25
25
|
<div
|
|
26
|
-
class="sc-htpNat sc-bxivhb
|
|
26
|
+
class="sc-htpNat sc-bxivhb FnNeB"
|
|
27
27
|
>
|
|
28
28
|
<div>
|
|
29
29
|
Widget
|
|
@@ -129,101 +129,155 @@ export const WidgetContainer = styled(WidgetContainerBase)`
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
-
.Opta-
|
|
133
|
-
|
|
134
|
-
margin-bottom: 10px;
|
|
132
|
+
table.Opta-batting {
|
|
133
|
+
margin-bottom: 10px;
|
|
135
134
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
135
|
+
thead {
|
|
136
|
+
th {
|
|
137
|
+
width: 8%;
|
|
138
|
+
padding: 0;
|
|
139
|
+
color: ${colours.functional.primary};
|
|
140
|
+
font-family: ${fonts.supporting};
|
|
141
|
+
font-size: 12px;
|
|
142
|
+
line-height: 14px;
|
|
143
|
+
font-weight: normal;
|
|
144
|
+
background-color: #ededed;
|
|
145
|
+
|
|
146
|
+
&:first-of-type {
|
|
147
|
+
width: 64%;
|
|
148
|
+
padding-left: 5px;
|
|
149
|
+
}
|
|
151
150
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
&:nth-of-type(4),
|
|
152
|
+
&:nth-of-type(5) {
|
|
153
|
+
width: 6%;
|
|
155
154
|
}
|
|
156
155
|
}
|
|
156
|
+
}
|
|
157
157
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
158
|
+
tfoot {
|
|
159
|
+
th {
|
|
160
|
+
color: ${colours.functional.brandColour};
|
|
161
|
+
font-family: ${fonts.supporting};
|
|
162
|
+
font-size: 14px;
|
|
163
|
+
line-height: 14px;
|
|
164
|
+
font-weight: bold;
|
|
165
|
+
background-color: #dbdbdb;
|
|
166
|
+
|
|
167
|
+
&:first-of-type {
|
|
168
|
+
padding-left: 5px;
|
|
169
|
+
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
171
|
+
&:last-of-type {
|
|
172
|
+
padding-left: 0;
|
|
174
173
|
}
|
|
175
174
|
}
|
|
175
|
+
}
|
|
176
176
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
177
|
+
tbody {
|
|
178
|
+
tr:nth-child(2n) th,
|
|
179
|
+
tr:nth-child(2n) td {
|
|
180
|
+
background-color: #ededed;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
tr:last-of-type td {
|
|
184
|
+
color: ${colours.functional.brandColour};
|
|
185
|
+
font-family: ${fonts.supporting};
|
|
186
|
+
font-size: 12px;
|
|
187
|
+
line-height: 14px;
|
|
188
|
+
font-weight: normal;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
th {
|
|
192
|
+
padding: 0;
|
|
193
|
+
color: ${colours.functional.brandColour};
|
|
194
|
+
font-family: ${fonts.supporting};
|
|
195
|
+
font-size: 12px;
|
|
196
|
+
line-height: 14px;
|
|
197
|
+
font-weight: bold;
|
|
198
|
+
}
|
|
182
199
|
|
|
183
|
-
|
|
200
|
+
td {
|
|
201
|
+
padding: 0;
|
|
202
|
+
color: ${colours.section.sport};
|
|
203
|
+
font-family: ${fonts.supporting};
|
|
204
|
+
font-size: 12px;
|
|
205
|
+
line-height: 14px;
|
|
206
|
+
font-weight: normal;
|
|
207
|
+
|
|
208
|
+
&:first-of-type,
|
|
209
|
+
&:nth-of-type(2) {
|
|
210
|
+
padding-left: 5px;
|
|
184
211
|
color: ${colours.functional.brandColour};
|
|
185
|
-
font-family: ${fonts.
|
|
186
|
-
font-size:
|
|
187
|
-
line-height: 14px;
|
|
212
|
+
font-family: ${fonts.headline};
|
|
213
|
+
font-size: 16px;
|
|
188
214
|
font-weight: normal;
|
|
215
|
+
line-height: 16px;
|
|
189
216
|
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
190
220
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
221
|
+
table.Opta-bowling {
|
|
222
|
+
width: calc(60% - 10px);
|
|
223
|
+
float: left;
|
|
224
|
+
|
|
225
|
+
thead {
|
|
226
|
+
th {
|
|
227
|
+
width: 12%;
|
|
228
|
+
color: ${colours.functional.brandColour};
|
|
229
|
+
font-family: ${fonts.supporting};
|
|
230
|
+
font-size: 12px;
|
|
231
|
+
line-height: 14px;
|
|
232
|
+
font-weight: normal;
|
|
233
|
+
text-align: center;
|
|
234
|
+
background-color: #ededed;
|
|
235
|
+
|
|
236
|
+
&:first-of-type {
|
|
237
|
+
width: 40%;
|
|
238
|
+
padding-left: 5px;
|
|
198
239
|
text-align: left;
|
|
199
240
|
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
200
243
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
244
|
+
tbody {
|
|
245
|
+
th {
|
|
246
|
+
padding: 0;
|
|
247
|
+
color: ${colours.functional.brandColour};
|
|
248
|
+
font-family: ${fonts.supporting};
|
|
249
|
+
font-size: 12px;
|
|
250
|
+
line-height: 14px;
|
|
251
|
+
font-weight: bold;
|
|
252
|
+
text-align: center;
|
|
253
|
+
}
|
|
209
254
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
255
|
+
td {
|
|
256
|
+
padding: 0;
|
|
257
|
+
color: ${colours.section.sport};
|
|
258
|
+
font-family: ${fonts.supporting};
|
|
259
|
+
font-size: 12px;
|
|
260
|
+
line-height: 14px;
|
|
261
|
+
font-weight: normal;
|
|
262
|
+
text-align: center;
|
|
263
|
+
|
|
264
|
+
&:first-of-type {
|
|
265
|
+
padding-left: 5px;
|
|
266
|
+
color: ${colours.functional.brandColour};
|
|
267
|
+
font-family: ${fonts.headline};
|
|
268
|
+
font-size: 16px;
|
|
269
|
+
font-weight: normal;
|
|
270
|
+
line-height: 16px;
|
|
271
|
+
text-align: left;
|
|
220
272
|
}
|
|
221
273
|
}
|
|
222
274
|
}
|
|
275
|
+
}
|
|
223
276
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
277
|
+
.Opta-Ranking {
|
|
278
|
+
table {
|
|
279
|
+
width: calc(40%);
|
|
280
|
+
float: right;
|
|
227
281
|
|
|
228
282
|
thead {
|
|
229
283
|
th {
|
|
@@ -274,62 +328,6 @@ export const WidgetContainer = styled(WidgetContainerBase)`
|
|
|
274
328
|
}
|
|
275
329
|
}
|
|
276
330
|
}
|
|
277
|
-
|
|
278
|
-
.Opta-Ranking {
|
|
279
|
-
table {
|
|
280
|
-
width: calc(30%);
|
|
281
|
-
float: right;
|
|
282
|
-
|
|
283
|
-
thead {
|
|
284
|
-
th {
|
|
285
|
-
color: ${colours.functional.brandColour};
|
|
286
|
-
font-family: ${fonts.supporting};
|
|
287
|
-
font-size: 12px;
|
|
288
|
-
line-height: 14px;
|
|
289
|
-
font-weight: normal;
|
|
290
|
-
text-align: center;
|
|
291
|
-
background-color: #ededed;
|
|
292
|
-
|
|
293
|
-
&:first-of-type {
|
|
294
|
-
padding-left: 5px;
|
|
295
|
-
text-align: left;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
tbody {
|
|
301
|
-
th {
|
|
302
|
-
padding: 0;
|
|
303
|
-
color: ${colours.functional.brandColour};
|
|
304
|
-
font-family: ${fonts.supporting};
|
|
305
|
-
font-size: 12px;
|
|
306
|
-
line-height: 14px;
|
|
307
|
-
font-weight: bold;
|
|
308
|
-
text-align: center;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
td {
|
|
312
|
-
padding: 0;
|
|
313
|
-
color: ${colours.section.sport};
|
|
314
|
-
font-family: ${fonts.supporting};
|
|
315
|
-
font-size: 12px;
|
|
316
|
-
line-height: 14px;
|
|
317
|
-
font-weight: normal;
|
|
318
|
-
text-align: center;
|
|
319
|
-
|
|
320
|
-
&:first-of-type {
|
|
321
|
-
padding-left: 5px;
|
|
322
|
-
color: ${colours.functional.brandColour};
|
|
323
|
-
font-family: ${fonts.headline};
|
|
324
|
-
font-size: 16px;
|
|
325
|
-
font-weight: normal;
|
|
326
|
-
line-height: 16px;
|
|
327
|
-
text-align: left;
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
331
|
}
|
|
334
332
|
}
|
|
335
333
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { storiesOf } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { WelcomeBanner } from './WelcomeBanner';
|
|
5
|
+
|
|
6
|
+
storiesOf('Typescript Component/Welcome Banner', module).add(
|
|
7
|
+
'Welcome Banner',
|
|
8
|
+
() => {
|
|
9
|
+
window.sessionStorage.setItem('showWelcomeBanner', 'true');
|
|
10
|
+
return <WelcomeBanner />;
|
|
11
|
+
}
|
|
12
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Container, Text, Title } from './styles';
|
|
4
|
+
|
|
5
|
+
export const WelcomeBanner: React.FC = () => {
|
|
6
|
+
const [isEnabled, setIsEnabled] = useState<boolean>(false);
|
|
7
|
+
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
if (window.sessionStorage.getItem('showWelcomeBanner')) {
|
|
10
|
+
window.sessionStorage.removeItem('showWelcomeBanner');
|
|
11
|
+
setIsEnabled(true);
|
|
12
|
+
}
|
|
13
|
+
}, []);
|
|
14
|
+
|
|
15
|
+
return isEnabled ? (
|
|
16
|
+
<Container>
|
|
17
|
+
<Title data-testId="title">
|
|
18
|
+
Welcome to The Times and The Sunday Times
|
|
19
|
+
</Title>
|
|
20
|
+
<Text data-testId="text">We hope you enjoy your free article</Text>
|
|
21
|
+
</Container>
|
|
22
|
+
) : null;
|
|
23
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { cleanup, render } from '@testing-library/react';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
|
|
5
|
+
import { WelcomeBanner } from '../WelcomeBanner';
|
|
6
|
+
|
|
7
|
+
describe('WelcomeBanner', () => {
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
cleanup();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should render the component if session storage token showWelcomeBanner is set to true', () => {
|
|
13
|
+
window.sessionStorage.setItem('showWelcomeBanner', 'true');
|
|
14
|
+
const { getByText } = render(<WelcomeBanner />);
|
|
15
|
+
expect(getByText('Welcome to The Times and The Sunday Times'));
|
|
16
|
+
expect(getByText('We hope you enjoy your free article'));
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('should not render the component if the session storage token showWelcomeBanner does not exist', () => {
|
|
20
|
+
const { queryByTestId } = render(<WelcomeBanner />);
|
|
21
|
+
expect(queryByTestId('title')).toBeFalsy();
|
|
22
|
+
expect(queryByTestId('text')).toBeFalsy();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should remove the showWelcomeBanner session storage token when the component is displayed', () => {
|
|
26
|
+
window.sessionStorage.setItem('showWelcomeBanner', 'true');
|
|
27
|
+
render(<WelcomeBanner />);
|
|
28
|
+
expect(window.sessionStorage.getItem('showWelcomeBanner')).toBeFalsy();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { colours, fonts } from '@times-components/ts-styleguide';
|
|
3
|
+
|
|
4
|
+
export const Container = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
width: 100%;
|
|
9
|
+
padding: 38px 33px 34px;
|
|
10
|
+
border: 1px solid ${colours.functional.primary};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const Title = styled.div`
|
|
14
|
+
font-family: ${fonts.headline};
|
|
15
|
+
font-size: 28px;
|
|
16
|
+
color: ${colours.functional.greyText};
|
|
17
|
+
text-align: center;
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
export const Text = styled.div`
|
|
21
|
+
font-family: ${fonts.supporting};
|
|
22
|
+
font-size: 18px;
|
|
23
|
+
color: ${colours.functional.primary};
|
|
24
|
+
padding-top: 9px;
|
|
25
|
+
text-align: center;
|
|
26
|
+
`;
|
package/src/index.ts
CHANGED
|
@@ -92,6 +92,7 @@ export {
|
|
|
92
92
|
|
|
93
93
|
export { UpdatedTimeProvider } from './helpers/time/UpdatedTimeProvider';
|
|
94
94
|
|
|
95
|
+
export { WelcomeBanner } from './components/welcome-banner/WelcomeBanner';
|
|
95
96
|
export {
|
|
96
97
|
default as safeDecodeURIComponent
|
|
97
98
|
} from './utils/safeDecodeURIComponent';
|