@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,254 @@
|
|
|
1
|
+
# Video
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Multimedia/Video
|
|
4
|
+
|
|
5
|
+
**Import:** `import { Video } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `src` | `string` | — | ✓ | Video source |
|
|
12
|
+
| `poster` | `string` | `''` | | Image to be shown while the video is downloading |
|
|
13
|
+
| `ariaDescription` | `string` | — | ✓ | ARIA description, passed in as a markdown string. |
|
|
14
|
+
| `class` | `string` | `''` | | Add extra classes to the block tag to target it with custom CSS. |
|
|
15
|
+
| `title` | `string` | — | | Title of the graphic |
|
|
16
|
+
| `notes` | `string \| Snippet` | — | | Notes to the graphic, passed in as a markdown string OR a custom snippet. |
|
|
17
|
+
| `description` | `string` | — | | Description of the graphic, passed in as a markdown string. |
|
|
18
|
+
| `width` | `ContainerWidth` | `'normal'` | | Width of the block within the article well. |
|
|
19
|
+
| `textWidth` | `ContainerWidth` | `'normal'` | | Set a different width for the text within the text well, for example, "normal" to keep the title, description and notes inline with the rest of the text well. Can't ever be wider than `width`. |
|
|
20
|
+
| `preloadVideo` | `'auto' \| 'none' \| 'metadata'` | `'auto'` | | Preload options. `auto` is ignored if `autoplay` is true. Can also be `none` or `metadata`. |
|
|
21
|
+
| `loopVideo` | `boolean` | `false` | | Whether the video should loop. |
|
|
22
|
+
| `muteVideo` | `boolean` | `true` | | Whether video should have sound or not. |
|
|
23
|
+
| `soundAutoplay` | `boolean` | `false` | | If `true`, this allow videos with sound to autoplay if the user has previously interacted with DOM |
|
|
24
|
+
| `playVideoWhenInView` | `boolean` | `true` | | Whether the video should play when it comes into view or just on page load |
|
|
25
|
+
| `playVideoThreshold` | `number` | `0.5` | | Controls how much of the video should be visible when it starts playing. This is a number between 0 and 1, where 0 means the video will start playing as soon as its top enters the viewport, and 1 means it will start when the whole video is in the viewport. |
|
|
26
|
+
| `possibleToPlayPause` | `boolean` | `true` | | Whether to have the option to pause and play video |
|
|
27
|
+
| `showControls` | `boolean` | `true` | | Whether to show the play / pause buttons |
|
|
28
|
+
| `separateReplayIcon` | `boolean` | `false` | | Whether to use a separate replay icon or use the play icon for replay as well |
|
|
29
|
+
| `controlsColour` | `string` | `'#333'` | | Change the colour of the play/pause button |
|
|
30
|
+
| `controlsOpacityMin` | `number` | `0` | | Change the minimum opacity of the play/pause button, which you see on mouseover. Must be between 0 and 1. |
|
|
31
|
+
| `controlsOpacityMax` | `number` | `0.7` | | Change the maximum opacity of the play/pause button, which you see on mouseout. Must be between 0 and 1. |
|
|
32
|
+
| `controlsPosition` | `ControlsPosition` | `'top left'` | | Have four options for controls position - top right, top left, bottom right, bottom left |
|
|
33
|
+
| `controlsBorderOffset` | `number` | `10` | | Offset for the controls from the border |
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Demo
|
|
38
|
+
|
|
39
|
+
```svelte
|
|
40
|
+
<Video
|
|
41
|
+
ariaDescription="Required description of your video for screen readers."
|
|
42
|
+
src={/* SilentVideo */}
|
|
43
|
+
width="wide"
|
|
44
|
+
notes="Optional caption for your video."
|
|
45
|
+
/>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Autoplay controls
|
|
49
|
+
|
|
50
|
+
```svelte
|
|
51
|
+
<Video
|
|
52
|
+
ariaDescription="Required description of your video for screen readers."
|
|
53
|
+
src={/* SilentVideo */}
|
|
54
|
+
loopVideo={true}
|
|
55
|
+
notes="World's longest glass bridge opens to public in Vietnam. (c) 2022 Thomson Reuters"
|
|
56
|
+
playVideoThreshold={0.9}
|
|
57
|
+
/>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Audio controls
|
|
61
|
+
|
|
62
|
+
```svelte
|
|
63
|
+
<Video
|
|
64
|
+
ariaDescription="Required description of your video for screen readers."
|
|
65
|
+
src={/* SoundVideo */}
|
|
66
|
+
notes="World's longest glass bridge opens to public in Vietnam. (c) 2022 Thomson Reuters"
|
|
67
|
+
controlsColour="#152a1c"
|
|
68
|
+
controlsOpacityMax={1}
|
|
69
|
+
controlsOpacityMin={0.5}
|
|
70
|
+
playVideoThreshold={0.9}
|
|
71
|
+
muteVideo={false}
|
|
72
|
+
soundAutoplay={true}
|
|
73
|
+
/>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Controls
|
|
77
|
+
|
|
78
|
+
```svelte
|
|
79
|
+
<Video
|
|
80
|
+
ariaDescription="Required description of your video for screen readers."
|
|
81
|
+
src={/* SilentVideo */}
|
|
82
|
+
width="normal"
|
|
83
|
+
notes="World's longest glass bridge opens to public in Vietnam. (c) 2022 Thomson Reuters"
|
|
84
|
+
playVideoThreshold={0.9}
|
|
85
|
+
controlsColour="white"
|
|
86
|
+
controlsOpacityMax={1}
|
|
87
|
+
controlsOpacityMin={0.5}
|
|
88
|
+
controlsPosition="bottom right"
|
|
89
|
+
separateReplayIcon={true}
|
|
90
|
+
loopVideo={false}
|
|
91
|
+
soundAutoplay={true}
|
|
92
|
+
/>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Text elements
|
|
96
|
+
|
|
97
|
+
```svelte
|
|
98
|
+
<Video
|
|
99
|
+
src={SilentVideo}
|
|
100
|
+
ariaDescription="Required description of your video for screen readers."
|
|
101
|
+
title="Title for your video"
|
|
102
|
+
description="Description for your video"
|
|
103
|
+
>
|
|
104
|
+
{#snippet notes()}
|
|
105
|
+
<aside>
|
|
106
|
+
<p class="notes">Custom-styled notes for the video.</p>
|
|
107
|
+
</aside>
|
|
108
|
+
{/snippet}
|
|
109
|
+
</Video>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Documentation
|
|
113
|
+
|
|
114
|
+
# Video
|
|
115
|
+
|
|
116
|
+
The `Video` component adds a video with various controls to your page such as:
|
|
117
|
+
|
|
118
|
+
- Play/pause button
|
|
119
|
+
- Autoplay controls, i.e. whether the video plays when it comes into view or on page load
|
|
120
|
+
- Looping
|
|
121
|
+
- Audio controls
|
|
122
|
+
- Text elements such as notes and titles
|
|
123
|
+
|
|
124
|
+
```svelte
|
|
125
|
+
<script>
|
|
126
|
+
import { Video } from '@reuters-graphics/graphics-components';
|
|
127
|
+
</script>
|
|
128
|
+
|
|
129
|
+
<Video
|
|
130
|
+
ariaDescription="Required description of your video for screen readers."
|
|
131
|
+
src="my-video.mp4"
|
|
132
|
+
width="wide"
|
|
133
|
+
notes="Optional caption for your video."
|
|
134
|
+
/>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Using with ArchieML docs
|
|
138
|
+
|
|
139
|
+
With the graphics kit, you'll likely get your text value from an ArchieML doc...
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
# ArchieML doc
|
|
143
|
+
[blocks]
|
|
144
|
+
type: video
|
|
145
|
+
src: videos/my-video.mp4
|
|
146
|
+
width: wide
|
|
147
|
+
ariaDescription: Required description of your video for screen readers.
|
|
148
|
+
notes: Optional caption for your video.
|
|
149
|
+
loopVideo: true
|
|
150
|
+
[]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
... which you'll parse out of a ArchieML block object before passing to the `Video` component.
|
|
154
|
+
|
|
155
|
+
```svelte
|
|
156
|
+
<!-- App.svelte -->
|
|
157
|
+
<script>
|
|
158
|
+
import { Video } from '@reuters-graphics/graphics-components';
|
|
159
|
+
import { asset } from '$app/paths'; // 👈 If using in the graphics kit...
|
|
160
|
+
import { truthy } from '$utils/propValidators'; // 👈 If using in the graphics kit...
|
|
161
|
+
</script>
|
|
162
|
+
|
|
163
|
+
{#each content.blocks as block}
|
|
164
|
+
{#if block.type === 'video'}
|
|
165
|
+
<Video
|
|
166
|
+
ariaDescription={block.ariaDescription}
|
|
167
|
+
src={asset(`/${block.src}`)}
|
|
168
|
+
width={block.width}
|
|
169
|
+
loopVideo={truthy(block.loopVideo)}
|
|
170
|
+
notes={block.notes}
|
|
171
|
+
/>
|
|
172
|
+
{/if}
|
|
173
|
+
{/each}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
> **Note:** Some props, like `loopVideo`, expect boolean values. If you're using the graphics kit, you can use the `truthy()` util function to convert a string value to a boolean.
|
|
177
|
+
|
|
178
|
+
## Autoplay controls
|
|
179
|
+
|
|
180
|
+
By default, the video starts playing when 50% (0.5) of the video element's height comes into view. Adjust this with `playVideoThreshold`, which is a value between 0 and 1, where 0 means the video will start playing as soon as its top enters the viewport, and 1 means it will start when the whole video is in the viewport.
|
|
181
|
+
|
|
182
|
+
To make the video play on page load regardless of whether it is in view, set the prop `playVideoWhenInView` to `false`.
|
|
183
|
+
|
|
184
|
+
```svelte
|
|
185
|
+
<script>
|
|
186
|
+
import { Video } from '@reuters-graphics/graphics-components';
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<Video
|
|
190
|
+
ariaDescription="Required description of your video for screen readers."
|
|
191
|
+
src="https://..."
|
|
192
|
+
loopVideo={true}
|
|
193
|
+
playVideoThreshold={0.9}
|
|
194
|
+
notes="World's longest glass bridge opens to public in Vietnam. (c) 2022 Thomson Reuters"
|
|
195
|
+
/>
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Audio controls
|
|
199
|
+
|
|
200
|
+
On most browsers, [autoplaying videos with sound](https://developer.chrome.com/blog/autoplay#:~:text=Muted%20autoplay%20is%20always%20allowed,to%20allow%20autoplay%20with%20sound.) is allowed only if the user has interacted with the page. (Autoplay is allowed with muted videos.)
|
|
201
|
+
|
|
202
|
+
By default, this component will not autoplay videos with sound. To change this, set `soundAutoplay` to `true`. This will allow the video to autoplay with sound when it comes into view, but only if the user has already interacted with the page by clicking or tapping on it.
|
|
203
|
+
|
|
204
|
+
Test this with the example below: the video will autoplay when it comes into view _only if_ you have clicked or tapped on the page before scrolling down to it.
|
|
205
|
+
|
|
206
|
+
```svelte
|
|
207
|
+
<script>
|
|
208
|
+
import { Video } from '@reuters-graphics/graphics-components';
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
<Video
|
|
212
|
+
ariaDescription="Required description of your video for screen readers."
|
|
213
|
+
src="https://..."
|
|
214
|
+
controlsColour="#152a1c"
|
|
215
|
+
controlsOpacityMax={1}
|
|
216
|
+
controlsOpacityMin={0.5}
|
|
217
|
+
muteVideo={false}
|
|
218
|
+
soundAutoplay={true}
|
|
219
|
+
/>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Adding text
|
|
223
|
+
|
|
224
|
+
The `Video` component allows you to add a title, description and notes to your video, which are rendered by the `GraphicBlock` component.
|
|
225
|
+
|
|
226
|
+
Customise the `notes` section by passing a [snippet](https://svelte.dev/docs/svelte/snippet) instead of a string.
|
|
227
|
+
|
|
228
|
+
```svelte
|
|
229
|
+
<script>
|
|
230
|
+
import { Video } from '@reuters-graphics/graphics-components';
|
|
231
|
+
</script>
|
|
232
|
+
|
|
233
|
+
<Video
|
|
234
|
+
src="https://..."
|
|
235
|
+
ariaDescription="Required description of your video for screen readers."
|
|
236
|
+
title="Title for your video"
|
|
237
|
+
description="Description for your video"
|
|
238
|
+
>
|
|
239
|
+
<!-- Custom notes snippet -->
|
|
240
|
+
{#snippet notes()}
|
|
241
|
+
<aside>
|
|
242
|
+
<p class="notes">Custom-styled notes for the video.</p>
|
|
243
|
+
</aside>
|
|
244
|
+
{/snippet}
|
|
245
|
+
</Video>
|
|
246
|
+
|
|
247
|
+
<style lang="scss">
|
|
248
|
+
@use '@reuters-graphics/graphics-components/dist/scss/mixins' as mixins;
|
|
249
|
+
|
|
250
|
+
p.notes {
|
|
251
|
+
@include mixins.body-note;
|
|
252
|
+
}
|
|
253
|
+
</style>
|
|
254
|
+
```
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Visible
|
|
2
|
+
|
|
3
|
+
**Category:** Components/Utilities/Visible
|
|
4
|
+
|
|
5
|
+
**Import:** `import { Visible } from '@reuters-graphics/graphics-components'`
|
|
6
|
+
|
|
7
|
+
## Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Required | Description |
|
|
10
|
+
|------|------|---------|:--------:|-------------|
|
|
11
|
+
| `once` | `boolean` | `false` | | Whether to change visibility just once. Useful for loading expensive images or other media and then keeping them around once they're first loaded. |
|
|
12
|
+
| `top` | `string` | `'0px'` | | Set Intersection Observer [rootMargin](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#rootmargin) `top` with units. Units must be `px` or other [absolute lengths units](https://arc.net/l/quote/jkukcxqq), or `%`. |
|
|
13
|
+
| `bottom` | `string` | `'0px'` | | Set Intersection Observer [rootMargin](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#rootmargin) `bottom` with units. Units must be `px` or other [absolute lengths units](https://arc.net/l/quote/jkukcxqq), or `%`. |
|
|
14
|
+
| `left` | `string` | `'0px'` | | Set Intersection Observer [rootMargin](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#rootmargin) `left` with units. Units must be `px` or other [absolute lengths units](https://arc.net/l/quote/jkukcxqq), or `%`. |
|
|
15
|
+
| `right` | `string` | `'0px'` | | Set Intersection Observer [rootMargin](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#rootmargin) `right` with units. Units must be `px` or other [absolute lengths units](https://arc.net/l/quote/jkukcxqq), or `%`. |
|
|
16
|
+
| `threshold` | `number` | `0` | | Set the Intersection Observer [threshold](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API#threshold). |
|
|
17
|
+
| `children` | `Snippet<[boolean]>` | — | | — |
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
### Demo
|
|
22
|
+
|
|
23
|
+
```svelte
|
|
24
|
+
<VisibleDemo />
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Documentation
|
|
28
|
+
|
|
29
|
+
# Visible
|
|
30
|
+
|
|
31
|
+
The `Visible` component wraps around other components or HTML elements and uses the [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) to determine if they are visible on the page.
|
|
32
|
+
|
|
33
|
+
This is useful for lazy loading elements, especially expensive media files or components that fetch lots of data. You can also use it trigger animations or play media once a reader scrolls a component into view.
|
|
34
|
+
|
|
35
|
+
By default, `visible` will switch between `false` and `true` whenever the element is in our out of view. To trigger this just once, set the prop `once` to `true`. This is useful for loading expensive media when they first come into view and then keeping them around once they're loaded.
|
|
36
|
+
|
|
37
|
+
> **Note:** Don't use this for content that's "above the fold" at the top of the page. That'll just slow down the first load of important visible content.
|
|
38
|
+
|
|
39
|
+
```svelte
|
|
40
|
+
<script>
|
|
41
|
+
import { Visible } from '@reuters-graphics/graphics-components';
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<!-- Optionally set your own `top`, `bottom`, `right` and `left` values with `px` or `%` units -->
|
|
45
|
+
<Visible top="10px">
|
|
46
|
+
{#snippet children(visible)}
|
|
47
|
+
{#if visible}
|
|
48
|
+
<p>Visible!</p>
|
|
49
|
+
{:else}
|
|
50
|
+
<p>Not yet visible.</p>
|
|
51
|
+
{/if}
|
|
52
|
+
{/snippet}
|
|
53
|
+
</Visible>
|
|
54
|
+
```
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# cssVariables
|
|
2
|
+
|
|
3
|
+
**Import:** `import { cssVariables } from '@reuters-graphics/graphics-components'`
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
# `cssVariables`
|
|
8
|
+
|
|
9
|
+
An action you can use to easily set [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) on HTML elements. Useful for passing JavaScript values to your component SCSS like this:
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script>
|
|
13
|
+
import { cssVariables } from '@reuters-graphics/graphics-components';
|
|
14
|
+
|
|
15
|
+
let { height = 300, textColour = 'red' } = $props();
|
|
16
|
+
|
|
17
|
+
// Create an object of variable names and CSS values...
|
|
18
|
+
let variables = $derived({
|
|
19
|
+
height: height + 'px',
|
|
20
|
+
textColour: textColour,
|
|
21
|
+
});
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<!-- Attach it to a parent element with the action -->
|
|
25
|
+
<div use:cssVariables={variables}>
|
|
26
|
+
<p>My text...</p>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<style lang="scss">
|
|
30
|
+
/**
|
|
31
|
+
* Now use your variables in your SCSS!
|
|
32
|
+
*/
|
|
33
|
+
div {
|
|
34
|
+
height: var(--height);
|
|
35
|
+
p {
|
|
36
|
+
color: var(--textColour);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
40
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Components
|
|
2
|
+
|
|
3
|
+
Per-component reference with props tables, type definitions, and usage examples.
|
|
4
|
+
|
|
5
|
+
| Component | Category | Description |
|
|
6
|
+
|-----------|----------|-------------|
|
|
7
|
+
| [AdSlot](./AdSlot.md) | | — |
|
|
8
|
+
| [Analytics](./Analytics.md) | Components/Ads & analytics/Analytics | — |
|
|
9
|
+
| [Article](./Article.md) | Components/Page layout/Article | — |
|
|
10
|
+
| [BeforeAfter](./BeforeAfter.md) | Components/Multimedia/BeforeAfter | — |
|
|
11
|
+
| [BioBox](./BioBox.md) | Components/Page furniture/BioBox | BioBox shows one or more author biographies in a bordered box, echoing the contributor box on Reuters.com stories. |
|
|
12
|
+
| [Block](./Block.md) | Components/Page layout/Block | — |
|
|
13
|
+
| [BlogPost](./BlogPost.md) | Components/Blog/BlogPost | — |
|
|
14
|
+
| [BlogTOC](./BlogTOC.md) | Components/Blog/BlogTOC | — |
|
|
15
|
+
| [BodyText](./BodyText.md) | Components/Text elements/BodyText | — |
|
|
16
|
+
| [Byline](./Byline.md) | Components/Text elements/Byline | — |
|
|
17
|
+
| [ClockWall](./ClockWall.md) | Components/Blog/ClockWall | — |
|
|
18
|
+
| [cssVariables](./cssVariables.md) | | — |
|
|
19
|
+
| [DatawrapperChart](./DatawrapperChart.md) | Components/Graphics/DatawrapperChart | — |
|
|
20
|
+
| [DocumentCloud](./DocumentCloud.md) | Components/Multimedia/DocumentCloud | — |
|
|
21
|
+
| [EmbedPreviewerLink](./EmbedPreviewerLink.md) | Components/Utilities/EmbedPreviewerLink | — |
|
|
22
|
+
| [EndNotes](./EndNotes.md) | Components/Text elements/EndNotes | — |
|
|
23
|
+
| [FeaturePhoto](./FeaturePhoto.md) | Components/Multimedia/FeaturePhoto | — |
|
|
24
|
+
| [Framer](./Framer.md) | Components/Utilities/Framer | — |
|
|
25
|
+
| [Geocoder](./Geocoder.md) | Components/Controls/Geocoder | — |
|
|
26
|
+
| [GraphicBlock](./GraphicBlock.md) | Components/Graphics/GraphicBlock | — |
|
|
27
|
+
| [Headline](./Headline.md) | Components/Text elements/Headline | — |
|
|
28
|
+
| [Headpile](./Headpile.md) | Components/Text elements/Headpile | — |
|
|
29
|
+
| [HeroHeadline](./HeroHeadline.md) | Components/Text elements/HeroHeadline | — |
|
|
30
|
+
| [HorizontalScroller](./HorizontalScroller.md) | Components/Graphics/HorizontalScroller | — |
|
|
31
|
+
| [InfoBox](./InfoBox.md) | Components/Text elements/InfoBox | — |
|
|
32
|
+
| [KinesisLogo](./KinesisLogo.md) | Components/Logos/KinesisLogo | — |
|
|
33
|
+
| [LanguageButton](./LanguageButton.md) | Components/Text elements/LanguageButton | — |
|
|
34
|
+
| [Legend](./Legend.md) | Components/Graphics/Legend | Quantitative and categorical legend for maps and data displays. Renders one of five legend types: - threshold: discrete bins with color swatches - continuous: a continuous gradient with ticks - diverging: threshold bins with a highlighted midpoint - categorical: square swatches with labels in a horizontal row - proportional-symbols: nested circles with leader lines and labels The component is presentational and can be placed anywhere in page layout. The optional noData prop renders a separate fallback swatch for missing, unknown, or unavailable values across all legend modes. |
|
|
35
|
+
| [Lottie](./Lottie.md) | Components/Multimedia/Lottie | — |
|
|
36
|
+
| [PaddingReset](./PaddingReset.md) | Components/Page layout/PaddingReset | — |
|
|
37
|
+
| [PhotoPack](./PhotoPack.md) | Components/Multimedia/PhotoPack | — |
|
|
38
|
+
| [PymChild](./PymChild.md) | Components/Utilities/PymChild | — |
|
|
39
|
+
| [ReferralBlock](./ReferralBlock.md) | Components/Page furniture/ReferralBlock | — |
|
|
40
|
+
| [resizeObserver](./resizeObserver.md) | | — |
|
|
41
|
+
| [ReutersGraphicsLogo](./ReutersGraphicsLogo.md) | Components/Logos/ReutersGraphicsLogo | — |
|
|
42
|
+
| [ReutersLogo](./ReutersLogo.md) | Components/Logos/ReutersLogo | — |
|
|
43
|
+
| [Scroller](./Scroller.md) | Components/Graphics/Scroller | — |
|
|
44
|
+
| [ScrollerBase](./ScrollerBase.md) | Components/Graphics/ScrollerBase | — |
|
|
45
|
+
| [ScrollerVideo](./ScrollerVideo.md) | Components/Graphics/ScrollerVideo | — |
|
|
46
|
+
| [SearchInput](./SearchInput.md) | Components/Controls/SearchInput | — |
|
|
47
|
+
| [SEO](./SEO.md) | Components/Ads & analytics/SEO | — |
|
|
48
|
+
| [ShareBar](./ShareBar.md) | Components/Page furniture/ShareBar | ShareBar shows a row of share buttons (X, Facebook, LinkedIn, Email, Copy link) and an optional "Purchase Licensing Rights" button, echoing the share toolbar on Reuters.com stories. |
|
|
49
|
+
| [SimpleTimeline](./SimpleTimeline.md) | Components/Text elements/SimpleTimeline | — |
|
|
50
|
+
| [SiteFooter](./SiteFooter.md) | Components/Page furniture/SiteFooter | — |
|
|
51
|
+
| [SiteHeader](./SiteHeader.md) | Components/Page furniture/SiteHeader | — |
|
|
52
|
+
| [SiteHeadline](./SiteHeadline.md) | Components/Text elements/SiteHeadline | — |
|
|
53
|
+
| [Spinner](./Spinner.md) | Components/Utilities/Spinner | — |
|
|
54
|
+
| [Table](./Table.md) | Components/Graphics/Table | — |
|
|
55
|
+
| [Theme](./Theme.md) | Components/Theming/Theme | — |
|
|
56
|
+
| [TileMap](./TileMap.md) | Components/Graphics/TileMap | — |
|
|
57
|
+
| [ToolsHeader](./ToolsHeader.md) | Components/Page furniture/ToolsHeader | — |
|
|
58
|
+
| [Video](./Video.md) | Components/Multimedia/Video | — |
|
|
59
|
+
| [Visible](./Visible.md) | Components/Utilities/Visible | — |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# resizeObserver
|
|
2
|
+
|
|
3
|
+
**Import:** `import { resizeObserver } from '@reuters-graphics/graphics-components'`
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
# `resizeObserver`
|
|
8
|
+
|
|
9
|
+
An action you can use to easily to check when a DOM element's dimensions change using the [Resize Observer API](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver). Use it like this:
|
|
10
|
+
|
|
11
|
+
```svelte
|
|
12
|
+
<script>
|
|
13
|
+
import { resizeObserver } from '@reuters-graphics/graphics-components';
|
|
14
|
+
|
|
15
|
+
let elementWidth = 0;
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<div use:resizeObserver={(element) => (elementWidth = element.clientWidth)}>
|
|
19
|
+
My width is: {elementWidth}
|
|
20
|
+
</div>
|
|
21
|
+
```
|