@reuters-graphics/graphics-components 1.0.4 → 1.0.6
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/ReferralBlock/ReferralBlock.svelte.d.ts +4 -2
- package/dist/components/DatawrapperChart/DatawrapperChart.svelte +1 -0
- package/dist/components/ReferralBlock/ReferralBlock.svelte +22 -12
- package/dist/components/SiteFooter/Referrals/Link.svelte +1 -0
- package/dist/components/SiteFooter/SiteFooter.svelte +3 -1
- package/dist/components/SiteHeader/SiteHeader.svelte +4 -0
- package/dist/scss/mixins/_block.scss +5 -8
- package/dist/scss/tokens/variables/_block.scss +6 -0
- package/dist/scss/tokens/variables/_main.scss +1 -0
- package/package.json +2 -2
- package/dist/@types/components/ReferralBlock/stores.d.ts +0 -2
- package/dist/components/ReferralBlock/stores.js +0 -3
|
@@ -5,8 +5,10 @@ declare const __propDef: {
|
|
|
5
5
|
* Section ID, which is often the URL path to the section page on reuters.com.
|
|
6
6
|
*
|
|
7
7
|
* Note that not all section pages will be available in the recent stories by section API.
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
*/ section?: string | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Collection alias, as defined in Arc Collections editor.
|
|
11
|
+
*/ collection: string | undefined;
|
|
10
12
|
/**
|
|
11
13
|
* Number of referrals to show.
|
|
12
14
|
* @required
|
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
* Section ID, which is often the URL path to the section page on reuters.com.
|
|
5
5
|
*
|
|
6
6
|
* Note that not all section pages will be available in the recent stories by section API.
|
|
7
|
-
* @required
|
|
8
7
|
*/
|
|
9
8
|
export let section = '/world/';
|
|
9
|
+
/**
|
|
10
|
+
* Collection alias, as defined in Arc Collections editor.
|
|
11
|
+
*/
|
|
12
|
+
export let collection;
|
|
10
13
|
/**
|
|
11
14
|
* Number of referrals to show.
|
|
12
15
|
* @required
|
|
@@ -28,29 +31,36 @@ export let width = 'wide';
|
|
|
28
31
|
/** Add an ID to target with SCSS. */
|
|
29
32
|
export let id = '';
|
|
30
33
|
/** Add a class to target with SCSS. */
|
|
31
|
-
let cls = '';
|
|
34
|
+
let cls = 'fmy-8';
|
|
32
35
|
export { cls as class };
|
|
33
36
|
import Block from '../Block/Block.svelte';
|
|
34
|
-
import { referrals } from './stores.js';
|
|
37
|
+
// import { referrals } from './stores.js';
|
|
35
38
|
import { onMount } from 'svelte';
|
|
36
39
|
import { getTime } from '../SiteHeader/NavBar/NavDropdown/StoryCard/time';
|
|
37
40
|
let clientWidth;
|
|
41
|
+
const SECTION_API = 'recent-stories-by-sections-v1';
|
|
42
|
+
const COLLECTION_API = 'articles-by-collection-alias-or-id-v1';
|
|
43
|
+
let referrals = [];
|
|
38
44
|
onMount(async () => {
|
|
45
|
+
const isCollection = Boolean(collection);
|
|
46
|
+
const API = isCollection ? COLLECTION_API : SECTION_API;
|
|
39
47
|
try {
|
|
40
|
-
const response = await fetch(
|
|
48
|
+
const response = await fetch(`https://www.reuters.com/pf/api/v3/content/fetch/${API}?` +
|
|
41
49
|
new URLSearchParams({
|
|
42
50
|
query: JSON.stringify({
|
|
43
|
-
section_ids: section,
|
|
51
|
+
section_ids: isCollection ? undefined : section,
|
|
52
|
+
collection_alias: isCollection ? collection : undefined,
|
|
44
53
|
size: 20,
|
|
45
54
|
website: 'reuters',
|
|
46
55
|
}),
|
|
47
56
|
}));
|
|
48
|
-
const
|
|
49
|
-
|
|
57
|
+
const data = await response.json();
|
|
58
|
+
const articles = data.result.articles
|
|
59
|
+
.filter((a) => a?.headline_category || a?.kicker?.name)
|
|
50
60
|
.filter((a) => a?.thumbnail?.renditions?.landscape?.['240w'])
|
|
51
61
|
.filter((a) => !a?.content?.third_party)
|
|
52
62
|
.slice(0, number);
|
|
53
|
-
referrals
|
|
63
|
+
referrals = articles;
|
|
54
64
|
}
|
|
55
65
|
catch (e) {
|
|
56
66
|
console.warn('Unable to fetch referral links.');
|
|
@@ -59,8 +69,8 @@ onMount(async () => {
|
|
|
59
69
|
getTime();
|
|
60
70
|
</script>
|
|
61
71
|
|
|
62
|
-
{#if
|
|
63
|
-
<Block width="{width}" id="{id}" class="referrals-block
|
|
72
|
+
{#if referrals.length === number}
|
|
73
|
+
<Block width="{width}" id="{id}" class="referrals-block {cls}">
|
|
64
74
|
{#if heading}
|
|
65
75
|
<div
|
|
66
76
|
class="heading h4 font-bold"
|
|
@@ -75,7 +85,7 @@ getTime();
|
|
|
75
85
|
class:xs="{clientWidth && clientWidth < 450}"
|
|
76
86
|
bind:clientWidth="{clientWidth}"
|
|
77
87
|
>
|
|
78
|
-
{#each
|
|
88
|
+
{#each referrals as referral}
|
|
79
89
|
<div class="referral">
|
|
80
90
|
<a
|
|
81
91
|
href="https://www.reuters.com{referral.canonical_url}"
|
|
@@ -91,7 +101,7 @@ getTime();
|
|
|
91
101
|
class="kicker m-0 body-caption leading-tighter"
|
|
92
102
|
data-chromatic="ignore"
|
|
93
103
|
>
|
|
94
|
-
{referral.kicker.name}
|
|
104
|
+
{referral.headline_category || referral.kicker.name}
|
|
95
105
|
</div>
|
|
96
106
|
<div
|
|
97
107
|
class="title m-0 body-caption leading-tighter"
|
|
@@ -11,6 +11,9 @@ import { onMount } from 'svelte';
|
|
|
11
11
|
export let referrals = [];
|
|
12
12
|
let data = starterData;
|
|
13
13
|
onMount(async () => {
|
|
14
|
+
if (new URL(document.location.href).origin !== 'https://www.reuters.com') {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
14
17
|
try {
|
|
15
18
|
const response = await fetch('https://www.reuters.com/site-api/footer/?' +
|
|
16
19
|
new URLSearchParams({
|
|
@@ -46,7 +49,6 @@ onMount(async () => {
|
|
|
46
49
|
</div>
|
|
47
50
|
</footer>
|
|
48
51
|
|
|
49
|
-
<!-- svelte-ignore css-unused-selector -->
|
|
50
52
|
<style>footer {
|
|
51
53
|
margin-top: 0;
|
|
52
54
|
background-color: var(--nav-background, #fff);
|
|
@@ -11,6 +11,10 @@ let data = starterData;
|
|
|
11
11
|
$: sections = data[0].sections;
|
|
12
12
|
let isMobileMenuOpen = false;
|
|
13
13
|
onMount(async () => {
|
|
14
|
+
// Only fire on prod...
|
|
15
|
+
if (new URL(document.location.href).origin !== 'https://www.reuters.com') {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
14
18
|
try {
|
|
15
19
|
const response = await fetch('https://www.reuters.com/site-api/header/?' +
|
|
16
20
|
new URLSearchParams({
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
$column-width-narrow: 510px !default;
|
|
3
|
-
$column-width-normal: 660px !default;
|
|
4
|
-
$column-width-wide: 930px !default;
|
|
5
|
-
$column-width-wider: 1200px !default;
|
|
1
|
+
@use '../tokens/variables/block' as *;
|
|
6
2
|
|
|
7
3
|
@mixin block-snap-widths($article-padding: 30px) {
|
|
8
4
|
width: $column-width-narrower;
|
|
@@ -52,11 +48,12 @@ $column-width-wider: 1200px !default;
|
|
|
52
48
|
}
|
|
53
49
|
}
|
|
54
50
|
|
|
55
|
-
&.widest,
|
|
51
|
+
&.widest,
|
|
52
|
+
&.fluid {
|
|
56
53
|
width: inherit;
|
|
57
54
|
}
|
|
58
|
-
|
|
55
|
+
|
|
59
56
|
&.fluid {
|
|
60
57
|
width: calc(100% + $article-padding);
|
|
61
58
|
}
|
|
62
|
-
}
|
|
59
|
+
}
|
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.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://reuters-graphics.github.io/graphics-components",
|
|
@@ -165,7 +165,6 @@
|
|
|
165
165
|
"./components/PymChild/PymChild.svelte": "./dist/components/PymChild/PymChild.svelte",
|
|
166
166
|
"./components/PymChild/stores": "./dist/components/PymChild/stores.js",
|
|
167
167
|
"./components/ReferralBlock/ReferralBlock.svelte": "./dist/components/ReferralBlock/ReferralBlock.svelte",
|
|
168
|
-
"./components/ReferralBlock/stores": "./dist/components/ReferralBlock/stores.js",
|
|
169
168
|
"./components/ReutersGraphicsLogo/ReutersGraphicsLogo.svelte": "./dist/components/ReutersGraphicsLogo/ReutersGraphicsLogo.svelte",
|
|
170
169
|
"./components/ReutersLogo/ReutersLogo.svelte": "./dist/components/ReutersLogo/ReutersLogo.svelte",
|
|
171
170
|
"./components/SEO/SEO.svelte": "./dist/components/SEO/SEO.svelte",
|
|
@@ -352,6 +351,7 @@
|
|
|
352
351
|
"./scss/tokens/text/mixins/main": "./dist/scss/tokens/text/mixins/_main.scss",
|
|
353
352
|
"./scss/tokens/text/mixins/text-role": "./dist/scss/tokens/text/mixins/_text-role.scss",
|
|
354
353
|
"./scss/tokens/text/mixins/text-stroke": "./dist/scss/tokens/text/mixins/_text-stroke.scss",
|
|
354
|
+
"./scss/tokens/variables/block": "./dist/scss/tokens/variables/_block.scss",
|
|
355
355
|
"./scss/tokens/variables/main": "./dist/scss/tokens/variables/_main.scss",
|
|
356
356
|
"./scss/tokens/variables/theme": "./dist/scss/tokens/variables/_theme.scss",
|
|
357
357
|
".": "./dist/index.js"
|