@@ -15,6 +15,7 @@ import { useOnce } from '../lib/useOnce';
15
15
import { palette as themePalette } from '../palette' ;
16
16
import type { RoleType } from '../types/content' ;
17
17
import { Caption } from './Caption' ;
18
+ import { useConfig } from './ConfigContext' ;
18
19
import { defaultRoleStyles } from './Figure' ;
19
20
import { Placeholder } from './Placeholder' ;
20
21
@@ -324,6 +325,7 @@ export const InteractiveBlockComponent = ({
324
325
const wrapperRef = useRef < HTMLDivElement > ( null ) ;
325
326
const placeholderLinkRef = useRef < HTMLAnchorElement > ( null ) ;
326
327
const [ loaded , setLoaded ] = useState ( false ) ;
328
+ const { darkModeAvailable } = useConfig ( ) ;
327
329
useOnce ( ( ) => {
328
330
// We've brought the behavior from boot.js into this file to avoid loading 2 extra scripts
329
331
if (
@@ -346,6 +348,22 @@ export const InteractiveBlockComponent = ({
346
348
// Datawrapper-specific fix to suppress scrollbars appearing
347
349
if ( url . includes ( 'datawrapper' ) ) {
348
350
iframe . scrolling = 'no' ;
351
+ // Turn off dark mode for Datawrapper embeds on web
352
+ // This should be removed if/when dark mode is implements on the website
353
+ if (
354
+ ! document . querySelector ( '.ios' ) &&
355
+ ! document . querySelector ( '.android' )
356
+ ) {
357
+ const prefersDarkScheme = window . matchMedia (
358
+ '(prefers-color-scheme: dark)' ,
359
+ ) . matches ;
360
+ const darkMode = darkModeAvailable && prefersDarkScheme ;
361
+ if ( ! darkMode ) {
362
+ iframe . src +=
363
+ ( iframe . src . includes ( '?' ) ? '&' : '?' ) +
364
+ 'dark=false' ;
365
+ }
366
+ }
349
367
}
350
368
351
369
setupWindowListeners ( iframe ) ;
0 commit comments