Skip to content

Commit 2574276

Browse files
committed
refactored mini match stats into separate component
1 parent 207a3df commit 2574276

1 file changed

Lines changed: 42 additions & 33 deletions

File tree

dotcom-rendering/src/layouts/LiveLayout.tsx

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ export const LiveLayout = (props: WebProps | AppsProps) => {
395395
format={format}
396396
article={article}
397397
liveBlogAreaId={liveBlogAreaId}
398+
isCricketRedesignEnabled={isCricketRedesignEnabled}
398399
/>
399400

400401
{/* This element is used to replace the liveblog with the scorecard when the scorecard tab is clicked */}
@@ -699,33 +700,17 @@ export const LiveLayout = (props: WebProps | AppsProps) => {
699700
</Island>
700701
</Hide>
701702
)}
702-
703-
{/* Match stats */}
704-
{!!footballMatchStatsUrl && (
705-
<Island
706-
priority="feature"
707-
defer={{ until: 'visible' }}
708-
>
709-
<FootballMiniMatchStatsWrapper
710-
matchStatsUrl={
711-
footballMatchStatsUrl
712-
}
713-
/>
714-
</Island>
715-
)}
716-
{!!cricketMatchStatsUrl &&
717-
isCricketRedesignEnabled && (
718-
<Island
719-
priority="feature"
720-
defer={{ until: 'visible' }}
721-
>
722-
<CricketMiniMatchStatsWrapper
723-
matchStatsUrl={
724-
cricketMatchStatsUrl
725-
}
726-
/>
727-
</Island>
728-
)}
703+
<MiniMatchStats
704+
footballMatchStatsUrl={
705+
footballMatchStatsUrl
706+
}
707+
cricketMatchStatsUrl={
708+
cricketMatchStatsUrl
709+
}
710+
isCricketRedesignEnabled={
711+
isCricketRedesignEnabled
712+
}
713+
/>
729714
</GridItem>
730715
<GridItem area="body">
731716
<div
@@ -1153,11 +1138,40 @@ export const LiveLayout = (props: WebProps | AppsProps) => {
11531138
);
11541139
};
11551140

1141+
const MiniMatchStats = (props: {
1142+
footballMatchStatsUrl: string | undefined;
1143+
cricketMatchStatsUrl: string | undefined;
1144+
isCricketRedesignEnabled: boolean;
1145+
}) => {
1146+
if (props.footballMatchStatsUrl) {
1147+
return (
1148+
<Island priority="feature" defer={{ until: 'visible' }}>
1149+
<FootballMiniMatchStatsWrapper
1150+
matchStatsUrl={props.footballMatchStatsUrl}
1151+
/>
1152+
</Island>
1153+
);
1154+
}
1155+
1156+
if (props.cricketMatchStatsUrl && props.isCricketRedesignEnabled) {
1157+
return (
1158+
<Island priority="feature" defer={{ until: 'visible' }}>
1159+
<CricketMiniMatchStatsWrapper
1160+
matchStatsUrl={props.cricketMatchStatsUrl}
1161+
/>
1162+
</Island>
1163+
);
1164+
}
1165+
1166+
return null;
1167+
};
1168+
11561169
const Header = (props: {
11571170
renderingTarget: RenderingTarget;
11581171
format: ArticleFormat;
11591172
article: ArticleDeprecated;
11601173
liveBlogAreaId: string;
1174+
isCricketRedesignEnabled: boolean;
11611175
}) => {
11621176
const footballMatchLeagueName = props.article.sectionLabel;
11631177
const footballMatchLeagueUrl = `${props.article.guardianBaseURL}/${props.article.sectionUrl}`;
@@ -1170,11 +1184,6 @@ const Header = (props: {
11701184
? props.article.matchHeaderUrl
11711185
: undefined;
11721186

1173-
const ab = useAB();
1174-
const isCricketRedesignEnabled = Boolean(
1175-
ab?.isUserInTestGroup('webx-cricket-redesign', 'enable'),
1176-
);
1177-
11781187
const isApps = props.renderingTarget === 'Apps';
11791188

11801189
if (footballMatchHeaderUrl) {
@@ -1202,7 +1211,7 @@ const Header = (props: {
12021211
);
12031212
}
12041213

1205-
if (!isApps && cricketMatchHeaderUrl && isCricketRedesignEnabled) {
1214+
if (!isApps && cricketMatchHeaderUrl && props.isCricketRedesignEnabled) {
12061215
return (
12071216
<>
12081217
<noscript>

0 commit comments

Comments
 (0)