@reuters-graphics/graphics-components 3.0.12 → 3.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/components/@types/global.d.ts +45 -0
  2. package/dist/components/Scroller/Scroller.mdx +2 -2
  3. package/dist/components/ScrollerBase/ScrollerBase.mdx +0 -5
  4. package/dist/components/ScrollerVideo/Debug.svelte +207 -0
  5. package/dist/components/ScrollerVideo/Debug.svelte.d.ts +5 -0
  6. package/dist/components/ScrollerVideo/ScrollerVideo.mdx +462 -0
  7. package/dist/components/ScrollerVideo/ScrollerVideo.stories.svelte +190 -0
  8. package/dist/components/ScrollerVideo/ScrollerVideo.stories.svelte.d.ts +19 -0
  9. package/dist/components/ScrollerVideo/ScrollerVideo.svelte +292 -0
  10. package/dist/components/ScrollerVideo/ScrollerVideo.svelte.d.ts +58 -0
  11. package/dist/components/ScrollerVideo/ScrollerVideoForeground.svelte +164 -0
  12. package/dist/components/ScrollerVideo/ScrollerVideoForeground.svelte.d.ts +17 -0
  13. package/dist/components/ScrollerVideo/demo/AdvancedUsecases.svelte +114 -0
  14. package/dist/components/ScrollerVideo/demo/AdvancedUsecases.svelte.d.ts +3 -0
  15. package/dist/components/ScrollerVideo/demo/Embedded.svelte +94 -0
  16. package/dist/components/ScrollerVideo/demo/Embedded.svelte.d.ts +3 -0
  17. package/dist/components/ScrollerVideo/demo/WithAi2svelteForegrounds.svelte +117 -0
  18. package/dist/components/ScrollerVideo/demo/WithAi2svelteForegrounds.svelte.d.ts +3 -0
  19. package/dist/components/ScrollerVideo/demo/WithScrollerBase.svelte +80 -0
  20. package/dist/components/ScrollerVideo/demo/WithScrollerBase.svelte.d.ts +3 -0
  21. package/dist/components/ScrollerVideo/demo/WithTextForegrounds.svelte +72 -0
  22. package/dist/components/ScrollerVideo/demo/WithTextForegrounds.svelte.d.ts +18 -0
  23. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/ai-chart.svelte +631 -0
  24. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/ai-chart.svelte.d.ts +3 -0
  25. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/annotation1.svelte +428 -0
  26. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/annotation1.svelte.d.ts +26 -0
  27. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/annotation2.svelte +402 -0
  28. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/annotation2.svelte.d.ts +26 -0
  29. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/annotation3.svelte +398 -0
  30. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/annotation3.svelte.d.ts +26 -0
  31. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/annotation4.svelte +360 -0
  32. package/dist/components/ScrollerVideo/demo/graphic/ai2svelte/annotation4.svelte.d.ts +26 -0
  33. package/dist/components/ScrollerVideo/demo/graphic/imgs/ai-chart-md.png +0 -0
  34. package/dist/components/ScrollerVideo/demo/graphic/imgs/ai-chart-sm.png +0 -0
  35. package/dist/components/ScrollerVideo/demo/graphic/imgs/ai-chart-xs.png +0 -0
  36. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation1-lg.png +0 -0
  37. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation1-md.png +0 -0
  38. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation1-sm.png +0 -0
  39. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation1-xl.png +0 -0
  40. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation1-xs.png +0 -0
  41. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation2-lg.png +0 -0
  42. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation2-md.png +0 -0
  43. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation2-sm.png +0 -0
  44. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation2-xl.png +0 -0
  45. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation2-xs.png +0 -0
  46. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation3-lg.png +0 -0
  47. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation3-md.png +0 -0
  48. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation3-sm.png +0 -0
  49. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation3-xl.png +0 -0
  50. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation3-xs.png +0 -0
  51. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation4-lg.png +0 -0
  52. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation4-md.png +0 -0
  53. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation4-sm.png +0 -0
  54. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation4-xl.png +0 -0
  55. package/dist/components/ScrollerVideo/demo/graphic/imgs/annotation4-xs.png +0 -0
  56. package/dist/components/ScrollerVideo/ts/ScrollerVideo.d.ts +248 -0
  57. package/dist/components/ScrollerVideo/ts/ScrollerVideo.js +762 -0
  58. package/dist/components/ScrollerVideo/ts/mp4box.d.ts +137 -0
  59. package/dist/components/ScrollerVideo/ts/state.svelte.d.ts +51 -0
  60. package/dist/components/ScrollerVideo/ts/state.svelte.js +25 -0
  61. package/dist/components/ScrollerVideo/ts/utils.d.ts +70 -0
  62. package/dist/components/ScrollerVideo/ts/utils.js +92 -0
  63. package/dist/components/ScrollerVideo/ts/videoDecoder.d.ts +11 -0
  64. package/dist/components/ScrollerVideo/ts/videoDecoder.js +193 -0
  65. package/dist/components/ScrollerVideo/videos/HPO.mp4 +0 -0
  66. package/dist/components/ScrollerVideo/videos/drone.mp4 +0 -0
  67. package/dist/components/ScrollerVideo/videos/goldengate.mp4 +0 -0
  68. package/dist/components/ScrollerVideo/videos/tennis.mp4 +0 -0
  69. package/dist/components/ScrollerVideo/videos/waves_lg.mp4 +0 -0
  70. package/dist/components/ScrollerVideo/videos/waves_md.mp4 +0 -0
  71. package/dist/components/ScrollerVideo/videos/waves_sm.mp4 +0 -0
  72. package/dist/components/SiteHeadline/SiteHeadline.mdx +4 -1
  73. package/dist/index.d.ts +3 -1
  74. package/dist/index.js +2 -0
  75. package/package.json +3 -1
@@ -0,0 +1,94 @@
1
+ <script lang="ts">
2
+ import ScrollerVideo from '../ScrollerVideo.svelte';
3
+ import ScrollerVideoForeground from '../ScrollerVideoForeground.svelte';
4
+ import Goldengate from '../videos/goldengate.mp4';
5
+ import BodyText from '../../BodyText/BodyText.svelte';
6
+
7
+ import type { ContainerWidth } from '../../@types/global';
8
+
9
+ const content = {
10
+ blocks: [
11
+ {
12
+ type: 'scroller-video',
13
+ id: 'goldengate-scroller',
14
+ src: '../videos/goldengate.mp4',
15
+ height: '200lvh',
16
+ foregrounds: [
17
+ {
18
+ startTime: '0',
19
+ endTime: '2',
20
+ width: 'normal',
21
+ position: 'bottom center',
22
+ backgroundColour: 'rgba(0, 0, 0, 0.8)',
23
+ text: '#### Golden Gate Bridge\n\nThe Golden Gate Bridge took over 4 years to build (1933-1937) and was the longest suspension bridge in the world at the time of its completion, spanning 4,200 feet between its towers.',
24
+ },
25
+ {
26
+ startTime: '4',
27
+ endTime: '7',
28
+ width: 'normal',
29
+ position: 'bottom center',
30
+ backgroundColour: 'rgba(0, 0, 0, 0.8)',
31
+ text: "The bridge's iconic International Orange color was chosen partly for visibility in San Francisco's frequent fog. The paint job requires constant maintenance, with a dedicated crew painting the bridge year-round to protect it from rust and corrosion.",
32
+ },
33
+ {
34
+ startTime: '8',
35
+ endTime: '11',
36
+ width: 'normal',
37
+ position: 'bottom center',
38
+ backgroundColour: 'rgba(0, 0, 0, 0.8)',
39
+ text: '#### Engineering Marvel\n\nThe Golden Gate Bridge sways up to **27 feet** sideways in strong winds and can handle winds up to 100 mph. On foggy days, the bridge can collect enough moisture to drip like rain, and it has been struck by ships only once in its history.',
40
+ },
41
+ ],
42
+ },
43
+ ],
44
+ };
45
+
46
+ const openerText =
47
+ '**In embedded mode, `ScrollerVideo` behaves like a normal video player, autoplaying the video when the user scrolls onto it.**';
48
+ const dummyText =
49
+ 'Reprehenderit hamburger pork bresaola, dolore chuck sirloin landjaeger ham hock tempor meatball alcatra nostrud pork belly. Culpa pork belly doner ea jowl, elit deserunt leberkas cow shoulder ham hock dolore.';
50
+ const scrollerVideoBlock = content.blocks[0];
51
+
52
+ let embedded = $state(true);
53
+ </script>
54
+
55
+ <BodyText text={openerText} />
56
+ <BodyText text={dummyText} />
57
+ <BodyText text={dummyText} />
58
+ <BodyText text={dummyText} />
59
+ <BodyText text={dummyText} />
60
+ <BodyText text={dummyText} />
61
+
62
+ <ScrollerVideo
63
+ src={Goldengate}
64
+ class="embedded-demo"
65
+ showDebugInfo={true}
66
+ {embedded}
67
+ embeddedProps={{
68
+ threshold: 0.5,
69
+ duration: 12000,
70
+ delay: 200,
71
+ }}
72
+ >
73
+ {#each scrollerVideoBlock.foregrounds as foreground}
74
+ <ScrollerVideoForeground
75
+ startTime={parseFloat(foreground.startTime)}
76
+ endTime={parseFloat(foreground.endTime)}
77
+ width={foreground.width as ContainerWidth}
78
+ position={foreground.position}
79
+ backgroundColour={foreground.backgroundColour}
80
+ text={foreground.text}
81
+ />
82
+ {/each}
83
+ </ScrollerVideo>
84
+ <BodyText text={dummyText} />
85
+ <BodyText text={dummyText} />
86
+ <BodyText text={dummyText} />
87
+ <BodyText text={dummyText} />
88
+ <BodyText text={dummyText} />
89
+ <BodyText text={dummyText} />
90
+
91
+ <style>:global .embedded-demo .foreground-text h4,
92
+ :global .embedded-demo .foreground-text p {
93
+ color: white;
94
+ }</style>
@@ -0,0 +1,3 @@
1
+ declare const Embedded: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type Embedded = ReturnType<typeof Embedded>;
3
+ export default Embedded;
@@ -0,0 +1,117 @@
1
+ <script lang="ts">
2
+ import ScrollerVideo from '../ScrollerVideo.svelte';
3
+ import ScrollerVideoForeground from '../ScrollerVideoForeground.svelte';
4
+ import SM from '../videos/waves_sm.mp4';
5
+ import MD from '../videos/waves_md.mp4';
6
+ import LG from '../videos/waves_lg.mp4';
7
+ import Headline from '../../Headline/Headline.svelte';
8
+
9
+ // Foreground ai2svelte components
10
+ import Foreground1 from './graphic/ai2svelte/annotation1.svelte';
11
+ import Foreground2 from './graphic/ai2svelte/annotation2.svelte';
12
+ import Foreground3 from './graphic/ai2svelte/annotation3.svelte';
13
+ import Foreground4 from './graphic/ai2svelte/annotation4.svelte';
14
+
15
+ // Foreground ai2svelte graphics components
16
+ const aiChartsForeground = {
17
+ Foreground1,
18
+ Foreground2,
19
+ Foreground3,
20
+ Foreground4,
21
+ };
22
+
23
+ const content = {
24
+ hed: 'Wind and waves',
25
+ authors: ['Jane Doe'],
26
+ publishTime: '2020-01-01T00:00:00Z',
27
+ startTime: '0',
28
+ endTime: '0.3',
29
+ blocks: [
30
+ {
31
+ type: 'scroller-video',
32
+ id: 'surf-scroller',
33
+ height: '800lvh',
34
+ foregrounds: [
35
+ {
36
+ startTime: '0.3',
37
+ endTime: '2.2',
38
+ width: 'fluid',
39
+ foreground: 'Foreground1',
40
+ },
41
+ {
42
+ startTime: '2.2',
43
+ endTime: '3.2',
44
+ width: 'fluid',
45
+ foreground: 'Foreground2',
46
+ },
47
+ {
48
+ startTime: '3.2',
49
+ endTime: '4.5',
50
+ width: 'fluid',
51
+ foreground: 'Foreground3',
52
+ },
53
+ {
54
+ startTime: '6.5',
55
+ endTime: '8',
56
+ width: 'fluid',
57
+ foreground: 'Foreground4',
58
+ },
59
+ ],
60
+ },
61
+ ],
62
+ };
63
+ const scrollerVideoBlock = content.blocks[0];
64
+
65
+ let width = $state(1);
66
+ </script>
67
+
68
+ <svelte:window bind:innerWidth={width} />
69
+
70
+ {#snippet ScrollVideo(height: string, src: string)}
71
+ <ScrollerVideo
72
+ id={scrollerVideoBlock.id}
73
+ {height}
74
+ {src}
75
+ useWebCodecs={true}
76
+ showDebugInfo
77
+ >
78
+ <ScrollerVideoForeground
79
+ startTime={parseFloat(content.startTime)}
80
+ endTime={parseFloat(content.endTime)}
81
+ >
82
+ <Headline
83
+ class="custom-headline"
84
+ hed={content.hed}
85
+ authors={content.authors}
86
+ publishTime={new Date(content.publishTime).toISOString()}
87
+ />
88
+ </ScrollerVideoForeground>
89
+
90
+ {#each scrollerVideoBlock.foregrounds as foreground}
91
+ <ScrollerVideoForeground
92
+ startTime={parseFloat(foreground.startTime)}
93
+ endTime={parseFloat(foreground.endTime)}
94
+ width={foreground.width as 'fluid'}
95
+ Foreground={aiChartsForeground[
96
+ foreground.foreground as keyof typeof aiChartsForeground
97
+ ]}
98
+ />
99
+ {/each}
100
+ </ScrollerVideo>
101
+ {/snippet}
102
+
103
+ {#if width < 600}
104
+ {@render ScrollVideo(scrollerVideoBlock.height, SM)}
105
+ {:else if width < 1200}
106
+ {@render ScrollVideo(scrollerVideoBlock.height, MD)}
107
+ {:else}
108
+ {@render ScrollVideo(scrollerVideoBlock.height, LG)}
109
+ {/if}
110
+
111
+ <style>:global(.custom-headline *) {
112
+ color: white;
113
+ }
114
+
115
+ :global(.surf-scroller .scroller-video-foreground) {
116
+ filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.85));
117
+ }</style>
@@ -0,0 +1,3 @@
1
+ declare const WithAi2svelteForegrounds: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type WithAi2svelteForegrounds = ReturnType<typeof WithAi2svelteForegrounds>;
3
+ export default WithAi2svelteForegrounds;
@@ -0,0 +1,80 @@
1
+ <script lang="ts">
2
+ import ScrollerVideo from '../ScrollerVideo.svelte';
3
+ import ScrollerBase from '../../ScrollerBase/ScrollerBase.svelte';
4
+ import Goldengate from '../videos/goldengate.mp4';
5
+
6
+ // ScrollerBase props
7
+ let progress = $state(0);
8
+ </script>
9
+
10
+ <ScrollerBase bind:progress query="div.step-foreground-container" visible>
11
+ {#snippet backgroundSnippet()}
12
+ <ScrollerVideo
13
+ src={Goldengate}
14
+ height="100lvh"
15
+ trackScroll={false}
16
+ videoPercentage={progress}
17
+ showDebugInfo
18
+ />
19
+ {/snippet}
20
+ {#snippet foregroundSnippet()}
21
+ <!-- Add custom foreground HTML or component -->
22
+ <div class="step-foreground-container">
23
+ <h3 class="text-center">Step 1</h3>
24
+ </div>
25
+ <div class="step-foreground-container">
26
+ <h3 class="text-center">Step 2</h3>
27
+ </div>
28
+ <div class="step-foreground-container">
29
+ <h3 class="text-center">Step 3</h3>
30
+ </div>
31
+ {/snippet}
32
+ </ScrollerBase>
33
+
34
+ <style>/* Generated from
35
+ https://utopia.fyi/space/calculator/?c=320,18,1.125,1280,21,1.25,7,3,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12
36
+ */
37
+ /* Generated from
38
+ https://utopia.fyi/space/calculator/?c=320,18,1.125,1280,21,1.25,7,3,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12
39
+ */
40
+ /* Scales by 1.125 */
41
+ #progress-bar {
42
+ background-color: rgba(0, 0, 0, 0.8);
43
+ position: absolute;
44
+ z-index: 2;
45
+ right: 0;
46
+ padding: 1rem;
47
+ }
48
+ #progress-bar progress {
49
+ height: 6px;
50
+ background-color: rgba(255, 0, 0, 0.2666666667); /* Background color of the entire bar */
51
+ }
52
+ #progress-bar progress::-webkit-progress-value {
53
+ background-color: white;
54
+ border-radius: 10px;
55
+ }
56
+ #progress-bar progress::-webkit-progress-bar {
57
+ background-color: #444444;
58
+ border-radius: 10px;
59
+ }
60
+ #progress-bar p {
61
+ font-family: var(--theme-font-family-sans-serif);
62
+ color: white;
63
+ font-size: var(--theme-font-size-xs);
64
+ padding: 0;
65
+ margin: 0;
66
+ }
67
+
68
+ .step-foreground-container {
69
+ height: 100lvh;
70
+ width: 50%;
71
+ padding: 1em;
72
+ margin: auto;
73
+ }
74
+ .step-foreground-container h3 {
75
+ display: flex;
76
+ align-items: center;
77
+ justify-content: center;
78
+ height: 100%;
79
+ color: white;
80
+ }</style>
@@ -0,0 +1,3 @@
1
+ declare const WithScrollerBase: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type WithScrollerBase = ReturnType<typeof WithScrollerBase>;
3
+ export default WithScrollerBase;
@@ -0,0 +1,72 @@
1
+ <script lang="ts">
2
+ import ScrollerVideo from '../ScrollerVideo.svelte';
3
+ import ScrollerVideoForeground from '../ScrollerVideoForeground.svelte';
4
+ import Drone from '../videos/drone.mp4';
5
+ import type { ContainerWidth } from '../../@types/global';
6
+
7
+ const content = {
8
+ blocks: [
9
+ {
10
+ type: 'scroller-video',
11
+ id: 'alps-scroller',
12
+ src: 'videos/alps.mp4',
13
+ height: '800lvh',
14
+ foregrounds: [
15
+ {
16
+ startTime: '0',
17
+ endTime: '5',
18
+ width: 'normal',
19
+ position: 'bottom center',
20
+ backgroundColour: 'rgba(0, 0, 0, 0.8)',
21
+ text: '#### The Alps\n\nThe Alps stretch across eight countries: France, Switzerland, Italy, Monaco, Liechtenstein, Austria, Germany, and Slovenia, covering about 1,200 kilometers (750 miles).',
22
+ },
23
+ {
24
+ startTime: '7',
25
+ endTime: '12',
26
+ width: 'normal',
27
+ position: 'bottom center',
28
+ backgroundColour: 'rgba(0, 0, 0, 0.8)',
29
+ text: "Mont Blanc, standing at 4,809 meters (15,777 feet), is the highest peak in the Alps and Western Europe, though there's ongoing debate between France and Italy about exactly where the summit lies.",
30
+ },
31
+ {
32
+ startTime: '14',
33
+ endTime: '20',
34
+ width: 'normal',
35
+ position: 'bottom center',
36
+ backgroundColour: 'rgba(0, 0, 0, 0.8)',
37
+ text: '#### History\n\nThe Alps were formed around **65 million years** ago when the African and Eurasian tectonic plates collided, pushing the land upward. Over 14 million people live in the Alpine region, with tourism supporting approximately 120 million visitors annually.',
38
+ },
39
+ ],
40
+ },
41
+ ],
42
+ };
43
+
44
+ const scrollerVideoBlock = content.blocks[0];
45
+ </script>
46
+
47
+ <ScrollerVideo
48
+ id={scrollerVideoBlock.id}
49
+ height={scrollerVideoBlock.height}
50
+ src={Drone}
51
+ useWebCodecs={true}
52
+ showDebugInfo
53
+ >
54
+ {#each scrollerVideoBlock.foregrounds as foreground}
55
+ <ScrollerVideoForeground
56
+ startTime={parseFloat(foreground.startTime)}
57
+ endTime={parseFloat(foreground.endTime)}
58
+ width={foreground.width as ContainerWidth}
59
+ position={foreground.position}
60
+ backgroundColour={foreground.backgroundColour}
61
+ text={foreground.text}
62
+ />
63
+ {/each}
64
+ </ScrollerVideo>
65
+
66
+ <style>:global(.custom-headline *) {
67
+ text-shadow: 0 0 8px rgba(0, 0, 0, 0.75);
68
+ }
69
+
70
+ :global #alps-scroller .foreground-text * {
71
+ color: white;
72
+ }</style>
@@ -0,0 +1,18 @@
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const WithTextForegrounds: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
+ [evt: string]: CustomEvent<any>;
16
+ }, {}, {}, string>;
17
+ type WithTextForegrounds = InstanceType<typeof WithTextForegrounds>;
18
+ export default WithTextForegrounds;