@reuters-graphics/graphics-components 0.0.29 → 0.0.30

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.
@@ -7,6 +7,7 @@ export declare type ContainerWidth = 'narrower' | 'narrow' | 'normal' | 'wide' |
7
7
  * A step in the Scroller component.
8
8
  */
9
9
  export interface ScrollerStep {
10
+ altText?: string;
10
11
  /**
11
12
  * A background component
12
13
  * @required
@@ -11,9 +11,10 @@ declare const __propDef: {
11
11
  *
12
12
  * Each step object in the array can have:
13
13
  *
14
- * - `background` A background component **REQUIRED**
14
+ * - `background` A background component. **REQUIRED**
15
15
  * - `backgroundProps` An object of props given to the background component
16
16
  * - `foreground` Either a markdown-formatted string or a foreground component **REQUIRED**
17
+ * - `altText` A string describing the background graphic, which is read aloud after the foreground blurb. You can add it to each step or, if you want to add just one alt text to describe all graphics in the scroll section, add it to just the first step. **RECOMMENDED**
17
18
  * - `foregroundProps` An object of props given to the foreground component
18
19
  *
19
20
  * @required
@@ -1,5 +1,6 @@
1
1
  import type { ComponentType } from 'svelte';
2
2
  interface BlockStep {
3
+ AltText?: string;
3
4
  Background: string;
4
5
  Text: string;
5
6
  }
@@ -27,6 +28,7 @@ export declare const getScrollerPropsFromDoc: (docBlock: Block, aiCharts: AiChar
27
28
  assetsPath: string;
28
29
  };
29
30
  foreground: string;
31
+ altText: string;
30
32
  }[];
31
33
  };
32
34
  export {};
@@ -4,8 +4,8 @@ export let index;
4
4
  import Block from '../../Block/Block.svelte';
5
5
  </script>
6
6
 
7
- <Block width={backgroundWidth} cls="background-container step-{index + 1}">
8
- <div class="embedded-background step-{index + 1}">
7
+ <Block width="{backgroundWidth}" cls="background-container step-{index + 1}">
8
+ <div class="embedded-background step-{index + 1}" aria-hidden="true">
9
9
  <svelte:component
10
10
  this="{step.background}"
11
11
  {...step.backgroundProps || {}}
@@ -7,11 +7,23 @@ import Block from '../../Block/Block.svelte';
7
7
  {#if step.foreground === '' || !step.foreground}
8
8
  <!-- Empty foreground -->
9
9
  <div class="empty-step-foreground step-{index + 1}"></div>
10
+
11
+ {#if typeof step.altText === 'string'}
12
+ <div class="background-alt-text visually-hidden">
13
+ {@html marked.parse(step.altText)}
14
+ </div>
15
+ {/if}
10
16
  {:else if typeof step.foreground === 'string'}
11
17
  <Block cls="body-text step-{index + 1}">
12
18
  <div class="embedded-foreground step-{index + 1}">
13
19
  {@html marked.parse(step.foreground)}
14
20
  </div>
21
+
22
+ {#if typeof step.altText === 'string'}
23
+ <div class="background-alt-text visually-hidden">
24
+ {@html marked.parse(step.altText)}
25
+ </div>
26
+ {/if}
15
27
  </Block>
16
28
  {:else}
17
29
  <div class="embedded-foreground step-{index + 1}">
@@ -200,4 +212,18 @@ div.embedded-foreground :global(.font-sans) {
200
212
  }
201
213
  div.embedded-foreground :global(p:last-child) {
202
214
  margin-bottom: 0;
215
+ }
216
+
217
+ .visually-hidden {
218
+ position: absolute !important;
219
+ width: 1px !important;
220
+ height: 1px !important;
221
+ padding: 0 !important;
222
+ margin: -1px !important;
223
+ overflow: hidden !important;
224
+ clip: rect(0, 0, 0, 0) !important;
225
+ -webkit-clip-path: polygon(0px 0px, 0px 0px, 0px 0px);
226
+ clip-path: polygon(0px 0px, 0px 0px, 0px 0px);
227
+ white-space: nowrap !important;
228
+ border: 0 !important;
203
229
  }</style>
@@ -7,6 +7,11 @@ import { marked } from 'marked';
7
7
  {#if step.foreground === '' || !step.foreground}
8
8
  <!-- Empty foreground -->
9
9
  <div class="empty-step-foreground"></div>
10
+ {#if typeof step.altText === 'string'}
11
+ <div class="background-alt-text visually-hidden">
12
+ {@html marked.parse(step.altText)}
13
+ </div>
14
+ {/if}
10
15
  {:else}
11
16
  <div class="step-foreground">
12
17
  {#if typeof step.foreground === 'string'}
@@ -18,11 +23,95 @@ import { marked } from 'marked';
18
23
  />
19
24
  {/if}
20
25
  </div>
26
+ {#if typeof step.altText === 'string'}
27
+ <div class="background-alt-text visually-hidden">
28
+ {@html marked.parse(step.altText)}
29
+ </div>
30
+ {/if}
21
31
  {/if}
22
32
  </div>
23
33
  {/each}
24
34
 
25
- <style>div.step-foreground-container {
35
+ <style>.paragraph-size {
36
+ font-size: 1.3rem;
37
+ line-height: 2.1rem;
38
+ }
39
+ .paragraph-size.font-sans {
40
+ font-size: 1.1rem;
41
+ line-height: 1.75rem;
42
+ }
43
+ @media (max-width: 540px) {
44
+ .paragraph-size {
45
+ font-size: 1.1rem;
46
+ line-height: 1.8rem;
47
+ }
48
+ .paragraph-size.font-sans {
49
+ font-size: 1rem;
50
+ line-height: 1.6rem;
51
+ }
52
+ }
53
+ .paragraph-size.important {
54
+ font-size: 1.3rem !important;
55
+ line-height: 2.1rem !important;
56
+ }
57
+ .paragraph-size.important.font-sans {
58
+ font-size: 1.1rem !important;
59
+ line-height: 1.8rem !important;
60
+ }
61
+ @media (max-width: 540px) {
62
+ .paragraph-size.important {
63
+ font-size: 1.1rem !important;
64
+ line-height: 1.8rem !important;
65
+ }
66
+ .paragraph-size.important.font-sans {
67
+ font-size: 1rem !important;
68
+ line-height: 1.6rem !important;
69
+ }
70
+ }
71
+
72
+ .small-size {
73
+ font-size: 0.9rem;
74
+ line-height: 1.2rem;
75
+ }
76
+ @media (max-width: 540px) {
77
+ .small-size {
78
+ font-size: 0.8rem;
79
+ line-height: 1.1rem;
80
+ }
81
+ }
82
+ .small-size.important {
83
+ font-size: 0.9rem !important;
84
+ line-height: 1.2rem !important;
85
+ }
86
+ @media (max-width: 540px) {
87
+ .small-size.important {
88
+ font-size: 0.8rem !important;
89
+ line-height: 1.1rem !important;
90
+ }
91
+ }
92
+
93
+ .blockquote-size {
94
+ font-size: 1.6rem;
95
+ line-height: 2.1rem;
96
+ }
97
+ @media (max-width: 540px) {
98
+ .blockquote-size {
99
+ font-size: 1.3rem;
100
+ line-height: 1.9rem;
101
+ }
102
+ }
103
+ .blockquote-size.important {
104
+ font-size: 1.6rem !important;
105
+ line-height: 2rem !important;
106
+ }
107
+ @media (max-width: 540px) {
108
+ .blockquote-size.important {
109
+ font-size: 1.3rem !important;
110
+ line-height: 1.8rem !important;
111
+ }
112
+ }
113
+
114
+ div.step-foreground-container {
26
115
  height: 100vh;
27
116
  width: initial;
28
117
  max-width: initial;
@@ -39,4 +128,18 @@ div.step-foreground-container .step-foreground {
39
128
  }
40
129
  div.step-foreground-container .step-foreground :global(p:last-child) {
41
130
  margin-bottom: 0;
131
+ }
132
+
133
+ .visually-hidden {
134
+ position: absolute !important;
135
+ width: 1px !important;
136
+ height: 1px !important;
137
+ padding: 0 !important;
138
+ margin: -1px !important;
139
+ overflow: hidden !important;
140
+ clip: rect(0, 0, 0, 0) !important;
141
+ -webkit-clip-path: polygon(0px 0px, 0px 0px, 0px 0px);
142
+ clip-path: polygon(0px 0px, 0px 0px, 0px 0px);
143
+ white-space: nowrap !important;
144
+ border: 0 !important;
42
145
  }</style>
@@ -9,9 +9,10 @@ export let id = '';
9
9
  *
10
10
  * Each step object in the array can have:
11
11
  *
12
- * - `background` A background component **REQUIRED**
12
+ * - `background` A background component. **REQUIRED**
13
13
  * - `backgroundProps` An object of props given to the background component
14
14
  * - `foreground` Either a markdown-formatted string or a foreground component **REQUIRED**
15
+ * - `altText` A string describing the background graphic, which is read aloud after the foreground blurb. You can add it to each step or, if you want to add just one alt text to describe all graphics in the scroll section, add it to just the first step. **RECOMMENDED**
15
16
  * - `foregroundProps` An object of props given to the foreground component
16
17
  *
17
18
  * @required
@@ -99,6 +100,7 @@ let progress;
99
100
  class="background"
100
101
  class:right="{foregroundPosition === 'left opposite'}"
101
102
  class:left="{foregroundPosition === 'right opposite'}"
103
+ aria-hidden="true"
102
104
  >
103
105
  <div class="scroller-graphic-well">
104
106
  <Block
@@ -9,6 +9,7 @@ export const getScrollerPropsFromDoc = (docBlock, aiCharts, assetsPath = '') =>
9
9
  background: aiCharts[step.Background],
10
10
  backgroundProps: { assetsPath },
11
11
  foreground: step.Text,
12
+ altText: step.AltText,
12
13
  })),
13
14
  };
14
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuters-graphics/graphics-components",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",