@reuters-graphics/graphics-components 1.0.17 → 1.0.18
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/@types/components/EndNotes/EndNotes.svelte.d.ts +2 -2
- package/dist/@types/components/Markdown/Markdown.svelte.d.ts +18 -0
- package/dist/@types/components/Markdown/stores.d.ts +24 -0
- package/dist/@types/index.d.ts +2 -0
- package/dist/components/BodyText/BodyText.svelte +3 -5
- package/dist/components/EndNotes/EndNotes.svelte +7 -3
- package/dist/components/GraphicBlock/GraphicBlock.svelte +4 -4
- package/dist/components/Headline/Headline.svelte +5 -3
- package/dist/components/InfoBox/InfoBox.svelte +10 -4
- package/dist/components/Markdown/Markdown.svelte +35 -0
- package/dist/components/Markdown/stores.js +25 -0
- package/dist/components/PhotoPack/PhotoPack.svelte +2 -2
- package/dist/components/Scroller/Embedded/Foreground.svelte +4 -4
- package/dist/components/Scroller/Foreground.svelte +4 -4
- package/dist/components/SimpleTimeline/SimpleTimeline.svelte +2 -2
- package/dist/index.js +2 -0
- package/package.json +3 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SvelteComponentTyped } from "svelte";
|
|
2
|
+
declare const __propDef: {
|
|
3
|
+
props: {
|
|
4
|
+
/** A Markdown formatted string */ source?: string;
|
|
5
|
+
/** Parse markdown inline, i.e., without wrapping it in paragraph tags */ parseInline?: boolean;
|
|
6
|
+
};
|
|
7
|
+
events: {
|
|
8
|
+
[evt: string]: CustomEvent<any>;
|
|
9
|
+
};
|
|
10
|
+
slots: {};
|
|
11
|
+
};
|
|
12
|
+
export type MarkdownProps = typeof __propDef.props;
|
|
13
|
+
export type MarkdownEvents = typeof __propDef.events;
|
|
14
|
+
export type MarkdownSlots = typeof __propDef.slots;
|
|
15
|
+
/** `Markdown` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-Markdown--default) */
|
|
16
|
+
export default class Markdown extends SvelteComponentTyped<MarkdownProps, MarkdownEvents, MarkdownSlots> {
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
|
2
|
+
/**
|
|
3
|
+
* Set to `false` in the browser to ensure Markdown content correctly updates
|
|
4
|
+
* when a SvelteKit app hyrates.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```javascript
|
|
8
|
+
* // +layout.js
|
|
9
|
+
* import { staticMarkdown } from '@reuters-graphics/graphics-components';
|
|
10
|
+
* import { building } from '$app/environment';
|
|
11
|
+
*
|
|
12
|
+
* export const load = async() => {
|
|
13
|
+
* // Set the store with the value of building.
|
|
14
|
+
* staticMarkdown.set(building);
|
|
15
|
+
*
|
|
16
|
+
* // Markdown using this content will correctly refresh when
|
|
17
|
+
* // a reader loads your page.
|
|
18
|
+
* const content = await fetchPageContent();
|
|
19
|
+
*
|
|
20
|
+
* return { content };
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare const staticMarkdown: import("svelte/store").Writable<boolean>;
|
package/dist/@types/index.d.ts
CHANGED
|
@@ -17,11 +17,13 @@ export { default as HeroHeadline } from "./components/HeroHeadline/Hero.svelte";
|
|
|
17
17
|
export { default as EndNotes } from "./components/EndNotes/EndNotes.svelte";
|
|
18
18
|
export { default as InfoBox } from "./components/InfoBox/InfoBox.svelte";
|
|
19
19
|
export { default as InlineAd } from "./components/AdSlot/InlineAd.svelte";
|
|
20
|
+
export { default as Markdown } from "./components/Markdown/Markdown.svelte";
|
|
20
21
|
export { default as PaddingReset } from "./components/PaddingReset/PaddingReset.svelte";
|
|
21
22
|
export { default as PhotoCarousel } from "./components/PhotoCarousel/PhotoCarousel.svelte";
|
|
22
23
|
export { default as PhotoPack } from "./components/PhotoPack/PhotoPack.svelte";
|
|
23
24
|
export { default as PymChild } from "./components/PymChild/PymChild.svelte";
|
|
24
25
|
export { pymChildStore } from "./components/PymChild/stores.js";
|
|
26
|
+
export { staticMarkdown } from "./components/Markdown/stores.js";
|
|
25
27
|
export { default as ReferralBlock } from "./components/ReferralBlock/ReferralBlock.svelte";
|
|
26
28
|
export { default as ReutersGraphicsLogo } from "./components/ReutersGraphicsLogo/ReutersGraphicsLogo.svelte";
|
|
27
29
|
export { default as ReutersLogo } from "./components/ReutersLogo/ReutersLogo.svelte";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<!-- @component `BodyText` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-bodytext--default) -->
|
|
2
|
-
<script
|
|
2
|
+
<script>import Markdown from '../Markdown/Markdown.svelte';
|
|
3
|
+
/**
|
|
3
4
|
* A markdown text string.
|
|
4
5
|
* @type {string}
|
|
5
6
|
* @required
|
|
@@ -10,12 +11,9 @@ let cls = '';
|
|
|
10
11
|
export { cls as class };
|
|
11
12
|
/** Add an id to the block tag to target it with custom CSS. */
|
|
12
13
|
export let id = '';
|
|
13
|
-
import { marked } from 'marked';
|
|
14
14
|
import Block from '../Block/Block.svelte';
|
|
15
15
|
</script>
|
|
16
16
|
|
|
17
17
|
<Block id="{id}" class="fmy-6 {cls}">
|
|
18
|
-
{
|
|
19
|
-
{@html marked.parse(text)}
|
|
20
|
-
{/if}
|
|
18
|
+
<Markdown source="{text}" />
|
|
21
19
|
</Block>
|
|
@@ -4,15 +4,19 @@
|
|
|
4
4
|
* @required
|
|
5
5
|
*/
|
|
6
6
|
export let notes = [];
|
|
7
|
-
import { marked } from 'marked';
|
|
8
7
|
import Block from '../Block/Block.svelte';
|
|
8
|
+
import Markdown from '../Markdown/Markdown.svelte';
|
|
9
9
|
</script>
|
|
10
10
|
|
|
11
11
|
<Block class="notes fmt-6 fmb-8">
|
|
12
12
|
{#if notes}
|
|
13
13
|
{#each notes as note}
|
|
14
|
-
<div class="note-title">
|
|
15
|
-
|
|
14
|
+
<div class="note-title">
|
|
15
|
+
<Markdown source="{note.title}" />
|
|
16
|
+
</div>
|
|
17
|
+
<div class="note-content">
|
|
18
|
+
<Markdown source="{note.text}" />
|
|
19
|
+
</div>
|
|
16
20
|
{/each}
|
|
17
21
|
{/if}
|
|
18
22
|
</Block>
|
|
@@ -58,7 +58,7 @@ import AriaHidden from './AriaHidden.svelte';
|
|
|
58
58
|
import TextBlock from './TextBlock.svelte';
|
|
59
59
|
import Block from '../Block/Block.svelte';
|
|
60
60
|
import PaddingReset from '../PaddingReset/PaddingReset.svelte';
|
|
61
|
-
import
|
|
61
|
+
import Markdown from '../Markdown/Markdown.svelte';
|
|
62
62
|
</script>
|
|
63
63
|
|
|
64
64
|
<Block
|
|
@@ -81,7 +81,7 @@ import { marked } from 'marked';
|
|
|
81
81
|
<TextBlock width="{textWidth}">
|
|
82
82
|
<h3>{title}</h3>
|
|
83
83
|
{#if description}
|
|
84
|
-
{
|
|
84
|
+
<Markdown source="{description}" />
|
|
85
85
|
{/if}
|
|
86
86
|
</TextBlock>
|
|
87
87
|
</PaddingReset>
|
|
@@ -96,7 +96,7 @@ import { marked } from 'marked';
|
|
|
96
96
|
<!-- Custom ARIA markup -->
|
|
97
97
|
<slot name="aria" />
|
|
98
98
|
{:else}
|
|
99
|
-
{
|
|
99
|
+
<Markdown source="{ariaDescription}" />
|
|
100
100
|
{/if}
|
|
101
101
|
</div>
|
|
102
102
|
{/if}
|
|
@@ -111,7 +111,7 @@ import { marked } from 'marked';
|
|
|
111
111
|
<PaddingReset containerIsFluid="{width === 'fluid'}">
|
|
112
112
|
<TextBlock width="{textWidth}">
|
|
113
113
|
<aside>
|
|
114
|
-
{
|
|
114
|
+
<Markdown source="{notes}" />
|
|
115
115
|
</aside>
|
|
116
116
|
</TextBlock>
|
|
117
117
|
</PaddingReset>
|
|
@@ -42,7 +42,7 @@ export let updateTime = '';
|
|
|
42
42
|
export let width = 'normal';
|
|
43
43
|
import Block from '../Block/Block.svelte';
|
|
44
44
|
import Byline from '../Byline/Byline.svelte';
|
|
45
|
-
import
|
|
45
|
+
import Markdown from '../Markdown/Markdown.svelte';
|
|
46
46
|
let hedClass;
|
|
47
47
|
$: {
|
|
48
48
|
switch (hedSize) {
|
|
@@ -85,7 +85,9 @@ $: {
|
|
|
85
85
|
<!-- Headline named slot -->
|
|
86
86
|
<slot name="hed" />
|
|
87
87
|
{:else}
|
|
88
|
-
<h1 class="{hedClass}">
|
|
88
|
+
<h1 class="{hedClass}">
|
|
89
|
+
<Markdown source="{hed}" parseInline />
|
|
90
|
+
</h1>
|
|
89
91
|
{/if}
|
|
90
92
|
{#if $$slots.dek}
|
|
91
93
|
<!-- Dek named slot-->
|
|
@@ -94,7 +96,7 @@ $: {
|
|
|
94
96
|
</div>
|
|
95
97
|
{:else if dek}
|
|
96
98
|
<div class="dek fmx-auto fmb-6">
|
|
97
|
-
{
|
|
99
|
+
<Markdown source="{dek}" />
|
|
98
100
|
</div>
|
|
99
101
|
{/if}
|
|
100
102
|
</div>
|
|
@@ -31,7 +31,7 @@ export let id = '';
|
|
|
31
31
|
*/
|
|
32
32
|
export let theme = 'light';
|
|
33
33
|
import Block from '../Block/Block.svelte';
|
|
34
|
-
import
|
|
34
|
+
import Markdown from '../Markdown/Markdown.svelte';
|
|
35
35
|
</script>
|
|
36
36
|
|
|
37
37
|
<aside class="infobox {theme}">
|
|
@@ -46,7 +46,9 @@ import { marked } from 'marked';
|
|
|
46
46
|
<slot name="header" />
|
|
47
47
|
</div>
|
|
48
48
|
{:else if title}
|
|
49
|
-
<div class="header fmb-2">
|
|
49
|
+
<div class="header fmb-2">
|
|
50
|
+
<Markdown source="{title}" />
|
|
51
|
+
</div>
|
|
50
52
|
{/if}
|
|
51
53
|
|
|
52
54
|
{#if $$slots.body}
|
|
@@ -55,7 +57,9 @@ import { marked } from 'marked';
|
|
|
55
57
|
<slot name="body" />
|
|
56
58
|
</div>
|
|
57
59
|
{:else}
|
|
58
|
-
<div class="body">
|
|
60
|
+
<div class="body">
|
|
61
|
+
<Markdown source="{text}" />
|
|
62
|
+
</div>
|
|
59
63
|
{/if}
|
|
60
64
|
|
|
61
65
|
{#if $$slots.footer}
|
|
@@ -64,7 +68,9 @@ import { marked } from 'marked';
|
|
|
64
68
|
<slot name="footer" />
|
|
65
69
|
</div>
|
|
66
70
|
{:else if notes}
|
|
67
|
-
<div class="footer fmt-2">
|
|
71
|
+
<div class="footer fmt-2">
|
|
72
|
+
<Markdown source="{notes}" />
|
|
73
|
+
</div>
|
|
68
74
|
{/if}
|
|
69
75
|
</Block>
|
|
70
76
|
</aside>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<!-- @component `Markdown` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-Markdown--default) -->
|
|
2
|
+
<script>import { marked } from 'marked';
|
|
3
|
+
import { staticMarkdown } from './stores';
|
|
4
|
+
/** A Markdown formatted string */
|
|
5
|
+
export let source = '';
|
|
6
|
+
/** Parse markdown inline, i.e., without wrapping it in paragraph tags */
|
|
7
|
+
export let parseInline = false;
|
|
8
|
+
$: markdown = parseInline ? marked.parseInline(source) : marked.parse(source);
|
|
9
|
+
const setInnerHTML = (node, html) => {
|
|
10
|
+
node.innerHTML = html;
|
|
11
|
+
return {
|
|
12
|
+
update(html) {
|
|
13
|
+
node.innerHTML = html;
|
|
14
|
+
},
|
|
15
|
+
destroy() {
|
|
16
|
+
node.innerHTML = '';
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
{#if source}
|
|
23
|
+
{#if $staticMarkdown}
|
|
24
|
+
<div>
|
|
25
|
+
{@html markdown}
|
|
26
|
+
</div>
|
|
27
|
+
{:else}
|
|
28
|
+
<div use:setInnerHTML="{markdown}"></div>
|
|
29
|
+
{/if}
|
|
30
|
+
{/if}
|
|
31
|
+
|
|
32
|
+
<style>
|
|
33
|
+
div {
|
|
34
|
+
display: contents;
|
|
35
|
+
}</style>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
/**
|
|
3
|
+
* Set to `false` in the browser to ensure Markdown content correctly updates
|
|
4
|
+
* when a SvelteKit app hyrates.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```javascript
|
|
8
|
+
* // +layout.js
|
|
9
|
+
* import { staticMarkdown } from '@reuters-graphics/graphics-components';
|
|
10
|
+
* import { building } from '$app/environment';
|
|
11
|
+
*
|
|
12
|
+
* export const load = async() => {
|
|
13
|
+
* // Set the store with the value of building.
|
|
14
|
+
* staticMarkdown.set(building);
|
|
15
|
+
*
|
|
16
|
+
* // Markdown using this content will correctly refresh when
|
|
17
|
+
* // a reader loads your page.
|
|
18
|
+
* const content = await fetchPageContent();
|
|
19
|
+
*
|
|
20
|
+
* return { content };
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export const staticMarkdown = writable(true);
|
|
25
|
+
//# sourceMappingURL=stores.js.map
|
|
@@ -39,7 +39,7 @@ export let width = 'normal';
|
|
|
39
39
|
export let textWidth = 'normal';
|
|
40
40
|
import Block from '../Block/Block.svelte';
|
|
41
41
|
import PaddingReset from '../PaddingReset/PaddingReset.svelte';
|
|
42
|
-
import
|
|
42
|
+
import Markdown from '../Markdown/Markdown.svelte';
|
|
43
43
|
let containerWidth;
|
|
44
44
|
const groupRows = (images, layout) => {
|
|
45
45
|
// Default layout, one img per row
|
|
@@ -102,7 +102,7 @@ $: rows = groupRows(images, layout);
|
|
|
102
102
|
{#each row as img, i}
|
|
103
103
|
{#if img.caption}
|
|
104
104
|
<div id="{id}-figure-{ri}-{i}" class="caption">
|
|
105
|
-
{
|
|
105
|
+
<Markdown source="{img.caption}" />
|
|
106
106
|
</div>
|
|
107
107
|
{/if}
|
|
108
108
|
{/each}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script>export let step;
|
|
2
2
|
export let index;
|
|
3
|
-
import { marked } from 'marked';
|
|
4
3
|
import Block from '../../Block/Block.svelte';
|
|
4
|
+
import Markdown from '../../Markdown/Markdown.svelte';
|
|
5
5
|
</script>
|
|
6
6
|
|
|
7
7
|
{#if step.foreground === '' || !step.foreground}
|
|
@@ -10,18 +10,18 @@ import Block from '../../Block/Block.svelte';
|
|
|
10
10
|
|
|
11
11
|
{#if typeof step.altText === 'string'}
|
|
12
12
|
<div class="background-alt-text visually-hidden">
|
|
13
|
-
{
|
|
13
|
+
<Markdown source="{step.altText}" />
|
|
14
14
|
</div>
|
|
15
15
|
{/if}
|
|
16
16
|
{:else if typeof step.foreground === 'string'}
|
|
17
17
|
<Block class="body-text step-{index + 1}">
|
|
18
18
|
<div class="embedded-foreground step-{index + 1}">
|
|
19
|
-
{
|
|
19
|
+
<Markdown source="{step.foreground}" />
|
|
20
20
|
</div>
|
|
21
21
|
|
|
22
22
|
{#if typeof step.altText === 'string'}
|
|
23
23
|
<div class="background-alt-text visually-hidden">
|
|
24
|
-
{
|
|
24
|
+
<Markdown source="{step.altText}" />
|
|
25
25
|
</div>
|
|
26
26
|
{/if}
|
|
27
27
|
</Block>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>export let steps = [];
|
|
2
|
-
import
|
|
2
|
+
import Markdown from '../Markdown/Markdown.svelte';
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
{#each steps as step, i}
|
|
@@ -12,13 +12,13 @@ import { marked } from 'marked';
|
|
|
12
12
|
<div class="empty-step-foreground"></div>
|
|
13
13
|
{#if typeof step.altText === 'string'}
|
|
14
14
|
<div class="background-alt-text visually-hidden">
|
|
15
|
-
{
|
|
15
|
+
<Markdown source="{step.altText}" />
|
|
16
16
|
</div>
|
|
17
17
|
{/if}
|
|
18
18
|
{:else}
|
|
19
19
|
<div class="step-foreground w-full">
|
|
20
20
|
{#if typeof step.foreground === 'string'}
|
|
21
|
-
{
|
|
21
|
+
<Markdown source="{step.foreground}" />
|
|
22
22
|
{:else}
|
|
23
23
|
<svelte:component
|
|
24
24
|
this="{step.foreground}"
|
|
@@ -28,7 +28,7 @@ import { marked } from 'marked';
|
|
|
28
28
|
</div>
|
|
29
29
|
{#if typeof step.altText === 'string'}
|
|
30
30
|
<div class="background-alt-text visually-hidden">
|
|
31
|
-
{
|
|
31
|
+
<Markdown source="{step.altText}" />
|
|
32
32
|
</div>
|
|
33
33
|
{/if}
|
|
34
34
|
{/if}
|
|
@@ -28,7 +28,7 @@ export let id = '';
|
|
|
28
28
|
import Block from '../Block/Block.svelte';
|
|
29
29
|
import Fa from 'svelte-fa/src/fa.svelte';
|
|
30
30
|
import { faLink } from '@fortawesome/free-solid-svg-icons';
|
|
31
|
-
import
|
|
31
|
+
import Markdown from '../Markdown/Markdown.svelte';
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<Block width="normal" id="{id}" class="simple-timeline-container fmy-6 {cls}">
|
|
@@ -65,7 +65,7 @@ import { marked } from 'marked';
|
|
|
65
65
|
</div>
|
|
66
66
|
{/if}
|
|
67
67
|
{#if event.context}
|
|
68
|
-
{
|
|
68
|
+
<Markdown source="{event.context}" />
|
|
69
69
|
{/if}
|
|
70
70
|
</div>
|
|
71
71
|
{/each}
|
package/dist/index.js
CHANGED
|
@@ -24,11 +24,13 @@ export { default as HeroHeadline } from './components/HeroHeadline/Hero.svelte';
|
|
|
24
24
|
export { default as EndNotes } from './components/EndNotes/EndNotes.svelte';
|
|
25
25
|
export { default as InfoBox } from './components/InfoBox/InfoBox.svelte';
|
|
26
26
|
export { default as InlineAd } from './components/AdSlot/InlineAd.svelte';
|
|
27
|
+
export { default as Markdown } from './components/Markdown/Markdown.svelte';
|
|
27
28
|
export { default as PaddingReset } from './components/PaddingReset/PaddingReset.svelte';
|
|
28
29
|
export { default as PhotoCarousel } from './components/PhotoCarousel/PhotoCarousel.svelte';
|
|
29
30
|
export { default as PhotoPack } from './components/PhotoPack/PhotoPack.svelte';
|
|
30
31
|
export { default as PymChild } from './components/PymChild/PymChild.svelte';
|
|
31
32
|
export { pymChildStore } from './components/PymChild/stores.js';
|
|
33
|
+
export { staticMarkdown } from './components/Markdown/stores.js';
|
|
32
34
|
export { default as ReferralBlock } from './components/ReferralBlock/ReferralBlock.svelte';
|
|
33
35
|
export { default as ReutersGraphicsLogo } from './components/ReutersGraphicsLogo/ReutersGraphicsLogo.svelte';
|
|
34
36
|
export { default as ReutersLogo } from './components/ReutersLogo/ReutersLogo.svelte';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reuters-graphics/graphics-components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"homepage": "https://reuters-graphics.github.io/graphics-components",
|
|
@@ -173,6 +173,8 @@
|
|
|
173
173
|
"./components/Headline/Headline.svelte": "./dist/components/Headline/Headline.svelte",
|
|
174
174
|
"./components/HeroHeadline/Hero.svelte": "./dist/components/HeroHeadline/Hero.svelte",
|
|
175
175
|
"./components/InfoBox/InfoBox.svelte": "./dist/components/InfoBox/InfoBox.svelte",
|
|
176
|
+
"./components/Markdown/Markdown.svelte": "./dist/components/Markdown/Markdown.svelte",
|
|
177
|
+
"./components/Markdown/stores.ts": "./dist/components/Markdown/stores.ts",
|
|
176
178
|
"./components/PaddingReset/PaddingReset.svelte": "./dist/components/PaddingReset/PaddingReset.svelte",
|
|
177
179
|
"./components/PhotoCarousel/PhotoCarousel.svelte": "./dist/components/PhotoCarousel/PhotoCarousel.svelte",
|
|
178
180
|
"./components/PhotoPack/PhotoPack.svelte": "./dist/components/PhotoPack/PhotoPack.svelte",
|