Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
55af5d4
refactor: getSansRegular, getSansBold, getSerifMedium to theme fontVa…
elvinasv Jun 30, 2025
581cfb2
refactor: remaining psammead font variant migration
elvinasv Jun 30, 2025
c26b531
refactor: font size migrations
elvinasv Jul 2, 2025
19a3284
Merge branch 'latest' into WS-550-use-theme-font-variants-for-legacy-…
elvinasv Jul 2, 2025
0d8a198
Merge branch 'latest' of github.com:bbc/simorgh into WS-550-use-theme…
karinathomasbbc Oct 9, 2025
bbeca36
Typography & font cleanup
karinathomasbbc Oct 9, 2025
8a5ea2f
Remove references of script & service as parameters if no longer requ…
karinathomasbbc Oct 10, 2025
4c25e72
Fix tests
karinathomasbbc Oct 10, 2025
2242e55
Remove references of script & service as parameters if no longer requ…
karinathomasbbc Oct 10, 2025
e33e967
Remove unused imports
karinathomasbbc Oct 10, 2025
637cee9
Merge branch 'latest' of github.com:bbc/simorgh into WS-550-use-theme…
karinathomasbbc Oct 16, 2025
6b2893b
Revert "Remove references of script & service as parameters if no lon…
karinathomasbbc Oct 18, 2025
ad38bd2
Remove references to script
karinathomasbbc Oct 18, 2025
b7d21ac
Further cleanup
karinathomasbbc Oct 18, 2025
2d49e5c
Further cleanup of imported scripts
karinathomasbbc Oct 18, 2025
ebd34c3
Fix test
karinathomasbbc Oct 18, 2025
598efbd
Revert refactor
karinathomasbbc Oct 18, 2025
13fef24
Move fontWeight to above fontStyle to determine how many snapshot tes…
karinathomasbbc Oct 18, 2025
df304c3
Bump bundle size
karinathomasbbc Oct 18, 2025
a03fdc4
Bump bundle size
karinathomasbbc Oct 18, 2025
583aa4d
Reorder snapshots
karinathomasbbc Oct 18, 2025
2b47687
Update all snapshots
karinathomasbbc Oct 18, 2025
8f55709
Merge branch 'test-failing-snaps-font-weight-order' into WS-550-use-t…
karinathomasbbc Oct 18, 2025
7a8e10a
Update snaps
karinathomasbbc Oct 18, 2025
0f9f684
Reinstate psammead-bulletin
karinathomasbbc Oct 18, 2025
430d188
Reinstate correct snapshots
karinathomasbbc Oct 18, 2025
f58cc28
Merge branch 'test-failing-snaps-font-weight-order' into WS-550-use-t…
karinathomasbbc Oct 18, 2025
a3579da
More updated snaps
karinathomasbbc Oct 18, 2025
ec13dda
Update NextJS snapshots
karinathomasbbc Oct 18, 2025
38fb89d
Merge branch 'test-failing-snaps-font-weight-order' into WS-550-use-t…
karinathomasbbc Oct 18, 2025
97ba52a
Fix bundle size
karinathomasbbc Oct 18, 2025
0b7e5b3
Update snaps
karinathomasbbc Oct 18, 2025
c5ba890
Update next snaps
karinathomasbbc Oct 18, 2025
8b0539c
Merge branch 'test-failing-snaps-font-weight-order' into WS-550-use-t…
karinathomasbbc Oct 18, 2025
6c0d6b1
Delete unused imports
karinathomasbbc Oct 18, 2025
925e354
Delete ContextProviders as they are no longer required (since service…
karinathomasbbc Oct 18, 2025
0bf4f6e
Fix tests
karinathomasbbc Oct 18, 2025
d14d875
Fix tests & update snapshots
karinathomasbbc Oct 18, 2025
6897a0d
Fix TS issue
karinathomasbbc Oct 18, 2025
aa18399
Remove comment
karinathomasbbc Oct 18, 2025
34e19d9
Set service for each test
karinathomasbbc Oct 18, 2025
eddf384
Remove script service params
karinathomasbbc Oct 19, 2025
7db10ae
Remove script service params
karinathomasbbc Oct 19, 2025
493d3fc
Merge branch 'latest' of github.com:bbc/simorgh into WS-550-use-theme…
karinathomasbbc Oct 19, 2025
0b998f4
Merge branch 'test-failing-snaps-font-weight-order' of github.com:bbc…
karinathomasbbc Oct 19, 2025
17a15f0
Revert change
karinathomasbbc Oct 19, 2025
6012246
Bump bundle size
karinathomasbbc Oct 19, 2025
daf9aa4
Merge branch 'WS-550-use-theme-font-variants-for-legacy-psammead-comp…
karinathomasbbc Oct 19, 2025
6cab9f9
Add semi-colon to the end of the font size / variant styled components
karinathomasbbc Oct 19, 2025
3224e28
Add semi-colon to the end of the font size / variant styled components
karinathomasbbc Oct 19, 2025
7c1c2d7
Pass service as a parameter to the `render` function to ensure that i…
karinathomasbbc Oct 19, 2025
56647c8
Pass service as a parameter to the `render` function to ensure that i…
karinathomasbbc Oct 19, 2025
7a152b8
Pass service as a parameter to the `render` function to ensure that i…
karinathomasbbc Oct 19, 2025
3c6071b
Merge branch 'test-failing-snaps-font-weight-order' of github.com:bbc…
karinathomasbbc Oct 20, 2025
2d047ef
Pass service as a parameter to the `render` function to ensure that i…
karinathomasbbc Oct 20, 2025
0de8de9
Update snapshots again
karinathomasbbc Oct 20, 2025
db9438b
Fix tests
karinathomasbbc Oct 20, 2025
57c8746
Merge branch 'latest' of github.com:bbc/simorgh into WS-550-use-theme…
karinathomasbbc Oct 20, 2025
1f8871e
Revert "Move fontWeight to above fontStyle to determine how many snap…
karinathomasbbc Oct 20, 2025
4de4e6b
Update snapshots
karinathomasbbc Oct 20, 2025
b3f64fd
Fix test & update snapshot
karinathomasbbc Oct 20, 2025
5761b41
Merge branch 'test-failing-snaps-font-weight-order' of github.com:bbc…
karinathomasbbc Oct 20, 2025
b4fa5a9
Fix tests & update snapshots
karinathomasbbc Oct 20, 2025
dccc011
Remove extra ;
karinathomasbbc Oct 20, 2025
90cb6c1
Delete unused imports
karinathomasbbc Oct 20, 2025
6914bad
Merge branch 'test-failing-snaps-font-weight-order' into WS-550-use-t…
karinathomasbbc Oct 28, 2025
757cb7e
Update snapshots
karinathomasbbc Oct 28, 2025
fabe31a
Merge branch 'WS-550-use-theme-font-variants-for-legacy-psammead-comp…
karinathomasbbc Nov 6, 2025
e4a2e55
Add test case for dari
karinathomasbbc Nov 6, 2025
647e05e
Update snaps
karinathomasbbc Nov 6, 2025
f71949a
Update snaps
karinathomasbbc Nov 6, 2025
c8a93b5
Merge branch 'latest' of github.com:bbc/simorgh into WS-550-use-theme…
karinathomasbbc Nov 6, 2025
3b7905f
Merge branch 'WS-550-use-theme-font-variants-for-legacy-psammead-comp…
karinathomasbbc Nov 6, 2025
0800c96
Update snaps
karinathomasbbc Nov 6, 2025
6b8f645
Fix test
karinathomasbbc Nov 6, 2025
0980c93
Adjust bundle size
karinathomasbbc Nov 6, 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
66 changes: 7 additions & 59 deletions docs/Coding-Standards/Migrating-Legacy-Components.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ import {
GEL_GROUP_5_SCREEN_WIDTH_MIN,
GEL_GROUP_0_SCREEN_WIDTH_MAX,
} from '../../src/app/legacy/psammead/gel-foundations/src/breakpoints';
import * as spacings from '../../src/app/components/ThemeProvider/spacings'
import {MARGIN_BELOW_400PX, MARGIN_ABOVE_400PX, GUTTER_BELOW_600PX, GUTTER_ABOVE_600PX} from '../../src/app/components/ThemeProvider/spacings'
import * as spacings from '../../src/app/components/ThemeProvider/spacings';
import {
MARGIN_BELOW_400PX,
MARGIN_ABOVE_400PX,
GUTTER_BELOW_600PX,
GUTTER_ABOVE_600PX,
} from '../../src/app/components/ThemeProvider/spacings';

<Meta title="Coding Standards/Migrating Legacy Components" />

Expand Down Expand Up @@ -166,63 +171,6 @@ import styles from './index.styles';
<a css={styles.link} href={href}>Link Text Here</a>
```

## Migrating `fontVariants` and `fontSizes`

### Before

`script` and `service` were passed as props to the styled component, and used to determine the font size based on script , and the font variant, based on `service`.

**(index.jsx)**

```jsx
const StyledLink = styled.a`
/* Font Size */
${({ script }) => script && getCanon(script)}
/* Font Variant */
${({ service }) => getSerifMedium(service)}
...otherProps
`;
```

### After

**(index.styles.ts)**

```jsx

import { css, Theme } from '@emotion/react';

const styles = {
link: ({ fontSizes, fontVariants }: Theme) => css({
...fontSizes.canon,
...fontVariants.serifMedium
...otherProps
}),
};

export const styles;
```

### Font Sizes Mappings

<Markdown>
{`
| Before | After |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------- |
| \`${({ script }) => script && getCanon(script)}\` <br /> **OR** <br />\`${({ script }) => getCanon(script)}\` <br /> **OR** <br /> \`${() => getCanon(script)}\` | \`...fontSizes.canon\` |
`}
</Markdown>

### Font Variants Mappings

<Markdown>
{`
| Before | After |
| ----------------------------------------------------------------------------------------------------- | ----------------------------- |
| \`${({ service }) => getSerifMedium(service)}\` <br /> **OR** <br /> \`${() => getSerifMedium(service)}\` | \`...fontVariants.serifMedium\` |
`}
</Markdown>

## Migrating Media Queries

### Before
Expand Down
4 changes: 2 additions & 2 deletions scripts/bundleSize/bundleSizeConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@

export const VARIANCE = 5;

export const MIN_SIZE = 916;
export const MAX_SIZE = 1257;
export const MIN_SIZE = 905;
export const MAX_SIZE = 1245;
2 changes: 0 additions & 2 deletions src/app/components/Ad/Amp/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { HOME_PAGE } from '#app/routes/utils/pageTypes';
import AmpAd, { AMP_ACCESS_FETCH } from './index';
import { render } from '../../react-testing-library-with-providers';
import { ServiceContext } from '../../../contexts/ServiceContext';
import latinDiacritics from '../../ThemeProvider/fontScripts/latinWithDiacritics';
import { SlotType } from '../types';

const adJsonAttributes = (slotType: SlotType) => ({
Expand Down Expand Up @@ -34,7 +33,6 @@ const adWithContext = (slotType: SlotType, showAdPlaceholder = false) => (
value={{
service: 'afrique',
dir: 'ltr',
script: latinDiacritics,
// @ts-expect-error partial data required for testing
translations: adTranslations,
showAdPlaceholder,
Expand Down
2 changes: 0 additions & 2 deletions src/app/components/Ad/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { ToggleContext } from '#contexts/ToggleContext';
import { HOME_PAGE } from '#app/routes/utils/pageTypes';
import { Helmet } from 'react-helmet';
import { render } from '../react-testing-library-with-providers';
import latinDiacritics from '../ThemeProvider/fontScripts/latinWithDiacritics';
import {
ServiceContext,
ServiceContextProvider,
Expand All @@ -14,7 +13,6 @@ import AdContainer from './index';

const context = {
service: 'mundo',
script: latinDiacritics,
dir: 'ltr',
translations: {
ads: {
Expand Down
4 changes: 0 additions & 4 deletions src/app/components/Caption/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { OptimoBlock } from '#app/models/types/optimo';
import { ServiceContext } from '#app/contexts/ServiceContext';
import { ServiceConfig } from '#app/models/types/serviceConfig';
import CaptionContainer from '.';
import latin from '../ThemeProvider/fontScripts/latin';
import arabic from '../ThemeProvider/fontScripts/arabic';
import { render } from '../react-testing-library-with-providers';
import captionBlock, {
captionBlock3Paragraphs,
Expand All @@ -15,14 +13,12 @@ const newsServiceContextStub = {
imageCaptionOffscreenText: 'Image caption, ',
videoCaptionOffscreenText: 'Video caption, ',
defaultCaptionOffscreenText: 'Caption, ',
script: latin,
service: 'news',
};
const persianServiceContextStub = {
imageCaptionOffscreenText: ' ، عنوان تصویر',
videoCaptionOffscreenText: ' ، عنوان ویدئو',
defaultCaptionOffscreenText: ' ، عنوان',
script: arabic,
service: 'persian',
};

Expand Down
24 changes: 10 additions & 14 deletions src/app/components/LiveLabel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ The `LiveLabel` applied compound component implements a span for use on live con

## Props

| Argument | Type | Required | Default | Example |
| ----------------- | ------- | -------- | --------- | ----------------------- |
| offScreenText | string | no | `null` | `'Watch Live'` |
| lang | string | no | `'en-GB'` | `'en-GB'` |
| id | string | no | `null` | `'live-promo-1'` |
| children | node | no | `null` | `<span>Headline</span>` |
| Argument | Type | Required | Default | Example |
| ------------- | ------ | -------- | --------- | ----------------------- |
| offScreenText | string | no | `null` | `'Watch Live'` |
| lang | string | no | `'en-GB'` | `'en-GB'` |
| id | string | no | `null` | `'live-promo-1'` |
| children | node | no | `null` | `<span>Headline</span>` |

## Usage

Expand All @@ -20,13 +20,10 @@ This example shows the default usage of the `LiveLabel` component, passing in th
```jsx
import LiveLabel from '#app/components/LiveLabel';
import { Headline, Link } from '#psammead/psammead-story-promo/src';
import latin from '../../../components/ThemeProvider/fontScripts/latin';

<Headline script={latin} service="pidgin">
<Headline>
<Link href="https://www.bbc.com/pidgin/live/1234567890">
<LiveLabel>
The headline of the live promo
</LiveLabel>
<LiveLabel>The headline of the live promo</LiveLabel>
</Link>
</Headline>;
```
Expand All @@ -35,11 +32,10 @@ import latin from '../../../components/ThemeProvider/fontScripts/latin';

The `LiveLabel` component can be used to show a promo for a Live page.


### Accessibility notes

The `LiveLabel` component retrieves the translation of the word or phrase for "Live" for the specified service. If the translation for "Live" is in English e.g. "LIVE", then screenreaders will often read this as "live", rhyming with "give", which is incorrect. In order for the word "live" to be pronounced correctly, the offscreen (or visually hidden) text needs to be in lower case e.g. "Live" (rhyming with "hive"), which most screenreaders _can_ pronounce correctly.
The `LiveLabel` component retrieves the translation of the word or phrase for "Live" for the specified service. If the translation for "Live" is in English e.g. "LIVE", then screenreaders will often read this as "live", rhyming with "give", which is incorrect. In order for the word "live" to be pronounced correctly, the offscreen (or visually hidden) text needs to be in lower case e.g. "Live" (rhyming with "hive"), which most screenreaders _can_ pronounce correctly.

It is possible for alternative offscreen text to be provided to the `LiveLabel` component. In this case, and in the case above, whereby the label that is displayed is not exactly the same as the text which is read out to the screenreader, then the word or phrase for "LIVE" will be `aria-hidden` making it invisible to the screenreader. The alternate offscreen text will be visually hidden, but will be announced by the screenreader instead.

If the `children` prop is provided to the `LiveLabel` component, then a comma and a space (", ") will be inserted into the offscreen text, which results in the screenreader pausing briefly after announcing the word or phrase for "Live".
If the `children` prop is provided to the `LiveLabel` component, then a comma and a space (", ") will be inserted into the offscreen text, which results in the screenreader pausing briefly after announcing the word or phrase for "Live".
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { render } from '../../../react-testing-library-with-providers';
import latin from '../../../ThemeProvider/fontScripts/latin';
import LastUpdated from '.';

describe('MostReadCanonical - LastUpdated', () => {
Expand All @@ -9,8 +8,6 @@ describe('MostReadCanonical - LastUpdated', () => {
<LastUpdated
timestamp={864691200}
prefix="Last Updated:"
script={latin}
service="news"
locale="en-gb"
timezone="Europe/London"
/>,
Expand Down
8 changes: 0 additions & 8 deletions src/app/components/MostRead/Canonical/LastUpdated/index.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import React from 'react';
import Timestamp from '../../../../legacy/psammead/psammead-timestamp-container/src';
import { Services } from '../../../../models/types/global';
import { TypographyScript } from '../../../../models/types/theming';

interface LastUpdatedProps {
locale: string;
prefix: string;
script: TypographyScript;
service: Services;
timestamp: number | string;
timezone: string;
}

const LastUpdated = ({
locale,
prefix,
script,
service,
timestamp,
timezone,
}: LastUpdatedProps) => (
Expand All @@ -25,8 +19,6 @@ const LastUpdated = ({
dateTimeFormat="YYYY-MM-DD"
prefix={prefix}
format="LL"
script={script}
service={service}
locale={locale}
timezone={timezone}
padding={false}
Expand Down
5 changes: 0 additions & 5 deletions src/app/components/MostRead/Canonical/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import MostReadRank from './Rank';
import LastUpdated from './LastUpdated';
import { ColumnLayout, MostReadData, Size } from '../types';
import { Direction } from '../../../models/types/global';
import { TypographyScript } from '../../../models/types/theming';

interface MostReadProps {
columnLayout?: ColumnLayout;
Expand All @@ -26,7 +25,6 @@ const MostRead = ({
}: MostReadProps) => {
const {
service,
script,
dir,
datetimeLocale,
serviceDatetimeLocale,
Expand Down Expand Up @@ -55,7 +53,6 @@ const MostRead = ({
const locale = serviceDatetimeLocale || datetimeLocale;

const direction = dir as Direction;
const fontScript = script as TypographyScript;

return (
<MostReadList
Expand Down Expand Up @@ -94,8 +91,6 @@ const MostRead = ({
{shouldRenderLastUpdated(timestamp) && timestamp && (
<LastUpdated
prefix={lastUpdated}
script={fontScript}
service={service}
timestamp={timestamp}
locale={locale}
timezone={timezone}
Expand Down
9 changes: 3 additions & 6 deletions src/app/components/MostRead/Label/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import React from 'react';
import { render } from '../../react-testing-library-with-providers';
import { ServiceContextProvider } from '../../../contexts/ServiceContext';
import MostReadSectionLabel from '.';

describe('MostReadSectionLabel assertion', () => {
it('should render most-read section label with correct attributes', async () => {
const { container } = render(
<ServiceContextProvider service="persian">
<MostReadSectionLabel />
</ServiceContextProvider>,
);
const { container } = render(<MostReadSectionLabel />, {
service: 'persian',
});
const label = container.getElementsByTagName('span')[2];
expect(label).toHaveAttribute('id', 'Most-Read');
expect(label.textContent).toEqual('مطالب پرخواننده');
Expand Down
4 changes: 0 additions & 4 deletions src/app/components/MostRead/Label/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ const MostReadSectionLabel = ({
overrideHeadingAs,
}: MostReadSectionLabelProps) => {
const {
service,
script,
dir,
mostRead: { header },
} = use(ServiceContext);
return (
<SectionLabel
css={styles.sectionLabel}
script={script}
labelId="Most-Read"
service={service}
dir={dir}
mobileDivider={mobileDivider}
backgroundColor={backgroundColor}
Expand Down
21 changes: 3 additions & 18 deletions src/app/components/MostRead/utilities/testHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,14 @@ import { ToggleContextProvider } from '#contexts/ToggleContext';
import TEXT_VARIANTS from '#storybook/withServicesDecorator/text-variants';
import Timestamp from '../../../legacy/psammead/psammead-timestamp/src';
import { ServiceContextProvider } from '../../../contexts/ServiceContext';
import latin from '../../ThemeProvider/fontScripts/latin';
import { MostReadItemWrapper, MostReadLink } from '../Canonical/Item';
import MostReadRank from '../Canonical/Rank';
import { Services, Direction } from '../../../models/types/global';
import { TypographyScript } from '../../../models/types/theming';
import { MostReadBaseProps, MostReadData, Size } from '../types';

const lastUpdated = ({
script,
service,
}: {
script: TypographyScript;
service: Services;
}) => (
const lastUpdated = () => (
// This will return the provided english translations
<Timestamp
datetime="2019-03-01T14:00+00:00"
script={script}
padding={false}
service={service}
>
<Timestamp datetime="2019-03-01T14:00+00:00" padding={false}>
Last updated: 5th November 2016
</Timestamp>
);
Expand All @@ -49,9 +36,7 @@ export const getItem = ({
}) => {
const baseUrl = 'https://www.bbc.com';
const { text, articlePath } = TEXT_VARIANTS[service];
const timestamp = withTimestamp
? lastUpdated({ script: latin, service })
: null;
const timestamp = withTimestamp ? lastUpdated() : null;

return {
id: `${Math.floor(Math.random() * 100000) + 1}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,8 @@ exports[`PageLayoutWrapper should render default page wrapper with children 1`]
background-color: transparent;
border: 0;
float: left;
height: 2.75rem;
width: 2.75rem;
height: NaNrem;
width: NaNrem;
}

.emotion-35:hover,
Expand Down Expand Up @@ -573,8 +573,8 @@ exports[`PageLayoutWrapper should render default page wrapper with children 1`]

@media (min-width: 20rem) {
.emotion-35 {
height: 2.75rem;
width: 2.75rem;
height: NaNrem;
width: NaNrem;
}
}

Expand Down
7 changes: 2 additions & 5 deletions src/app/components/Recommendations/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ const eventTrackingData = {
};

const Recommendations = ({ data }: { data: Recommendation[] }) => {
const { recommendations, mostRead, script, service, dir } =
use(ServiceContext);
const { recommendations, mostRead, dir } = use(ServiceContext);

const viewTracker = useViewTracker(eventTrackingData);

Expand Down Expand Up @@ -67,12 +66,10 @@ const Recommendations = ({ data }: { data: Recommendation[] }) => {
data-e2e={labelId}
{...a11yAttributes}
>
<SkipLinkWrapper service={service} {...skipLinkProps}>
<SkipLinkWrapper {...skipLinkProps}>
{title ? (
<SectionLabel
css={styles.labelComponent}
script={script}
service={service}
dir={dir}
labelId={labelId}
columnType="main"
Expand Down
Loading