Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wsteama 1522 header investigation incorporating ojs into nav #12282

Draft
wants to merge 22 commits into
base: latest
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ac13f6c
top stories showing on page
LilyL0u Dec 28, 2024
184d4e8
most read data in component and OJ is complementary aside
LilyL0u Dec 28, 2024
63035bc
fix broken other scrollable promo
LilyL0u Dec 28, 2024
f6ae1e3
use switch case
LilyL0u Dec 28, 2024
212bb01
do not show on PGLs or TC2s
LilyL0u Dec 28, 2024
6a1fcd5
do not show component over 1007px
LilyL0u Dec 28, 2024
613642b
storybook components and fixture data for storybook
LilyL0u Dec 28, 2024
f7df9cd
ariaLabelledBy must be different from other most read or top stories …
LilyL0u Dec 29, 2024
5bac80c
snapshots and check for presence of most read data before trying to a…
LilyL0u Dec 29, 2024
c1260da
translations for titles
LilyL0u Dec 29, 2024
c51eb0b
add fallback title for if no translations
LilyL0u Dec 29, 2024
81e5bc6
scrollable promo tests
LilyL0u Dec 29, 2024
102c169
snapshots with translation
LilyL0u Dec 29, 2024
37004c5
some top stories do not have same headline structure
LilyL0u Dec 30, 2024
79ba241
comments on getting variant from optimizely
LilyL0u Dec 30, 2024
c602b5c
renames, refactors
LilyL0u Dec 30, 2024
f0dfaea
else if needed or title fall through
LilyL0u Dec 30, 2024
7a287c7
default value for pathOr in proper place
LilyL0u Dec 30, 2024
f525490
add hyphen to title so it isn't the same as other oj component
LilyL0u Dec 30, 2024
4d01e13
check for presence of any oj data needed before rendering
LilyL0u Dec 31, 2024
42f60b8
check nothing has broken with control variant none
LilyL0u Dec 31, 2024
00bc7de
WSTEAMA-1531-oj-top-bar-in-nav-list-spike
LilyL0u Jan 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions src/app/components/PageLayoutWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import pathOr from 'ramda/src/pathOr';

import GlobalStyles from '#psammead/psammead-styles/src/global-styles';
import { PageTypes } from '#app/models/types/global';
// import useOptimizelyVariation from '#app/hooks/useOptimizelyVariation';
import WebVitals from '../../legacy/containers/WebVitals';
import HeaderContainer from '../../legacy/containers/Header';
import FooterContainer from '../../legacy/containers/Footer';
Expand All @@ -34,15 +35,11 @@ type Props = {
pageData: {
metadata: {
type: PageTypes;
topics?: [
{
topicName: string;
},
];
};
content?: {
model?: ModelType;
topics?: { topicName: string }[];
};
content?: { model?: ModelType };
secondaryColumn?: { topStories: any[] };
mostRead?: { items: any[] };
};
status: number;
};
Expand All @@ -56,7 +53,32 @@ const PageLayoutWrapper = ({
}: PropsWithChildren<Props>) => {
const { service } = useContext(ServiceContext);
const { isLite, isAmp } = useContext(RequestContext);
const topStories = pageData.secondaryColumn?.topStories;
const mostReadItems = pageData.mostRead?.items;

// const scrollableOJExperimentVariation = useOptimizelyVariation(
// 'oj_scroll',
// ) as unknown as string;
const variantValue = 'A'; // We would get this value from useOptimizelyVariation (as commented out above)
// so just manually switch the hardcoded variant for now while getting this working
const experimentVariant: 'A' | 'B' | 'none' = ['A', 'B'].includes(
variantValue,
)
? (variantValue as 'A' | 'B')
: 'none';
let dataForOJExperiment;
if (experimentVariant === 'A') {
dataForOJExperiment = topStories;
} else if (experimentVariant === 'B' && mostReadItems) {
dataForOJExperiment = mostReadItems;
}

const propsForOJExperiment = {
blocks: dataForOJExperiment || [],
experimentVariant,
};

console.log('mostReadItems', mostReadItems, 'topStories', topStories);
const scriptSwitchId = pathOr('', ['scriptSwitchId'], pageData);
const renderScriptSwitch = pathOr(true, ['renderScriptSwitch'], pageData);

Expand Down Expand Up @@ -209,6 +231,7 @@ const PageLayoutWrapper = ({
<HeaderContainer
scriptSwitchId={scriptSwitchId}
renderScriptSwitch={renderScriptSwitch}
propsForOJExperiment={propsForOJExperiment}
/>
<div css={styles.content}>{children}</div>
<FooterContainer />
Expand Down
81 changes: 56 additions & 25 deletions src/app/legacy/components/ScrollablePromo/Promo/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,35 +81,66 @@ const TimeStamp = styled(PromoTimestamp)`
color: ${({ theme }) => theme.isDarkUi && theme.palette.GREY_6};
`;

const Promo = ({ block, onClick }) => {
const Promo = ({ block, experimentVariant, onClick }) => {
const { script, service, serviceDatetimeLocale } = useContext(ServiceContext);
const textBlock = filterForBlockType(
pathOr({}, ['model', 'blocks'], block),
'text',
);
const aresLinkBlock = filterForBlockType(
pathOr({}, ['model', 'blocks'], block),
'aresLink',
);
const href = pathOr(
'',
['model', 'blocks', '0', 'model', 'blocks', '0', 'model', 'locator'],
textBlock,
);
const title = pathOr(
'',
['model', 'blocks', '0', 'model', 'blocks', '0', 'model', 'text'],
textBlock,
);
const timestamp = path(
['model', 'blocks', '0', 'model', 'timestamp'],
aresLinkBlock,
);
let title;
let href;
let textBlock;
let aresLinkBlock;
let timestamp;
switch (experimentVariant) {
case 'A':
title = pathOr(
block.headline || '',
[
'headlines',
'promoHeadline',
'blocks',
'0',
'model',
'blocks',
'0',
'model',
'text',
],
block,
);
href = pathOr('', ['locators', 'canonicalUrl'], block);
break;
case 'B':
title = block.title;
href = block.href;
break;
default:
textBlock = filterForBlockType(
pathOr({}, ['model', 'blocks'], block),
'text',
);
aresLinkBlock = filterForBlockType(
pathOr({}, ['model', 'blocks'], block),
'aresLink',
);
timestamp = path(
['model', 'blocks', '0', 'model', 'timestamp'],
aresLinkBlock,
);
href = pathOr(
'',
['model', 'blocks', '0', 'model', 'blocks', '0', 'model', 'locator'],
textBlock,
);
title = pathOr(
'',
['model', 'blocks', '0', 'model', 'blocks', '0', 'model', 'text'],
textBlock,
);
break;
}
console.log('title', title, 'href', href, 'timestamp', timestamp);

const isOperaMini = useOperaMiniDetection();

const WrapperPromoBox = isOperaMini ? OperaPromoBox : PromoBox;

return (
<WrapperPromoBox>
<StyledLink
Expand All @@ -120,7 +151,7 @@ const Promo = ({ block, onClick }) => {
>
{title}
</StyledLink>
{timestamp && (
{timestamp && !experimentVariant && (
<TimeStamp serviceDatetimeLocale={serviceDatetimeLocale}>
{timestamp}
</TimeStamp>
Expand Down
14 changes: 11 additions & 3 deletions src/app/legacy/components/ScrollablePromo/PromoList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Promo from '../Promo';

const StandardScrollPromo = styled.ul`
list-style: none;
border: 1px solid red;
${({ dir }) => `padding-${dir === 'ltr' ? 'left' : 'right'}: 0;`}
margin: 0;
display: flex;
Expand All @@ -40,6 +41,7 @@ const OperaScrollPromo = styled.ul`
const StyledList = styled.li`
display: flex;
flex-shrink: 0;
border: 1px, solid, red;

${({ dir }) =>
`
Expand Down Expand Up @@ -79,10 +81,12 @@ const OperaStyledList = styled.li`
margin-${dir === 'ltr' ? `left` : `right`}: 0;}`}
`;

const PromoList = ({ blocks, viewTracker, onClick }) => {
const PromoList = ({ blocks, experimentVariant, viewTracker, onClick }) => {
console.log('in promo list', blocks, experimentVariant);
const { dir } = useContext(ServiceContext);
const isOperaMini = useOperaMiniDetection();
const listBlocks = blocks.slice(0, 3);
const listBlocks =
experimentVariant === 'B' ? blocks.slice(0, 5) : blocks.slice(0, 3);

const ScrollPromo = isOperaMini ? OperaScrollPromo : StandardScrollPromo;
const List = isOperaMini ? OperaStyledList : StyledList;
Expand All @@ -97,7 +101,11 @@ const PromoList = ({ blocks, viewTracker, onClick }) => {
return (
// eslint-disable-next-line react/no-array-index-key
<List key={index} dir={dir}>
<Promo block={block} onClick={onClick} />
<Promo
block={block}
experimentVariant={experimentVariant}
onClick={onClick}
/>
</List>
);
})}
Expand Down
Loading
Loading