@reuters-graphics/graphics-components 3.10.0 → 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.
Files changed (85) hide show
  1. package/dist/components/Analytics/GTM.svelte.d.ts +3 -3
  2. package/dist/components/BlogPost/BlogPost.svelte +6 -5
  3. package/dist/components/BlogPost/BlogPost.svelte.d.ts +3 -2
  4. package/dist/components/BlogPost/CopyLink.svelte +7 -4
  5. package/dist/components/BlogPost/CopyLink.svelte.d.ts +5 -2
  6. package/dist/components/BlogPost/PostHeadline.svelte +7 -4
  7. package/dist/components/BlogPost/PostHeadline.svelte.d.ts +5 -2
  8. package/dist/components/BlogPost/utils.d.ts +2 -1
  9. package/dist/components/BlogPost/utils.js +8 -2
  10. package/dist/components/BlogTOC/BlogTOC.svelte +7 -4
  11. package/dist/components/BlogTOC/BlogTOC.svelte.d.ts +8 -5
  12. package/dist/components/BlogTOC/TOCList.svelte.d.ts +3 -3
  13. package/dist/components/Headpile/Headpile.svelte +2 -2
  14. package/dist/components/Headpile/Headpile.svelte.d.ts +2 -2
  15. package/dist/components/LanguageButton/LanguageButton.svelte +10 -7
  16. package/dist/components/LanguageButton/LanguageButton.svelte.d.ts +5 -2
  17. package/dist/components/SEO/SEO.svelte.d.ts +3 -3
  18. package/dist/components/Video/Video.svelte +2 -2
  19. package/dist/llm-docs/components/AdSlot.md +11 -0
  20. package/dist/llm-docs/components/Analytics.md +89 -0
  21. package/dist/llm-docs/components/Article.md +183 -0
  22. package/dist/llm-docs/components/BeforeAfter.md +170 -0
  23. package/dist/llm-docs/components/BioBox.md +74 -0
  24. package/dist/llm-docs/components/Block.md +211 -0
  25. package/dist/llm-docs/components/BlogPost.md +66 -0
  26. package/dist/llm-docs/components/BlogTOC.md +89 -0
  27. package/dist/llm-docs/components/BodyText.md +143 -0
  28. package/dist/llm-docs/components/Byline.md +242 -0
  29. package/dist/llm-docs/components/ClockWall.md +48 -0
  30. package/dist/llm-docs/components/DatawrapperChart.md +87 -0
  31. package/dist/llm-docs/components/DocumentCloud.md +47 -0
  32. package/dist/llm-docs/components/EmbedPreviewerLink.md +35 -0
  33. package/dist/llm-docs/components/EndNotes.md +79 -0
  34. package/dist/llm-docs/components/FeaturePhoto.md +102 -0
  35. package/dist/llm-docs/components/Framer.md +44 -0
  36. package/dist/llm-docs/components/Geocoder.md +49 -0
  37. package/dist/llm-docs/components/GraphicBlock.md +319 -0
  38. package/dist/llm-docs/components/Headline.md +248 -0
  39. package/dist/llm-docs/components/Headpile.md +55 -0
  40. package/dist/llm-docs/components/HeroHeadline.md +515 -0
  41. package/dist/llm-docs/components/HorizontalScroller.md +523 -0
  42. package/dist/llm-docs/components/InfoBox.md +196 -0
  43. package/dist/llm-docs/components/KinesisLogo.md +34 -0
  44. package/dist/llm-docs/components/LanguageButton.md +170 -0
  45. package/dist/llm-docs/components/Legend.md +251 -0
  46. package/dist/llm-docs/components/Lottie.md +464 -0
  47. package/dist/llm-docs/components/PaddingReset.md +78 -0
  48. package/dist/llm-docs/components/PhotoPack.md +238 -0
  49. package/dist/llm-docs/components/PymChild.md +49 -0
  50. package/dist/llm-docs/components/ReferralBlock.md +119 -0
  51. package/dist/llm-docs/components/ReutersGraphicsLogo.md +37 -0
  52. package/dist/llm-docs/components/ReutersLogo.md +35 -0
  53. package/dist/llm-docs/components/SEO.md +113 -0
  54. package/dist/llm-docs/components/Scroller.md +350 -0
  55. package/dist/llm-docs/components/ScrollerBase.md +104 -0
  56. package/dist/llm-docs/components/ScrollerVideo.md +576 -0
  57. package/dist/llm-docs/components/SearchInput.md +44 -0
  58. package/dist/llm-docs/components/ShareBar.md +78 -0
  59. package/dist/llm-docs/components/SimpleTimeline.md +141 -0
  60. package/dist/llm-docs/components/SiteFooter.md +77 -0
  61. package/dist/llm-docs/components/SiteHeader.md +55 -0
  62. package/dist/llm-docs/components/SiteHeadline.md +111 -0
  63. package/dist/llm-docs/components/Spinner.md +43 -0
  64. package/dist/llm-docs/components/Table.md +298 -0
  65. package/dist/llm-docs/components/Theme.md +266 -0
  66. package/dist/llm-docs/components/TileMap.md +477 -0
  67. package/dist/llm-docs/components/ToolsHeader.md +46 -0
  68. package/dist/llm-docs/components/Video.md +254 -0
  69. package/dist/llm-docs/components/Visible.md +54 -0
  70. package/dist/llm-docs/components/cssVariables.md +40 -0
  71. package/dist/llm-docs/components/index.md +59 -0
  72. package/dist/llm-docs/components/resizeObserver.md +21 -0
  73. package/dist/llm-docs/guides/archieml.md +406 -0
  74. package/dist/llm-docs/guides/colours.md +443 -0
  75. package/dist/llm-docs/guides/customising-with-scss.md +61 -0
  76. package/dist/llm-docs/guides/graphics-kit.md +25 -0
  77. package/dist/llm-docs/guides/index.md +16 -0
  78. package/dist/llm-docs/guides/intro.md +21 -0
  79. package/dist/llm-docs/guides/layout.md +13 -0
  80. package/dist/llm-docs/guides/llm-docs.md +71 -0
  81. package/dist/llm-docs/guides/styles.md +16 -0
  82. package/dist/llm-docs/guides/theming.md +100 -0
  83. package/dist/llm-docs/guides/tokens.md +150 -0
  84. package/dist/llm-docs/index.md +36 -0
  85. package/package.json +18 -24
@@ -11,8 +11,8 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
11
11
  };
12
12
  z_$$bindings?: Bindings;
13
13
  }
14
- declare const Gtm: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
14
+ declare const GTM: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
15
  [evt: string]: CustomEvent<any>;
16
16
  }, {}, {}, string>;
17
- type Gtm = InstanceType<typeof Gtm>;
18
- export default Gtm;
17
+ type GTM = InstanceType<typeof GTM>;
18
+ export default GTM;
@@ -10,9 +10,10 @@
10
10
  */
11
11
  slugTitle: string;
12
12
  /**
13
- * Base path prepended to the copied URL, e.g. "/graphics", usually gotten from base store in SvelteKit.
13
+ * SvelteKit's `resolve` function from `$app/paths`, used to build the post's
14
+ * canonical URL against your project's base path. Defaults to an identity function.
14
15
  */
15
- base: string;
16
+ resolve?(pathname: string): string;
16
17
  /** Array of author names, which will be slugified to create links to Reuters author pages */
17
18
  authors: string[];
18
19
  /** Publish time as a datetime string. */
@@ -33,7 +34,7 @@
33
34
  let {
34
35
  title = 'Reuters Graphics blog post',
35
36
  slugTitle = 'Reuters Graphics blog post',
36
- base = '',
37
+ resolve = (pathname: string) => pathname,
37
38
  authors = [],
38
39
  publishTime = '',
39
40
  updateTime = '',
@@ -54,14 +55,14 @@
54
55
  <PostHeadline
55
56
  hed={title}
56
57
  sluggableHed={slugTitle}
57
- {base}
58
+ {resolve}
58
59
  {authors}
59
60
  {publishTime}
60
61
  {updateTime}
61
62
  {id}
62
63
  {cls}
63
64
  />
64
- <a href="{base}/{shortPubDate}/{slugify(slugTitle)}/" hidden>
65
+ <a href={resolve(`/${shortPubDate}/${slugify(slugTitle)}/`)} hidden>
65
66
  {title}
66
67
  </a>
67
68
  {@render children?.()}
@@ -9,9 +9,10 @@ interface Props {
9
9
  */
10
10
  slugTitle: string;
11
11
  /**
12
- * Base path prepended to the copied URL, e.g. "/graphics", usually gotten from base store in SvelteKit.
12
+ * SvelteKit's `resolve` function from `$app/paths`, used to build the post's
13
+ * canonical URL against your project's base path. Defaults to an identity function.
13
14
  */
14
- base: string;
15
+ resolve?(pathname: string): string;
15
16
  /** Array of author names, which will be slugified to create links to Reuters author pages */
16
17
  authors: string[];
17
18
  /** Publish time as a datetime string. */
@@ -9,8 +9,11 @@
9
9
  publishedDate?: string;
10
10
  /** The heading of the post. */
11
11
  hed?: string;
12
- /** Base path prepended to the copied URL, e.g. "/graphics". */
13
- base: string;
12
+ /**
13
+ * SvelteKit's `resolve` function from `$app/paths`, used to build the copied URL
14
+ * against your project's base path. Defaults to an identity function.
15
+ */
16
+ resolve?(pathname: string): string;
14
17
  /** The ARIA label for the copy link button. */
15
18
  ariaLabel?: string;
16
19
  /** The message to display before copying the link. */
@@ -22,7 +25,7 @@
22
25
  let {
23
26
  publishedDate = '',
24
27
  hed = '',
25
- base = '',
28
+ resolve = (pathname: string) => pathname,
26
29
  ariaLabel = 'Copy link to this post',
27
30
  copyMessageBefore = 'Copy link',
28
31
  copyMessageAfter = 'Copied',
@@ -44,7 +47,7 @@
44
47
  e.preventDefault();
45
48
  clicked = true;
46
49
  navigator.clipboard.writeText(
47
- `${window.location.origin}${base}/${publishDate}/${slugify(hed)}/`
50
+ `${window.location.origin}${resolve(`/${publishDate}/${slugify(hed)}/`)}`
48
51
  );
49
52
  setTimeout(() => {
50
53
  clicked = false;
@@ -3,8 +3,11 @@ interface Props {
3
3
  publishedDate?: string;
4
4
  /** The heading of the post. */
5
5
  hed?: string;
6
- /** Base path prepended to the copied URL, e.g. "/graphics". */
7
- base: string;
6
+ /**
7
+ * SvelteKit's `resolve` function from `$app/paths`, used to build the copied URL
8
+ * against your project's base path. Defaults to an identity function.
9
+ */
10
+ resolve?(pathname: string): string;
8
11
  /** The ARIA label for the copy link button. */
9
12
  ariaLabel?: string;
10
13
  /** The message to display before copying the link. */
@@ -16,8 +16,11 @@
16
16
  * published links to the post.
17
17
  */
18
18
  sluggableHed: string;
19
- /** Base path prepended to the copied URL, e.g. "/graphics". */
20
- base: string;
19
+ /**
20
+ * SvelteKit's `resolve` function from `$app/paths`, used to build the copied URL
21
+ * against your project's base path. Defaults to an identity function.
22
+ */
23
+ resolve?(pathname: string): string;
21
24
  /** Array of author names, which will be slugified to create links to Reuters author pages */
22
25
  authors: string[];
23
26
  /** Publish time as a datetime string. */
@@ -33,7 +36,7 @@
33
36
  let {
34
37
  hed = 'Reuters Graphics blog post',
35
38
  sluggableHed = 'Reuters Graphics blog post',
36
- base = '',
39
+ resolve = (pathname: string) => pathname,
37
40
  authors = [],
38
41
  publishTime = '',
39
42
  updateTime = '',
@@ -105,7 +108,7 @@
105
108
  <CopyLink
106
109
  hed={sluggableHed}
107
110
  publishedDate={publishTime}
108
- {base}
111
+ {resolve}
109
112
  /></span
110
113
  >
111
114
  </a>
@@ -8,8 +8,11 @@ interface Props {
8
8
  * published links to the post.
9
9
  */
10
10
  sluggableHed: string;
11
- /** Base path prepended to the copied URL, e.g. "/graphics". */
12
- base: string;
11
+ /**
12
+ * SvelteKit's `resolve` function from `$app/paths`, used to build the copied URL
13
+ * against your project's base path. Defaults to an identity function.
14
+ */
15
+ resolve?(pathname: string): string;
13
16
  /** Array of author names, which will be slugified to create links to Reuters author pages */
14
17
  authors: string[];
15
18
  /** Publish time as a datetime string. */
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Converts a date string to a short date format.
3
3
  * @param d - The date string to be converted.
4
- * @returns The short date format string.
4
+ * @returns The short date format string (`YYYY-MM-DD`), or an empty string if
5
+ * `d` is missing or not a valid date.
5
6
  */
6
7
  export declare const getShortDate: (d: string) => string;
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * Converts a date string to a short date format.
3
3
  * @param d - The date string to be converted.
4
- * @returns The short date format string.
4
+ * @returns The short date format string (`YYYY-MM-DD`), or an empty string if
5
+ * `d` is missing or not a valid date.
5
6
  */
6
- export const getShortDate = (d) => new Date(d).toISOString().split('T')[0];
7
+ export const getShortDate = (d) => {
8
+ const date = new Date(d);
9
+ if (Number.isNaN(date.getTime()))
10
+ return '';
11
+ return date.toISOString().split('T')[0];
12
+ };
@@ -19,8 +19,11 @@
19
19
 
20
20
  interface Props {
21
21
  posts: Post[];
22
- /** Base path prepended to post links, e.g. "/graphics". */
23
- base: string;
22
+ /**
23
+ * SvelteKit's `resolve` function from `$app/paths`, used to build post links
24
+ * against your project's base path. Defaults to an identity function.
25
+ */
26
+ resolve?(pathname: string): string;
24
27
  /** The label for the table of contents toggle button. */
25
28
  label?: string;
26
29
  /** The maximum height of the table of contents list in pixels. */
@@ -29,7 +32,7 @@
29
32
 
30
33
  let {
31
34
  posts,
32
- base = '',
35
+ resolve = (pathname: string) => pathname,
33
36
  label = 'Show all articles',
34
37
  maxHeight = 300,
35
38
  }: Props = $props();
@@ -51,7 +54,7 @@
51
54
  const existing = acc.find((entry) => entry.dateKey === dateKey);
52
55
  const event = {
53
56
  title: post.title,
54
- titleLink: `${base}/#${slugify(post.slugTitle)}`,
57
+ titleLink: `${resolve('/')}#${slugify(post.slugTitle)}`,
55
58
  };
56
59
  if (existing) {
57
60
  existing.events.push(event);
@@ -5,13 +5,16 @@ interface Post {
5
5
  }
6
6
  interface Props {
7
7
  posts: Post[];
8
- /** Base path prepended to post links, e.g. "/graphics". */
9
- base: string;
8
+ /**
9
+ * SvelteKit's `resolve` function from `$app/paths`, used to build post links
10
+ * against your project's base path. Defaults to an identity function.
11
+ */
12
+ resolve?(pathname: string): string;
10
13
  /** The label for the table of contents toggle button. */
11
14
  label?: string;
12
15
  /** The maximum height of the table of contents list in pixels. */
13
16
  maxHeight?: number;
14
17
  }
15
- declare const BlogToc: import("svelte").Component<Props, {}, "">;
16
- type BlogToc = ReturnType<typeof BlogToc>;
17
- export default BlogToc;
18
+ declare const BlogTOC: import("svelte").Component<Props, {}, "">;
19
+ type BlogTOC = ReturnType<typeof BlogTOC>;
20
+ export default BlogTOC;
@@ -17,6 +17,6 @@ interface Props {
17
17
  id?: string;
18
18
  class?: string;
19
19
  }
20
- declare const TocList: import("svelte").Component<Props, {}, "listHeight">;
21
- type TocList = ReturnType<typeof TocList>;
22
- export default TocList;
20
+ declare const TOCList: import("svelte").Component<Props, {}, "listHeight">;
21
+ type TOCList = ReturnType<typeof TOCList>;
22
+ export default TOCList;
@@ -28,9 +28,9 @@
28
28
  * Headshot image src. Be sure to prefix the image
29
29
  *
30
30
  * ```typescript
31
- * import { assets } from '$app/paths';
31
+ * import { asset } from '$app/paths';
32
32
  *
33
- * const imgSrc = `${assets}/images/my-image.jpg`;
33
+ * const imgSrc = asset('/images/my-image.jpg');
34
34
  * ```
35
35
  */
36
36
  img: string;
@@ -24,9 +24,9 @@ interface Props {
24
24
  * Headshot image src. Be sure to prefix the image
25
25
  *
26
26
  * ```typescript
27
- * import { assets } from '$app/paths';
27
+ * import { asset } from '$app/paths';
28
28
  *
29
- * const imgSrc = `${assets}/images/my-image.jpg`;
29
+ * const imgSrc = asset('/images/my-image.jpg');
30
30
  * ```
31
31
  */
32
32
  img: string;
@@ -5,8 +5,11 @@
5
5
  locale: string | undefined;
6
6
  /** Whether the article is embedded */
7
7
  embedded?: boolean;
8
- /** The base URL for the article */
9
- base?: string;
8
+ /**
9
+ * SvelteKit's `resolve` function from `$app/paths`, used to build locale links
10
+ * against your project's base path. Defaults to an identity function.
11
+ */
12
+ resolve?(pathname: string): string;
10
13
  /** Options for the language toggle button */
11
14
  buttonOptions?: {
12
15
  locale: string;
@@ -19,7 +22,7 @@
19
22
  let {
20
23
  locale = 'en',
21
24
  embedded = false,
22
- base,
25
+ resolve = (pathname: string) => pathname,
23
26
  buttonOptions = {
24
27
  locale: 'es',
25
28
  label: 'Leer en español',
@@ -37,16 +40,16 @@
37
40
  if (embedded) {
38
41
  if (locale === translationLocale) {
39
42
  // If we're in the non-English article, link to the English article
40
- return `${base}/embeds/en/page/`;
43
+ return resolve('/embeds/en/page/');
41
44
  } else {
42
- return `${base}/embeds/${translationLocale}/page/`;
45
+ return resolve(`/embeds/${translationLocale}/page/`);
43
46
  }
44
47
  } else {
45
48
  if (locale === translationLocale) {
46
49
  // If we're in the non-English article, link to the English article
47
- return `${base}/`;
50
+ return resolve('/');
48
51
  } else {
49
- return `${base}/${translationLocale}/`;
52
+ return resolve(`/${translationLocale}/`);
50
53
  }
51
54
  }
52
55
  };
@@ -3,8 +3,11 @@ interface Props {
3
3
  locale: string | undefined;
4
4
  /** Whether the article is embedded */
5
5
  embedded?: boolean;
6
- /** The base URL for the article */
7
- base?: string;
6
+ /**
7
+ * SvelteKit's `resolve` function from `$app/paths`, used to build locale links
8
+ * against your project's base path. Defaults to an identity function.
9
+ */
10
+ resolve?(pathname: string): string;
8
11
  /** Options for the language toggle button */
9
12
  buttonOptions?: {
10
13
  locale: string;
@@ -49,6 +49,6 @@ interface Props {
49
49
  authors?: GraphicAuthor[];
50
50
  }
51
51
  /** `SEO` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-ads-analytic-seo--docs) */
52
- declare const Seo: import("svelte").Component<Props, {}, "">;
53
- type Seo = ReturnType<typeof Seo>;
54
- export default Seo;
52
+ declare const SEO: import("svelte").Component<Props, {}, "">;
53
+ type SEO = ReturnType<typeof SEO>;
54
+ export default SEO;
@@ -196,8 +196,8 @@
196
196
  {/snippet}
197
197
 
198
198
  <svelte:window
199
- on:click={setInteractedWithDom}
200
- on:touchstart={setInteractedWithDom}
199
+ onclick={setInteractedWithDom}
200
+ ontouchstart={setInteractedWithDom}
201
201
  />
202
202
 
203
203
  <GraphicBlock
@@ -0,0 +1,11 @@
1
+ # AdSlot
2
+
3
+ **Import:** `import { AdSlot } from '@reuters-graphics/graphics-components'`
4
+
5
+ ## Props
6
+
7
+ | Prop | Type | Default | Required | Description |
8
+ |------|------|---------|:--------:|-------------|
9
+ | `placementName` | `DesktopPlacementName \| MobilePlacementName` | — | ✓ | — |
10
+ | `adType` | `DesktopAdType \| MobileAdType` | — | ✓ | — |
11
+ | `dataFreestarAd` | `string` | `'__970x250'` | | — |
@@ -0,0 +1,89 @@
1
+ # Analytics
2
+
3
+ **Category:** Components/Ads & analytics/Analytics
4
+
5
+ **Import:** `import { Analytics } from '@reuters-graphics/graphics-components'`
6
+
7
+ ## Props
8
+
9
+ | Prop | Type | Default | Required | Description |
10
+ |------|------|---------|:--------:|-------------|
11
+ | `authors` | `Author[]` | `[]` | | Used to associate a page with its author(s) in Chartbeat. |
12
+
13
+ ## Examples
14
+
15
+ ### Demo
16
+
17
+ ```svelte
18
+ <Analytics authors={[{ name: 'Jane Doe' }, { name: 'John Doe' }]} />
19
+ ```
20
+
21
+ ## Documentation
22
+
23
+ # Analytics
24
+
25
+ The `Analytics` component adds Google and Chartbeat analytics to your page.
26
+
27
+ ```svelte
28
+ <script>
29
+ import { Analytics } from '@reuters-graphics/graphics-components';
30
+
31
+ const authors = [{ name: 'Jane Doe' }, { name: 'John Doe' }];
32
+ </script>
33
+
34
+ <Analytics {authors} />
35
+ ```
36
+
37
+ ## Environments
38
+
39
+ Generally, you only want to send page analytics in production environments.
40
+
41
+ In a SvelteKit context, you can use `$app` stores to restrict when you send analytics.
42
+
43
+ For example, the following excludes analytics from pages in development or hosted on our preview server:
44
+
45
+ ```svelte
46
+ <script>
47
+ import { Analytics } from '@reuters-graphics/graphics-components';
48
+ import { dev } from '$app/environment';
49
+ import { page } from '$app/stores';
50
+ </script>
51
+
52
+ {#if !dev && $page.url?.hostname !== 'graphics.thomsonreuters.com'}
53
+ <Analytics />
54
+ {/if}
55
+ ```
56
+
57
+ ## Multipage apps
58
+
59
+ If you're using analytics to measure a multipage newsapp that uses [client-side routing](https://kit.svelte.dev/docs/glossary#routing), then you may need to trigger analytics after virtual page navigation.
60
+
61
+ This component exports a function you can call to register pageviews.
62
+
63
+ For example, here's how you can use SvelteKit's [`afterNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-afternavigate) lifecycle to capture additional pageviews:
64
+
65
+ ```svelte
66
+ <script>
67
+ import {
68
+ Analytics,
69
+ registerPageview,
70
+ } from '@reuters-graphics/graphics-components';
71
+ import { afterNavigate } from '$app/navigation';
72
+
73
+ let isFirstPageview = true;
74
+
75
+ afterNavigate(() => {
76
+ // We shouldn't fire on initial page load because the Analytics component
77
+ // already registers a reader's first pageview. After this component
78
+ // has initially mounted, we can be sure that further navigation is virtual
79
+ // and register pageviews using this function.
80
+ if (!isFirstPageview) {
81
+ registerPageview();
82
+ } else {
83
+ isFirstPageview = false;
84
+ }
85
+ });
86
+ </script>
87
+
88
+ <Analytics />
89
+ ```
@@ -0,0 +1,183 @@
1
+ # Article
2
+
3
+ **Category:** Components/Page layout/Article
4
+
5
+ **Import:** `import { Article } from '@reuters-graphics/graphics-components'`
6
+
7
+ ## Props
8
+
9
+ | Prop | Type | Default | Required | Description |
10
+ |------|------|---------|:--------:|-------------|
11
+ | `embedded` | `boolean` | `false` | | Set to true for embeddables. |
12
+ | `id` | `string` | `''` | | Add an id to the article tag to target it with custom CSS. |
13
+ | `role` | `string \| null` | `null` | | ARIA role of the article |
14
+ | `columnWidths` | `ColumnWidths` | `{
15
+ narrower: 330,
16
+ narrow: 510,
17
+ normal: 660,
18
+ wide: 930,
19
+ wider: 1200,
20
+ }` | | Set custom widths for the normal, wide and wider column dimensions |
21
+ | `children` | `import('svelte').Snippet` | — | | — |
22
+
23
+ ## Examples
24
+
25
+ ### Demo
26
+
27
+ ```svelte
28
+ <Article id="article-story-basic">
29
+ <div class="demo-container">
30
+ <div class="background-label">Article well</div>
31
+ <div class="padding-label"><span>⇤</span>15px padding</div>
32
+ </div>
33
+ </Article>
34
+ ```
35
+
36
+ ### Custom columns
37
+
38
+ ```svelte
39
+ <h3>Default column widths</h3>
40
+
41
+ <Article id="article-column-widths-demo">
42
+ <div class="article-boundaries">
43
+ <Block id="section-demo" width="narrower">narrower</Block>
44
+ <Block id="section-demo" width="narrow">narrow</Block>
45
+ <Block id="section-demo">normal</Block>
46
+ <Block id="section-demo" width="wide">wide</Block>
47
+ <Block id="section-demo" width="wider">wider</Block>
48
+ <Block id="section-demo" width="widest">widest</Block>
49
+ <Block id="section-demo" width="fluid">fluid</Block>
50
+ </div>
51
+ </Article>
52
+ <h3>Custom column widths</h3>
53
+ <Article
54
+ id="article-column-widths-demo"
55
+ columnWidths={{
56
+ narrower: 250,
57
+ narrow: 400,
58
+ normal: 500,
59
+ wide: 675,
60
+ wider: 1400,
61
+ }}
62
+ >
63
+ <div class="article-boundaries custom">
64
+ <Block id="section-demo" width="narrower">narrower</Block>
65
+ <Block id="section-demo" width="narrow">narrow</Block>
66
+ <Block id="section-demo">normal</Block>
67
+ <Block id="section-demo" width="wide">wide</Block>
68
+ <Block id="section-demo" width="wider">wider</Block>
69
+ <Block id="section-demo" width="widest">widest</Block>
70
+ <Block id="section-demo" width="fluid">fluid</Block>
71
+ </div>
72
+ </Article>
73
+ ```
74
+
75
+ ## Documentation
76
+
77
+ # Article
78
+
79
+ The `Article` component contains all the contents of our story.
80
+
81
+ > 📌 In most cases, **you don't need to mess with the `Article` component** because it's already set up in the graphics kit.
82
+
83
+ ```svelte
84
+ <script>
85
+ import { Article } from '@reuters-graphics/graphics-components';
86
+ </script>
87
+
88
+ <Article>
89
+ <!-- The story content goes here! -->
90
+ </Article>
91
+ ```
92
+
93
+ ## Custom column widths
94
+
95
+ The `Article` component also establishes the widths of columns that contain individual sections of the story, such as text, photos, and charts. The default column widths follow a basic class scheme:
96
+
97
+ - `narrower` The narrowest...
98
+ - `narrow` A bit narrower than the default body text column
99
+ - `normal` **The default width of the body text column**
100
+ - `wide` A bit wider
101
+ - `wider` A bit wider than wide...
102
+ - `widest` Edge-to-edge, but _excluding_ the left and right padding on `Article`
103
+ - `fluid` Fully edge-to-edge
104
+
105
+ You can set custom column widths by passing an object to the `columnWidths` prop with pixel values for the `narrower`, `narrow`, `normal`, `wide` and `wider` classes. These can then be used by the `Block` component or other elements housed inside `<Article>`.
106
+
107
+ > **For most graphics kit pages, you shouldn't customise the column widths.** Other Reuters tools, like our AI templates, use our default column widths, so customising those widths here has downstream consequences for graphics made outside graphics kit. The main exception is SREP stories.
108
+
109
+ ```svelte
110
+ <!-- Set custom column widths -->
111
+ <Article
112
+ columnWidths={{
113
+ narrower: 310,
114
+ narrow: 450,
115
+ normal: 550,
116
+ wide: 675,
117
+ wider: 1400,
118
+ }}
119
+ >
120
+ <!-- Custom column widths get passed down to the `Block` component -->
121
+ <Block width="narrower" />
122
+ <Block width="narrow" />
123
+ <Block width="normal" />
124
+ <Block width="wide" />
125
+ <Block width="wider" />
126
+ <Block width="widest" />
127
+ <Block width="fluid" />
128
+ </Article>
129
+ ```
130
+
131
+ If you're not using our `Block` component, you can still inherit the column widths from `Article` and create your own custom containers by using [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) like this:
132
+
133
+ ```svelte
134
+ <div class="my-special-container">
135
+ <!-- Story content -->
136
+ </div>
137
+
138
+ <style lang="scss">
139
+ div.my-special-container {
140
+ max-width: var(--wide-column-width);
141
+ }
142
+ </style>
143
+ ```
144
+
145
+ ... or you can make your column widths entirely configurable by adding classes and manually specifying widths:
146
+
147
+ ```svelte
148
+ <script>
149
+ let { width = 'normal' } = $props();
150
+ </script>
151
+
152
+ <div class="my-special-container {width}">
153
+ <!-- Story content -->
154
+ </div>
155
+
156
+ <style lang="scss">
157
+ div.my-special-container {
158
+ max-width: var(--normal-column-width);
159
+ &.narrower {
160
+ max-width: var(--narrower-column-width);
161
+ }
162
+ &.narrow {
163
+ max-width: var(--narrow-column-width);
164
+ }
165
+ &.wide {
166
+ max-width: var(--wide-column-width);
167
+ }
168
+ &.wider {
169
+ max-width: var(--wider-column-width);
170
+ }
171
+ &.widest {
172
+ max-width: 100%;
173
+ }
174
+ &.fluid {
175
+ width: calc(100% + 30px);
176
+ margin-inline-start: -15px;
177
+ max-width: none;
178
+ }
179
+ }
180
+ </style>
181
+ ```
182
+
183
+ Here's an example of how `columnWidths` can be used to change column widths: