@reuters-graphics/graphics-components 1.0.7 → 1.0.8--canary.c0819ff.0
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/AdScripts.svelte.d.ts +14 -0
- package/dist/@types/components/AdSlot/AdSlot.svelte.d.ts +25 -0
- package/dist/@types/components/AdSlot/scripts/bootstrapLoad.d.ts +2 -0
- package/dist/@types/components/AdSlot/scripts/getParameterByName.d.ts +2 -0
- package/dist/@types/components/AdSlot/scripts/ias.d.ts +2 -0
- package/dist/@types/components/Framer/Typeahead/index.svelte.d.ts +2 -2
- package/dist/@types/index.d.ts +2 -0
- package/dist/components/AdSlot/AdScripts.svelte +31 -0
- package/dist/components/AdSlot/AdSlot.svelte +29 -0
- package/dist/components/AdSlot/scripts/bootstrapLoad.js +64 -0
- package/dist/components/AdSlot/scripts/getParameterByName.js +12 -0
- package/dist/components/AdSlot/scripts/ias.js +25 -0
- package/dist/components/Article/Article.svelte +1 -1
- package/dist/components/BeforeAfter/BeforeAfter.svelte +6 -6
- package/dist/components/EmbedPreviewerLink/EmbedPreviewerLink.svelte +2 -3
- package/dist/components/Framer/Framer.svelte +1 -1
- package/dist/components/Framer/Resizer/index.svelte +1 -0
- package/dist/components/Framer/Typeahead/index.svelte +24 -17
- package/dist/components/HeroHeadline/Hero.svelte +0 -19
- package/dist/components/PhotoPack/docProps.js +12 -12
- package/dist/components/Scroller/Embedded/index.svelte +14 -6
- package/dist/components/Sharer/Sharer.svelte +67 -69
- package/dist/components/Video/Controls.svelte +1 -1
- package/dist/index.js +4 -2
- package/package.json +10 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: Record<string, never>;
|
|
4
|
+
events: {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
};
|
|
7
|
+
slots: {};
|
|
8
|
+
};
|
|
9
|
+
export type AdScriptsProps = typeof __propDef.props;
|
|
10
|
+
export type AdScriptsEvents = typeof __propDef.events;
|
|
11
|
+
export type AdScriptsSlots = typeof __propDef.slots;
|
|
12
|
+
export default class AdScripts extends SvelteComponentTyped<AdScriptsProps, AdScriptsEvents, AdScriptsSlots> {
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
/**
|
|
5
|
+
* The unique placement name from FreeStar dashboard.
|
|
6
|
+
* @required
|
|
7
|
+
*/ placementName: string;
|
|
8
|
+
/**
|
|
9
|
+
* The unique slot Id from FreeStar dashboard.
|
|
10
|
+
*/ dataFreestarAd: string;
|
|
11
|
+
/** Add an ID to target with SCSS. */ id?: string;
|
|
12
|
+
/** Add a class to target with SCSS. */ cls?: string;
|
|
13
|
+
};
|
|
14
|
+
events: {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
};
|
|
17
|
+
slots: {};
|
|
18
|
+
};
|
|
19
|
+
export type AdSlotProps = typeof __propDef.props;
|
|
20
|
+
export type AdSlotEvents = typeof __propDef.events;
|
|
21
|
+
export type AdSlotSlots = typeof __propDef.slots;
|
|
22
|
+
/** `AdSlot` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-AdSlot--default) */
|
|
23
|
+
export default class AdSlot extends SvelteComponentTyped<AdSlotProps, AdSlotEvents, AdSlotSlots> {
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
@@ -12,11 +12,11 @@ export default class Index extends SvelteComponentTyped<{
|
|
|
12
12
|
index: number;
|
|
13
13
|
embed: string;
|
|
14
14
|
}) => boolean;
|
|
15
|
+
id?: string;
|
|
15
16
|
extract?: (item: {
|
|
16
17
|
index: number;
|
|
17
18
|
embed: string;
|
|
18
19
|
}) => any;
|
|
19
|
-
id?: string;
|
|
20
20
|
disable?: (item: {
|
|
21
21
|
index: number;
|
|
22
22
|
embed: string;
|
|
@@ -80,11 +80,11 @@ declare const __propDef: {
|
|
|
80
80
|
index: number;
|
|
81
81
|
embed: string;
|
|
82
82
|
}) => boolean;
|
|
83
|
+
id?: string;
|
|
83
84
|
extract?: (item: {
|
|
84
85
|
index: number;
|
|
85
86
|
embed: string;
|
|
86
87
|
}) => any;
|
|
87
|
-
id?: string;
|
|
88
88
|
disable?: (item: {
|
|
89
89
|
index: number;
|
|
90
90
|
embed: string;
|
package/dist/@types/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
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
|
+
export { default as AdScripts } from "./components/AdSlot/AdScripts.svelte";
|
|
5
|
+
export { default as AdSlot } from "./components/AdSlot/AdSlot.svelte";
|
|
4
6
|
export { default as BeforeAfter } from "./components/BeforeAfter/BeforeAfter.svelte";
|
|
5
7
|
export { default as Block } from "./components/Block/Block.svelte";
|
|
6
8
|
export { default as BodyText } from "./components/BodyText/BodyText.svelte";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script>import { onMount } from 'svelte';
|
|
2
|
+
onMount(() => {
|
|
3
|
+
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
|
4
|
+
});
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<svelte:head>
|
|
8
|
+
<link rel="preconnect" href="https://a.pub.network/" crossorigin="" />
|
|
9
|
+
<link rel="preconnect" href="https://b.pub.network/" crossorigin="" />
|
|
10
|
+
<link rel="preconnect" href="https://c.pub.network/" crossorigin="" />
|
|
11
|
+
<link rel="preconnect" href="https://d.pub.network/" crossorigin="" />
|
|
12
|
+
<link rel="preconnect" href="https://c.amazon-adsystem.com" crossorigin="" />
|
|
13
|
+
<link rel="preconnect" href="https://s.amazon-adsystem.com" crossorigin="" />
|
|
14
|
+
<link rel="preconnect" href="https://btloader.com/" crossorigin="" />
|
|
15
|
+
<link rel="preconnect" href="https://api.btloader.com/" crossorigin="" />
|
|
16
|
+
<link
|
|
17
|
+
rel="preconnect"
|
|
18
|
+
href="https://confiant-integrations.global.ssl.fastly.net"
|
|
19
|
+
crossorigin=""
|
|
20
|
+
/>
|
|
21
|
+
<link rel="stylesheet" href="https://a.pub.network/reuters-com/cls.css" />
|
|
22
|
+
|
|
23
|
+
<script
|
|
24
|
+
src="https://graphics.thomsonreuters.com/cdn/js/bootstrap.static.js"
|
|
25
|
+
on:load="{bootstrapLoad}"></script>
|
|
26
|
+
|
|
27
|
+
<script
|
|
28
|
+
src="https://a.pub.network/reuters-com/pubfig.min.js"
|
|
29
|
+
data-cfasync="false"
|
|
30
|
+
async></script>
|
|
31
|
+
</svelte:head>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script>/** ✏️ DOCUMENT your chart's props using TypeScript and JSDoc comments like below! */
|
|
2
|
+
/**
|
|
3
|
+
* The unique placement name from FreeStar dashboard.
|
|
4
|
+
* @required
|
|
5
|
+
*/
|
|
6
|
+
export let placementName;
|
|
7
|
+
/**
|
|
8
|
+
* The unique slot Id from FreeStar dashboard.
|
|
9
|
+
*/
|
|
10
|
+
export let dataFreestarAd;
|
|
11
|
+
/** Add an ID to target with SCSS. */
|
|
12
|
+
export let id = '';
|
|
13
|
+
/** Add a class to target with SCSS. */
|
|
14
|
+
export let cls = '';
|
|
15
|
+
import { onMount } from 'svelte';
|
|
16
|
+
import Block from '../Block/Block.svelte';
|
|
17
|
+
onMount(() => {
|
|
18
|
+
window.graphicsAdQueue = window.graphicsAdQueue || [];
|
|
19
|
+
window.graphicsAdQueue.push({
|
|
20
|
+
placementName,
|
|
21
|
+
slotId: placementName,
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<!-- @component `AdSlot` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-AdSlot--default) -->
|
|
27
|
+
<Block id="{id}" cls="freestar-adslot {cls}">
|
|
28
|
+
<div data-freestar-ad="{dataFreestarAd || null}" id="{placementName}"></div>
|
|
29
|
+
</Block>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import getParameterByName from './getParameterByName';
|
|
2
|
+
import Ias from './ias';
|
|
3
|
+
const ONETRUST_LOGS = 'ot_logs';
|
|
4
|
+
const ONETRUST_GEOLOCATION_MOCK = 'ot_geolocation_mock';
|
|
5
|
+
const ONETRUST_SCRIPT_ID = '38cb75bd-fbe1-4ac8-b4af-e531ab368caf-test';
|
|
6
|
+
export default () => {
|
|
7
|
+
const freestar = window.freestar || {};
|
|
8
|
+
freestar.queue = freestar.queue || [];
|
|
9
|
+
freestar.config = freestar.config || {};
|
|
10
|
+
freestar.config.enabled_slots = [];
|
|
11
|
+
freestar.initCallback = function () {
|
|
12
|
+
freestar.config.enabled_slots.length === 0 ?
|
|
13
|
+
(freestar.initCallbackCalled = false) :
|
|
14
|
+
freestar.newAdSlots(freestar.config.enabled_slots);
|
|
15
|
+
};
|
|
16
|
+
// Ask Rachel
|
|
17
|
+
freestar.config.channel = '/4735792/reuters.com/home';
|
|
18
|
+
window.initBootstrap({
|
|
19
|
+
onetrust_logs: getParameterByName(ONETRUST_LOGS) || 'false',
|
|
20
|
+
geolocation_mock: getParameterByName(ONETRUST_GEOLOCATION_MOCK) || 'default',
|
|
21
|
+
onetrust_script_id: ONETRUST_SCRIPT_ID,
|
|
22
|
+
}, (onetrustResponse) => {
|
|
23
|
+
const iasPromise = Ias();
|
|
24
|
+
// Ask Thea about Permutive implementation (considering there are no logged in users on Graphics)
|
|
25
|
+
// Should we use Permutive at all?
|
|
26
|
+
// Should we import ArcP SDK to graphics to get the same user as logged in on RCom?
|
|
27
|
+
return Promise.all([iasPromise]).then((responses) => {
|
|
28
|
+
const [iasResponse] = responses;
|
|
29
|
+
return {
|
|
30
|
+
...onetrustResponse,
|
|
31
|
+
ias: iasResponse,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
window.bootstrap.getResults((result) => {
|
|
36
|
+
// Set GAM
|
|
37
|
+
window.googletag = window.googletag || { cmd: [] };
|
|
38
|
+
window.googletag.cmd.push(() => {
|
|
39
|
+
window.googletag.pubads().enableSingleRequest();
|
|
40
|
+
window.googletag.pubads().enableAsyncRendering();
|
|
41
|
+
window.googletag.pubads().collapseEmptyDivs(true);
|
|
42
|
+
// Global Ads test targeting
|
|
43
|
+
const adstest = new URL(document.location.href).searchParams.get('adstest');
|
|
44
|
+
if (adstest) {
|
|
45
|
+
window.googletag.pubads().setTargeting('adstest', adstest);
|
|
46
|
+
}
|
|
47
|
+
// Ask Rachel about targeting
|
|
48
|
+
const template = document.querySelector('meta[name="ad:template"]')?.content;
|
|
49
|
+
if (template) {
|
|
50
|
+
window.googletag.pubads().setTargeting('template', template);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (!Array.isArray(window.graphicsAdQueue)) {
|
|
54
|
+
console.error('Ad queue not initialized!');
|
|
55
|
+
}
|
|
56
|
+
freestar.queue.push(function () {
|
|
57
|
+
freestar.newAdSlots(window.graphicsAdQueue || [], 'foobar');
|
|
58
|
+
});
|
|
59
|
+
freestar.queue.push(function () {
|
|
60
|
+
window.googletag.pubads().set('page_url', 'https://www.reuters.com/'); // This line should only be used for testing
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=bootstrapLoad.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default (name, url = window.location.href) => {
|
|
2
|
+
// eslint-disable-next-line no-useless-escape
|
|
3
|
+
name = name.replace(/[\[\]]/g, '\\$&');
|
|
4
|
+
const regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
|
|
5
|
+
const results = regex.exec(url);
|
|
6
|
+
if (!results)
|
|
7
|
+
return null;
|
|
8
|
+
if (!results[2])
|
|
9
|
+
return '';
|
|
10
|
+
return decodeURIComponent(results[2].replace(/\+/g, ' '));
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=getParameterByName.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const IAS_REQUEST_TIMEOUT = 600;
|
|
2
|
+
export default () => {
|
|
3
|
+
return new Promise((resolve) => {
|
|
4
|
+
const timerId = setTimeout(() => {
|
|
5
|
+
resolve('Resolved with timeout');
|
|
6
|
+
}, IAS_REQUEST_TIMEOUT);
|
|
7
|
+
const setupIAS = () => {
|
|
8
|
+
clearTimeout(timerId);
|
|
9
|
+
window.__iasPET = window.__iasPET || {};
|
|
10
|
+
window.__iasPET.queue = window.__iasPET.queue || [];
|
|
11
|
+
window.__iasPET.pubId = '931336'; // Ask Rachel
|
|
12
|
+
resolve('loaded');
|
|
13
|
+
};
|
|
14
|
+
// Set up IAS pet.js
|
|
15
|
+
const script = document.createElement('script');
|
|
16
|
+
script.src = '//static.adsafeprotected.com/iasPET.1.js';
|
|
17
|
+
script.setAttribute('async', 'async');
|
|
18
|
+
document.head.appendChild(script);
|
|
19
|
+
script.onload = setupIAS;
|
|
20
|
+
script.onerror = () => {
|
|
21
|
+
resolve('error');
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=ias.js.map
|
|
@@ -65,6 +65,12 @@ let isFocused = false;
|
|
|
65
65
|
let containerWidth;
|
|
66
66
|
$: containerHeight =
|
|
67
67
|
containerWidth && heightRatio ? containerWidth * heightRatio : height;
|
|
68
|
+
$: w = (imgOffset && imgOffset.width) || 0;
|
|
69
|
+
$: x = w * offset;
|
|
70
|
+
$: figStyle = `width:100%;height:${containerHeight}px;`;
|
|
71
|
+
$: imgStyle = 'width:100%;height:100%;';
|
|
72
|
+
$: beforeOverlayClip =
|
|
73
|
+
x < beforeOverlayWidth ? Math.abs(x - beforeOverlayWidth) : 0;
|
|
68
74
|
const onFocus = () => (isFocused = true);
|
|
69
75
|
const onBlur = () => (isFocused = false);
|
|
70
76
|
const handleKeyDown = (e) => {
|
|
@@ -114,12 +120,6 @@ const start = (e) => {
|
|
|
114
120
|
const end = () => {
|
|
115
121
|
sliding = false;
|
|
116
122
|
};
|
|
117
|
-
$: w = (imgOffset && imgOffset.width) || 0;
|
|
118
|
-
$: x = w * offset;
|
|
119
|
-
$: figStyle = `width:100%;height:${containerHeight}px;`;
|
|
120
|
-
$: imgStyle = 'width:100%;height:100%;';
|
|
121
|
-
$: beforeOverlayClip =
|
|
122
|
-
x < beforeOverlayWidth ? Math.abs(x - beforeOverlayWidth) : 0;
|
|
123
123
|
if (!(beforeSrc && beforeAlt && afterSrc && afterAlt)) {
|
|
124
124
|
console.warn('Missing required src or alt props for BeforeAfter component');
|
|
125
125
|
}
|
|
@@ -6,12 +6,11 @@ import { faWindowRestore } from '@fortawesome/free-regular-svg-icons';
|
|
|
6
6
|
{#if dev}
|
|
7
7
|
<div>
|
|
8
8
|
<a rel="external" href="/embed-previewer">
|
|
9
|
-
<Fa icon={faWindowRestore} />
|
|
9
|
+
<Fa icon="{faWindowRestore}" />
|
|
10
10
|
</a>
|
|
11
11
|
</div>
|
|
12
12
|
{/if}
|
|
13
13
|
|
|
14
|
-
|
|
15
14
|
<style>div {
|
|
16
15
|
position: fixed;
|
|
17
16
|
bottom: 5px;
|
|
@@ -23,4 +22,4 @@ div a {
|
|
|
23
22
|
}
|
|
24
23
|
div a:hover {
|
|
25
24
|
color: #666;
|
|
26
|
-
}</style>
|
|
25
|
+
}</style>
|
|
@@ -57,6 +57,23 @@
|
|
|
57
57
|
let prevResults = '';
|
|
58
58
|
let isFocused = false;
|
|
59
59
|
|
|
60
|
+
$: options = { pre: '<mark>', post: '</mark>', extract };
|
|
61
|
+
$: results =
|
|
62
|
+
value !== ''
|
|
63
|
+
? fuzzy
|
|
64
|
+
.filter(value, data, options)
|
|
65
|
+
.filter(({ score }) => score > 0)
|
|
66
|
+
.slice(0, limit)
|
|
67
|
+
.filter((result) => !filter(result.original))
|
|
68
|
+
.map((result) => ({ ...result, disabled: disable(result.original) }))
|
|
69
|
+
: data.map((d) => ({ string: extract(d), original: d }));
|
|
70
|
+
|
|
71
|
+
$: resultsId = results.map((result) => extract(result.original)).join('');
|
|
72
|
+
$: showResults = !hideDropdown && results.length > 0 && isFocused;
|
|
73
|
+
$: if (showDropdownOnFocus) {
|
|
74
|
+
showResults = showResults && isFocused;
|
|
75
|
+
}
|
|
76
|
+
|
|
60
77
|
afterUpdate(() => {
|
|
61
78
|
if (prevResults !== resultsId && autoselect) {
|
|
62
79
|
selectedIndex = getNextNonDisabledIndex();
|
|
@@ -137,23 +154,6 @@
|
|
|
137
154
|
|
|
138
155
|
const open = () => (hideDropdown = false);
|
|
139
156
|
const close = () => (hideDropdown = true);
|
|
140
|
-
|
|
141
|
-
$: options = { pre: '<mark>', post: '</mark>', extract };
|
|
142
|
-
$: results =
|
|
143
|
-
value !== ''
|
|
144
|
-
? fuzzy
|
|
145
|
-
.filter(value, data, options)
|
|
146
|
-
.filter(({ score }) => score > 0)
|
|
147
|
-
.slice(0, limit)
|
|
148
|
-
.filter((result) => !filter(result.original))
|
|
149
|
-
.map((result) => ({ ...result, disabled: disable(result.original) }))
|
|
150
|
-
: data.map((d) => ({ string: extract(d), original: d }));
|
|
151
|
-
|
|
152
|
-
$: resultsId = results.map((result) => extract(result.original)).join('');
|
|
153
|
-
$: showResults = !hideDropdown && results.length > 0 && isFocused;
|
|
154
|
-
$: if (showDropdownOnFocus) {
|
|
155
|
-
showResults = showResults && isFocused;
|
|
156
|
-
}
|
|
157
157
|
</script>
|
|
158
158
|
|
|
159
159
|
<svelte:window
|
|
@@ -171,6 +171,7 @@
|
|
|
171
171
|
aria-haspopup="listbox"
|
|
172
172
|
aria-owns="{id}-listbox"
|
|
173
173
|
class:dropdown="{results.length > 0}"
|
|
174
|
+
aria-controls="{id}-listbox"
|
|
174
175
|
aria-expanded="{showResults ||
|
|
175
176
|
(isFocused && value.length > 0 && results.length === 0)}"
|
|
176
177
|
id="{id}-typeahead"
|
|
@@ -247,6 +248,12 @@
|
|
|
247
248
|
selectedIndex = index;
|
|
248
249
|
select();
|
|
249
250
|
}}"
|
|
251
|
+
on:keyup="{(e) => {
|
|
252
|
+
if (e.key !== 'Enter') return;
|
|
253
|
+
if (result.disabled) return;
|
|
254
|
+
selectedIndex = index;
|
|
255
|
+
select();
|
|
256
|
+
}}"
|
|
250
257
|
on:mouseenter="{() => {
|
|
251
258
|
if (result.disabled) return;
|
|
252
259
|
selectedIndex = index;
|
|
@@ -71,25 +71,6 @@ import GraphicBlock from '../GraphicBlock/GraphicBlock.svelte';
|
|
|
71
71
|
import Block from '../Block/Block.svelte';
|
|
72
72
|
import Byline from '../Byline/Byline.svelte';
|
|
73
73
|
import PaddingReset from '../PaddingReset/PaddingReset.svelte';
|
|
74
|
-
let hedClass;
|
|
75
|
-
$: {
|
|
76
|
-
switch (hedSize) {
|
|
77
|
-
case 'biggest':
|
|
78
|
-
hedClass = 'text-6xl';
|
|
79
|
-
break;
|
|
80
|
-
case 'bigger':
|
|
81
|
-
hedClass = 'text-5xl';
|
|
82
|
-
break;
|
|
83
|
-
case 'big':
|
|
84
|
-
hedClass = 'text-4xl';
|
|
85
|
-
break;
|
|
86
|
-
case 'small':
|
|
87
|
-
hedClass = 'text-2xl';
|
|
88
|
-
break;
|
|
89
|
-
default:
|
|
90
|
-
hedClass = 'text-3xl';
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
74
|
</script>
|
|
94
75
|
|
|
95
76
|
<div style="--heroHeight: {embedded ? '850px' : '100svh'}; display:contents;">
|
|
@@ -5,23 +5,23 @@ export const getPhotoPackPropsFromDoc = (docBlock, assetsPath = '') => {
|
|
|
5
5
|
cls: docBlock.Class,
|
|
6
6
|
width: docBlock.Width,
|
|
7
7
|
textWidth: docBlock.textWidth,
|
|
8
|
-
gap: docBlock.Gap && isNaN(docBlock.Gap)
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
gap: docBlock.Gap && isNaN(docBlock.Gap) ?
|
|
9
|
+
null :
|
|
10
|
+
parseInt(docBlock.Gap),
|
|
11
11
|
images: docBlock.Images.map((img) => ({
|
|
12
|
-
src: /^https?:\/\/|^\/\//i.test(img.Src)
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
src: /^https?:\/\/|^\/\//i.test(img.Src) ?
|
|
13
|
+
img.Src :
|
|
14
|
+
urlJoin(assetsPath, img.Src),
|
|
15
15
|
altText: img.AltText,
|
|
16
16
|
caption: img.Caption,
|
|
17
|
-
maxHeight: img.MaxHeight && isNaN(img.MaxHeight)
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
maxHeight: img.MaxHeight && isNaN(img.MaxHeight) ?
|
|
18
|
+
null :
|
|
19
|
+
parseFloat(img.MaxHeight),
|
|
20
20
|
})),
|
|
21
21
|
layouts: docBlock.Layouts.map((layout) => ({
|
|
22
|
-
breakpoint: isNaN(layout.Breakpoint)
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
breakpoint: isNaN(layout.Breakpoint) ?
|
|
23
|
+
null :
|
|
24
|
+
parseFloat(layout.Breakpoint),
|
|
25
25
|
rows: layout.Rows.split(',').map((r) => parseInt(r.trim())),
|
|
26
26
|
})),
|
|
27
27
|
};
|
|
@@ -8,11 +8,19 @@ import Foreground from './Foreground.svelte';
|
|
|
8
8
|
{#each steps as step, index}
|
|
9
9
|
<!-- Background first -->
|
|
10
10
|
{#if embeddedLayout === 'bf'}
|
|
11
|
-
<Background
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
<Background
|
|
12
|
+
step="{step}"
|
|
13
|
+
index="{index}"
|
|
14
|
+
backgroundWidth="{backgroundWidth}"
|
|
15
|
+
/>
|
|
16
|
+
<Foreground step="{step}" index="{index}" />
|
|
17
|
+
<!-- Foreground first, default -->
|
|
14
18
|
{:else}
|
|
15
|
-
<Foreground {step} {index} />
|
|
16
|
-
<Background
|
|
19
|
+
<Foreground step="{step}" index="{index}" />
|
|
20
|
+
<Background
|
|
21
|
+
step="{step}"
|
|
22
|
+
index="{index}"
|
|
23
|
+
backgroundWidth="{backgroundWidth}"
|
|
24
|
+
/>
|
|
17
25
|
{/if}
|
|
18
|
-
{/each}
|
|
26
|
+
{/each}
|
|
@@ -1,90 +1,88 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import Fa from 'svelte-fa/src/fa.svelte';
|
|
3
|
-
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
-
import { faTwitter } from '@fortawesome/free-brands-svg-icons';
|
|
5
|
-
import { faFacebookF } from '@fortawesome/free-brands-svg-icons';
|
|
6
|
-
import { throttle } from 'lodash-es';
|
|
7
|
-
import handleTweet from './utils/twitter';
|
|
8
|
-
import handlePost from './utils/facebook';
|
|
9
|
-
import UAParser from 'ua-parser-js';
|
|
10
|
-
import { onMount } from 'svelte';
|
|
2
|
+
import Fa from 'svelte-fa/src/fa.svelte';
|
|
3
|
+
import { faShareAlt } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { faTwitter } from '@fortawesome/free-brands-svg-icons';
|
|
5
|
+
import { faFacebookF } from '@fortawesome/free-brands-svg-icons';
|
|
6
|
+
import { throttle } from 'lodash-es';
|
|
7
|
+
import handleTweet from './utils/twitter';
|
|
8
|
+
import handlePost from './utils/facebook';
|
|
9
|
+
import UAParser from 'ua-parser-js';
|
|
10
|
+
import { onMount } from 'svelte';
|
|
11
11
|
|
|
12
|
-
const uaParser = new UAParser();
|
|
12
|
+
const uaParser = new UAParser();
|
|
13
13
|
|
|
14
|
-
const getMetaContent = (property) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
const handleShare = async function() {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
if (
|
|
25
|
-
navigator &&
|
|
26
|
-
navigator.share &&
|
|
27
|
-
uaParser.getBrowser().name !== 'Safari'
|
|
28
|
-
) {
|
|
29
|
-
try {
|
|
30
|
-
await navigator.share({
|
|
31
|
-
title: getMetaContent('og:title'),
|
|
32
|
-
text: getMetaContent('og:description'),
|
|
33
|
-
url: window.location.href,
|
|
34
|
-
});
|
|
35
|
-
} catch (err) {
|
|
36
|
-
console.log('Share error', err);
|
|
14
|
+
const getMetaContent = (property) => {
|
|
15
|
+
const el = document.querySelector(`meta[property="${property}"]`);
|
|
16
|
+
if (el) return el.getAttribute('content');
|
|
17
|
+
return '';
|
|
18
|
+
};
|
|
19
|
+
const handleShare = async function () {
|
|
20
|
+
if (showSecondaryDialogue) {
|
|
21
|
+
showSecondaryDialogue = false;
|
|
22
|
+
return;
|
|
37
23
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
24
|
+
if (
|
|
25
|
+
navigator &&
|
|
26
|
+
navigator.share &&
|
|
27
|
+
uaParser.getBrowser().name !== 'Safari'
|
|
28
|
+
) {
|
|
29
|
+
try {
|
|
30
|
+
await navigator.share({
|
|
31
|
+
title: getMetaContent('og:title'),
|
|
32
|
+
text: getMetaContent('og:description'),
|
|
33
|
+
url: window.location.href,
|
|
34
|
+
});
|
|
35
|
+
} catch (err) {
|
|
36
|
+
console.log('Share error', err);
|
|
37
|
+
}
|
|
38
|
+
// Otherwise copy URL to a clipboard
|
|
39
|
+
} else {
|
|
40
|
+
showSecondaryDialogue = true;
|
|
50
41
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
42
|
+
};
|
|
43
|
+
let lastScroll = 0;
|
|
44
|
+
let showShare = false;
|
|
45
|
+
let showSecondaryDialogue = false;
|
|
46
|
+
function handleScroll() {
|
|
47
|
+
if (lastScroll > window.scrollY) {
|
|
48
|
+
if (!showShare) {
|
|
49
|
+
showShare = true;
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
if (showShare) {
|
|
53
|
+
if (showSecondaryDialogue) {
|
|
54
|
+
showSecondaryDialogue = false;
|
|
55
|
+
} else {
|
|
56
|
+
showShare = false;
|
|
57
|
+
}
|
|
57
58
|
}
|
|
58
59
|
}
|
|
60
|
+
lastScroll = window.scrollY;
|
|
59
61
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
window.addEventListener('scroll', throttle(handleScroll, 250));
|
|
64
|
-
});
|
|
62
|
+
onMount(() => {
|
|
63
|
+
window.addEventListener('scroll', throttle(handleScroll, 250));
|
|
64
|
+
});
|
|
65
65
|
</script>
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
<div class="
|
|
69
|
-
<div class="drawer" class:active={showSecondaryDialogue }>
|
|
67
|
+
<div class="sharetool" class:active="{showShare}">
|
|
68
|
+
<div class="drawer" class:active="{showSecondaryDialogue}">
|
|
70
69
|
<button
|
|
71
|
-
on:click={handleShare}
|
|
70
|
+
on:click="{handleShare}"
|
|
72
71
|
title="Share this!"
|
|
73
|
-
disabled={showSecondaryDialogue}
|
|
74
|
-
class=
|
|
72
|
+
disabled="{showSecondaryDialogue}"
|
|
73
|
+
class="box-shadow-low"
|
|
75
74
|
>
|
|
76
|
-
<div><Fa fw icon={faShareAlt} /></div>
|
|
75
|
+
<div><Fa fw icon="{faShareAlt}" /></div>
|
|
77
76
|
</button>
|
|
78
|
-
<button on:click={handleTweet} title="Twitter">
|
|
79
|
-
<div><Fa fw icon={faTwitter} /></div>
|
|
77
|
+
<button on:click="{handleTweet}" title="Twitter">
|
|
78
|
+
<div><Fa fw icon="{faTwitter}" /></div>
|
|
80
79
|
</button>
|
|
81
|
-
<button on:click={handlePost} title="Facebook">
|
|
82
|
-
<div><Fa fw icon={faFacebookF} /></div>
|
|
80
|
+
<button on:click="{handlePost}" title="Facebook">
|
|
81
|
+
<div><Fa fw icon="{faFacebookF}" /></div>
|
|
83
82
|
</button>
|
|
84
83
|
</div>
|
|
85
84
|
</div>
|
|
86
85
|
|
|
87
|
-
|
|
88
86
|
<style>.sharetool.active {
|
|
89
87
|
bottom: 10px;
|
|
90
88
|
}
|
|
@@ -154,4 +152,4 @@ onMount(() => {
|
|
|
154
152
|
.drawer.active {
|
|
155
153
|
width: calc(9.5rem + 4px);
|
|
156
154
|
}
|
|
157
|
-
}</style>
|
|
155
|
+
}</style>
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,11 @@ export { default as resizeObserver } from './actions/resizeObserver/index.js';
|
|
|
5
5
|
// Components
|
|
6
6
|
export {
|
|
7
7
|
default as Analytics,
|
|
8
|
-
registerPageview
|
|
8
|
+
registerPageview
|
|
9
9
|
} from './components/Analytics/Analytics.svelte';
|
|
10
10
|
export { default as Article } from './components/Article/Article.svelte';
|
|
11
|
+
export { default as AdScripts } from './components/AdSlot/AdScripts.svelte';
|
|
12
|
+
export { default as AdSlot } from './components/AdSlot/AdSlot.svelte';
|
|
11
13
|
export { default as BeforeAfter } from './components/BeforeAfter/BeforeAfter.svelte';
|
|
12
14
|
export { default as Block } from './components/Block/Block.svelte';
|
|
13
15
|
export { default as BodyText } from './components/BodyText/BodyText.svelte';
|
|
@@ -43,7 +45,7 @@ export { default as Table } from './components/Table/Table.svelte';
|
|
|
43
45
|
export {
|
|
44
46
|
default as Theme,
|
|
45
47
|
// @ts-ignore
|
|
46
|
-
themes
|
|
48
|
+
themes
|
|
47
49
|
} from './components/Theme/Theme.svelte';
|
|
48
50
|
export { default as ToolsHeader } from './components/ToolsHeader/ToolsHeader.svelte';
|
|
49
51
|
export { default as Video } from './components/Video/Video.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.8--canary.c0819ff.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://reuters-graphics.github.io/graphics-components",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"start": "storybook dev -p 3000",
|
|
17
17
|
"new": "node ./bin/newComponent/index.cjs",
|
|
18
|
+
"lint": "npx eslint --fix --ext .ts,.js,.svelte src",
|
|
18
19
|
"build:package": "node ./bin/buildPackage/index.js",
|
|
19
20
|
"build:chromatic": "storybook build -o docs",
|
|
20
21
|
"build:docs": "storybook build -o docs && touch ./docs/.nojekyll",
|
|
@@ -68,8 +69,8 @@
|
|
|
68
69
|
"colord": "^2.9.3",
|
|
69
70
|
"css-color-converter": "^2.0.0",
|
|
70
71
|
"deep-object-diff": "^1.1.9",
|
|
71
|
-
"eslint": "^8.
|
|
72
|
-
"eslint-config-prettier": "^
|
|
72
|
+
"eslint": "^8.56.0",
|
|
73
|
+
"eslint-config-prettier": "^9.1.0",
|
|
73
74
|
"eslint-config-standard-jsx": "^11.0.0",
|
|
74
75
|
"eslint-config-standard-react": "^13.0.0",
|
|
75
76
|
"eslint-plugin-import": "^2.27.5",
|
|
@@ -78,7 +79,7 @@
|
|
|
78
79
|
"eslint-plugin-promise": "^6.1.1",
|
|
79
80
|
"eslint-plugin-react": "^7.32.2",
|
|
80
81
|
"eslint-plugin-storybook": "^0.6.12",
|
|
81
|
-
"eslint-plugin-svelte": "^2.
|
|
82
|
+
"eslint-plugin-svelte": "^2.35.1",
|
|
82
83
|
"fs-extra": "^11.1.1",
|
|
83
84
|
"kleur": "^4.1.5",
|
|
84
85
|
"mermaid": "^10.3.0",
|
|
@@ -131,6 +132,11 @@
|
|
|
131
132
|
"./actions/cssVariables": "./dist/actions/cssVariables/index.js",
|
|
132
133
|
"./actions/resizeObserver": "./dist/actions/resizeObserver/index.js",
|
|
133
134
|
"./components/@types/global.ts": "./dist/components/@types/global.ts",
|
|
135
|
+
"./components/AdSlot/AdScripts.svelte": "./dist/components/AdSlot/AdScripts.svelte",
|
|
136
|
+
"./components/AdSlot/AdSlot.svelte": "./dist/components/AdSlot/AdSlot.svelte",
|
|
137
|
+
"./components/AdSlot/scripts/bootstrapLoad.ts": "./dist/components/AdSlot/scripts/bootstrapLoad.ts",
|
|
138
|
+
"./components/AdSlot/scripts/getParameterByName.ts": "./dist/components/AdSlot/scripts/getParameterByName.ts",
|
|
139
|
+
"./components/AdSlot/scripts/ias.ts": "./dist/components/AdSlot/scripts/ias.ts",
|
|
134
140
|
"./components/Analytics/Analytics.svelte": "./dist/components/Analytics/Analytics.svelte",
|
|
135
141
|
"./components/Analytics/providers/chartbeat.ts": "./dist/components/Analytics/providers/chartbeat.ts",
|
|
136
142
|
"./components/Analytics/providers/ga.ts": "./dist/components/Analytics/providers/ga.ts",
|