Skip to content

Conversation

@andrewscfc
Copy link
Contributor

Resolves JIRA:

Summary

A very high-level summary of easily-reproducible changes that can be understood by non-devs, and why these changes where made.

Code changes

  • A bullet point list of key code changes that have been made.

Developer Checklist

  • UX
    • UX Criteria met (visual UX & screenreader UX)
  • Accessibility
    • Accessibility Acceptance Criteria met
    • Accessibility swarm completed
    • Component Health updated
    • P1 accessibility bugs resolved
    • P2/P3 accessibility bugs planned (if not resolved)
  • Security
    • Security issues addressed
    • Threat Model updated
  • Documentation
    • Docs updated (runbook, READMEs)
  • Testing
    • Feature tested on relevant environments
  • Comms
    • Relevant parties notified of changes

Testing

  • Manual Testing required?
    • Local (Ready-For-Test, Local)
    • Test (Ready-For-Test, Test)
    • Preview (Ready-For-Test, Preview)
    • Live (Ready-For-Test, Live)
  • Manual Testing complete?
    • Local
    • Test
    • Preview
    • Live

Additional Testing Steps

  1. List the steps required to test this PR.

Useful Links

"puppeteer": "24.10.2",
"retry": "0.13.1",
"sass": "1.89.2",
"sass-loader": "16.0.5",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copilot recommended packages to support SCSS

@@ -0,0 +1,223 @@
// fontFaces.module.scss
// SCSS mixins for @font-face rules, matching the fontFaces.ts constants
// Usage: @include reith-serif-regular-face; etc.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,22 @@
// fontFamilies.module.scss
// SCSS variables for font-family stacks, matching fontFamilies.ts
// Usage: font-family: $reith-sans;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,14 @@
// fontMediaQueries.module.scss
// SCSS variables for font media query breakpoints, matching fontMediaQueries.ts
// These are static values representing only the media query condition (no @media, no quotes).
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some back and forth with Copilot it told me that you can't have constants that contain full media queries like the original file

You can get very close though with the condition being encapsulating in a variable

$values: map-get(map-get($font-sizes, $scale), $group);
font-size: map-get($values, font-size);
line-height: map-get($values, line-height);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a really difficult conversion, the theme dictates the font size and line height so it seemed sensible for these be declared as global variables to set at runtime by JS based on the service theme. In theory the algorithm otherwise works the same as the ts version: https://github.com/bbc/simorgh/blob/latest/src/app/components/ThemeProvider/fontSizes.ts

$storm: #404040;
$success-core: #148A00;
$weather-blue: #067EB3;
$white: #FFFFFF;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$margin-below-400px: $full;
$gutter-below-600px: $full;
$margin-above-400px: $double;
$gutter-above-600px: $double;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a good comparison to the just CSS Modules equivalent, pretty much all the imperative logic is retained from the original: https://github.com/bbc/simorgh/blob/latest/src/app/components/ThemeProvider/spacings.ts

use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot contributed webpack config for SCSS

use: ['style-loader', 'css-loader', 'sass-loader'],
},
],
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot contributed webpack config for SCSS

'brand-logo': 'var(--white)',
'brand-foreground': 'var(--ghost)',
'brand-highlight': 'var(--white)',
'brand-border': 'var(--postbox-30)',
Copy link
Contributor Author

@andrewscfc andrewscfc Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First example pulling in custom properties dynamically based on theme, this should reflect current behaviour

@andrewscfc andrewscfc force-pushed the andrew-scss-modules branch from c3a0d1d to 8821093 Compare August 1, 2025 14:22
@andrewscfc andrewscfc force-pushed the andrew-scss-modules branch from 8821093 to 0a8dcd6 Compare August 1, 2025 14:27
package.json Outdated
"jest-serializer-html": "7.1.0",
"jest-silent-reporter": "0.6.0",
"jsdom": "26.1.0",
"mini-css-extract-plugin": "2.9.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot claims this enables extraction of css into seperate chunks based on usage

$ratio: if($cropped-height != 0, $cropped-width / $cropped-height, 1);

:root {
--brand-logo-ratio: #{$ratio};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit of a stretch but in principle this algorithm will set this custom css property to refer to when putting the css together for the brand here:

const svgRatio = brandSVG && brandSVG.ratio;

@@ -0,0 +1,30 @@
@mixin build-logo(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This meant to be roughly functional equivalent to: https://github.com/bbc/simorgh/blob/latest/src/app/components/ThemeProvider/chameleonLogos/index.tsx#L5

it compute values to use elsewhere for the brand and provides a suitable css class to use for styles

stroke: #000;
stroke-width: 0.335;
/* Optionally, set stroke via custom property or theme */
} No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs moving to the :root declaration above to make it global for use elsewhere


.mundoLogoTheme {
@include logo.build-logo(1738, 425);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applies mundo specific config to logo and actually executes the function, adding the suitably populated custom properties to the page

Based on: https://github.com/bbc/simorgh/blob/latest/src/app/components/ThemeProvider/chameleonLogos/mundo.tsx#L4

import '../../../fontVariants/reith.module.scss';
import './palette.module.scss';
import '../../../fontScripts/latinWithDiacritics.module.scss';
import '../../../chameleonLogos/mundoLogo.module.scss';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite important implementation detail here, these scss modules are imported and applied to the page, but because this is dynamically imported via loadable the theory is this css is correctly chunked with mundo only i.e. only css for the chosen theme is loaded

Comment on lines 1 to 7
:root {
--brand-background: var(--postbox);
--brand-logo: var(--white);
--brand-foreground: var(--ghost);
--brand-highlight: var(--white);
--brand-border: var(--postbox-30);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
:root {
--brand-background: var(--postbox);
--brand-logo: var(--white);
--brand-foreground: var(--ghost);
--brand-highlight: var(--white);
--brand-border: var(--postbox-30);
}

This file was moved, should be deleted

Comment on lines 1 to 7
:root {
--brand-background: var(--postbox);
--brand-logo: var(--white);
--brand-foreground: var(--ghost);
--brand-highlight: var(--white);
--brand-border: var(--postbox-30);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

};


export default ThemeProvider; No newline at end of file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Equivalent of

This is simplified for now and obviously creates its own Provider rather than use emotion

};
};

export default buildLogo;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Existing logic for brand svg unchanged by move to SCSS modules

import '../../../fontFaces/reith-serif-light.module.scss';
import '../../../fontVariants/reith.module.scss';
import './palette.module.scss';
import '../../../fontScripts/latinWithDiacritics.module.scss';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite important implementation detail here, these scss modules are imported and applied to the page, but because this is dynamically imported via loadable the theory is this css is correctly chunked with mundo only i.e. only css for the chosen theme is loaded

import '../../fontFaces/reith-serif-light.module.scss';
import '../../fontVariants/reith.module.scss';
import './palette.module.scss';
import '../../fontScripts/latinWithDiacritics.module.scss';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite important implementation detail here, these scss modules are imported and applied to the page, but because this is dynamically imported via loadable the theory is this css is correctly chunked with mundo only i.e. only css for the chosen theme is loaded

: Fragment;
return (
<h2 css={styles.h2} id={id}>
<h2 className="h2" id={id}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs integrating properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants