@reuters-graphics/graphics-components 2.0.0 → 2.0.2
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/components/Block/Block.stories.svelte +7 -1
- package/dist/components/Block/Block.stories.svelte.d.ts +8 -5
- package/dist/components/FeaturePhoto/stories/docs/archieML.md +37 -0
- package/dist/components/GraphicBlock/stories/docs/archieML.md +40 -0
- package/dist/components/PhotoPack/stories/docs/archieML.md +63 -0
- package/dist/components/ReferralBlock/ReferralBlock.svelte +22 -8
- package/dist/components/ReferralBlock/filterCurrentPage.d.ts +2 -0
- package/dist/components/ReferralBlock/filterCurrentPage.js +32 -0
- package/dist/components/ReferralBlock/types.d.ts +99 -0
- package/dist/components/ReferralBlock/types.js +1 -0
- package/dist/components/SEO/stories/docs/archieML.md +36 -0
- package/dist/components/Scroller/stories/docs/ai2svelte.md +0 -82
- package/dist/components/Scroller/stories/docs/archieML.md +87 -0
- package/dist/components/SiteHeader/NavBar/NavDropdown/StoryCard/index.svelte +12 -5
- package/dist/components/SiteHeadline/stories/docs/archieML.md +26 -0
- package/dist/docs/docs-components/CopyColourTable/styles.module.scss +4 -2
- package/dist/docs/docs-components/Herbie/Herbie.d.ts +7 -0
- package/dist/docs/docs-components/Herbie/Herbie.tsx +47 -0
- package/dist/docs/docs-components/Highlight/Highlight.d.ts +6 -0
- package/dist/docs/docs-components/Highlight/Highlight.tsx +19 -0
- package/dist/docs/docs-components/SubtleHighlight/SubtleHighlight.d.ts +6 -0
- package/dist/docs/docs-components/SubtleHighlight/SubtleHighlight.tsx +16 -0
- package/dist/docs/docs-components/ThemeBuilder/NewTheme/styles.module.scss +3 -1
- package/dist/docs/docs-components/syntax/nord.d.ts +7 -0
- package/dist/docs/docs-components/syntax/nord.js +155 -0
- package/dist/docs/guides/archieml.mdx +441 -0
- package/dist/docs/guides/svelte-components.mdx +138 -0
- package/package.json +2 -1
|
@@ -3,10 +3,16 @@ import customLayoutsDocs from "./stories/docs/customLayouts.md?raw";
|
|
|
3
3
|
import snapWidthsDocs from "./stories/docs/snapWidths.md?raw";
|
|
4
4
|
import Block from "./Block.svelte";
|
|
5
5
|
import { withComponentDocs, withStoryDocs } from "$docs/utils/withParams.js";
|
|
6
|
+
import { toId } from "@storybook/csf";
|
|
6
7
|
export const meta = {
|
|
7
8
|
title: "Components/Page layout/Block",
|
|
8
9
|
component: Block,
|
|
9
|
-
|
|
10
|
+
parameters: {
|
|
11
|
+
...withComponentDocs(componentDocs).parameters,
|
|
12
|
+
canvasDocs: {
|
|
13
|
+
[toId("Components/Page layout/Block", "default")]: componentDocs
|
|
14
|
+
}
|
|
15
|
+
},
|
|
10
16
|
argTypes: {
|
|
11
17
|
width: {
|
|
12
18
|
control: "select",
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
export declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: typeof Block;
|
|
5
|
+
parameters: {
|
|
6
|
+
canvasDocs: {
|
|
7
|
+
[x: string]: any;
|
|
8
|
+
};
|
|
9
|
+
docs: any;
|
|
10
|
+
};
|
|
3
11
|
argTypes: {
|
|
4
12
|
width: {
|
|
5
13
|
control: string;
|
|
6
14
|
options: string[];
|
|
7
15
|
};
|
|
8
16
|
};
|
|
9
|
-
parameters: {
|
|
10
|
-
docs: any;
|
|
11
|
-
};
|
|
12
|
-
title: string;
|
|
13
|
-
component: typeof Block;
|
|
14
17
|
};
|
|
15
18
|
declare const __propDef: {
|
|
16
19
|
props: Record<string, never>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
```yaml
|
|
2
|
+
[blocks]
|
|
3
|
+
|
|
4
|
+
type: photo
|
|
5
|
+
width: normal
|
|
6
|
+
src: images/shark.jpg
|
|
7
|
+
altText: The king of the sea
|
|
8
|
+
caption: Carcharodon carcharias - REUTERS
|
|
9
|
+
|
|
10
|
+
[]
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```svelte
|
|
14
|
+
<!-- App.svelte -->
|
|
15
|
+
<script>
|
|
16
|
+
import { FeaturePhoto } from '@reuters-graphics/graphics-components';
|
|
17
|
+
|
|
18
|
+
import content from '$locales/en/content.json';
|
|
19
|
+
import { assets } from '$app/paths';
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
{#each content.blocks as block}
|
|
23
|
+
{#if block.Type === 'text'}
|
|
24
|
+
<!-- ... -->
|
|
25
|
+
|
|
26
|
+
{:else if block.type === 'photo'}
|
|
27
|
+
<FeaturePhoto
|
|
28
|
+
width="{block.width}"
|
|
29
|
+
src="{`${assets}/${block.src}`}"
|
|
30
|
+
altText="{block.altText}"
|
|
31
|
+
caption="{block.caption}"
|
|
32
|
+
/>
|
|
33
|
+
|
|
34
|
+
<!-- ... -->
|
|
35
|
+
{/if}
|
|
36
|
+
{/each}
|
|
37
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
For Graphics Kit users, the `GraphicBlock` component is built-in to handle [ai2svelte](https://github.com/reuters-graphics/ai2svelte) graphics.
|
|
2
|
+
|
|
3
|
+
First, import your ai2svelte graphic in `App.svelte` and add it to the `aiCharts` object;
|
|
4
|
+
|
|
5
|
+
```svelte
|
|
6
|
+
<!-- App.svelte -->
|
|
7
|
+
<script>
|
|
8
|
+
// Other stuff...
|
|
9
|
+
|
|
10
|
+
import AiMap from './ai2svelte/my-map.svelte';
|
|
11
|
+
|
|
12
|
+
const aiCharts = {
|
|
13
|
+
// Other charts...
|
|
14
|
+
AiMap,
|
|
15
|
+
};
|
|
16
|
+
</script>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Then add the following structure to your ArchieML doc, taking care that the name of your chart in the `aiCharts` object matches the name of your `chart`:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
[blocks]
|
|
23
|
+
# ...
|
|
24
|
+
|
|
25
|
+
type: ai-graphic
|
|
26
|
+
chart: AiMap
|
|
27
|
+
width: normal
|
|
28
|
+
textWidth: normal
|
|
29
|
+
title: Earthquake in Haiti
|
|
30
|
+
description: The 7.2-magnitude earthquake struck at 8:29 a.m. EST, Aug. 14, 2021.
|
|
31
|
+
notes: \Note: A shakemap represents the ground shaking produced by an earthquake.
|
|
32
|
+
|
|
33
|
+
\Source: USGIS
|
|
34
|
+
:end
|
|
35
|
+
altText: A map that shows the shake intensity of the earthquake, which was worst in central Haiti.
|
|
36
|
+
:end
|
|
37
|
+
|
|
38
|
+
# ...
|
|
39
|
+
[]
|
|
40
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
```yaml
|
|
2
|
+
[blocks]
|
|
3
|
+
# ...
|
|
4
|
+
|
|
5
|
+
type: photo-pack
|
|
6
|
+
id: my-photo-pack
|
|
7
|
+
class: mb-2
|
|
8
|
+
width: wide
|
|
9
|
+
textWidth: normal
|
|
10
|
+
gap: 10
|
|
11
|
+
[.images]
|
|
12
|
+
src: images/my-img-1.jpg
|
|
13
|
+
altText: Alt text
|
|
14
|
+
caption: Lorem ipsum. REUTERS/Photog
|
|
15
|
+
|
|
16
|
+
src: images/my-img-2.jpg
|
|
17
|
+
altText: Alt text
|
|
18
|
+
caption: Lorem ipsum. REUTERS/Photog
|
|
19
|
+
|
|
20
|
+
src: images/my-img-3.jpg
|
|
21
|
+
altText: Alt text
|
|
22
|
+
caption: Lorem ipsum. REUTERS/Photog
|
|
23
|
+
|
|
24
|
+
src: images/my-img-4.jpg
|
|
25
|
+
altText: Alt text
|
|
26
|
+
caption: Lorem ipsum. REUTERS/Photog
|
|
27
|
+
|
|
28
|
+
src: images/my-img-5.jpg
|
|
29
|
+
altText: Alt text
|
|
30
|
+
caption: Lorem ipsum. REUTERS/Photog
|
|
31
|
+
[]
|
|
32
|
+
|
|
33
|
+
# ...
|
|
34
|
+
[]
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```svelte
|
|
38
|
+
<!-- App.svelte -->
|
|
39
|
+
{#each content.blocks as block}
|
|
40
|
+
{#if block.type === 'text'}
|
|
41
|
+
<!-- ... -->
|
|
42
|
+
|
|
43
|
+
{:else if block.type === 'photo-pack'}
|
|
44
|
+
<PhotoPack
|
|
45
|
+
id={block.id}
|
|
46
|
+
class={block.class}
|
|
47
|
+
width={block.width}
|
|
48
|
+
textWidth={block.textWidth}
|
|
49
|
+
images={block.images.map((img) => ({
|
|
50
|
+
src: `${assets}/${img.src}`,
|
|
51
|
+
altText: img.altText,
|
|
52
|
+
caption: img.caption,
|
|
53
|
+
}))}
|
|
54
|
+
layouts={[
|
|
55
|
+
{ breakpoint: 750, rows: [2, 3] },
|
|
56
|
+
{ breakpoint: 450, rows: [1, 2, 2] },
|
|
57
|
+
]}
|
|
58
|
+
/>
|
|
59
|
+
|
|
60
|
+
<!-- ... -->
|
|
61
|
+
{/if}
|
|
62
|
+
{/each}
|
|
63
|
+
```
|
|
@@ -11,6 +11,7 @@ export { cls as class };
|
|
|
11
11
|
import Block from "../Block/Block.svelte";
|
|
12
12
|
import { onMount } from "svelte";
|
|
13
13
|
import { getTime } from "../SiteHeader/NavBar/NavDropdown/StoryCard/time";
|
|
14
|
+
import { articleIsNotCurrentPage } from "./filterCurrentPage";
|
|
14
15
|
let clientWidth;
|
|
15
16
|
const SECTION_API = "recent-stories-by-sections-v1";
|
|
16
17
|
const COLLECTION_API = "articles-by-collection-alias-or-id-v1";
|
|
@@ -30,7 +31,9 @@ const getReferrals = async () => {
|
|
|
30
31
|
})
|
|
31
32
|
);
|
|
32
33
|
const data = await response.json();
|
|
33
|
-
const articles = data.result.articles.filter((a) => a?.headline_category || a?.kicker?.name).filter(
|
|
34
|
+
const articles = data.result.articles.filter((a) => a?.headline_category || a?.kicker?.name).filter(
|
|
35
|
+
(a) => a?.thumbnail?.renditions?.landscape?.["240w"] || a?.thumbnail?.resizer_url
|
|
36
|
+
).filter((a) => !a?.content?.third_party).filter(articleIsNotCurrentPage).slice(0, number);
|
|
34
37
|
referrals = articles;
|
|
35
38
|
} catch {
|
|
36
39
|
console.warn("Unable to fetch referral links.");
|
|
@@ -94,13 +97,24 @@ onMount(getReferrals);
|
|
|
94
97
|
class="image-container block m-0 overflow-hidden relative"
|
|
95
98
|
class:xs="{clientWidth && clientWidth < 450}"
|
|
96
99
|
>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
{#if referral.thumbnail.resizer_url}
|
|
101
|
+
<img
|
|
102
|
+
class="block object-cover m-0 w-full"
|
|
103
|
+
data-chromatic="ignore"
|
|
104
|
+
src="{referral.thumbnail
|
|
105
|
+
.resizer_url}&width=120&quality=80"
|
|
106
|
+
alt="{referral.thumbnail.caption ||
|
|
107
|
+
referral.thumbnail.alt_text}"
|
|
108
|
+
/>
|
|
109
|
+
{:else}
|
|
110
|
+
<img
|
|
111
|
+
class="block object-cover m-0 w-full"
|
|
112
|
+
data-chromatic="ignore"
|
|
113
|
+
src="{referral.thumbnail.renditions.landscape['240w']}"
|
|
114
|
+
alt="{referral.thumbnail.caption ||
|
|
115
|
+
referral.thumbnail.alt_text}"
|
|
116
|
+
/>
|
|
117
|
+
{/if}
|
|
104
118
|
</div>
|
|
105
119
|
</div>
|
|
106
120
|
</a>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const getUrlFromPath = (path) => {
|
|
2
|
+
const base = 'https://www.reuters.com';
|
|
3
|
+
try {
|
|
4
|
+
return new URL(path);
|
|
5
|
+
}
|
|
6
|
+
catch {
|
|
7
|
+
try {
|
|
8
|
+
return new URL(path, base);
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const isCurrentPage = (urlPath) => {
|
|
16
|
+
if (typeof window === 'undefined' || typeof window.location === 'undefined') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const url = getUrlFromPath(urlPath);
|
|
20
|
+
if (!url)
|
|
21
|
+
return false;
|
|
22
|
+
return (window.location.origin === url.origin &&
|
|
23
|
+
window.location.pathname === url.pathname);
|
|
24
|
+
};
|
|
25
|
+
export const articleIsNotCurrentPage = (article) => {
|
|
26
|
+
const { redirect_url: redirectUrl, canonical_url: canonicalUrl } = article;
|
|
27
|
+
if (redirectUrl)
|
|
28
|
+
return !isCurrentPage(redirectUrl);
|
|
29
|
+
if (canonicalUrl)
|
|
30
|
+
return !isCurrentPage(canonicalUrl);
|
|
31
|
+
return true;
|
|
32
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export interface Referrals {
|
|
2
|
+
statusCode: number;
|
|
3
|
+
message: string;
|
|
4
|
+
result: Result;
|
|
5
|
+
}
|
|
6
|
+
interface Result {
|
|
7
|
+
date_modified: Date;
|
|
8
|
+
pagination: Pagination;
|
|
9
|
+
fetch_type: string;
|
|
10
|
+
title: string;
|
|
11
|
+
articles: Article[];
|
|
12
|
+
}
|
|
13
|
+
export interface Article {
|
|
14
|
+
id: string;
|
|
15
|
+
canonical_url: string;
|
|
16
|
+
basic_headline: string;
|
|
17
|
+
title: string;
|
|
18
|
+
lead_art: LeadArt;
|
|
19
|
+
description: string;
|
|
20
|
+
web: string;
|
|
21
|
+
content_code: string;
|
|
22
|
+
updated_time: Date;
|
|
23
|
+
published_time: Date;
|
|
24
|
+
display_time: Date;
|
|
25
|
+
thumbnail: LeadArt;
|
|
26
|
+
primary_media_type: string;
|
|
27
|
+
source: Source;
|
|
28
|
+
redirect_url: string;
|
|
29
|
+
distributor: string;
|
|
30
|
+
authors: Author[];
|
|
31
|
+
kicker: Kicker;
|
|
32
|
+
content_elements: unknown[];
|
|
33
|
+
headline_category?: unknown;
|
|
34
|
+
content?: {
|
|
35
|
+
third_party?: unknown;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
interface Author {
|
|
39
|
+
topic_url: string;
|
|
40
|
+
thumbnail: Thumbnail;
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
first_name: string;
|
|
44
|
+
last_name: string;
|
|
45
|
+
company: string;
|
|
46
|
+
social_links: SocialLink[];
|
|
47
|
+
byline: string;
|
|
48
|
+
}
|
|
49
|
+
interface SocialLink {
|
|
50
|
+
url: string;
|
|
51
|
+
site: string;
|
|
52
|
+
}
|
|
53
|
+
interface Thumbnail {
|
|
54
|
+
url: string;
|
|
55
|
+
resizer_url: string;
|
|
56
|
+
renditions: Renditions;
|
|
57
|
+
}
|
|
58
|
+
interface Renditions {
|
|
59
|
+
square: Landscape;
|
|
60
|
+
landscape: Landscape;
|
|
61
|
+
portrait: Landscape;
|
|
62
|
+
original: Landscape;
|
|
63
|
+
}
|
|
64
|
+
interface Landscape {
|
|
65
|
+
'60w': string;
|
|
66
|
+
'120w': string;
|
|
67
|
+
'240w': string;
|
|
68
|
+
'480w': string;
|
|
69
|
+
'960w': string;
|
|
70
|
+
'1080w': string;
|
|
71
|
+
'1200w': string;
|
|
72
|
+
'1920w': string;
|
|
73
|
+
}
|
|
74
|
+
interface Kicker {
|
|
75
|
+
name: string;
|
|
76
|
+
path: string;
|
|
77
|
+
names: string[];
|
|
78
|
+
}
|
|
79
|
+
interface LeadArt {
|
|
80
|
+
type: string;
|
|
81
|
+
url: string;
|
|
82
|
+
resizer_url: string;
|
|
83
|
+
renditions: Renditions;
|
|
84
|
+
id: string;
|
|
85
|
+
caption?: string;
|
|
86
|
+
alt_text: string;
|
|
87
|
+
width: number;
|
|
88
|
+
height: number;
|
|
89
|
+
subtitle: string;
|
|
90
|
+
updated_at: Date;
|
|
91
|
+
}
|
|
92
|
+
interface Source {
|
|
93
|
+
name: string;
|
|
94
|
+
}
|
|
95
|
+
interface Pagination {
|
|
96
|
+
size: number;
|
|
97
|
+
expected_size: number;
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
```yaml
|
|
2
|
+
slug: ROOT-SLUG/WILD
|
|
3
|
+
seoTitle: Page title for search
|
|
4
|
+
seoDescription: Page description for search
|
|
5
|
+
shareTitle: Page title for social media
|
|
6
|
+
shareDescription: Page description for social media
|
|
7
|
+
shareImgPath: images/reuters-graphics.jpg
|
|
8
|
+
shareImgAlt: Alt text for share image.
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script>
|
|
13
|
+
import { SEO } from '@reuters-graphics/graphics-components';
|
|
14
|
+
import pkg from '$pkg';
|
|
15
|
+
import content from '$locales/en/content.json';
|
|
16
|
+
import { assets } from '$app/paths';
|
|
17
|
+
import { page } from '$app/stores';
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<SEO
|
|
21
|
+
baseUrl="{VITE_BASE_URL}"
|
|
22
|
+
pageUrl="{$page.url}"
|
|
23
|
+
seoTitle="{content.seoTitle}"
|
|
24
|
+
seoDescription="{content.seoDescription}"
|
|
25
|
+
shareTitle="{content.shareTitle}"
|
|
26
|
+
shareDescription="{content.shareDescription}"
|
|
27
|
+
shareImgPath="{`${assets}/${content.shareImgPath}`}"
|
|
28
|
+
shareImgAlt="{content.shareImgAlt}"
|
|
29
|
+
publishTime="{pkg?.reuters?.graphic?.published}"
|
|
30
|
+
updateTime="{pkg?.reuters?.graphic?.updated}"
|
|
31
|
+
authors="{pkg?.reuters?.graphic?.authors}"
|
|
32
|
+
/>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
> **Note:** For _reasons_, we can't document the value of `VITE_BASE_URL` below. It's `import` + `.meta.env.BASE_URL` (concatenate all that) in the Graphics Kit and other Vite-based rigs.
|
|
36
|
+
|
|
@@ -40,85 +40,3 @@ A more detailed example of using `Scroller` with graphics created by [ai2svelte]
|
|
|
40
40
|
embedded="{false}"
|
|
41
41
|
/>
|
|
42
42
|
```
|
|
43
|
-
|
|
44
|
-
When working with a ArchieML doc, here's an example of how you can tie your text into your steps.
|
|
45
|
-
|
|
46
|
-
```yaml
|
|
47
|
-
# Google doc block
|
|
48
|
-
Type: scroller
|
|
49
|
-
ID: map-scrolly
|
|
50
|
-
Step1Text: #### Step 1
|
|
51
|
-
|
|
52
|
-
Lorem Ipsum
|
|
53
|
-
:end
|
|
54
|
-
AltText1: A map showing the Upper West side in New York City.
|
|
55
|
-
:end
|
|
56
|
-
|
|
57
|
-
Step2Text: #### Step 2
|
|
58
|
-
|
|
59
|
-
Lorem Ipsum
|
|
60
|
-
:end
|
|
61
|
-
AltText2: The same map now highlights 98th Street.
|
|
62
|
-
:end
|
|
63
|
-
|
|
64
|
-
Step3Text: #### Step 3
|
|
65
|
-
|
|
66
|
-
Lorem Ipsum
|
|
67
|
-
:end
|
|
68
|
-
AltText3: The same map now highlights three locations near 98th Street where something particulary important happened.
|
|
69
|
-
:end
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
```svelte
|
|
73
|
-
<!-- App.svelte -->
|
|
74
|
-
<script>
|
|
75
|
-
// Previos imports and stuff...
|
|
76
|
-
|
|
77
|
-
// This should be already imported for you.
|
|
78
|
-
import content from '$locales/en/content.json';
|
|
79
|
-
|
|
80
|
-
// Get the data for the block in content by its ID
|
|
81
|
-
const scrollerBlock = content.blocks.find(
|
|
82
|
-
(block) => block.ID === 'map-scrolly'
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// Now plug your text into your step foregrounds
|
|
86
|
-
const steps = [
|
|
87
|
-
{
|
|
88
|
-
background: MyAiMap1,
|
|
89
|
-
backgroundProps: { basePath: assets },
|
|
90
|
-
foreground: scrollerBlock.Step1Text,
|
|
91
|
-
altText: scrollerBlock.AltText1,
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
background: MyAiMap2,
|
|
95
|
-
backgroundProps: { basePath: assets },
|
|
96
|
-
foreground: scrollerBlock.Step2Text,
|
|
97
|
-
altText: scrollerBlock.AltText2,
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
background: MyAiMap3,
|
|
101
|
-
backgroundProps: { basePath: assets },
|
|
102
|
-
foreground: scrollerBlock.Step3Text,
|
|
103
|
-
altText: scrollerBlock.AltText3,
|
|
104
|
-
},
|
|
105
|
-
];
|
|
106
|
-
</script>
|
|
107
|
-
|
|
108
|
-
{#each content.blocks as block}
|
|
109
|
-
{#if block.Type === 'text'}
|
|
110
|
-
<!-- ... other blocks -->
|
|
111
|
-
|
|
112
|
-
<!-- Copy/paste into your blocks loop! -->
|
|
113
|
-
{:else if block.Type === 'scroller' && block.ID === 'map-scrolly'}
|
|
114
|
-
<Scroller
|
|
115
|
-
steps="{steps}"
|
|
116
|
-
backgroundWidth="fluid"
|
|
117
|
-
foregroundPosition="middle"
|
|
118
|
-
stackBackground="{true}"
|
|
119
|
-
embedded="{false}"
|
|
120
|
-
/>
|
|
121
|
-
<!-- END copy/paste -->
|
|
122
|
-
{/if}
|
|
123
|
-
{/each}
|
|
124
|
-
```
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
First, import your ai2svelte graphics in `App.svelte` and add them to the `aiCharts` object;
|
|
2
|
+
|
|
3
|
+
```svelte
|
|
4
|
+
<!-- App.svelte -->
|
|
5
|
+
<script>
|
|
6
|
+
// Other stuff...
|
|
7
|
+
|
|
8
|
+
import AiMap1 from './ai2svelte/my-map-1.svelte';
|
|
9
|
+
import AiMap2 from './ai2svelte/my-map-2.svelte';
|
|
10
|
+
import AiMap3 from './ai2svelte/my-map-3.svelte';
|
|
11
|
+
|
|
12
|
+
const aiCharts = {
|
|
13
|
+
// Other charts...
|
|
14
|
+
AiMap1,
|
|
15
|
+
AiMap2,
|
|
16
|
+
AiMap3,
|
|
17
|
+
};
|
|
18
|
+
</script>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Then add the following structure to your ArchieML Doc, taking care that the names of your charts in the `aiCharts` object match the names of your step backgrounds:
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
[blocks]
|
|
25
|
+
# ...
|
|
26
|
+
|
|
27
|
+
type: ai-scroller
|
|
28
|
+
id: my-map-scroller
|
|
29
|
+
width: normal
|
|
30
|
+
foregroundPosition: middle
|
|
31
|
+
stackBackground: true
|
|
32
|
+
[.steps]
|
|
33
|
+
background: AiMap1
|
|
34
|
+
text: #### Step 1
|
|
35
|
+
|
|
36
|
+
Lorem ipsum
|
|
37
|
+
:end
|
|
38
|
+
altText: A map showing the Upper West side in New York City.
|
|
39
|
+
|
|
40
|
+
Can add paragraphs of alt text if you want to break up sentences.
|
|
41
|
+
:end
|
|
42
|
+
|
|
43
|
+
background: AiMap2
|
|
44
|
+
text: #### Step 2
|
|
45
|
+
|
|
46
|
+
Lorem ipsum
|
|
47
|
+
:end
|
|
48
|
+
altText: The same map now highlights 98th Street.
|
|
49
|
+
:end
|
|
50
|
+
|
|
51
|
+
background: AiMap3
|
|
52
|
+
text: #### Step 3
|
|
53
|
+
|
|
54
|
+
Lorem ipsum
|
|
55
|
+
:end
|
|
56
|
+
altText: The same map now highlights three locations near 98th Street where something particulary important happened.
|
|
57
|
+
:end
|
|
58
|
+
[]
|
|
59
|
+
|
|
60
|
+
# ...
|
|
61
|
+
[]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
```svelte
|
|
65
|
+
<!-- App.svelte -->
|
|
66
|
+
{#each content.blocks as block}
|
|
67
|
+
{#if block.type === 'text'}
|
|
68
|
+
<!-- ... -->
|
|
69
|
+
|
|
70
|
+
{:else if block.type === 'ai-scroller'}
|
|
71
|
+
<Scroller
|
|
72
|
+
id="{block.id}"
|
|
73
|
+
backgroundWidth="{block.width}"
|
|
74
|
+
foregroundPosition="{block.foregroundPosition}"
|
|
75
|
+
stackBackground="{block.stackBackground === 'true'}"
|
|
76
|
+
steps="{block.steps.map((step) => ({
|
|
77
|
+
background: aiCharts[step.background],
|
|
78
|
+
backgroundProps: { assetsPath: assets || '/' },
|
|
79
|
+
foreground: step.text,
|
|
80
|
+
altText: step.altText,
|
|
81
|
+
}))}"
|
|
82
|
+
/>
|
|
83
|
+
|
|
84
|
+
<!-- ... -->
|
|
85
|
+
{/if}
|
|
86
|
+
{/each}
|
|
87
|
+
```
|
|
@@ -13,12 +13,19 @@
|
|
|
13
13
|
<span>{story.title}</span>
|
|
14
14
|
<time datetime="{story.display_time}">{getTime(story.display_time)}</time>
|
|
15
15
|
</div>
|
|
16
|
-
{#if thumbnail}
|
|
16
|
+
{#if thumbnail && (thumbnail.resizer_url || thumbnail?.renditions?.square?.['120w'])}
|
|
17
17
|
<div class="thumbnail">
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
{#if thumbnail.resizer_url}
|
|
19
|
+
<img
|
|
20
|
+
src="{thumbnail.resizer_url}&width=120&quality=80"
|
|
21
|
+
alt="{thumbnail.alt_text}"
|
|
22
|
+
/>
|
|
23
|
+
{:else}
|
|
24
|
+
<img
|
|
25
|
+
src="{thumbnail.renditions.square['120w']}"
|
|
26
|
+
alt="{thumbnail.alt_text}"
|
|
27
|
+
/>
|
|
28
|
+
{/if}
|
|
22
29
|
</div>
|
|
23
30
|
{/if}
|
|
24
31
|
</a>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
```yaml
|
|
2
|
+
section: Graphics
|
|
3
|
+
sectionUrl: https://www.reuters.com/graphics/
|
|
4
|
+
hed: A beautiful page
|
|
5
|
+
authors: Samuel Granados,Dea Bankova
|
|
6
|
+
published: 2022-09-12T08:30:00.000Z
|
|
7
|
+
updated:
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```svelte
|
|
11
|
+
<!-- App.svelte -->
|
|
12
|
+
<script>
|
|
13
|
+
import { SiteHeadline } from '@reuters-graphics/graphics-components';
|
|
14
|
+
|
|
15
|
+
import content from '$locales/en/content.json';
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<SiteHeadline
|
|
19
|
+
section="{content.section}"
|
|
20
|
+
sectionUrl="{content.sectionUrl}"
|
|
21
|
+
hed="{content.hed}"
|
|
22
|
+
authors="{content.authors.split(',')}"
|
|
23
|
+
publishTime="{content.published}"
|
|
24
|
+
updateTime="{content.updated}"
|
|
25
|
+
/>
|
|
26
|
+
```
|
|
@@ -134,7 +134,7 @@ $header: #5e81ac;
|
|
|
134
134
|
.importsnippet :global {
|
|
135
135
|
max-width: 600px;
|
|
136
136
|
position: relative;
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
p {
|
|
139
139
|
font-size: 0.8rem;
|
|
140
140
|
line-height: 1;
|
|
@@ -147,7 +147,9 @@ $header: #5e81ac;
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
pre {
|
|
150
|
-
box-shadow:
|
|
150
|
+
box-shadow:
|
|
151
|
+
0 5px 10px rgba(0, 0, 0, 0.19),
|
|
152
|
+
0 3px 3px rgba(0, 0, 0, 0.23) !important;
|
|
151
153
|
margin-top: 0 !important;
|
|
152
154
|
border-radius: 4px;
|
|
153
155
|
border: 1px solid hsla(203, 50%, 30%, 0.15);
|