@reuters-graphics/graphics-components 0.0.1-beta.7 → 0.0.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.
@@ -27,6 +27,11 @@ declare const __propDef: {
27
27
  export declare type ArticleProps = typeof __propDef.props;
28
28
  export declare type ArticleEvents = typeof __propDef.events;
29
29
  export declare type ArticleSlots = typeof __propDef.slots;
30
+ /**
31
+ * The `Article` component contains all the content of our story and also establishes the dimensions of our article well, the default central trunk of our page layout.
32
+ *
33
+ * [Docs](https://reuters-graphics.github.io/graphics-components/?path=/docs/layout-article--default)
34
+ */
30
35
  export default class Article extends SvelteComponentTyped<ArticleProps, ArticleEvents, ArticleSlots> {
31
36
  }
32
37
  export {};
@@ -1,11 +1,17 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
+ /**
5
+ * Base url for the page, which in [Vite-based projects](https://vitejs.dev/guide/build.html#public-base-path)
6
+ * is globally available as `import.meta.env.BASE_URL`.
7
+ * @required
8
+ * @type {string}
9
+ */ baseUrl?: string;
4
10
  /**
5
11
  * [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object for the page.
6
12
  * @required
7
13
  * @type {URL}
8
- */ url?: URL | null;
14
+ */ pageUrl?: URL | null;
9
15
  /**
10
16
  * SEO title
11
17
  * @required
@@ -0,0 +1,32 @@
1
+ import type { ComponentType } from 'svelte';
2
+ interface BlockStep {
3
+ Background: string;
4
+ Text: string;
5
+ }
6
+ interface Block {
7
+ Type: string;
8
+ Width: string;
9
+ ForegroundPosition: string;
10
+ StackBackground?: string;
11
+ EmbeddedLayout?: string;
12
+ ID?: string;
13
+ Steps: BlockStep[];
14
+ }
15
+ interface AiCharts {
16
+ [key: string]: ComponentType;
17
+ }
18
+ export declare const getScrollerPropsFromDoc: (docBlock: Block, aiCharts: AiCharts, assetsPath?: string) => {
19
+ id: string;
20
+ backgroundWidth: string;
21
+ foregroundPosition: string;
22
+ stackBackground: boolean;
23
+ embeddedLayout: string;
24
+ steps: {
25
+ background: ComponentType<import("svelte").SvelteComponentTyped<any, any, any>>;
26
+ backgroundProps: {
27
+ assetsPath: string;
28
+ };
29
+ foreground: string;
30
+ }[];
31
+ };
32
+ export {};
@@ -23,4 +23,5 @@ export { default as Spinner } from "./components/Spinner/Spinner.svelte";
23
23
  export { default as Video } from "./components/Video/Video.svelte";
24
24
  export { default as Visible } from "./components/Visible/Visible.svelte";
25
25
  export { getPhotoPackPropsFromDoc } from "./components/PhotoPack/docProps.js";
26
+ export { getScrollerPropsFromDoc } from "./components/Scroller/docProps.js";
26
27
  export { default as Theme, themes } from "./components/Theme/Theme.svelte";
@@ -1,3 +1,8 @@
1
+ <!--
2
+ @component The `Article` component contains all the content of our story and also establishes the dimensions of our article well, the default central trunk of our page layout.
3
+
4
+ [Docs](https://reuters-graphics.github.io/graphics-components/?path=/docs/layout-article--default)
5
+ -->
1
6
  <script>/** Set to true for embeddables. */
2
7
  export let embedded = false;
3
8
  /** Add an id to the article tag to target it with custom CSS. */
@@ -8,7 +8,7 @@ import { marked } from 'marked';
8
8
  import Block from '../Block/Block.svelte';
9
9
  </script>
10
10
 
11
- <Block cls="notes">
11
+ <Block cls="notes mb-6">
12
12
  {#if text}
13
13
  {@html marked.parse(text)}
14
14
  {/if}
@@ -1,11 +1,18 @@
1
1
  <script>import analytics from './analytics';
2
2
  import publisherTags from './publisherTags';
3
+ /**
4
+ * Base url for the page, which in [Vite-based projects](https://vitejs.dev/guide/build.html#public-base-path)
5
+ * is globally available as `import.meta.env.BASE_URL`.
6
+ * @required
7
+ * @type {string}
8
+ */
9
+ export let baseUrl = '';
3
10
  /**
4
11
  * [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) object for the page.
5
12
  * @required
6
13
  * @type {URL}
7
14
  */
8
- export let url = null;
15
+ export let pageUrl = null;
9
16
  /**
10
17
  * SEO title
11
18
  * @required
@@ -59,9 +66,23 @@ export let authors = [];
59
66
  * Whether to inject Google Analytics code for this page.
60
67
  */
61
68
  export let includeAnalytics = false;
69
+ const getOrigin = (baseUrl) => {
70
+ try {
71
+ return new URL(baseUrl).origin;
72
+ }
73
+ catch {
74
+ // This handles a weird case where Vite's base path is
75
+ // reset to './' after the app hydrates...
76
+ if (typeof window !== 'undefined')
77
+ return getOrigin(window.location.href);
78
+ return '';
79
+ }
80
+ };
81
+ $: origin = getOrigin(baseUrl);
82
+ $: canonicalUrl = origin + pageUrl.pathname;
62
83
  // Only fire analytics on prod sites
63
84
  if (typeof window !== 'undefined' && includeAnalytics) {
64
- analytics(url, seoTitle);
85
+ analytics(canonicalUrl, seoTitle);
65
86
  publisherTags();
66
87
  }
67
88
  const orgLdJson = {
@@ -81,10 +102,10 @@ const articleLdJson = {
81
102
  '@context': 'http://schema.org',
82
103
  '@type': 'NewsArticle',
83
104
  headline: seoTitle,
84
- url: url.href,
105
+ url: canonicalUrl,
85
106
  mainEntityOfPage: {
86
107
  '@type': 'WebPage',
87
- '@id': url.href,
108
+ '@id': canonicalUrl,
88
109
  },
89
110
  thumbnailUrl: shareImgPath,
90
111
  image: [
@@ -117,7 +138,7 @@ const articleLdJson = {
117
138
  <html lang="{lang}"></html>
118
139
  <title>{seoTitle}</title>
119
140
  <meta name="description" content="{seoDescription}" />
120
- <link rel="canonical" href="{url.href}" />
141
+ <link rel="canonical" href="{canonicalUrl}" />
121
142
  <link
122
143
  rel="shortcut icon"
123
144
  type="image/x-icon"
@@ -142,7 +163,7 @@ const articleLdJson = {
142
163
  sizes="96x96"
143
164
  />
144
165
 
145
- <meta property="og:url" content="{url.href}" />
166
+ <meta property="og:url" content="{canonicalUrl}" />
146
167
  <meta property="og:type" content="article" />
147
168
  <meta property="og:title" content="{shareTitle}" itemprop="name" />
148
169
  <meta
@@ -150,17 +171,13 @@ const articleLdJson = {
150
171
  content="{shareDescription}"
151
172
  itemprop="description"
152
173
  />
153
- <meta
154
- property="og:image"
155
- content="{shareImgPath}"
156
- itemprop="image"
157
- />
174
+ <meta property="og:image" content="{shareImgPath}" itemprop="image" />
158
175
  <meta property="og:site_name" content="Reuters" />
159
176
 
160
177
  <meta name="twitter:card" content="summary_large_image" />
161
178
  <meta name="twitter:site" content="@ReutersGraphics" />
162
179
  <meta name="twitter:creator" content="@ReutersGraphics" />
163
- <meta name="twitter:domain" content="{url.origin}" />
180
+ <meta name="twitter:domain" content="{origin}" />
164
181
  <meta name="twitter:title" content="{shareTitle}" />
165
182
  <meta name="twitter:description" content="{shareDescription}" />
166
183
  <meta name="twitter:image:src" content="{shareImgPath}" />
@@ -0,0 +1,14 @@
1
+ export const getScrollerPropsFromDoc = (docBlock, aiCharts, assetsPath = '') => {
2
+ return {
3
+ id: docBlock.ID,
4
+ backgroundWidth: docBlock.Width,
5
+ foregroundPosition: docBlock.ForegroundPosition,
6
+ stackBackground: docBlock.StackBackground === 'true' || !docBlock.StackBackground,
7
+ embeddedLayout: docBlock.EmbeddedLayout,
8
+ steps: docBlock.Steps.map((step) => ({
9
+ background: aiCharts[step.Background],
10
+ backgroundProps: { assetsPath },
11
+ foreground: step.Text,
12
+ })),
13
+ };
14
+ };
@@ -10,6 +10,7 @@ export let referrals = [];
10
10
  </script>
11
11
 
12
12
  <footer
13
+ class="my-0"
13
14
  style="{`
14
15
  --nav-background: var(--theme-colour-background, #fff);
15
16
  --nav-primary: var(--theme-colour-text-primary, #404040);
@@ -26,7 +27,7 @@ export let referrals = [];
26
27
 
27
28
  <!-- svelte-ignore css-unused-selector -->
28
29
  <style>footer {
29
- margin-top: 4rem;
30
+ margin-top: 0;
30
31
  background-color: var(--nav-background, #fff);
31
32
  }
32
33
  footer div {
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import { ReutersLogo } from '../../../index.js';
2
+ import ReutersLogo from '../../ReutersLogo/ReutersLogo.svelte';
3
3
  import CloseIcon from '../svgs/Close.svelte';
4
4
  import { normalizeUrl } from '../NavBar/utils/index.js';
5
5
 
@@ -1,4 +1,4 @@
1
- <script>import { ReutersLogo } from '../../index.js';
1
+ <script>import ReutersLogo from '../ReutersLogo/ReutersLogo.svelte';
2
2
  import NavBar from './NavBar/index.svelte';
3
3
  import data from './data.json';
4
4
  import { setContext } from 'svelte';
@@ -17,18 +17,16 @@ export let theme = {};
17
17
  * explicitly set.
18
18
  */
19
19
  export let base = 'light';
20
- import cssVariables from '../../actions/cssVariables';
21
20
  import flatten from './utils/flatten';
22
21
  import mergeThemes from './utils/merge';
23
22
  /** @type {Theme} */
24
23
  $: mergedTheme = mergeThemes({}, themes[base] || themes.light, theme);
24
+ $: cssVariables = Object.entries(flatten({ theme: mergedTheme }))
25
+ .map(([key, value]) => `--${key}: ${value};`)
26
+ .join(' ');
25
27
  </script>
26
28
 
27
- <div
28
- class="theme"
29
- style="display: contents;"
30
- use:cssVariables="{flatten({ theme: mergedTheme })}"
31
- >
29
+ <div class="theme" style="{cssVariables}" style:display="contents">
32
30
  <!-- Clients can override the theme above by attaching custom properties to this element. -->
33
31
  <div class="theme-client-override" style="display: contents;">
34
32
  <!-- Themed content -->
@@ -5,8 +5,8 @@ export default {
5
5
  'text-primary': '#ffffff',
6
6
  'text-secondary': 'rgb(255 255 255 / 60%)',
7
7
  accent: ' #ef3c2a',
8
- 'brand-logo': '#fa6400',
9
- 'brand-rules': '#999999',
8
+ 'brand-logo': '#ffffff',
9
+ 'brand-rules': 'rgb(255 255 255 / 25%)',
10
10
  'brand-shadow': 'rgb(255 255 255 / 10%)',
11
11
  },
12
12
  font: {
@@ -238,7 +238,7 @@ if (ariaHidden && !ariaDescription) {
238
238
  </div>
239
239
  {/if}
240
240
  {#if caption}
241
- <figcaption>{caption}</figcaption>
241
+ <div class="caption">{caption}</div>
242
242
  {/if}
243
243
  {/if}
244
244
  </div>
@@ -265,7 +265,7 @@ if (ariaHidden && !ariaDescription) {
265
265
  border: 0 !important;
266
266
  }
267
267
 
268
- figcaption {
268
+ div.caption {
269
269
  font-size: 0.8rem;
270
270
  color: var(--theme-colour-text-secondary, #666666);
271
271
  }
package/dist/index.js CHANGED
@@ -31,3 +31,4 @@ export { default as Visible } from './components/Visible/Visible.svelte';
31
31
 
32
32
  // Utilities
33
33
  export { getPhotoPackPropsFromDoc } from './components/PhotoPack/docProps.js';
34
+ export { getScrollerPropsFromDoc } from './components/Scroller/docProps.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuters-graphics/graphics-components",
3
- "version": "0.0.1-beta.7",
3
+ "version": "0.0.1",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",
@@ -15,7 +15,7 @@
15
15
  "postversion": "git push origin && git push origin --tags"
16
16
  },
17
17
  "license": "MIT",
18
- "types": "dist/@types/index.d.ts",
18
+ "types": "./dist/@types/index.d.ts",
19
19
  "files": [
20
20
  "dist"
21
21
  ],
@@ -127,6 +127,7 @@
127
127
  "./components/Scroller/Embedded/index.svelte": "./dist/components/Scroller/Embedded/index.svelte",
128
128
  "./components/Scroller/Foreground.svelte": "./dist/components/Scroller/Foreground.svelte",
129
129
  "./components/Scroller/Scroller.svelte": "./dist/components/Scroller/Scroller.svelte",
130
+ "./components/Scroller/docProps.ts": "./dist/components/Scroller/docProps.ts",
130
131
  "./components/Sharer/Sharer.svelte": "./dist/components/Sharer/Sharer.svelte",
131
132
  "./components/Sharer/utils/copyToClipboard": "./dist/components/Sharer/utils/copyToClipboard.js",
132
133
  "./components/Sharer/utils/facebook": "./dist/components/Sharer/utils/facebook.js",
@@ -189,7 +190,7 @@
189
190
  "./scss/fonts/mixins": "./dist/scss/fonts/_mixins.scss",
190
191
  "./scss/fonts/rules": "./dist/scss/fonts/_rules.scss",
191
192
  "./scss/fonts/variables": "./dist/scss/fonts/_variables.scss",
192
- "./scss/main.scss": "./dist/scss/main.scss",
193
+ "./scss/main": "./dist/scss/main.scss",
193
194
  "./scss/mixins/block": "./dist/scss/mixins/_block.scss",
194
195
  "./scss/mixins/body-text": "./dist/scss/mixins/_body-text.scss",
195
196
  "./scss/mixins/graphic": "./dist/scss/mixins/_graphic.scss",