@reuters-graphics/graphics-components 3.10.1 → 4.0.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/components/Analytics/GTM.svelte.d.ts +3 -3
- package/dist/components/BlogPost/BlogPost.svelte +6 -5
- package/dist/components/BlogPost/BlogPost.svelte.d.ts +3 -2
- package/dist/components/BlogPost/CopyLink.svelte +7 -4
- package/dist/components/BlogPost/CopyLink.svelte.d.ts +5 -2
- package/dist/components/BlogPost/PostHeadline.svelte +7 -4
- package/dist/components/BlogPost/PostHeadline.svelte.d.ts +5 -2
- package/dist/components/BlogPost/utils.d.ts +2 -1
- package/dist/components/BlogPost/utils.js +8 -2
- package/dist/components/BlogTOC/BlogTOC.svelte +7 -4
- package/dist/components/BlogTOC/BlogTOC.svelte.d.ts +8 -5
- package/dist/components/BlogTOC/TOCList.svelte.d.ts +3 -3
- package/dist/components/Headpile/Headpile.svelte +2 -2
- package/dist/components/Headpile/Headpile.svelte.d.ts +2 -2
- package/dist/components/LanguageButton/LanguageButton.svelte +10 -7
- package/dist/components/LanguageButton/LanguageButton.svelte.d.ts +5 -2
- package/dist/components/SEO/SEO.svelte.d.ts +3 -3
- package/dist/components/Video/Video.svelte +2 -2
- package/dist/llm-docs/components/BeforeAfter.md +5 -5
- package/dist/llm-docs/components/BlogPost.md +2 -4
- package/dist/llm-docs/components/BlogTOC.md +4 -6
- package/dist/llm-docs/components/EmbedPreviewerLink.md +1 -1
- package/dist/llm-docs/components/FeaturePhoto.md +4 -4
- package/dist/llm-docs/components/GraphicBlock.md +4 -4
- package/dist/llm-docs/components/Headline.md +3 -3
- package/dist/llm-docs/components/Headpile.md +4 -4
- package/dist/llm-docs/components/HeroHeadline.md +9 -9
- package/dist/llm-docs/components/HorizontalScroller.md +4 -4
- package/dist/llm-docs/components/LanguageButton.md +12 -13
- package/dist/llm-docs/components/Lottie.md +14 -14
- package/dist/llm-docs/components/PhotoPack.md +10 -9
- package/dist/llm-docs/components/SEO.md +2 -2
- package/dist/llm-docs/components/Scroller.md +7 -7
- package/dist/llm-docs/components/ScrollerVideo.md +6 -6
- package/dist/llm-docs/components/Video.md +2 -2
- package/dist/llm-docs/guides/archieml.md +9 -9
- package/dist/llm-docs/guides/graphics-kit.md +5 -5
- package/package.json +18 -24
|
@@ -216,14 +216,14 @@ To use a photo as the hero, simply pass the image source to the `img` prop.
|
|
|
216
216
|
<!-- App.svelte -->
|
|
217
217
|
<script>
|
|
218
218
|
import { HeroHeadline } from '@reuters-graphics/graphics-components';
|
|
219
|
-
import {
|
|
219
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
220
220
|
|
|
221
221
|
let { embedded = false } = $props(); // 👈 If using in the graphics kit...
|
|
222
222
|
</script>
|
|
223
223
|
|
|
224
224
|
<HeroHeadline
|
|
225
225
|
{embedded}
|
|
226
|
-
img={
|
|
226
|
+
img={asset('/images/polar-bear.jpg')}
|
|
227
227
|
ariaDescription="A photo of a polar bear"
|
|
228
228
|
notes="Photo by REUTERS"
|
|
229
229
|
section={'World News'}
|
|
@@ -269,7 +269,7 @@ To customise styles, use CSS to target the class passed to `HeroHeadline`.
|
|
|
269
269
|
|
|
270
270
|
import QuakeMap from './ai2svelte/graphic.svelte'; // Your ai2svelte component
|
|
271
271
|
|
|
272
|
-
import {
|
|
272
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
273
273
|
|
|
274
274
|
let { embedded = false } = $props(); // 👈 If using in the graphics kit...
|
|
275
275
|
</script>
|
|
@@ -300,7 +300,7 @@ To customise styles, use CSS to target the class passed to `HeroHeadline`.
|
|
|
300
300
|
ariaDescription="Earthquake impact map"
|
|
301
301
|
>
|
|
302
302
|
<!-- Pass `assetsPath` if in graphics kit -->
|
|
303
|
-
<QuakeMap assetsPath={
|
|
303
|
+
<QuakeMap assetsPath={asset('/').replace(/\/$/, '')} />
|
|
304
304
|
</GraphicBlock>
|
|
305
305
|
</HeroHeadline>
|
|
306
306
|
```
|
|
@@ -354,7 +354,7 @@ To add a video as the hero, use the [Video](?path=/docs/components-multimedia-vi
|
|
|
354
354
|
```svelte
|
|
355
355
|
<script>
|
|
356
356
|
import { HeroHeadline, Video } from '@reuters-graphics/graphics-components';
|
|
357
|
-
import {
|
|
357
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
358
358
|
|
|
359
359
|
let { embedded = false } = $props(); // 👈 If using in the graphics kit...
|
|
360
360
|
</script>
|
|
@@ -374,8 +374,8 @@ To add a video as the hero, use the [Video](?path=/docs/components-multimedia-vi
|
|
|
374
374
|
showControls={false}
|
|
375
375
|
preloadVideo="auto"
|
|
376
376
|
playVideoWhenInView={false}
|
|
377
|
-
src={
|
|
378
|
-
poster={
|
|
377
|
+
src={asset('/videos/intro.mp4')}
|
|
378
|
+
poster={asset('/images/video-poster-intro.jpg')}
|
|
379
379
|
notes="Drone footage from the Village 8 refugee camp in Sudan."
|
|
380
380
|
ariaDescription="Aerial footage of people houses in refugee camp"
|
|
381
381
|
/>
|
|
@@ -414,7 +414,7 @@ To use a photo, graphic, video, etc. as an inline hero -- i.e., to make the hero
|
|
|
414
414
|
HeroHeadline,
|
|
415
415
|
GraphicBlock,
|
|
416
416
|
} from '@reuters-graphics/graphics-components';
|
|
417
|
-
import {
|
|
417
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
418
418
|
|
|
419
419
|
let { embedded = false } = $props(); // 👈 If using in the graphics kit...
|
|
420
420
|
</script>
|
|
@@ -438,7 +438,7 @@ To use a photo, graphic, video, etc. as an inline hero -- i.e., to make the hero
|
|
|
438
438
|
notes="Source: Satellite image from Google, Maxar Technologies, CNES/Airbus, Landsat/Copernicus"
|
|
439
439
|
>
|
|
440
440
|
<!-- Pass `assetsPath` if in graphics kit -->
|
|
441
|
-
<CrashMap assetsPath={
|
|
441
|
+
<CrashMap assetsPath={asset('/').replace(/\/$/, '')} />
|
|
442
442
|
</GraphicBlock>
|
|
443
443
|
</HeroHeadline>
|
|
444
444
|
```
|
|
@@ -247,7 +247,7 @@ allow_overflow: true
|
|
|
247
247
|
import AiGraphic from './ai2svelte/ai-graphic.svelte';
|
|
248
248
|
|
|
249
249
|
// If using with the graphics kit
|
|
250
|
-
import {
|
|
250
|
+
import { asset } from '$app/paths';
|
|
251
251
|
|
|
252
252
|
// Optional easing function
|
|
253
253
|
import { sineInOut } from 'svelte/easing';
|
|
@@ -256,7 +256,7 @@ allow_overflow: true
|
|
|
256
256
|
<!-- Wrap `HorizontalScroller` in a fluid container for a full bleed experience -->
|
|
257
257
|
<Block width="fluid">
|
|
258
258
|
<HorizontalScroller height="800lvh" easing={sineInOut} showDebugInfo>
|
|
259
|
-
<AiGraphic assetsPath={
|
|
259
|
+
<AiGraphic assetsPath={asset('/').replace(/\/$/, '')} />
|
|
260
260
|
</HorizontalScroller>
|
|
261
261
|
</Block>
|
|
262
262
|
```
|
|
@@ -287,7 +287,7 @@ This demo has a tagged `png` [layer](https://reuters-graphics.github.io/ai2svelt
|
|
|
287
287
|
import { sineInOut } from 'svelte/easing';
|
|
288
288
|
|
|
289
289
|
// If using with the graphics kit
|
|
290
|
-
import {
|
|
290
|
+
import { asset } from '$app/paths';
|
|
291
291
|
|
|
292
292
|
// bind progress for advanced interactivity
|
|
293
293
|
let progress: number = $state(0);
|
|
@@ -351,7 +351,7 @@ This demo has a tagged `png` [layer](https://reuters-graphics.github.io/ai2svelt
|
|
|
351
351
|
showDebugInfo={true}
|
|
352
352
|
>
|
|
353
353
|
<AiGraphic
|
|
354
|
-
assetsPath={
|
|
354
|
+
assetsPath={asset('/').replace(/\/$/, '')}
|
|
355
355
|
{onArtboardChange}
|
|
356
356
|
taggedText={{
|
|
357
357
|
htext: {
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
|------|------|---------|:--------:|-------------|
|
|
11
11
|
| `locale` | `string \| undefined` | `'en'` | | The current locale of the article |
|
|
12
12
|
| `embedded` | `boolean` | `false` | | Whether the article is embedded |
|
|
13
|
-
| `base` | `string` | — | | The base URL for the article |
|
|
14
13
|
| `buttonOptions` | `{ locale: string; label: string; }` | `{
|
|
15
14
|
locale: 'es',
|
|
16
15
|
label: 'Leer en español',
|
|
@@ -71,8 +70,8 @@ The `LanguageButton` component creates a button that switches between an article
|
|
|
71
70
|
<script>
|
|
72
71
|
import { LanguageButton } from '@reuters-graphics/graphics-components';
|
|
73
72
|
|
|
74
|
-
// If using in the graphics kit, use `
|
|
75
|
-
import {
|
|
73
|
+
// If using in the graphics kit, use `resolve` from `$app/paths` to ensure the toggle links to the correct URL
|
|
74
|
+
import { resolve } from '$app/paths';
|
|
76
75
|
|
|
77
76
|
// If using in the graphics kit, `embedded` prop will already be available in App.svelte.
|
|
78
77
|
// Additionally, pass `locale = 'en'` as a prop
|
|
@@ -80,7 +79,7 @@ The `LanguageButton` component creates a button that switches between an article
|
|
|
80
79
|
</script>
|
|
81
80
|
|
|
82
81
|
<!-- Pass `embedded` to `LanguageButton` if the embed page is translated -->
|
|
83
|
-
<LanguageButton {locale} {embedded} {
|
|
82
|
+
<LanguageButton {locale} {embedded} {resolve} />
|
|
84
83
|
```
|
|
85
84
|
|
|
86
85
|
## Customise language and button label
|
|
@@ -91,8 +90,8 @@ By default, the toggle button will switch between English and Spanish, and the `
|
|
|
91
90
|
<script>
|
|
92
91
|
import { LanguageButton } from '@reuters-graphics/graphics-components';
|
|
93
92
|
|
|
94
|
-
// If using in the graphics kit, use `
|
|
95
|
-
import {
|
|
93
|
+
// If using in the graphics kit, use `resolve` from `$app/paths` to ensure the toggle links to the correct URL
|
|
94
|
+
import { resolve } from '$app/paths';
|
|
96
95
|
|
|
97
96
|
// If using in the graphics kit, `embedded` prop will already be available in App.svelte.
|
|
98
97
|
// Additionally, pass `locale = 'en'` as a prop
|
|
@@ -103,7 +102,7 @@ By default, the toggle button will switch between English and Spanish, and the `
|
|
|
103
102
|
<LanguageButton
|
|
104
103
|
{locale}
|
|
105
104
|
{embedded}
|
|
106
|
-
{
|
|
105
|
+
{resolve}
|
|
107
106
|
buttonOptions={{
|
|
108
107
|
locale: 'fr',
|
|
109
108
|
label: 'Lire en français',
|
|
@@ -140,8 +139,8 @@ To customise this, pass a function to the `setUrl` prop that returns the URLs yo
|
|
|
140
139
|
<script>
|
|
141
140
|
import { LanguageButton } from '@reuters-graphics/graphics-components';
|
|
142
141
|
|
|
143
|
-
// If using in the graphics kit, use `
|
|
144
|
-
import {
|
|
142
|
+
// If using in the graphics kit, use `resolve` from `$app/paths` to ensure the toggle links to the correct URL
|
|
143
|
+
import { resolve } from '$app/paths';
|
|
145
144
|
|
|
146
145
|
// If using in the graphics kit, `embedded` prop will already be available in App.svelte.
|
|
147
146
|
// Additionally, pass `locale = 'en'` as a prop
|
|
@@ -152,16 +151,16 @@ To customise this, pass a function to the `setUrl` prop that returns the URLs yo
|
|
|
152
151
|
if (embedded) {
|
|
153
152
|
if (locale === 'es') {
|
|
154
153
|
// If we're in the non-English article, link to the English article
|
|
155
|
-
return
|
|
154
|
+
return resolve('/embeds/en/custom-embed-url/');
|
|
156
155
|
} else {
|
|
157
|
-
return
|
|
156
|
+
return resolve('/embeds/es/custom-embed-url/');
|
|
158
157
|
}
|
|
159
158
|
} else {
|
|
160
159
|
if (locale === 'es') {
|
|
161
160
|
// If we're in the non-English article, link to the English article
|
|
162
|
-
return
|
|
161
|
+
return resolve('/');
|
|
163
162
|
} else {
|
|
164
|
-
return
|
|
163
|
+
return resolve('/es/');
|
|
165
164
|
}
|
|
166
165
|
}
|
|
167
166
|
};
|
|
@@ -9,38 +9,38 @@
|
|
|
9
9
|
### Demo
|
|
10
10
|
|
|
11
11
|
```svelte
|
|
12
|
-
{#snippet
|
|
13
|
-
<Lottie src={DemoLottie}
|
|
12
|
+
{#snippet template(args)}
|
|
13
|
+
<Lottie {...args} src={DemoLottie} />
|
|
14
14
|
{/snippet}
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
### Segment
|
|
18
18
|
|
|
19
19
|
```svelte
|
|
20
|
-
{#snippet
|
|
21
|
-
<Lottie src={DemoLottie}
|
|
20
|
+
{#snippet template(args)}
|
|
21
|
+
<Lottie {...args} src={DemoLottie} />
|
|
22
22
|
{/snippet}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Marker
|
|
26
26
|
|
|
27
27
|
```svelte
|
|
28
|
-
{#snippet
|
|
29
|
-
<Lottie src={MarkerSample}
|
|
28
|
+
{#snippet template(args)}
|
|
29
|
+
<Lottie {...args} src={MarkerSample} />
|
|
30
30
|
{/snippet}
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
### Themes
|
|
34
34
|
|
|
35
35
|
```svelte
|
|
36
|
-
{#snippet
|
|
36
|
+
{#snippet template(args)}
|
|
37
37
|
<Lottie
|
|
38
|
+
{...args}
|
|
38
39
|
src={ThemesSample}
|
|
39
40
|
bind:progress
|
|
40
41
|
themeId={progress < 0.33 ? 'Water'
|
|
41
42
|
: progress < 0.66 ? 'air'
|
|
42
43
|
: 'earth'}
|
|
43
|
-
{...args}
|
|
44
44
|
/>
|
|
45
45
|
{/snippet}
|
|
46
46
|
```
|
|
@@ -164,7 +164,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi
|
|
|
164
164
|
import { Lottie } from '@reuters-graphics/graphics-components';
|
|
165
165
|
|
|
166
166
|
// Graphics kit only
|
|
167
|
-
import {
|
|
167
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
168
168
|
import { truthy } from '$utils/propValidators'; // 👈 If using in the graphics kit...
|
|
169
169
|
</script>
|
|
170
170
|
|
|
@@ -172,7 +172,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi
|
|
|
172
172
|
<!-- Inside the content.blocks for loop... -->
|
|
173
173
|
{#if block.type == 'lottie'}
|
|
174
174
|
<Lottie
|
|
175
|
-
src={
|
|
175
|
+
src={asset(`/${block.src}`)}
|
|
176
176
|
autoplay={truthy(block.autoplay)}
|
|
177
177
|
loop={truthy(block.loop)}
|
|
178
178
|
showDebugInfo={truthy(block.showDebugInfo)}
|
|
@@ -215,7 +215,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi
|
|
|
215
215
|
import { Lottie } from '@reuters-graphics/graphics-components';
|
|
216
216
|
|
|
217
217
|
// Graphics kit only
|
|
218
|
-
import {
|
|
218
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
219
219
|
import { truthy } from '$utils/propValidators'; // 👈 If using in the graphics kit...
|
|
220
220
|
</script>
|
|
221
221
|
|
|
@@ -223,7 +223,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi
|
|
|
223
223
|
<!-- Inside the content.blocks for loop... -->
|
|
224
224
|
{#if block.type == 'lottie'}
|
|
225
225
|
<Lottie
|
|
226
|
-
src={
|
|
226
|
+
src={asset(`/${block.src}`)}
|
|
227
227
|
segment={[parseInt(block.segment.start), parseInt(block.segment.end)]}
|
|
228
228
|
showDebugInfo={truthy(block.showDebugInfo)}
|
|
229
229
|
loop={truthy(block.loop)}
|
|
@@ -428,7 +428,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi
|
|
|
428
428
|
Lottie,
|
|
429
429
|
LottieForeground,
|
|
430
430
|
} from '@reuters-graphics/graphics-components';
|
|
431
|
-
import {
|
|
431
|
+
import { asset } from '$app/paths';
|
|
432
432
|
|
|
433
433
|
// Make an object of components to use as foregrounds
|
|
434
434
|
const Components = $state({
|
|
@@ -439,7 +439,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi
|
|
|
439
439
|
{#each content.blocks as block}
|
|
440
440
|
<!-- Inside the content.blocks for loop... -->
|
|
441
441
|
{#if block.type == 'lottie'}
|
|
442
|
-
<Lottie src={
|
|
442
|
+
<Lottie src={asset(`/${block.src}`)}>
|
|
443
443
|
{#each block.foregrounds as foreground}
|
|
444
444
|
{#if foreground.type == 'text'}
|
|
445
445
|
<LottieForeground
|
|
@@ -57,8 +57,9 @@ export interface Layout {
|
|
|
57
57
|
### Smart layouts
|
|
58
58
|
|
|
59
59
|
```svelte
|
|
60
|
-
{#snippet
|
|
61
|
-
{@const { imageCount, ...photoPackProps } =
|
|
60
|
+
{#snippet template(args)}
|
|
61
|
+
{@const { imageCount, ...photoPackProps } =
|
|
62
|
+
args as unknown as SmartDefaultsArgs}
|
|
62
63
|
<PhotoPack
|
|
63
64
|
{...photoPackProps}
|
|
64
65
|
images={allImages.slice(0, imageCount || 4)}
|
|
@@ -172,14 +173,14 @@ gap: 10 # Optional; must be a number.
|
|
|
172
173
|
<!-- App.svelte -->
|
|
173
174
|
<script>
|
|
174
175
|
import { PhotoPack } from '@reuters-graphics/graphics-components';
|
|
175
|
-
import {
|
|
176
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
176
177
|
|
|
177
178
|
import content from '$locales/en/content.json';
|
|
178
179
|
</script>
|
|
179
180
|
|
|
180
181
|
{#each content.blocks as block}
|
|
181
182
|
{#if block.type === 'photo-pack'}
|
|
182
|
-
<!--
|
|
183
|
+
<!-- Use `asset` for the image source in graphics kit -->
|
|
183
184
|
<PhotoPack
|
|
184
185
|
id={block.id}
|
|
185
186
|
class={block.class}
|
|
@@ -188,7 +189,7 @@ gap: 10 # Optional; must be a number.
|
|
|
188
189
|
gap={Number(block.gap)}
|
|
189
190
|
images={block.images.map((img) => ({
|
|
190
191
|
...img,
|
|
191
|
-
src:
|
|
192
|
+
src: asset(`/${img.src}`),
|
|
192
193
|
}))}
|
|
193
194
|
layouts={[
|
|
194
195
|
{ breakpoint: 750, rows: [2, 3] },
|
|
@@ -225,10 +226,10 @@ The smart defaults use a **bottom-heavy distribution**, meaning earlier rows hav
|
|
|
225
226
|
import { PhotoPack } from '@reuters-graphics/graphics-components';
|
|
226
227
|
|
|
227
228
|
const images = [
|
|
228
|
-
{ src:
|
|
229
|
-
{ src:
|
|
230
|
-
{ src:
|
|
231
|
-
{ src:
|
|
229
|
+
{ src: asset('/image1.jpg'), altText: 'Photo 1', caption: 'Caption 1' },
|
|
230
|
+
{ src: asset('/image2.jpg'), altText: 'Photo 2', caption: 'Caption 2' },
|
|
231
|
+
{ src: asset('/image3.jpg'), altText: 'Photo 3', caption: 'Caption 3' },
|
|
232
|
+
{ src: asset('/image4.jpg'), altText: 'Photo 4', caption: 'Caption 4' },
|
|
232
233
|
];
|
|
233
234
|
</script>
|
|
234
235
|
|
|
@@ -88,7 +88,7 @@ shareImgAlt: Alt text for share image.
|
|
|
88
88
|
import { SEO } from '@reuters-graphics/graphics-components';
|
|
89
89
|
import pkg from '$pkg';
|
|
90
90
|
import content from '$locales/en/content.json';
|
|
91
|
-
import {
|
|
91
|
+
import { asset } from '$app/paths';
|
|
92
92
|
import { page } from '$app/stores';
|
|
93
93
|
</script>
|
|
94
94
|
|
|
@@ -99,7 +99,7 @@ shareImgAlt: Alt text for share image.
|
|
|
99
99
|
seoDescription={content.seoDescription}
|
|
100
100
|
shareTitle={content.shareTitle}
|
|
101
101
|
shareDescription={content.shareDescription}
|
|
102
|
-
shareImgPath={
|
|
102
|
+
shareImgPath={asset(`/${content.shareImgPath}`)}
|
|
103
103
|
shareImgAlt={content.shareImgAlt}
|
|
104
104
|
publishTime={pkg?.reuters?.graphic?.published}
|
|
105
105
|
updateTime={pkg?.reuters?.graphic?.updated}
|
|
@@ -131,7 +131,7 @@ In your graphics kit project, import your ai2svelte graphics in `App.svelte` and
|
|
|
131
131
|
import content from '$locales/en/content.json';
|
|
132
132
|
|
|
133
133
|
// Graphics kit only
|
|
134
|
-
import {
|
|
134
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
135
135
|
import { truthy } from '$utils/propValidators'; // 👈 If using in the graphics kit...
|
|
136
136
|
|
|
137
137
|
const aiCharts = {
|
|
@@ -198,7 +198,7 @@ Then parse the relevant ArchieML block object before passing to the `Scroller` c
|
|
|
198
198
|
stackBackground={truthy(block.stackBackground)}
|
|
199
199
|
steps={block.steps.map((step) => ({
|
|
200
200
|
background: aiCharts[step.background],
|
|
201
|
-
backgroundProps: { assetsPath:
|
|
201
|
+
backgroundProps: { assetsPath: asset('/').replace(/\/$/, '') },
|
|
202
202
|
foreground: step.foreground,
|
|
203
203
|
altText: step.altText,
|
|
204
204
|
}))}
|
|
@@ -209,7 +209,7 @@ Then parse the relevant ArchieML block object before passing to the `Scroller` c
|
|
|
209
209
|
|
|
210
210
|
> **Note:** Some props, like `stackBackground`, expect boolean values. If you're using the graphics kit, use the `truthy()` util function to convert a string value to a boolean.
|
|
211
211
|
|
|
212
|
-
> **Note:** In the graphics kit, the image source paths in ai2svelte components have to be fixed by passing `
|
|
212
|
+
> **Note:** In the graphics kit, the image source paths in ai2svelte components have to be fixed by passing the resolved `asset('/')` root to each step object's `assetsPath`, like in the example above.
|
|
213
213
|
|
|
214
214
|
## Custom foreground
|
|
215
215
|
|
|
@@ -269,7 +269,7 @@ In your graphics kit project's `App.svelte`, import your custom foregroud compon
|
|
|
269
269
|
import Foreground1 from './ai2svelte/my-foreground-1.svelte';
|
|
270
270
|
|
|
271
271
|
// Graphics kit only
|
|
272
|
-
import {
|
|
272
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
273
273
|
import { truthy } from '$utils/propValidators'; // 👈 If using in the graphics kit...
|
|
274
274
|
|
|
275
275
|
// Background ai2svelte graphics components
|
|
@@ -337,9 +337,9 @@ Then parse the relevant ArchieML block object before passing to the `Scroller` c
|
|
|
337
337
|
stackBackground={truthy(block.stackBackground)}
|
|
338
338
|
steps={block.steps.map((step) => ({
|
|
339
339
|
background: aiCharts[step.background],
|
|
340
|
-
backgroundProps: { assetsPath:
|
|
340
|
+
backgroundProps: { assetsPath: asset('/').replace(/\/$/, '') },
|
|
341
341
|
foreground: foregroundComponents[step.foreground] || step.foreground,
|
|
342
|
-
foregroundProps: { assetsPath:
|
|
342
|
+
foregroundProps: { assetsPath: asset('/').replace(/\/$/, '') },
|
|
343
343
|
altText: step.altText,
|
|
344
344
|
}))}
|
|
345
345
|
/>
|
|
@@ -347,4 +347,4 @@ Then parse the relevant ArchieML block object before passing to the `Scroller` c
|
|
|
347
347
|
{/each}
|
|
348
348
|
```
|
|
349
349
|
|
|
350
|
-
> **Note:** You only need to pass `foregroundProps: { assetsPath:
|
|
350
|
+
> **Note:** You only need to pass `foregroundProps: { assetsPath: asset('/').replace(/\/$/, '') }` in the graphics kit if your foreground components are ai2svelte graphicss.
|
|
@@ -276,7 +276,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi
|
|
|
276
276
|
ScrollerVideo,
|
|
277
277
|
ScrollerVideoForeground,
|
|
278
278
|
} from '@reuters-graphics/graphics-components';
|
|
279
|
-
import {
|
|
279
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
280
280
|
</script>
|
|
281
281
|
|
|
282
282
|
{#each content.blocks as block}
|
|
@@ -284,7 +284,7 @@ With the graphics kit, you'll likely get your text and prop values from an Archi
|
|
|
284
284
|
{#if block.type == 'scroller-video'}
|
|
285
285
|
<ScrollerVideo
|
|
286
286
|
id={block.id}
|
|
287
|
-
src={
|
|
287
|
+
src={asset(`/${block.src}`)}
|
|
288
288
|
height={block.height}
|
|
289
289
|
>
|
|
290
290
|
<!-- Loop through foregrounds to add text blurbs that appear/disappear at specific times -->
|
|
@@ -364,7 +364,7 @@ endTime: 0.3 # When to stop showing the headline
|
|
|
364
364
|
|
|
365
365
|
```svelte
|
|
366
366
|
<script lang="ts">
|
|
367
|
-
import {
|
|
367
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
368
368
|
import {
|
|
369
369
|
Headline,
|
|
370
370
|
GraphicBlock,
|
|
@@ -426,11 +426,11 @@ endTime: 0.3 # When to stop showing the headline
|
|
|
426
426
|
|
|
427
427
|
<!-- Render the ScrollVideo snippet for different screen sizes -->
|
|
428
428
|
{#if width < 600}
|
|
429
|
-
{@render ScrollVideo(block.height,
|
|
429
|
+
{@render ScrollVideo(block.height, asset(`/${block.srcSm}`))}
|
|
430
430
|
{:else if width < 1200}
|
|
431
|
-
{@render ScrollVideo(block.height,
|
|
431
|
+
{@render ScrollVideo(block.height, asset(`/${block.srcMd}`))}
|
|
432
432
|
{:else}
|
|
433
|
-
{@render ScrollVideo(block.height,
|
|
433
|
+
{@render ScrollVideo(block.height, asset(`/${block.srcLg}`))}
|
|
434
434
|
{/if}
|
|
435
435
|
{/if}
|
|
436
436
|
{/each}
|
|
@@ -156,7 +156,7 @@ loopVideo: true
|
|
|
156
156
|
<!-- App.svelte -->
|
|
157
157
|
<script>
|
|
158
158
|
import { Video } from '@reuters-graphics/graphics-components';
|
|
159
|
-
import {
|
|
159
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
160
160
|
import { truthy } from '$utils/propValidators'; // 👈 If using in the graphics kit...
|
|
161
161
|
</script>
|
|
162
162
|
|
|
@@ -164,7 +164,7 @@ loopVideo: true
|
|
|
164
164
|
{#if block.type === 'video'}
|
|
165
165
|
<Video
|
|
166
166
|
ariaDescription={block.ariaDescription}
|
|
167
|
-
src={
|
|
167
|
+
src={asset(`/${block.src}`)}
|
|
168
168
|
width={block.width}
|
|
169
169
|
loopVideo={truthy(block.loopVideo)}
|
|
170
170
|
notes={block.notes}
|
|
@@ -69,7 +69,7 @@ Notice all the values in the data are **strings**. More on that soon.
|
|
|
69
69
|
```svelte
|
|
70
70
|
<script>
|
|
71
71
|
// These are usually already imported for you
|
|
72
|
-
import {
|
|
72
|
+
import { asset } from '$app/paths';
|
|
73
73
|
// Your ArchieML doc
|
|
74
74
|
import content from '$locales/en/content.json';
|
|
75
75
|
|
|
@@ -84,7 +84,7 @@ Notice all the values in the data are **strings**. More on that soon.
|
|
|
84
84
|
<ProfileCard
|
|
85
85
|
name={block.name}
|
|
86
86
|
age={parseInt(block.age)}
|
|
87
|
-
img={
|
|
87
|
+
img={asset(`/${block.picture}`)}
|
|
88
88
|
birthday={new Date(block.birthday)}
|
|
89
89
|
bio={block.bio}
|
|
90
90
|
isGood={block.isGood === 'true'}
|
|
@@ -120,7 +120,7 @@ Once we've identified we have the right block for our component, we need to conv
|
|
|
120
120
|
<ProfileCard
|
|
121
121
|
name={block.name}
|
|
122
122
|
age={parseInt(block.age)}
|
|
123
|
-
img={
|
|
123
|
+
img={asset(`/${block.picture}`)}
|
|
124
124
|
birthday={new Date(block.birthday)}
|
|
125
125
|
bio={block.bio}
|
|
126
126
|
isGood={block.isGood === 'true'}
|
|
@@ -145,10 +145,10 @@ For example, we're converting Tom's age into a number with JavaScript's [parseIn
|
|
|
145
145
|
{block.isGood === 'true'}
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
**Especially note** how we're using the `
|
|
148
|
+
**Especially note** how we're using the `asset` helper we talked about in ["Using with the graphics kit"](./?path=/docs/guides-using-with-the-graphics-kit--docs) to turn the _relative_ path to Tom's profile pic in our ArchieML doc into an _absolute_ path that will have the full `https://reuters.com...` bit attached.
|
|
149
149
|
|
|
150
150
|
```svelte
|
|
151
|
-
{
|
|
151
|
+
{asset(`/${block.picture}`)}
|
|
152
152
|
```
|
|
153
153
|
|
|
154
154
|
### Sum it all up 🏁
|
|
@@ -173,7 +173,7 @@ Let's look at another example component:
|
|
|
173
173
|
date: new Date('1992-01-01'),
|
|
174
174
|
subhed:
|
|
175
175
|
'Cynthia Dwork and Moni Naor come with an idea for "cryptocurrency"',
|
|
176
|
-
img:
|
|
176
|
+
img: asset('/images/dwork-naor.jpeg'),
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
date: new Date('2008-08-18'),
|
|
@@ -183,7 +183,7 @@ Let's look at another example component:
|
|
|
183
183
|
{
|
|
184
184
|
date: new Date('2013-07-22'),
|
|
185
185
|
subhed: 'The Winklevoss twins buy in',
|
|
186
|
-
img:
|
|
186
|
+
img: asset('/images/winkle-boys.jpeg'),
|
|
187
187
|
},
|
|
188
188
|
]}
|
|
189
189
|
/>
|
|
@@ -281,7 +281,7 @@ But this is a problem we can solve by looping over our JSON data and making a ne
|
|
|
281
281
|
let link;
|
|
282
282
|
|
|
283
283
|
if (d.img) {
|
|
284
|
-
img =
|
|
284
|
+
img = asset(`/${d.img}`);
|
|
285
285
|
}
|
|
286
286
|
if (d.link) {
|
|
287
287
|
link = d.link;
|
|
@@ -355,7 +355,7 @@ const timelineDates = timelineBlock.dates.map((d) => {
|
|
|
355
355
|
|
|
356
356
|
// If our date has an image, we'll make it an absolute URL
|
|
357
357
|
if (d.img) {
|
|
358
|
-
img =
|
|
358
|
+
img = asset(`/${d.img}`);
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
// If it has a link, we'll just pass that on, as is
|
|
@@ -10,16 +10,16 @@ When working with multimedia files like images or videos, components expect all
|
|
|
10
10
|
|
|
11
11
|
❌ `./myImage.jpg`
|
|
12
12
|
|
|
13
|
-
In the graphics kit, that means you'll need to prefix relative paths with the special [`
|
|
13
|
+
In the graphics kit, that means you'll need to prefix relative paths with the special [`asset`](https://svelte.dev/docs/kit/$app-paths#asset) SvelteKit helper that resolves the path to the root URL for your project. Many examples in these docs show how to do it. But it's also easy enough to demo again here!
|
|
14
14
|
|
|
15
15
|
```svelte
|
|
16
16
|
<script>
|
|
17
17
|
import { FeaturePhoto } from '@reuters-graphics/graphics-components';
|
|
18
18
|
|
|
19
|
-
// Import the
|
|
20
|
-
import {
|
|
19
|
+
// Import the asset helper if it's not already there.
|
|
20
|
+
import { asset } from '$app/paths';
|
|
21
21
|
</script>
|
|
22
22
|
|
|
23
|
-
<!-- Use the
|
|
24
|
-
<FeautrePhoto src=
|
|
23
|
+
<!-- Use the asset helper to prefix the path to your image. -->
|
|
24
|
+
<FeautrePhoto src={asset('/imgs/myImage.jpg')} />
|
|
25
25
|
```
|