@reuters-graphics/graphics-components 1.0.13 → 1.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/components/AdSlot/@types/ads.d.ts +4 -0
- package/dist/@types/components/AdSlot/AdSlot.svelte.d.ts +4 -8
- package/dist/@types/components/AdSlot/InlineAd.svelte.d.ts +18 -0
- package/dist/@types/components/AdSlot/OneTrust.svelte.d.ts +23 -0
- package/dist/@types/components/AdSlot/ResponsiveAd.svelte.d.ts +18 -0
- package/dist/@types/components/AdSlot/utils.d.ts +1 -0
- package/dist/@types/index.d.ts +1 -1
- package/dist/components/AdSlot/@types/ads.js +2 -0
- package/dist/components/AdSlot/AdScripts.svelte +3 -32
- package/dist/components/AdSlot/AdSlot.svelte +27 -97
- package/dist/components/AdSlot/InlineAd.svelte +64 -0
- package/dist/components/AdSlot/OneTrust.svelte +39 -0
- package/dist/components/AdSlot/ResponsiveAd.svelte +43 -0
- package/dist/components/AdSlot/adScripts/bootstrap.js +16 -14
- package/dist/components/AdSlot/utils.js +5 -0
- package/dist/index.js +1 -1
- package/package.json +7 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type AdType = 'leaderboard' | 'sponsorlogo' | 'native' | 'mpu' | 'billboard';
|
|
2
|
+
export type PlacementName = 'reuters_desktop_leaderboard_atf' | 'reuters_mobile_leaderboard' | 'reuters_desktop_native_1' | 'reuters_mobile_mpu_1' | 'reuters_sponsorlogo' | 'reuters_billboard_desktop';
|
|
3
|
+
export type DesktopPlacementName = 'reuters_desktop_leaderboard_atf' | 'reuters_desktop_native_1' | 'reuters_sponsorlogo' | 'reuters_billboard_desktop';
|
|
4
|
+
export type MobilePlacementName<DesktopPlacementName extends string> = DesktopPlacementName extends 'reuters_desktop_leaderboard_atf' ? 'reuters_mobile_leaderboard' : DesktopPlacementName extends 'reuters_desktop_native_1' ? 'reuters_mobile_mpu_1' : DesktopPlacementName extends 'reuters_sponsorlogo' ? 'reuters_sponsorlogo' : DesktopPlacementName extends 'reuters_billboard_desktop' ? 'reuters_mobile_mpu_1' : never;
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { PlacementName, AdType } from './@types/ads';
|
|
2
3
|
declare const __propDef: {
|
|
3
4
|
props: {
|
|
5
|
+
placementName: PlacementName;
|
|
6
|
+
adType: AdType;
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
6
|
-
* @required
|
|
7
|
-
*/ placementName?: "reuters_desktop_native_1" | "reuters_mobile_mpu_1" | "reuters_sponsorlogo" | "reuters_desktop_canvas";
|
|
8
|
-
/**
|
|
9
|
-
* The unique slot Id from FreeStar dashboard.
|
|
8
|
+
* @TODO Unclear at what level this bit of config is used with placements...
|
|
10
9
|
*/ dataFreestarAd?: string;
|
|
11
|
-
/** Add an ID to target with SCSS. */ id?: string;
|
|
12
|
-
/** Add a class to target with SCSS. */ class?: string;
|
|
13
10
|
};
|
|
14
11
|
events: {
|
|
15
12
|
[evt: string]: CustomEvent<any>;
|
|
@@ -19,7 +16,6 @@ declare const __propDef: {
|
|
|
19
16
|
export type AdSlotProps = typeof __propDef.props;
|
|
20
17
|
export type AdSlotEvents = typeof __propDef.events;
|
|
21
18
|
export type AdSlotSlots = typeof __propDef.slots;
|
|
22
|
-
/** `AdSlot` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-AdSlot--default) */
|
|
23
19
|
export default class AdSlot extends SvelteComponentTyped<AdSlotProps, AdSlotEvents, AdSlotSlots> {
|
|
24
20
|
}
|
|
25
21
|
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
/** Add an ID to target with SCSS. */ id?: string;
|
|
5
|
+
/** Add a class to target with SCSS. */ class?: string;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type InlineAdProps = typeof __propDef.props;
|
|
13
|
+
export type InlineAdEvents = typeof __propDef.events;
|
|
14
|
+
export type InlineAdSlots = typeof __propDef.slots;
|
|
15
|
+
/** `InlineAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-InlineAd--default) */
|
|
16
|
+
export default class InlineAd extends SvelteComponentTyped<InlineAdProps, InlineAdEvents, InlineAdSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} OneTrustProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} OneTrustEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} OneTrustSlots */
|
|
4
|
+
export default class OneTrust extends SvelteComponentTyped<{
|
|
5
|
+
[x: string]: never;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {}> {
|
|
9
|
+
}
|
|
10
|
+
export type OneTrustProps = typeof __propDef.props;
|
|
11
|
+
export type OneTrustEvents = typeof __propDef.events;
|
|
12
|
+
export type OneTrustSlots = typeof __propDef.slots;
|
|
13
|
+
import { SvelteComponentTyped } from "svelte";
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
[x: string]: never;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
import type { DesktopPlacementName } from './@types/ads';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
desktopPlacementName: DesktopPlacementName;
|
|
6
|
+
mobileBreakpoint?: number;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
[evt: string]: CustomEvent<any>;
|
|
10
|
+
};
|
|
11
|
+
slots: {};
|
|
12
|
+
};
|
|
13
|
+
export type ResponsiveAdProps = typeof __propDef.props;
|
|
14
|
+
export type ResponsiveAdEvents = typeof __propDef.events;
|
|
15
|
+
export type ResponsiveAdSlots = typeof __propDef.slots;
|
|
16
|
+
export default class ResponsiveAd extends SvelteComponentTyped<ResponsiveAdProps, ResponsiveAdEvents, ResponsiveAdSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getRandomAdId: () => string;
|
package/dist/@types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { default as cssVariables } from "./actions/cssVariables/index.js";
|
|
|
2
2
|
export { default as resizeObserver } from "./actions/resizeObserver/index.js";
|
|
3
3
|
export { default as Article } from "./components/Article/Article.svelte";
|
|
4
4
|
export { default as AdScripts } from "./components/AdSlot/AdScripts.svelte";
|
|
5
|
-
export { default as
|
|
5
|
+
export { default as InlineAd } from "./components/AdSlot/InlineAd.svelte";
|
|
6
6
|
export { default as BeforeAfter } from "./components/BeforeAfter/BeforeAfter.svelte";
|
|
7
7
|
export { default as Block } from "./components/Block/Block.svelte";
|
|
8
8
|
export { default as BodyText } from "./components/BodyText/BodyText.svelte";
|
|
@@ -2,35 +2,7 @@
|
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
3
|
import { loadBootstrap } from './adScripts/bootstrap';
|
|
4
4
|
import { loadScript } from './adScripts/loadScript';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
let lastScroll = 0;
|
|
8
|
-
let showManagePreferences = true;
|
|
9
|
-
|
|
10
|
-
const togglePrefs = (on = true) => {
|
|
11
|
-
const btn = document.getElementById('ot-sdk-btn-floating');
|
|
12
|
-
if (!btn) return;
|
|
13
|
-
if (on) {
|
|
14
|
-
showManagePreferences = true;
|
|
15
|
-
btn.style.bottom = '';
|
|
16
|
-
} else {
|
|
17
|
-
showManagePreferences = false;
|
|
18
|
-
btn.style.bottom = '-5rem';
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const handleScroll = () => {
|
|
23
|
-
if (lastScroll > window.scrollY) {
|
|
24
|
-
if (!showManagePreferences) {
|
|
25
|
-
togglePrefs(true);
|
|
26
|
-
}
|
|
27
|
-
} else {
|
|
28
|
-
if (showManagePreferences && window.scrollY > 250) {
|
|
29
|
-
togglePrefs(false);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
lastScroll = window.scrollY;
|
|
33
|
-
};
|
|
5
|
+
import OneTrust from './OneTrust.svelte';
|
|
34
6
|
|
|
35
7
|
onMount(() => {
|
|
36
8
|
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
|
@@ -38,9 +10,6 @@
|
|
|
38
10
|
'https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js',
|
|
39
11
|
loadBootstrap
|
|
40
12
|
);
|
|
41
|
-
window.addEventListener('scroll', throttle(handleScroll, 250), {
|
|
42
|
-
passive: true,
|
|
43
|
-
});
|
|
44
13
|
});
|
|
45
14
|
</script>
|
|
46
15
|
|
|
@@ -60,3 +29,5 @@
|
|
|
60
29
|
/>
|
|
61
30
|
<link rel="stylesheet" href="https://a.pub.network/reuters-com/cls.css" />
|
|
62
31
|
</svelte:head>
|
|
32
|
+
|
|
33
|
+
<OneTrust />
|
|
@@ -1,105 +1,35 @@
|
|
|
1
|
-
<script
|
|
1
|
+
<script>import { onMount } from 'svelte';
|
|
2
|
+
import { getRandomAdId } from './utils';
|
|
3
|
+
export let placementName;
|
|
4
|
+
export let adType;
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @required
|
|
5
|
-
*/
|
|
6
|
-
export let placementName = 'reuters_desktop_native_1';
|
|
7
|
-
/**
|
|
8
|
-
* The unique slot Id from FreeStar dashboard.
|
|
6
|
+
* @TODO Unclear at what level this bit of config is used with placements...
|
|
9
7
|
*/
|
|
10
8
|
export let dataFreestarAd = '__970x250';
|
|
11
|
-
|
|
12
|
-
export let id = '';
|
|
13
|
-
/** Add a class to target with SCSS. */
|
|
14
|
-
let cls = 'my-12';
|
|
15
|
-
export { cls as class };
|
|
16
|
-
import { onMount } from 'svelte';
|
|
17
|
-
import Block from '../Block/Block.svelte';
|
|
18
|
-
const random4 = () => Math.floor((1 + Math.random()) * 0x10000)
|
|
19
|
-
.toString(16)
|
|
20
|
-
.substring(1);
|
|
21
|
-
const randomAdId = 'ad-' + random4() + random4();
|
|
22
|
-
const getAdType = (placementName) => {
|
|
23
|
-
switch (placementName) {
|
|
24
|
-
// case 'reuters_desktop_leaderboard_atf':
|
|
25
|
-
// case 'reuters_mobile_leaderboard':
|
|
26
|
-
// return 'leaderboard';
|
|
27
|
-
case 'reuters_sponsorlogo':
|
|
28
|
-
return 'Sponsorlogo';
|
|
29
|
-
case 'reuters_mobile_mpu_1':
|
|
30
|
-
return 'mpu';
|
|
31
|
-
default:
|
|
32
|
-
return 'native';
|
|
33
|
-
}
|
|
34
|
-
};
|
|
9
|
+
const adId = getRandomAdId();
|
|
35
10
|
onMount(() => {
|
|
36
|
-
const
|
|
37
|
-
const adstest = urlParams.get('adstest');
|
|
38
|
-
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
|
39
|
-
window.graphicsAdQueue.push({
|
|
11
|
+
const adSlot = {
|
|
40
12
|
placementName,
|
|
41
|
-
slotId:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
13
|
+
slotId: adId,
|
|
14
|
+
targeting: {
|
|
15
|
+
div_id: adId,
|
|
16
|
+
type: adType,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
const freestar = window?.freestar;
|
|
21
|
+
// Add adSlot to freestar queue directly if already initialised
|
|
22
|
+
if (freestar) {
|
|
23
|
+
freestar.queue.push(function () {
|
|
24
|
+
freestar.newAdSlots([adSlot], freestar.config.channel);
|
|
25
|
+
});
|
|
26
|
+
// ... otherwise add to the graphicsAdQueue queue.
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
|
30
|
+
window.graphicsAdQueue.push(adSlot);
|
|
31
|
+
}
|
|
46
32
|
});
|
|
47
33
|
</script>
|
|
48
34
|
|
|
49
|
-
|
|
50
|
-
<Block id="{id}" class="freestar-adslot {cls}">
|
|
51
|
-
<div class="ad-block">
|
|
52
|
-
<div class="ad-label">Advertisement · Scroll to continue</div>
|
|
53
|
-
<div class="ad-container">
|
|
54
|
-
<div class="ad-slot__inner">
|
|
55
|
-
<div>
|
|
56
|
-
<div
|
|
57
|
-
data-freestar-ad="{dataFreestarAd || null}"
|
|
58
|
-
id="{randomAdId}"
|
|
59
|
-
></div>
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
</Block>
|
|
65
|
-
|
|
66
|
-
<style>div.ad-block {
|
|
67
|
-
border-bottom: 1px solid var(--theme-colour-brand-rules);
|
|
68
|
-
border-top: 1px solid var(--theme-colour-brand-rules);
|
|
69
|
-
}
|
|
70
|
-
div.ad-block div.ad-label {
|
|
71
|
-
font-family: Knowledge, "Source Sans Pro", Arial, Helvetica, sans-serif;
|
|
72
|
-
font-size: 14px;
|
|
73
|
-
margin: 6px 0;
|
|
74
|
-
line-height: 1.333;
|
|
75
|
-
color: var(--theme-colour-text-secondary);
|
|
76
|
-
width: 100%;
|
|
77
|
-
text-align: center;
|
|
78
|
-
}
|
|
79
|
-
div.ad-block div.ad-container {
|
|
80
|
-
display: flex;
|
|
81
|
-
flex-direction: column;
|
|
82
|
-
justify-content: center;
|
|
83
|
-
align-items: center;
|
|
84
|
-
min-height: 415px;
|
|
85
|
-
}
|
|
86
|
-
@media (max-width: 767.9px) {
|
|
87
|
-
div.ad-block div.ad-container {
|
|
88
|
-
min-height: 320px;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
div.ad-block div.ad-container div.ad-slot__inner {
|
|
92
|
-
margin: auto 0;
|
|
93
|
-
width: 100%;
|
|
94
|
-
max-width: 100%;
|
|
95
|
-
flex: unset;
|
|
96
|
-
}
|
|
97
|
-
div.ad-block div.ad-container div.ad-slot__inner > div {
|
|
98
|
-
display: block;
|
|
99
|
-
}
|
|
100
|
-
div.ad-block div.ad-container div.ad-slot__inner > div div[data-freestar-ad] {
|
|
101
|
-
display: flex;
|
|
102
|
-
flex-direction: column;
|
|
103
|
-
justify-content: center;
|
|
104
|
-
align-items: center;
|
|
105
|
-
}</style>
|
|
35
|
+
<div data-freestar-ad="{dataFreestarAd || null}" id="{adId}"></div>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<script>import Block from '../Block/Block.svelte';
|
|
2
|
+
import ResponsiveAd from './ResponsiveAd.svelte';
|
|
3
|
+
/** Add an ID to target with SCSS. */
|
|
4
|
+
export let id = '';
|
|
5
|
+
/** Add a class to target with SCSS. */
|
|
6
|
+
let cls = 'my-12';
|
|
7
|
+
export { cls as class };
|
|
8
|
+
const desktopPlacementName = 'reuters_desktop_native_1';
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<!-- @component `InlineAd` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-InlineAd--default) -->
|
|
12
|
+
<Block id="{id}" class="freestar-adslot {cls}">
|
|
13
|
+
<div class="ad-block">
|
|
14
|
+
<div class="ad-label">Advertisement · Scroll to continue</div>
|
|
15
|
+
<div class="ad-container">
|
|
16
|
+
<div class="ad-slot__inner">
|
|
17
|
+
<div>
|
|
18
|
+
<ResponsiveAd desktopPlacementName="{desktopPlacementName}" />
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</Block>
|
|
24
|
+
|
|
25
|
+
<style>div.ad-block {
|
|
26
|
+
border-bottom: 1px solid var(--theme-colour-brand-rules);
|
|
27
|
+
border-top: 1px solid var(--theme-colour-brand-rules);
|
|
28
|
+
}
|
|
29
|
+
div.ad-block div.ad-label {
|
|
30
|
+
font-family: Knowledge, "Source Sans Pro", Arial, Helvetica, sans-serif;
|
|
31
|
+
font-size: 14px;
|
|
32
|
+
margin: 6px 0;
|
|
33
|
+
line-height: 1.333;
|
|
34
|
+
color: var(--theme-colour-text-secondary);
|
|
35
|
+
width: 100%;
|
|
36
|
+
text-align: center;
|
|
37
|
+
}
|
|
38
|
+
div.ad-block div.ad-container {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
align-items: center;
|
|
43
|
+
min-height: 415px;
|
|
44
|
+
}
|
|
45
|
+
@media (max-width: 767.9px) {
|
|
46
|
+
div.ad-block div.ad-container {
|
|
47
|
+
min-height: 320px;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
div.ad-block div.ad-container div.ad-slot__inner {
|
|
51
|
+
margin: auto 0;
|
|
52
|
+
width: 100%;
|
|
53
|
+
max-width: 100%;
|
|
54
|
+
flex: unset;
|
|
55
|
+
}
|
|
56
|
+
div.ad-block div.ad-container div.ad-slot__inner > div {
|
|
57
|
+
display: block;
|
|
58
|
+
}
|
|
59
|
+
div.ad-block div.ad-container div.ad-slot__inner > div :global(div[data-freestar-ad]) {
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
justify-content: center;
|
|
63
|
+
align-items: center;
|
|
64
|
+
}</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<!-- This component manages the OneTrust prefs button, so it's not permanently fixed on page... -->
|
|
2
|
+
<script>
|
|
3
|
+
import { onMount } from 'svelte';
|
|
4
|
+
import { throttle } from 'lodash-es';
|
|
5
|
+
|
|
6
|
+
let lastScroll = 0;
|
|
7
|
+
let showManagePreferences = true;
|
|
8
|
+
|
|
9
|
+
const togglePrefs = (on = true) => {
|
|
10
|
+
const btn = document.getElementById('ot-sdk-btn-floating');
|
|
11
|
+
if (!btn) return;
|
|
12
|
+
if (on) {
|
|
13
|
+
showManagePreferences = true;
|
|
14
|
+
btn.style.bottom = '';
|
|
15
|
+
} else {
|
|
16
|
+
showManagePreferences = false;
|
|
17
|
+
btn.style.bottom = '-5rem';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const handleScroll = () => {
|
|
22
|
+
if (lastScroll > window.scrollY) {
|
|
23
|
+
if (!showManagePreferences) {
|
|
24
|
+
togglePrefs(true);
|
|
25
|
+
}
|
|
26
|
+
} else {
|
|
27
|
+
if (showManagePreferences && window.scrollY > 250) {
|
|
28
|
+
togglePrefs(false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
lastScroll = window.scrollY;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
onMount(() => {
|
|
35
|
+
window.addEventListener('scroll', throttle(handleScroll, 250), {
|
|
36
|
+
passive: true,
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
</script>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<script>import AdSlot from './AdSlot.svelte';
|
|
2
|
+
export let desktopPlacementName;
|
|
3
|
+
export let mobileBreakpoint = 1024;
|
|
4
|
+
let windowWidth;
|
|
5
|
+
const getMobilePlacementName = (desktopPlacementName) => {
|
|
6
|
+
switch (desktopPlacementName) {
|
|
7
|
+
case 'reuters_desktop_leaderboard_atf':
|
|
8
|
+
return 'reuters_mobile_leaderboard';
|
|
9
|
+
case 'reuters_sponsorlogo':
|
|
10
|
+
return 'reuters_sponsorlogo';
|
|
11
|
+
default:
|
|
12
|
+
return 'reuters_mobile_mpu_1';
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const getAdType = (placementName) => {
|
|
16
|
+
switch (placementName) {
|
|
17
|
+
case 'reuters_desktop_leaderboard_atf':
|
|
18
|
+
case 'reuters_mobile_leaderboard':
|
|
19
|
+
return 'leaderboard';
|
|
20
|
+
case 'reuters_sponsorlogo':
|
|
21
|
+
return 'sponsorlogo';
|
|
22
|
+
case 'reuters_mobile_mpu_1':
|
|
23
|
+
return 'mpu';
|
|
24
|
+
case 'reuters_billboard_desktop':
|
|
25
|
+
return 'billboard';
|
|
26
|
+
default:
|
|
27
|
+
return 'native';
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
$: placementName =
|
|
31
|
+
windowWidth && windowWidth < mobileBreakpoint
|
|
32
|
+
? getMobilePlacementName(desktopPlacementName)
|
|
33
|
+
: desktopPlacementName;
|
|
34
|
+
$: adType = getAdType(placementName);
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<svelte:window bind:innerWidth="{windowWidth}" />
|
|
38
|
+
|
|
39
|
+
{#if windowWidth}
|
|
40
|
+
{#key placementName}
|
|
41
|
+
<AdSlot placementName="{placementName}" adType="{adType}" />
|
|
42
|
+
{/key}
|
|
43
|
+
{/if}
|
|
@@ -16,17 +16,13 @@ export const loadBootstrap = () => {
|
|
|
16
16
|
(freestar.initCallbackCalled = false) :
|
|
17
17
|
freestar.newAdSlots(freestar.config.enabled_slots);
|
|
18
18
|
};
|
|
19
|
-
|
|
20
|
-
freestar.config.channel = '/4735792/reuters.com/home';
|
|
19
|
+
freestar.config.channel = '/4735792/reuters.com/graphics';
|
|
21
20
|
window.initBootstrap({
|
|
22
21
|
onetrust_logs: getParameterByName(ONETRUST_LOGS) || 'false',
|
|
23
22
|
geolocation_mock: getParameterByName(ONETRUST_GEOLOCATION_MOCK) || 'default',
|
|
24
23
|
onetrust_script_id: ONETRUST_SCRIPT_ID,
|
|
25
24
|
}, (onetrustResponse) => {
|
|
26
25
|
const iasPromise = Ias();
|
|
27
|
-
// Ask Thea about Permutive implementation (considering there are no logged in users on Graphics)
|
|
28
|
-
// Should we use Permutive at all?
|
|
29
|
-
// Should we import ArcP SDK to graphics to get the same user as logged in on RCom?
|
|
30
26
|
return Promise.all([iasPromise]).then((responses) => {
|
|
31
27
|
const [iasResponse] = responses;
|
|
32
28
|
return {
|
|
@@ -42,27 +38,33 @@ export const loadBootstrap = () => {
|
|
|
42
38
|
window.googletag = window.googletag || { cmd: [] };
|
|
43
39
|
window.googletag.cmd.push(() => {
|
|
44
40
|
window.googletag.pubads().enableSingleRequest();
|
|
41
|
+
/**
|
|
42
|
+
* @TODO Property 'enableAsyncRendering' does not exist on type 'PubAdsService'.
|
|
43
|
+
*/
|
|
44
|
+
// @ts-ignore
|
|
45
45
|
window.googletag.pubads().enableAsyncRendering();
|
|
46
46
|
window.googletag.pubads().collapseEmptyDivs(true);
|
|
47
|
+
});
|
|
48
|
+
// Set page-level key-values
|
|
49
|
+
// cf: https://help.freestar.com/help/using-key-values
|
|
50
|
+
freestar.queue.push(function () {
|
|
47
51
|
// Global Ads test targeting
|
|
48
52
|
const adstest = new URL(document.location.href).searchParams.get('adstest');
|
|
49
53
|
if (adstest) {
|
|
50
54
|
window.googletag.pubads().setTargeting('adstest', adstest);
|
|
51
55
|
}
|
|
52
|
-
//
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
// Use the URL path to create a unique ID for the page.
|
|
57
|
+
const graphicId = window.location.pathname
|
|
58
|
+
.replace(/^\/(.*)\/$/, '$1')
|
|
59
|
+
.replaceAll('/', '-');
|
|
60
|
+
window.googletag.pubads().setTargeting('template', 'graphics');
|
|
61
|
+
window.googletag.pubads().setTargeting('graphicId', graphicId);
|
|
57
62
|
});
|
|
58
63
|
if (!Array.isArray(window.graphicsAdQueue)) {
|
|
59
64
|
console.error('Ad queue not initialized!');
|
|
60
65
|
}
|
|
61
66
|
freestar.queue.push(function () {
|
|
62
|
-
freestar.newAdSlots(window.graphicsAdQueue || [],
|
|
63
|
-
});
|
|
64
|
-
freestar.queue.push(function () {
|
|
65
|
-
window.googletag.pubads().set('page_url', 'https://www.reuters.com/'); // This line should only be used for testing
|
|
67
|
+
freestar.newAdSlots(window.graphicsAdQueue || [], freestar.config.channel);
|
|
66
68
|
});
|
|
67
69
|
});
|
|
68
70
|
};
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ export {
|
|
|
9
9
|
} from './components/Analytics/Analytics.svelte';
|
|
10
10
|
export { default as Article } from './components/Article/Article.svelte';
|
|
11
11
|
export { default as AdScripts } from './components/AdSlot/AdScripts.svelte';
|
|
12
|
-
export { default as
|
|
12
|
+
export { default as InlineAd } from './components/AdSlot/InlineAd.svelte';
|
|
13
13
|
export { default as BeforeAfter } from './components/BeforeAfter/BeforeAfter.svelte';
|
|
14
14
|
export { default as Block } from './components/Block/Block.svelte';
|
|
15
15
|
export { default as BodyText } from './components/BodyText/BodyText.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reuters-graphics/graphics-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://reuters-graphics.github.io/graphics-components",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"@storybook/theming": "^7.4.2",
|
|
56
56
|
"@sveltejs/vite-plugin-svelte": "^2.4.1",
|
|
57
57
|
"@tsconfig/svelte": "^4.0.1",
|
|
58
|
+
"@types/google-publisher-tag": "^1.20240219.0",
|
|
58
59
|
"@types/gtag.js": "^0.0.12",
|
|
59
60
|
"@types/mdx": "^2.0.5",
|
|
60
61
|
"@types/proper-url-join": "^2.1.1",
|
|
@@ -133,12 +134,17 @@
|
|
|
133
134
|
"./actions/cssVariables": "./dist/actions/cssVariables/index.js",
|
|
134
135
|
"./actions/resizeObserver": "./dist/actions/resizeObserver/index.js",
|
|
135
136
|
"./components/@types/global.ts": "./dist/components/@types/global.ts",
|
|
137
|
+
"./components/AdSlot/@types/ads.ts": "./dist/components/AdSlot/@types/ads.ts",
|
|
136
138
|
"./components/AdSlot/AdScripts.svelte": "./dist/components/AdSlot/AdScripts.svelte",
|
|
137
139
|
"./components/AdSlot/AdSlot.svelte": "./dist/components/AdSlot/AdSlot.svelte",
|
|
140
|
+
"./components/AdSlot/InlineAd.svelte": "./dist/components/AdSlot/InlineAd.svelte",
|
|
141
|
+
"./components/AdSlot/OneTrust.svelte": "./dist/components/AdSlot/OneTrust.svelte",
|
|
142
|
+
"./components/AdSlot/ResponsiveAd.svelte": "./dist/components/AdSlot/ResponsiveAd.svelte",
|
|
138
143
|
"./components/AdSlot/adScripts/bootstrap.ts": "./dist/components/AdSlot/adScripts/bootstrap.ts",
|
|
139
144
|
"./components/AdSlot/adScripts/getParameterByName.ts": "./dist/components/AdSlot/adScripts/getParameterByName.ts",
|
|
140
145
|
"./components/AdSlot/adScripts/ias.ts": "./dist/components/AdSlot/adScripts/ias.ts",
|
|
141
146
|
"./components/AdSlot/adScripts/loadScript.ts": "./dist/components/AdSlot/adScripts/loadScript.ts",
|
|
147
|
+
"./components/AdSlot/utils.ts": "./dist/components/AdSlot/utils.ts",
|
|
142
148
|
"./components/Analytics/Analytics.svelte": "./dist/components/Analytics/Analytics.svelte",
|
|
143
149
|
"./components/Analytics/providers/chartbeat.ts": "./dist/components/Analytics/providers/chartbeat.ts",
|
|
144
150
|
"./components/Analytics/providers/ga.ts": "./dist/components/Analytics/providers/ga.ts",
|