@reuters-graphics/graphics-components 3.9.0 → 3.10.1
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/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 +68 -0
- package/dist/llm-docs/components/BlogTOC.md +91 -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 +171 -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 +237 -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 +23 -3
|
@@ -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,68 @@
|
|
|
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
|
+
| `base` | `string` | `''` | | Base path prepended to the copied URL, e.g. "/graphics", usually gotten from base store in SvelteKit. |
|
|
14
|
+
| `authors` | `string[]` | `[]` | | Array of author names, which will be slugified to create links to Reuters author pages |
|
|
15
|
+
| `publishTime` | `string` | `''` | | Publish time as a datetime string. |
|
|
16
|
+
| `updateTime` | `string` | `''` | | Update time as a datetime string. |
|
|
17
|
+
| `id` | `string` | `''` | | Add an id to target post headline with custom CSS. |
|
|
18
|
+
| `cls` | `string` | `''` | | Add extra classes to target post headline with custom CSS. |
|
|
19
|
+
| `isLastPost` | `boolean` | `false` | | If the post is the last on the page, remove the dividing rule used to separate posts. |
|
|
20
|
+
| `children` | `import('svelte').Snippet` | — | | — |
|
|
21
|
+
|
|
22
|
+
## Examples
|
|
23
|
+
|
|
24
|
+
### Demo
|
|
25
|
+
|
|
26
|
+
```svelte
|
|
27
|
+
<BlogPost
|
|
28
|
+
title="Iran fires ballistic missiles at Israel in major escalation"
|
|
29
|
+
slugTitle="Iran fires ballistic missiles at Israel in major escalation"
|
|
30
|
+
authors={['John Smith', 'Jane Doe']}
|
|
31
|
+
publishTime="2024-10-01T18:30:00Z"
|
|
32
|
+
updateTime="2024-10-01T21:45:00Z"
|
|
33
|
+
base=""
|
|
34
|
+
>
|
|
35
|
+
<BodyText
|
|
36
|
+
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."
|
|
37
|
+
/>
|
|
38
|
+
<BodyText
|
|
39
|
+
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."
|
|
40
|
+
/>
|
|
41
|
+
</BlogPost>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Documentation
|
|
45
|
+
|
|
46
|
+
# BlogPost
|
|
47
|
+
|
|
48
|
+
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.
|
|
49
|
+
|
|
50
|
+
```svelte
|
|
51
|
+
<script>
|
|
52
|
+
import { BlogPost } from '@reuters-graphics/graphics-components';
|
|
53
|
+
import { base } from '$app/paths';
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<BlogPost
|
|
57
|
+
title="Iran fires ballistic missiles at Israel in major escalation"
|
|
58
|
+
slugTitle="Iran fires ballistic missiles at Israel in major escalation"
|
|
59
|
+
authors={['John Smith', 'Jane Doe']}
|
|
60
|
+
publishTime="2024-10-01T18:30:00Z"
|
|
61
|
+
updateTime="2024-10-01T21:45:00Z"
|
|
62
|
+
{base}
|
|
63
|
+
>
|
|
64
|
+
<!-- Post body content goes here -->
|
|
65
|
+
</BlogPost>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
> **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,91 @@
|
|
|
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
|
+
| `base` | `string` | `''` | | Base path prepended to post links, e.g. "/graphics". |
|
|
13
|
+
| `label` | `string` | `'Show all articles'` | | The label for the table of contents toggle button. |
|
|
14
|
+
| `maxHeight` | `number` | `300` | | The maximum height of the table of contents list in pixels. |
|
|
15
|
+
|
|
16
|
+
## Examples
|
|
17
|
+
|
|
18
|
+
### Demo
|
|
19
|
+
|
|
20
|
+
```svelte
|
|
21
|
+
<Headline
|
|
22
|
+
section="Graphics"
|
|
23
|
+
hed="Maps of the Iran crisis"
|
|
24
|
+
hedSize="big"
|
|
25
|
+
width="normal"
|
|
26
|
+
class="mb-2"
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
<ClockWall
|
|
30
|
+
cities={[
|
|
31
|
+
{ name: 'Tehran', tzIdentifier: 'Asia/Tehran' },
|
|
32
|
+
{ name: 'Tel Aviv', tzIdentifier: 'Asia/Tel_Aviv' },
|
|
33
|
+
{ name: 'Washington D.C.', tzIdentifier: 'America/New_York' },
|
|
34
|
+
]}
|
|
35
|
+
/>
|
|
36
|
+
|
|
37
|
+
<BlogTOC {posts} base="" />
|
|
38
|
+
|
|
39
|
+
<BlogPost
|
|
40
|
+
title="Iran fires ballistic missiles at Israel in major escalation"
|
|
41
|
+
slugTitle="Iran fires ballistic missiles at Israel in major escalation"
|
|
42
|
+
authors={['John Smith', 'Jane Doe']}
|
|
43
|
+
publishTime="2024-10-01T18:30:00Z"
|
|
44
|
+
updateTime="2024-10-01T21:45:00Z"
|
|
45
|
+
base=""
|
|
46
|
+
>
|
|
47
|
+
<BodyText
|
|
48
|
+
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."
|
|
49
|
+
/>
|
|
50
|
+
<BodyText
|
|
51
|
+
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."
|
|
52
|
+
/>
|
|
53
|
+
</BlogPost>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Documentation
|
|
57
|
+
|
|
58
|
+
# BlogTOC
|
|
59
|
+
|
|
60
|
+
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.
|
|
61
|
+
|
|
62
|
+
```svelte
|
|
63
|
+
<script>
|
|
64
|
+
import { BlogTOC } from '@reuters-graphics/graphics-components';
|
|
65
|
+
import { base } from '$app/paths';
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<BlogTOC
|
|
69
|
+
posts={[
|
|
70
|
+
{
|
|
71
|
+
title: 'Iran fires ballistic missiles at Israel',
|
|
72
|
+
slugTitle: 'Iran fires ballistic missiles at Israel',
|
|
73
|
+
publishTime: '2024-10-01T18:30:00Z',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: 'Israel vows response',
|
|
77
|
+
slugTitle: 'Israel vows response',
|
|
78
|
+
publishTime: '2024-10-02T09:15:00Z',
|
|
79
|
+
},
|
|
80
|
+
]}
|
|
81
|
+
{base}
|
|
82
|
+
/>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The `base` prop should be set to your SvelteKit `base` path (e.g. `"/graphics"`) so that post links resolve correctly.
|
|
86
|
+
|
|
87
|
+
Each post in the `posts` array must have:
|
|
88
|
+
|
|
89
|
+
- `title` — the display title
|
|
90
|
+
- `slugTitle` — used to generate the anchor link; **do not change after publishing**
|
|
91
|
+
- `publishTime` — an ISO datetime string used for sorting and the dateline
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# BodyText
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Text elements/BodyText
|
|
4
|
+
|
|
5
|
+
**Import:** `import { BodyText } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `text` | `string` | — | ✓ | A markdown text string. |
|
|
12
|
+
| `class` | `string` | `''` | | Add a class to target with SCSS. |
|
|
13
|
+
| `id` | `string` | `''` | | Add an id to the block tag to target it with custom CSS. |
|
|
14
|
+
|
|
15
|
+
## Examples
|
|
16
|
+
|
|
17
|
+
### Demo
|
|
18
|
+
|
|
19
|
+
```svelte
|
|
20
|
+
<BodyText text={/* value — see Props/Types for full type */} />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Typography sample
|
|
24
|
+
|
|
25
|
+
```svelte
|
|
26
|
+
<BodyText
|
|
27
|
+
class="body-text-typography-example-story"
|
|
28
|
+
text={/* value — see Props/Types for full type */}
|
|
29
|
+
/>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Custom styles
|
|
33
|
+
|
|
34
|
+
```svelte
|
|
35
|
+
<BodyText
|
|
36
|
+
class="body-text-custom-styles-story"
|
|
37
|
+
text="Venison shoulder <span class="highlight">ham hock</span> ham leberkas."
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Documentation
|
|
42
|
+
|
|
43
|
+
# BodyText
|
|
44
|
+
|
|
45
|
+
The `BodyText` component creates the main text of your page. You can pass the `text` prop a [markdown-formatted](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) string, which will be parsed into paragraphs, headers, lists, links, blockquotes and other markdown-supported elements.
|
|
46
|
+
|
|
47
|
+
```svelte
|
|
48
|
+
<script>
|
|
49
|
+
import { BodyText } from '@reuters-graphics/graphics-components';
|
|
50
|
+
|
|
51
|
+
const markdownText = `Bacon ipsum **dolor amet** cow tongue tri-tip.
|
|
52
|
+
|
|
53
|
+
Biltong turducken ground round kevin [hamburger turkey](https://reuters.com) pig.
|
|
54
|
+
|
|
55
|
+
- Steak
|
|
56
|
+
- [Pork chop](https://www.google.com)
|
|
57
|
+
- Fillet
|
|
58
|
+
|
|
59
|
+
Venison shoulder *ham hock ham leberkas*. Flank beef ribs fatback, jerky meatball ham hock.`;
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<BodyText text={markdownText} />
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Using with ArchieML docs
|
|
66
|
+
|
|
67
|
+
With the graphics kit, you'll likely get your text value from an ArchieML doc...
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
# ArchieML doc
|
|
71
|
+
[blocks]
|
|
72
|
+
|
|
73
|
+
type: text
|
|
74
|
+
text: Bacon ipsum ...
|
|
75
|
+
|
|
76
|
+
... etc.
|
|
77
|
+
:end
|
|
78
|
+
|
|
79
|
+
[]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
... which you'll parse out of a ArchieML block object before passing to the `BodyText` component.
|
|
83
|
+
|
|
84
|
+
```svelte
|
|
85
|
+
<!-- App.svelte -->
|
|
86
|
+
<script>
|
|
87
|
+
import { BodyText } from '@reuters-graphics/graphics-components';
|
|
88
|
+
import content from '$locales/en/content.json';
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
{#each content.blocks as block}
|
|
92
|
+
{#if block.type === 'text'}
|
|
93
|
+
<BodyText text={block.text} />
|
|
94
|
+
{/if}
|
|
95
|
+
{/each}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Styling text
|
|
99
|
+
|
|
100
|
+
Styles are built in for many text elements created by `BodyText`, including headings, ordered and unordered lists, links, blockquotes and even drop caps (using a `"drop-cap"` classed span).
|
|
101
|
+
|
|
102
|
+
```svelte
|
|
103
|
+
<BodyText
|
|
104
|
+
text="<span class='drop-cap'>R</span>eprehenderit hamburger pork bresaola ..."
|
|
105
|
+
/>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Custom styles
|
|
109
|
+
|
|
110
|
+
To add your own styling, you can write styles in a global SCSS stylesheet:
|
|
111
|
+
|
|
112
|
+
```svelte
|
|
113
|
+
<BodyText
|
|
114
|
+
text="Venison shoulder <span class='highlight'>ham hock</span> ham leberkas."
|
|
115
|
+
/>
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
```scss
|
|
119
|
+
// global.scss
|
|
120
|
+
span.highlight {
|
|
121
|
+
background: palegoldenrod;
|
|
122
|
+
padding: 2px 4px;
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
If you want to make sure styles for one portion of text don't apply other parts of the page, add a `class` to BodyText to use as an additional selector.
|
|
127
|
+
|
|
128
|
+
```svelte highlight=2
|
|
129
|
+
<BodyText
|
|
130
|
+
class="my-special-text-block"
|
|
131
|
+
text="Venison shoulder <span class='highlight'>ham hock</span> ham leberkas."
|
|
132
|
+
/>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```scss
|
|
136
|
+
// global.scss
|
|
137
|
+
.my-special-text-block {
|
|
138
|
+
span.highlight {
|
|
139
|
+
background: palegoldenrod;
|
|
140
|
+
padding: 2px 4px;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|