@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.
- 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/AdSlot.md +11 -0
- package/dist/llm-docs/components/Analytics.md +89 -0
- package/dist/llm-docs/components/Article.md +183 -0
- package/dist/llm-docs/components/BeforeAfter.md +170 -0
- package/dist/llm-docs/components/BioBox.md +74 -0
- package/dist/llm-docs/components/Block.md +211 -0
- package/dist/llm-docs/components/BlogPost.md +66 -0
- package/dist/llm-docs/components/BlogTOC.md +89 -0
- package/dist/llm-docs/components/BodyText.md +143 -0
- package/dist/llm-docs/components/Byline.md +242 -0
- package/dist/llm-docs/components/ClockWall.md +48 -0
- package/dist/llm-docs/components/DatawrapperChart.md +87 -0
- package/dist/llm-docs/components/DocumentCloud.md +47 -0
- package/dist/llm-docs/components/EmbedPreviewerLink.md +35 -0
- package/dist/llm-docs/components/EndNotes.md +79 -0
- package/dist/llm-docs/components/FeaturePhoto.md +102 -0
- package/dist/llm-docs/components/Framer.md +44 -0
- package/dist/llm-docs/components/Geocoder.md +49 -0
- package/dist/llm-docs/components/GraphicBlock.md +319 -0
- package/dist/llm-docs/components/Headline.md +248 -0
- package/dist/llm-docs/components/Headpile.md +55 -0
- package/dist/llm-docs/components/HeroHeadline.md +515 -0
- package/dist/llm-docs/components/HorizontalScroller.md +523 -0
- package/dist/llm-docs/components/InfoBox.md +196 -0
- package/dist/llm-docs/components/KinesisLogo.md +34 -0
- package/dist/llm-docs/components/LanguageButton.md +170 -0
- package/dist/llm-docs/components/Legend.md +251 -0
- package/dist/llm-docs/components/Lottie.md +464 -0
- package/dist/llm-docs/components/PaddingReset.md +78 -0
- package/dist/llm-docs/components/PhotoPack.md +238 -0
- package/dist/llm-docs/components/PymChild.md +49 -0
- package/dist/llm-docs/components/ReferralBlock.md +119 -0
- package/dist/llm-docs/components/ReutersGraphicsLogo.md +37 -0
- package/dist/llm-docs/components/ReutersLogo.md +35 -0
- package/dist/llm-docs/components/SEO.md +113 -0
- package/dist/llm-docs/components/Scroller.md +350 -0
- package/dist/llm-docs/components/ScrollerBase.md +104 -0
- package/dist/llm-docs/components/ScrollerVideo.md +576 -0
- package/dist/llm-docs/components/SearchInput.md +44 -0
- package/dist/llm-docs/components/ShareBar.md +78 -0
- package/dist/llm-docs/components/SimpleTimeline.md +141 -0
- package/dist/llm-docs/components/SiteFooter.md +77 -0
- package/dist/llm-docs/components/SiteHeader.md +55 -0
- package/dist/llm-docs/components/SiteHeadline.md +111 -0
- package/dist/llm-docs/components/Spinner.md +43 -0
- package/dist/llm-docs/components/Table.md +298 -0
- package/dist/llm-docs/components/Theme.md +266 -0
- package/dist/llm-docs/components/TileMap.md +477 -0
- package/dist/llm-docs/components/ToolsHeader.md +46 -0
- package/dist/llm-docs/components/Video.md +254 -0
- package/dist/llm-docs/components/Visible.md +54 -0
- package/dist/llm-docs/components/cssVariables.md +40 -0
- package/dist/llm-docs/components/index.md +59 -0
- package/dist/llm-docs/components/resizeObserver.md +21 -0
- package/dist/llm-docs/guides/archieml.md +406 -0
- package/dist/llm-docs/guides/colours.md +443 -0
- package/dist/llm-docs/guides/customising-with-scss.md +61 -0
- package/dist/llm-docs/guides/graphics-kit.md +25 -0
- package/dist/llm-docs/guides/index.md +16 -0
- package/dist/llm-docs/guides/intro.md +21 -0
- package/dist/llm-docs/guides/layout.md +13 -0
- package/dist/llm-docs/guides/llm-docs.md +71 -0
- package/dist/llm-docs/guides/styles.md +16 -0
- package/dist/llm-docs/guides/theming.md +100 -0
- package/dist/llm-docs/guides/tokens.md +150 -0
- package/dist/llm-docs/index.md +36 -0
- package/package.json +18 -24
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# BeforeAfter
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Multimedia/BeforeAfter
|
|
4
|
+
|
|
5
|
+
**Import:** `import { BeforeAfter } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `width` | `ContainerWidth` | `'normal'` | | Width of the chart within the text well. Options: wide, wider, widest, fluid Options: `normal`, `wide`, `wider`, `widest`, `fluid` |
|
|
12
|
+
| `height` | `number` | `600` | | Height of the component |
|
|
13
|
+
| `heightRatio` | `number` | — | | If set, makes the height a ratio of the component's width. |
|
|
14
|
+
| `beforeSrc` | `string` | — | ✓ | Before image source |
|
|
15
|
+
| `beforeAlt` | `string` | — | ✓ | Before image altText |
|
|
16
|
+
| `afterSrc` | `string` | — | ✓ | After image source |
|
|
17
|
+
| `afterAlt` | `string` | — | ✓ | After image altText |
|
|
18
|
+
| `class` | `string` | `''` | | Class to target with SCSS. |
|
|
19
|
+
| `handleColour` | `string` | `'white'` | | Drag handle colour |
|
|
20
|
+
| `handleInactiveOpacity` | `number` | `0.9` | | Drag handle opacity |
|
|
21
|
+
| `handleMargin` | `number` | `20` | | Margin at the edge of the image to stop dragging |
|
|
22
|
+
| `keyPressStep` | `number` | `0.05` | | Percentage of the component width the handle will travel ona key press |
|
|
23
|
+
| `offset` | `number` | `0.5` | | Initial offset of the handle, between 0 and 1. |
|
|
24
|
+
| `id` | `string` | `'before-after-' + random4() + random4()` | | ID to target with SCSS. |
|
|
25
|
+
| `beforeOverlay` | `Snippet` | — | | Optional snippet for a custom overlay for the before image. |
|
|
26
|
+
| `afterOverlay` | `Snippet` | — | | Optional snippet for a custom overlay for the after image. |
|
|
27
|
+
| `caption` | `Snippet` | — | | Optional snippet for a custom caption. |
|
|
28
|
+
| `ariaLabel` | `string` | `'Stacked before and after images with an adjustable slider'` | | Custom ARIA label language to label the component. |
|
|
29
|
+
|
|
30
|
+
## Examples
|
|
31
|
+
|
|
32
|
+
### Demo
|
|
33
|
+
|
|
34
|
+
```svelte
|
|
35
|
+
<BeforeAfter
|
|
36
|
+
beforeSrc={/* beforeImg */}
|
|
37
|
+
beforeAlt="Satellite image of Russian base at Myrne taken on July 7, 2020."
|
|
38
|
+
afterSrc={/* afterImg */}
|
|
39
|
+
afterAlt="Satellite image of Russian base at Myrne taken on Oct. 20, 2020."
|
|
40
|
+
/>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### With text
|
|
44
|
+
|
|
45
|
+
```svelte
|
|
46
|
+
<BeforeAfter
|
|
47
|
+
beforeSrc={beforeImg}
|
|
48
|
+
beforeAlt="Satellite image of Russian base at Myrne taken on July 7, 2020."
|
|
49
|
+
afterSrc={afterImg}
|
|
50
|
+
afterAlt="Satellite image of Russian base at Myrne taken on Oct. 20, 2020."
|
|
51
|
+
>
|
|
52
|
+
{#snippet beforeOverlay()}
|
|
53
|
+
<div class="overlay p-3 before">
|
|
54
|
+
<p class="h4 font-bold">July 7, 2020</p>
|
|
55
|
+
<p class="body-note">Initially, this site was far smaller.</p>
|
|
56
|
+
</div>
|
|
57
|
+
{/snippet}
|
|
58
|
+
{#snippet afterOverlay()}
|
|
59
|
+
<div class="overlay p-3 after">
|
|
60
|
+
<p class="h4 font-bold">Oct. 20, 2020</p>
|
|
61
|
+
<p class="body-note">But then forces built up.</p>
|
|
62
|
+
</div>
|
|
63
|
+
{/snippet}
|
|
64
|
+
{#snippet caption()}
|
|
65
|
+
<p class="body-note">Photos by MAXAR Technologies, 2021.</p>
|
|
66
|
+
{/snippet}
|
|
67
|
+
</BeforeAfter>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Documentation
|
|
71
|
+
|
|
72
|
+
# BeforeAfter
|
|
73
|
+
|
|
74
|
+
The `BeforeAfter` component shows a before-and-after comparison of an image.
|
|
75
|
+
|
|
76
|
+
```svelte
|
|
77
|
+
<script>
|
|
78
|
+
import { BeforeAfter } from '@reuters-graphics/graphics-components';
|
|
79
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<BeforeAfter
|
|
83
|
+
beforeSrc={asset('/images/before-after/myrne-before.jpg')}
|
|
84
|
+
beforeAlt="Satellite image of Russian base at Myrne taken on July 7, 2020."
|
|
85
|
+
afterSrc={asset('/images/before-after/myrne-after.jpg')}
|
|
86
|
+
afterAlt="Satellite image of Russian base at Myrne taken on Oct. 20, 2020."
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Using with ArchieML docs
|
|
91
|
+
|
|
92
|
+
With the graphics kit, you'll likely get your text value from an ArchieML doc...
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
# ArchieML doc
|
|
96
|
+
[blocks]
|
|
97
|
+
|
|
98
|
+
type: before-after
|
|
99
|
+
beforeSrc: images/before-after/myrne-before.jpg
|
|
100
|
+
beforeAlt: Satellite image of Russian base at Myrne taken on July 7, 2020.
|
|
101
|
+
afterSrc: images/before-after/myrne-after.jpg
|
|
102
|
+
afterAlt: Satellite image of Russian base at Myrne taken on Oct. 20, 2020.
|
|
103
|
+
|
|
104
|
+
[]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
... which you'll parse out of a ArchieML block object before passing to the `BeforeAfter` component.
|
|
108
|
+
|
|
109
|
+
```svelte
|
|
110
|
+
<!-- App.svelte -->
|
|
111
|
+
{#each content.blocks as block}
|
|
112
|
+
{#if block.type === 'before-after'}
|
|
113
|
+
<BeforeAfter
|
|
114
|
+
beforeSrc={asset(`/${block.beforeSrc}`)}
|
|
115
|
+
beforeAlt={block.beforeAlt}
|
|
116
|
+
afterSrc={asset(`/${block.afterSrc}`)}
|
|
117
|
+
afterAlt={block.afterAlt}
|
|
118
|
+
/>
|
|
119
|
+
{/if}
|
|
120
|
+
{/each}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Adding text
|
|
124
|
+
|
|
125
|
+
To add text overlays and captions, use [snippets](https://svelte.dev/docs/svelte/snippet) for `beforeOverlay`, `afterOverlay` and `caption`. You can style the snippets to match your page design, like in [this demo](./?path=/story/components-multimedia-beforeafter--with-overlays).
|
|
126
|
+
|
|
127
|
+
> 💡**NOTE:** The text in the overlays are used as [ARIA descriptions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) for your before and after images. You must always use the `beforeAlt` / `afterAlt` props to label your image for visually impaired readers, but these ARIA descriptions provide additional information or context that the reader might need.
|
|
128
|
+
|
|
129
|
+
```svelte
|
|
130
|
+
<BeforeAfter
|
|
131
|
+
beforeSrc={beforeImg}
|
|
132
|
+
beforeAlt="Satellite image of Russian base at Myrne taken on July 7, 2020."
|
|
133
|
+
afterSrc={afterImg}
|
|
134
|
+
afterAlt="Satellite image of Russian base at Myrne taken on Oct. 20, 2020."
|
|
135
|
+
>
|
|
136
|
+
<!-- Optional custom text overlay for the before image -->
|
|
137
|
+
{#snippet beforeOverlay()}
|
|
138
|
+
<div class="overlay p-3 before text-left">
|
|
139
|
+
<p class="h4 font-bold">July 7, 2020</p>
|
|
140
|
+
<p class="body-note">Initially, this site was far smaller.</p>
|
|
141
|
+
</div>
|
|
142
|
+
{/snippet}
|
|
143
|
+
|
|
144
|
+
<!-- Optional custom text overlay for the after image -->
|
|
145
|
+
{#snippet afterOverlay()}
|
|
146
|
+
<div class="overlay p-3 after text-right">
|
|
147
|
+
<p class="h4 font-bold">Oct. 20, 2020</p>
|
|
148
|
+
<p class="body-note">But then forces built up.</p>
|
|
149
|
+
</div>
|
|
150
|
+
{/snippet}
|
|
151
|
+
|
|
152
|
+
<!-- Optional custom caption for both images -->
|
|
153
|
+
{#snippet caption()}
|
|
154
|
+
<p class="body-note">Photos by MAXAR Technologies, 2021.</p>
|
|
155
|
+
{/snippet}
|
|
156
|
+
</BeforeAfter>
|
|
157
|
+
|
|
158
|
+
<style lang="scss">
|
|
159
|
+
.overlay {
|
|
160
|
+
background: rgba(0, 0, 0, 0.45);
|
|
161
|
+
max-width: 350px;
|
|
162
|
+
&.after {
|
|
163
|
+
text-align: right;
|
|
164
|
+
}
|
|
165
|
+
p {
|
|
166
|
+
color: #ffffff;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
</style>
|
|
170
|
+
```
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# BioBox
|
|
2
|
+
|
|
3
|
+
BioBox shows one or more author biographies in a bordered box, echoing the contributor box on Reuters.com stories.
|
|
4
|
+
|
|
5
|
+
**Category:** Components/Page furniture/BioBox
|
|
6
|
+
|
|
7
|
+
**Import:** `import { BioBox } from '@reuters-graphics/graphics-components'`
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
| Prop | Type | Default | Required | Description |
|
|
12
|
+
|------|------|---------|:--------:|-------------|
|
|
13
|
+
| `authors` | `Author[]` | — | ✓ | Authors to display, in order. |
|
|
14
|
+
| `id` | `string` | `''` | | ID on the containing block. |
|
|
15
|
+
| `class` | `string` | `'fmy-8'` | | Extra classes on the containing block. |
|
|
16
|
+
|
|
17
|
+
## Examples
|
|
18
|
+
|
|
19
|
+
### Demo
|
|
20
|
+
|
|
21
|
+
```svelte
|
|
22
|
+
<BioBox authors={/* authors */} />
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Single author
|
|
26
|
+
|
|
27
|
+
```svelte
|
|
28
|
+
<BioBox authors={[authors[1]]} />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Logo fallback
|
|
32
|
+
|
|
33
|
+
```svelte
|
|
34
|
+
<BioBox authors={/* array — see Props/Types for full type */} />
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Documentation
|
|
38
|
+
|
|
39
|
+
# BioBox
|
|
40
|
+
|
|
41
|
+
The `BioBox` component shows one or more author biographies in a bordered box, echoing the contributor box at the bottom of Reuters.com stories.
|
|
42
|
+
|
|
43
|
+
Each author can include a name, job title, short bio, avatar image and a row of contact and social links (email, X, LinkedIn, Facebook, Instagram, Bluesky or a generic link). When no avatar is provided, the Reuters Kinesis logo is shown instead.
|
|
44
|
+
|
|
45
|
+
On narrow screens the social links move below the bio text so names and titles stay readable.
|
|
46
|
+
|
|
47
|
+
```svelte
|
|
48
|
+
<script>
|
|
49
|
+
import { BioBox } from '@reuters-graphics/graphics-components';
|
|
50
|
+
|
|
51
|
+
const authors = [
|
|
52
|
+
{
|
|
53
|
+
name: 'Ben Welsh',
|
|
54
|
+
title: 'News Applications Editor',
|
|
55
|
+
bio: 'Ben Welsh leads the development of dashboards, databases and other automated systems.',
|
|
56
|
+
imageUrl: 'https://www.reuters.com/.../avatar.jpg',
|
|
57
|
+
links: [
|
|
58
|
+
{ platform: 'email', url: 'ben.welsh@thomsonreuters.com' },
|
|
59
|
+
{ platform: 'x', url: 'https://x.com/palewire' },
|
|
60
|
+
{ platform: 'linkedin', url: 'https://www.linkedin.com/in/palewire' },
|
|
61
|
+
{ platform: 'link', url: 'https://palewi.re/who-is-ben-welsh/' },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<BioBox {authors} />
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Single author
|
|
71
|
+
|
|
72
|
+
## Logo fallback
|
|
73
|
+
|
|
74
|
+
When an author has no `imageUrl`, the box falls back to the Reuters Kinesis logo.
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# Block
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Page layout/Block
|
|
4
|
+
|
|
5
|
+
**Import:** `import { Block } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `children` | `Snippet` | — | ✓ | Content that goes inside `<Block>` |
|
|
12
|
+
| `width` | `ContainerWidth` | `'normal'` | | Width of the block within the article well. Options: `narrower`, `narrow`, `normal`, `wide`, `wider`, `widest`, `fluid` |
|
|
13
|
+
| `id` | `string` | `''` | | Add an id to the block tag to target it with custom CSS. |
|
|
14
|
+
| `class` | `string` | `''` | | Add custom classes to the block tag to target it with custom CSS. |
|
|
15
|
+
| `snap` | `boolean` | `false` | | Snap block to column widths, rather than fluidly resizing them. |
|
|
16
|
+
| `role` | `string` | — | | ARIA [role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles) for the block |
|
|
17
|
+
| `ariaLabel` | `string` | — | | ARIA [label](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label) for the block |
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### Demo
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<Article id="block-demo-article">
|
|
25
|
+
<div class="article-boundaries">
|
|
26
|
+
<div class="label">Article</div>
|
|
27
|
+
<Block>
|
|
28
|
+
<div class="label">Block</div>
|
|
29
|
+
</Block>
|
|
30
|
+
</div>
|
|
31
|
+
</Article>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Custom layout
|
|
35
|
+
|
|
36
|
+
```svelte
|
|
37
|
+
<Block width="fluid">
|
|
38
|
+
<!-- Enter bootstrap grid! -->
|
|
39
|
+
<div id="block-flex-example">
|
|
40
|
+
<div class="row">
|
|
41
|
+
<div class="col">Column</div>
|
|
42
|
+
<div class="col-6">Column</div>
|
|
43
|
+
<div class="col">Column</div>
|
|
44
|
+
</div>
|
|
45
|
+
<div class="row">
|
|
46
|
+
<div class="col">Column</div>
|
|
47
|
+
<div class="col">Column</div>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</Block>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Snap widths
|
|
54
|
+
|
|
55
|
+
```svelte
|
|
56
|
+
<Article id="block-demo-article">
|
|
57
|
+
<div class="article-boundaries">
|
|
58
|
+
<div class="label">Article</div>
|
|
59
|
+
<h4>snap widths</h4>
|
|
60
|
+
<Block snap={true}>
|
|
61
|
+
<div class="label">Block</div>
|
|
62
|
+
</Block>
|
|
63
|
+
</div>
|
|
64
|
+
</Article>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Snap and skip widths
|
|
68
|
+
|
|
69
|
+
```svelte
|
|
70
|
+
<Article id="block-demo-article">
|
|
71
|
+
<div class="article-boundaries">
|
|
72
|
+
<div class="label">Article</div>
|
|
73
|
+
<h4>Regular layout</h4>
|
|
74
|
+
|
|
75
|
+
<Block width="narrower" snap={true} class="block-snap-widths-demo">
|
|
76
|
+
narrower
|
|
77
|
+
</Block>
|
|
78
|
+
<Block width="narrow" snap={true} class="block-snap-widths-demo">
|
|
79
|
+
narrow
|
|
80
|
+
</Block>
|
|
81
|
+
<Block width="normal" snap={true} class="block-snap-widths-demo">
|
|
82
|
+
normal
|
|
83
|
+
</Block>
|
|
84
|
+
<Block width="wide" snap={true} class="block-snap-widths-demo">
|
|
85
|
+
wide
|
|
86
|
+
</Block>
|
|
87
|
+
<Block width="wider" snap={true} class="block-snap-widths-demo">
|
|
88
|
+
wider
|
|
89
|
+
</Block>
|
|
90
|
+
|
|
91
|
+
<h4>with snap and skip</h4>
|
|
92
|
+
<Block width="narrower" snap={true} class="block-snap-widths-demo even">
|
|
93
|
+
narrower
|
|
94
|
+
</Block>
|
|
95
|
+
<Block width="narrow" snap={true} class="block-snap-widths-demo even">
|
|
96
|
+
narrow
|
|
97
|
+
</Block>
|
|
98
|
+
<Block
|
|
99
|
+
width="normal"
|
|
100
|
+
snap={true}
|
|
101
|
+
class="block-snap-widths-demo even skip-narrow"
|
|
102
|
+
>
|
|
103
|
+
normal.skip-narrow
|
|
104
|
+
</Block>
|
|
105
|
+
<Block
|
|
106
|
+
width="wide"
|
|
107
|
+
snap={true}
|
|
108
|
+
class="block-snap-widths-demo even skip-normal skip-narrow"
|
|
109
|
+
>
|
|
110
|
+
wide.skip-normal.skip-narrow
|
|
111
|
+
</Block>
|
|
112
|
+
<Block
|
|
113
|
+
width="wider"
|
|
114
|
+
snap={true}
|
|
115
|
+
class="block-snap-widths-demo even skip-wide"
|
|
116
|
+
>
|
|
117
|
+
wider.skip-wide
|
|
118
|
+
</Block>
|
|
119
|
+
</div>
|
|
120
|
+
</Article>
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Documentation
|
|
124
|
+
|
|
125
|
+
# Block
|
|
126
|
+
|
|
127
|
+
The `Block` component is the basic building block of pages, a responsive container that wraps around each section of your piece.
|
|
128
|
+
|
|
129
|
+
Blocks are stacked vertically within the well created by the [Article](./?path=/docs/components-page-layout-article--docs) component. They can have different widths on larger screens depending on the `width` prop.
|
|
130
|
+
|
|
131
|
+
> 📌 Many of our other components already use the `Block` component internally. You'll usually only need to use it yourself if you're making something custom.
|
|
132
|
+
|
|
133
|
+
```svelte
|
|
134
|
+
<script>
|
|
135
|
+
import { Block } from '@reuters-graphics/graphics-components';
|
|
136
|
+
</script>
|
|
137
|
+
|
|
138
|
+
<Block>
|
|
139
|
+
<!-- Contents for this block goes here -->
|
|
140
|
+
</Block>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Custom layouts
|
|
144
|
+
|
|
145
|
+
Our article well is designed to provide a basic responsive layout for you, but it also lets you customise.
|
|
146
|
+
|
|
147
|
+
The radical but easiest way to do this is to create a `Block` with a `fluid` width -- which basically cancels out the article well dimensions -- and then code whatever you need from scratch or with another framework.
|
|
148
|
+
|
|
149
|
+
The demo below does exactly that to create an edge-to-edge grid with [flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/).
|
|
150
|
+
|
|
151
|
+
```svelte
|
|
152
|
+
<Block width="fluid">
|
|
153
|
+
<div class="my-radical-container">
|
|
154
|
+
<!-- Now, you have full control over layout! -->
|
|
155
|
+
</div>
|
|
156
|
+
</Block>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Snap widths
|
|
160
|
+
|
|
161
|
+
Normally, `Block` containers resize fluidly below the original `width`. Sometimes, though, you may want the container to snap to the next breakpoint -- for example, if you have a static graphic that looks fine at the set block breakpoints, but isn't so great at widths inbetween.
|
|
162
|
+
|
|
163
|
+
You can use the `snap` prop to force the container to snap to each block width successively as the window sizes down.
|
|
164
|
+
|
|
165
|
+
```svelte
|
|
166
|
+
<Block width="wider" snap={true}>
|
|
167
|
+
<!-- Contents for this block -->
|
|
168
|
+
</Block>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
If you want to skip certain block widths entirely, you can add one or more class of `skip-{block width class}` to the `Block`.
|
|
172
|
+
|
|
173
|
+
> **NOTE:** The snap width breakpoints only work on `Block` components with widths `wider` and below. `widest` and `fluid` are both **always** fluid, since they go edge-to-edge.
|
|
174
|
+
|
|
175
|
+
```svelte
|
|
176
|
+
<!-- Will skip wide and go straight to normal column width on resize. -->
|
|
177
|
+
<Block width="wider" snap={true} class="skip-wide">
|
|
178
|
+
<!-- Contents for this block -->
|
|
179
|
+
</Block>
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
This is probably easier to see in action than explain in words, so [resize the demo](./?path=/docs/components-page-layout-block--snap-skip-widths) to get a better picture of how it all works.
|
|
183
|
+
|
|
184
|
+
## Using with custom column widths
|
|
185
|
+
|
|
186
|
+
Snap width breakpoints are hard-coded to the default article well column widths, so if you set custom `columnWidths` on the [Article](./?path=/docs/components-page-layout-article--docs) component (**rare!**), you need to do a littie work to use this functionality.
|
|
187
|
+
|
|
188
|
+
Luckily, it's still pretty easy. Just add a `cls` or `id` to your `Block` so you can target it with some custom SCSS. Then define a few SCSS variables corresponding to your custom column widths, and use the `block-snap-widths` SCSS mixin to get the same functionality at your custom breakpoints.
|
|
189
|
+
|
|
190
|
+
```svelte
|
|
191
|
+
<Block width="wider" snap={true} class="custom-blocks">
|
|
192
|
+
<!-- Contents for this block -->
|
|
193
|
+
</Block>
|
|
194
|
+
|
|
195
|
+
<style lang="scss">
|
|
196
|
+
// Define custom column widths
|
|
197
|
+
$column-width-narrower: 310px;
|
|
198
|
+
$column-width-narrow: 450px;
|
|
199
|
+
$column-width-normal: 600px;
|
|
200
|
+
$column-width-wide: 860px;
|
|
201
|
+
$column-width-wider: 1400px;
|
|
202
|
+
|
|
203
|
+
@use '@reuters-graphics/graphics-components/scss/mixins' as mixins;
|
|
204
|
+
|
|
205
|
+
:global {
|
|
206
|
+
div.custom-blocks {
|
|
207
|
+
@include mixins.block-snap-widths; // Use the `block-snap-widths` mixin
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
</style>
|
|
211
|
+
```
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# BlogPost
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Blog/BlogPost
|
|
4
|
+
|
|
5
|
+
**Import:** `import { BlogPost } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `title` | `string` | `'Reuters Graphics blog post'` | | Title of the blog post |
|
|
12
|
+
| `slugTitle` | `string` | `'Reuters Graphics blog post'` | | A sluggable title of the blog post. **Important:** Do not change this title after publishing the post. Changes will break published links to the post. |
|
|
13
|
+
| `authors` | `string[]` | `[]` | | Array of author names, which will be slugified to create links to Reuters author pages |
|
|
14
|
+
| `publishTime` | `string` | `''` | | Publish time as a datetime string. |
|
|
15
|
+
| `updateTime` | `string` | `''` | | Update time as a datetime string. |
|
|
16
|
+
| `id` | `string` | `''` | | Add an id to target post headline with custom CSS. |
|
|
17
|
+
| `cls` | `string` | `''` | | Add extra classes to target post headline with custom CSS. |
|
|
18
|
+
| `isLastPost` | `boolean` | `false` | | If the post is the last on the page, remove the dividing rule used to separate posts. |
|
|
19
|
+
| `children` | `import('svelte').Snippet` | — | | — |
|
|
20
|
+
|
|
21
|
+
## Examples
|
|
22
|
+
|
|
23
|
+
### Demo
|
|
24
|
+
|
|
25
|
+
```svelte
|
|
26
|
+
<BlogPost
|
|
27
|
+
title="Iran fires ballistic missiles at Israel in major escalation"
|
|
28
|
+
slugTitle="Iran fires ballistic missiles at Israel in major escalation"
|
|
29
|
+
authors={['John Smith', 'Jane Doe']}
|
|
30
|
+
publishTime="2024-10-01T18:30:00Z"
|
|
31
|
+
updateTime="2024-10-01T21:45:00Z"
|
|
32
|
+
>
|
|
33
|
+
<BodyText
|
|
34
|
+
text="Iran launched a barrage of ballistic missiles at Israel on Tuesday in its first direct attack on Israeli territory, marking a significant escalation in the conflict gripping the Middle East."
|
|
35
|
+
/>
|
|
36
|
+
<BodyText
|
|
37
|
+
text="The attack, which Iran said was in retaliation for Israeli strikes that killed senior Hezbollah and Hamas leaders, prompted Israel and the United States to vow a response."
|
|
38
|
+
/>
|
|
39
|
+
</BlogPost>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
# BlogPost
|
|
45
|
+
|
|
46
|
+
The `BlogPost` component renders a single entry in a graphics blog page, including a headline, dateline, authors and a divider. Body content is passed as children.
|
|
47
|
+
|
|
48
|
+
```svelte
|
|
49
|
+
<script>
|
|
50
|
+
import { BlogPost } from '@reuters-graphics/graphics-components';
|
|
51
|
+
import { resolve } from '$app/paths';
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<BlogPost
|
|
55
|
+
title="Iran fires ballistic missiles at Israel in major escalation"
|
|
56
|
+
slugTitle="Iran fires ballistic missiles at Israel in major escalation"
|
|
57
|
+
authors={['John Smith', 'Jane Doe']}
|
|
58
|
+
publishTime="2024-10-01T18:30:00Z"
|
|
59
|
+
updateTime="2024-10-01T21:45:00Z"
|
|
60
|
+
{resolve}
|
|
61
|
+
>
|
|
62
|
+
<!-- Post body content goes here -->
|
|
63
|
+
</BlogPost>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
> **Important:** Do not change `slugTitle` after publishing. It is used to generate the post's anchor link — changing it will break any published links to the post.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# BlogTOC
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Blog/BlogTOC
|
|
4
|
+
|
|
5
|
+
**Import:** `import { BlogTOC } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `posts` | `Post[]` | — | ✓ | — |
|
|
12
|
+
| `label` | `string` | `'Show all articles'` | | The label for the table of contents toggle button. |
|
|
13
|
+
| `maxHeight` | `number` | `300` | | The maximum height of the table of contents list in pixels. |
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Demo
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<Headline
|
|
21
|
+
section="Graphics"
|
|
22
|
+
hed="Maps of the Iran crisis"
|
|
23
|
+
hedSize="big"
|
|
24
|
+
width="normal"
|
|
25
|
+
class="mb-2"
|
|
26
|
+
/>
|
|
27
|
+
|
|
28
|
+
<ClockWall
|
|
29
|
+
cities={[
|
|
30
|
+
{ name: 'Tehran', tzIdentifier: 'Asia/Tehran' },
|
|
31
|
+
{ name: 'Tel Aviv', tzIdentifier: 'Asia/Tel_Aviv' },
|
|
32
|
+
{ name: 'Washington D.C.', tzIdentifier: 'America/New_York' },
|
|
33
|
+
]}
|
|
34
|
+
/>
|
|
35
|
+
|
|
36
|
+
<BlogTOC {posts} />
|
|
37
|
+
|
|
38
|
+
<BlogPost
|
|
39
|
+
title="Iran fires ballistic missiles at Israel in major escalation"
|
|
40
|
+
slugTitle="Iran fires ballistic missiles at Israel in major escalation"
|
|
41
|
+
authors={['John Smith', 'Jane Doe']}
|
|
42
|
+
publishTime="2024-10-01T18:30:00Z"
|
|
43
|
+
updateTime="2024-10-01T21:45:00Z"
|
|
44
|
+
>
|
|
45
|
+
<BodyText
|
|
46
|
+
text="Iran launched a barrage of ballistic missiles at Israel on Tuesday in its first direct attack on Israeli territory, marking a significant escalation in the conflict gripping the Middle East."
|
|
47
|
+
/>
|
|
48
|
+
<BodyText
|
|
49
|
+
text="The attack, which Iran said was in retaliation for Israeli strikes that killed senior Hezbollah and Hamas leaders, prompted Israel and the United States to vow a response."
|
|
50
|
+
/>
|
|
51
|
+
</BlogPost>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Documentation
|
|
55
|
+
|
|
56
|
+
# BlogTOC
|
|
57
|
+
|
|
58
|
+
The `BlogTOC` component renders a collapsible table of contents for a graphics blog page, listing all posts sorted chronologically. It only renders when there are two or more posts.
|
|
59
|
+
|
|
60
|
+
```svelte
|
|
61
|
+
<script>
|
|
62
|
+
import { BlogTOC } from '@reuters-graphics/graphics-components';
|
|
63
|
+
import { resolve } from '$app/paths';
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<BlogTOC
|
|
67
|
+
posts={[
|
|
68
|
+
{
|
|
69
|
+
title: 'Iran fires ballistic missiles at Israel',
|
|
70
|
+
slugTitle: 'Iran fires ballistic missiles at Israel',
|
|
71
|
+
publishTime: '2024-10-01T18:30:00Z',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
title: 'Israel vows response',
|
|
75
|
+
slugTitle: 'Israel vows response',
|
|
76
|
+
publishTime: '2024-10-02T09:15:00Z',
|
|
77
|
+
},
|
|
78
|
+
]}
|
|
79
|
+
{resolve}
|
|
80
|
+
/>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Pass SvelteKit's `resolve` function (from `$app/paths`) so that post links resolve correctly against your project's base path.
|
|
84
|
+
|
|
85
|
+
Each post in the `posts` array must have:
|
|
86
|
+
|
|
87
|
+
- `title` — the display title
|
|
88
|
+
- `slugTitle` — used to generate the anchor link; **do not change after publishing**
|
|
89
|
+
- `publishTime` — an ISO datetime string used for sorting and the dateline
|