Skip to content

Commit 1f55dca

Browse files
authored
Merge pull request #14007 from bbc/WS-2581-Productionise-Head-To-Headv2
WS-2581 Productionise files in head-to-head-v2/ (root directory only)
2 parents c8e1b33 + edc509a commit 1f55dca

10 files changed

Lines changed: 98 additions & 108 deletions

File tree

src/app/components-webcore/SportDataHeader/head-to-head-v2/head-to-head-v2.jsx

Lines changed: 0 additions & 100 deletions
This file was deleted.

src/app/components-webcore/SportDataHeader/head-to-head-v2/head-to-head-v2.stories.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ interface ComponentProps {
7272
data: StoryData;
7373
isConciseView?: boolean;
7474
shouldShowActions?: boolean;
75-
maximumContainerScoreDigits?: string;
75+
maximumContainerScoreDigits?: number;
7676
teamBadgePlaceholderFallbackType?: 'badge' | 'flag';
7777
}
7878

@@ -88,7 +88,6 @@ const Component = ({
8888
teamBadgePlaceholderFallbackType = 'badge',
8989
}: ComponentProps) => {
9090
return (
91-
// @ts-expect-error - PS copy and paste
9291
<HeadToHeadV2
9392
data={data}
9493
isConciseView={isConciseView}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import Footer from './components/footer';
2+
import HeadToHeadHeader from './components/head-to-head-header';
3+
import { HeadToHeadBanner } from './components/head-to-head-banner';
4+
import { ConditionalOnwardJourneyLink } from './components/conditional-onward-journey-link';
5+
import { Actions } from './components/actions';
6+
import { HeadToHeadV2Data } from './types';
7+
import styles from './index.styles';
8+
9+
export const HeadToHeadV2 = ({
10+
data,
11+
isConciseView,
12+
shouldShowActions,
13+
maximumContainerScoreDigits,
14+
teamBadgePlaceholderFallbackType = 'badge',
15+
}: {
16+
data: HeadToHeadV2Data;
17+
isConciseView?: boolean;
18+
shouldShowActions?: boolean;
19+
maximumContainerScoreDigits?: number;
20+
teamBadgePlaceholderFallbackType?: 'badge' | 'flag';
21+
}) => {
22+
const hasActions =
23+
(data?.home?.actions?.length ?? 0) > 0 ||
24+
(data?.away?.actions?.length ?? 0) > 0;
25+
26+
// TODO: Re-enable badge visibility logic once we have the necessary badge mappings in place
27+
const shouldHideBadges = true;
28+
29+
return (
30+
<div css={styles.wrapper({ isConciseView })}>
31+
<ConditionalOnwardJourneyLink>
32+
<div css={styles.container({ isConciseView })}>
33+
{!isConciseView && (
34+
<HeadToHeadHeader
35+
date={data.date}
36+
status={data.status}
37+
tournamentDescriptionLabel={data.tournamentDescriptionLabel}
38+
/>
39+
)}
40+
<HeadToHeadBanner
41+
data={data}
42+
isConciseView={isConciseView}
43+
eventSummary={data.accessibleEventSummary}
44+
shouldHideBadges={shouldHideBadges}
45+
maxScoreLength={maximumContainerScoreDigits}
46+
teamBadgePlaceholderFallbackType={teamBadgePlaceholderFallbackType}
47+
/>
48+
{hasActions && shouldShowActions && <Actions data={data} />}
49+
{!isConciseView && <Actions data={data} />}
50+
{!isConciseView && (
51+
<Footer
52+
venue={data.venue?.name || 'To be confirmed'}
53+
status={data.status}
54+
attendanceValue={data.attendance?.value}
55+
attendanceInfo={data.attendance?.additionalInfo}
56+
/>
57+
)}
58+
</div>
59+
</ConditionalOnwardJourneyLink>
60+
</div>
61+
);
62+
};
63+
64+
export default HeadToHeadV2;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { css, Theme } from '@emotion/react';
2+
import pixelsToRem from '../../../utilities/pixelsToRem';
3+
4+
export default {
5+
wrapper:
6+
({ isConciseView }: { isConciseView?: boolean }) =>
7+
({ palette }: Theme) =>
8+
css({
9+
background: isConciseView ? palette.GREY_15 : palette.GREY_16,
10+
borderLeft: `medium none ${palette.LIVE_CORE}`,
11+
}),
12+
container:
13+
({ isConciseView }: { isConciseView?: boolean }) =>
14+
({ mq, palette }: Theme) =>
15+
css({
16+
fontFamily: 'ReithSans, Helvetica, Arial, freesans, sans-serif',
17+
fontWeight: 400,
18+
fontFeatureSettings: "'ss01' off",
19+
color: palette.LUNAR_LIGHT,
20+
padding: isConciseView ? '8px' : '0',
21+
...(!isConciseView && { paddingBottom: `${pixelsToRem(24)}rem` }),
22+
[mq.GROUP_2_MAX_WIDTH]: {
23+
paddingTop: isConciseView ? '8px' : '0',
24+
...(!isConciseView && { paddingBottom: `${pixelsToRem(8)}rem` }),
25+
},
26+
}),
27+
};

src/app/components-webcore/SportDataHeader/head-to-head-v2/index.js renamed to src/app/components-webcore/SportDataHeader/head-to-head-v2/index.ts

File renamed without changes.

src/app/components-webcore/SportDataHeader/head-to-head-v2/storybook/helpers/base-component.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export const HeadToHeadV2ConciseComponent = (args: StoryArgs) => {
101101
<HeadToHeadV2
102102
data={updatedStoryBookControls}
103103
isConciseView
104-
shouldHideBadges={false}
105104
shouldShowActions={false}
106105
/>
107106
);
@@ -159,7 +158,6 @@ export const HeadToHeadV2Component = (args: StoryArgs) => {
159158
<HeadToHeadV2
160159
data={updatedStoryBookControls}
161160
isConciseView={false}
162-
shouldHideBadges={false}
163161
shouldShowActions={false}
164162
/>
165163
);

src/app/components-webcore/SportDataHeader/head-to-head-v2/tests/index.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const renderHeadToHead = ({
4545
data={data}
4646
isConciseView={isConciseView}
4747
shouldShowActions={shouldShowActions}
48-
shouldHideBadges={false}
4948
/>,
5049
);
5150

src/app/components-webcore/SportDataHeader/head-to-head-v2/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,11 @@ export type HeadToHeadV2Data = {
137137
* Summary of event to be used with assistive technology.
138138
*/
139139
accessibleEventSummary: string;
140+
141+
attendance?: {
142+
value?: number;
143+
additionalInfo?: string;
144+
};
140145
};
141146

142147
export declare const HeadToHeadV2: (props: {
@@ -150,7 +155,7 @@ export declare const HeadToHeadV2: (props: {
150155
*
151156
* By default, the central section of H2Hv2 will expand as little as possible to fit the given score.
152157
*/
153-
maximumContainerScoreDigits?: string;
158+
maximumContainerScoreDigits?: number;
154159
/**
155160
* Optional setting for the sport badge's placeholder fallback type when a mapping doesn't exist for a team.
156161
*

ws-nextjs-app/pages/[service]/live/[id]/LivePageLayout.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ const LivePage = ({ pageData, assetId }: LivePageProps) => {
205205
<HeadToHeadV2
206206
data={sportData}
207207
isConciseView={false} // defaulted to false for developement/ MVP
208-
shouldHideBadges={false} // defaulted to false for developement/ MVP
209208
shouldShowActions={false} // defaulted to false for developement/ MVP
210209
/>
211210
)}

ws-nextjs-app/pages/[service]/live/[id]/live.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ describe('Live Page', () => {
624624

625625
const headToHeadElement = screen.getByTestId('head-to-head-v2');
626626
expect(headToHeadElement).toHaveAttribute('data-concise', 'false');
627-
expect(headToHeadElement).toHaveAttribute('data-hide-badges', 'false');
628627
expect(headToHeadElement).toHaveAttribute('data-show-actions', 'false');
629628
});
630629

0 commit comments

Comments
 (0)