Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions src/app/legacy/containers/Navigation/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
import useClickTrackerHandler from '#app/hooks/useClickTrackerHandler';
import useViewTracker from '#app/hooks/useViewTracker';
import { RequestContext } from '#contexts/RequestContext';
import isLiveTVNavItem from '#lib/utilities/navigation/isLiveTVNavItem';
import LanguageNavigation from './LanguageNavigation/lazy';
import { ServiceContext } from '../../../contexts/ServiceContext';
import Canonical from './index.canonical';
Expand All @@ -22,6 +23,7 @@ const renderListItems = (
activeIndex,
clickTracker,
viewTracker,
liveTVChannelIdentifier,
isLite,
) =>
navigation.reduce((listAcc, item, index) => {
Expand All @@ -30,6 +32,11 @@ const renderListItems = (

if (hideOnLiteSite && isLite) return listAcc;

const showLivePulse = isLiveTVNavItem({
navItemUrl: url,
liveTVChannelIdentifier,
});

const listItem = (
<Li
key={title}
Expand All @@ -41,6 +48,7 @@ const renderListItems = (
dir={dir}
clickTracker={clickTracker}
viewTracker={viewTracker}
showLivePulse={showLivePulse}
>
{title}
</Li>
Expand All @@ -59,6 +67,7 @@ const NavigationContainer = ({ propsForTopBarOJComponent }) => {
service,
dir,
collapsibleNavigation,
liveTVChannelIdentifier,
} = use(ServiceContext);

const { canonicalLink, origin } = use(RequestContext);
Expand Down Expand Up @@ -112,6 +121,7 @@ const NavigationContainer = ({ propsForTopBarOJComponent }) => {
activeIndex,
scrollableNavClickTrackerHandler,
scrollableNavViewTracker,
liveTVChannelIdentifier,
isLite,
)}
</NavigationUl>
Expand All @@ -129,6 +139,7 @@ const NavigationContainer = ({ propsForTopBarOJComponent }) => {
activeIndex,
dropdownNavClickTrackerHandler,
dropdownNavViewTracker,
liveTVChannelIdentifier,
)}
</DropdownUl>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
GEL_GROUP_3_SCREEN_WIDTH_MIN,
GEL_GROUP_B_MIN_WIDTH,
} from '#psammead/gel-foundations/src/breakpoints';
import Pulse from '#app/components/LivePulse';
import VisuallyHiddenText from '../../../../../components/VisuallyHiddenText';

export const NAV_BAR_TOP_BOTTOM_SPACING = 0.75; // 12px
Expand Down Expand Up @@ -116,13 +117,21 @@ export const DropdownLi = ({
url,
dir = 'ltr',
viewTracker = null,
showLivePulse = null,
}) => {
const ariaId = `dropdownNavigation-${children
.replace(/\s+/g, '-')
.toLowerCase()}`;
return (
// aria-labelledby is a temporary fix for the a11y nested span's bug experienced in TalkBack, refer to the following issue: https://github.com/bbc/simorgh/issues/9652
<StyledDropdownLi role="listitem" {...viewTracker}>
{showLivePulse && (
<Pulse
width="18"
height="18"
style={{ verticalAlign: 'middle', marginInlineEnd: '0.25em' }}
/>
)}
<StyledDropdownLink
script={script}
service={service}
Expand Down
9 changes: 9 additions & 0 deletions src/app/legacy/psammead/psammead-navigation/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
GEL_GROUP_3_SCREEN_WIDTH_MAX,
GEL_GROUP_5_SCREEN_WIDTH_MIN,
} from '#psammead/gel-foundations/src/breakpoints';
import Pulse from '#app/components/LivePulse';
import { NAV_BAR_TOP_BOTTOM_SPACING } from './DropdownNavigation';
import { focusIndicatorThickness } from '../../../../components/ThemeProvider/focusIndicator';
import VisuallyHiddenText from '../../../../components/VisuallyHiddenText';
Expand Down Expand Up @@ -163,10 +164,18 @@ export const NavigationLi = ({
service,
dir = 'ltr',
viewTracker = null,
showLivePulse = false,
...props
}) => {
return (
<StyledListItem dir={dir} role="listitem" {...viewTracker}>
{showLivePulse && (
<Pulse
width="18"
height="18"
style={{ verticalAlign: 'middle', marginInlineEnd: '0.25em' }}
/>
)}
{active && currentPageText ? (
<StyledLink
href={url}
Expand Down
1 change: 1 addition & 0 deletions src/app/lib/config/services/arabic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ export const service: DefaultServiceConfig = {
'بي بي سي. بي بي سي ليست مسؤولة عن محتوى المواقع الخارجية.',
},
timezone: 'GMT',
liveTVChannelIdentifier: '/arabic/media-49522519',
navigation: [
{
title: 'رئيسية',
Expand Down
63 changes: 63 additions & 0 deletions src/app/lib/utilities/navigation/isLiveTVNavItem.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import isLiveTVNavItem from './isLiveTVNavItem';

describe('isLiveTVNavItem', () => {
it('returns true when navItemUrl matches liveTVChannelIdentifier', () => {
expect(
isLiveTVNavItem({
navItemUrl: '/arabic/media-49522519',
liveTVChannelIdentifier: '/arabic/media-49522519',
}),
).toBe(true);
});

it('returns false when navItemUrl does not match liveTVChannelIdentifier', () => {
expect(
isLiveTVNavItem({
navItemUrl: '/arabic/media-49522519',
liveTVChannelIdentifier: '/arabic/media-12345678',
}),
).toBe(false);
});

it('returns false when liveTVChannelIdentifier is falsy', () => {
expect(
isLiveTVNavItem({
navItemUrl: '/arabic/media-49522519',
liveTVChannelIdentifier: '',
}),
).toBe(false);
expect(
isLiveTVNavItem({
navItemUrl: '/arabic/media-49522519',
liveTVChannelIdentifier: null,
}),
).toBe(false);
expect(
isLiveTVNavItem({
navItemUrl: '/arabic/media-49522519',
liveTVChannelIdentifier: undefined,
}),
).toBe(false);
});

it('returns false when navItemUrl is falsy', () => {
expect(
isLiveTVNavItem({
navItemUrl: '',
liveTVChannelIdentifier: '/arabic/media-49522519',
}),
).toBe(false);
expect(
isLiveTVNavItem({
navItemUrl: null,
liveTVChannelIdentifier: '/arabic/media-49522519',
}),
).toBe(false);
expect(
isLiveTVNavItem({
navItemUrl: undefined,
liveTVChannelIdentifier: '/arabic/media-49522519',
}),
).toBe(false);
});
});
12 changes: 12 additions & 0 deletions src/app/lib/utilities/navigation/isLiveTVNavItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export interface IsLiveTVNavItemArgs {
navItemUrl: string | null | undefined;
liveTVChannelIdentifier: string | null | undefined;
}

const isLiveTVNavItem = ({
navItemUrl,
liveTVChannelIdentifier,
}: IsLiveTVNavItemArgs): boolean =>
Boolean(liveTVChannelIdentifier) && navItemUrl === liveTVChannelIdentifier;

export default isLiveTVNavItem;
1 change: 1 addition & 0 deletions src/app/models/types/serviceConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export type ServiceConfig = {
recommendations?: Recommendations;
footer: Footer;
collapsibleNavigation?: CollapsibleNavigationSection[];
liveTVChannelIdentifier?: string;
navigation?: {
title: string;
url: string;
Expand Down
Loading