@reuters-graphics/graphics-components 0.0.1-beta.2 → 0.0.1-beta.20

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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  # ⚙️ graphics-components
4
4
 
5
+ [![npm version](https://badge.fury.io/js/@reuters-graphics%2Fgraphics-components.svg)](https://badge.fury.io/js/@reuters-graphics%2Fgraphics-components)
6
+
5
7
  Svelte components, SCSS and more for Reuters Graphics pages.
6
8
 
7
9
  [Read the docs.](https://reuters-graphics.github.io/graphics-components/)
@@ -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 {};
@@ -22,5 +22,6 @@ export { default as SiteHeader } from "./components/SiteHeader/SiteHeader.svelte
22
22
  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
- export { getPhotoPackPropsFromDoc } from "./components/PhotoPack/docProps";
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. */
@@ -12,7 +17,7 @@ export let columnWidths = {
12
17
  wide: 930,
13
18
  wider: 1200,
14
19
  };
15
- import cssVariables from '$lib/actions/cssVariables/index.js';
20
+ import cssVariables from '../../actions/cssVariables/index.js';
16
21
  $: columnWidthVars = {
17
22
  'narrower-column-width': columnWidths.narrower + 'px',
18
23
  'narrow-column-width': columnWidths.narrow + 'px',
@@ -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: {
package/dist/index.js CHANGED
@@ -30,4 +30,5 @@ export { default as Video } from './components/Video/Video.svelte';
30
30
  export { default as Visible } from './components/Visible/Visible.svelte';
31
31
 
32
32
  // Utilities
33
- export { getPhotoPackPropsFromDoc } from './components/PhotoPack/docProps';
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.2",
3
+ "version": "0.0.1-beta.20",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",
@@ -11,10 +11,11 @@
11
11
  "build:package": "node ./bin/buildPackage/index.js",
12
12
  "build:docs": "build-storybook -o docs && touch ./docs/.nojekyll",
13
13
  "build": "npm-run-all build:package build:docs",
14
- "prepublishOnly": "npm run build:package"
14
+ "prepublishOnly": "npm run build:package",
15
+ "postversion": "git push origin && git push origin --tags"
15
16
  },
16
17
  "license": "MIT",
17
- "types": "dist/@types/index.d.ts",
18
+ "types": "./dist/@types/index.d.ts",
18
19
  "files": [
19
20
  "dist"
20
21
  ],
@@ -126,6 +127,7 @@
126
127
  "./components/Scroller/Embedded/index.svelte": "./dist/components/Scroller/Embedded/index.svelte",
127
128
  "./components/Scroller/Foreground.svelte": "./dist/components/Scroller/Foreground.svelte",
128
129
  "./components/Scroller/Scroller.svelte": "./dist/components/Scroller/Scroller.svelte",
130
+ "./components/Scroller/docProps.ts": "./dist/components/Scroller/docProps.ts",
129
131
  "./components/Sharer/Sharer.svelte": "./dist/components/Sharer/Sharer.svelte",
130
132
  "./components/Sharer/utils/copyToClipboard": "./dist/components/Sharer/utils/copyToClipboard.js",
131
133
  "./components/Sharer/utils/facebook": "./dist/components/Sharer/utils/facebook.js",
@@ -160,11 +162,11 @@
160
162
  "./components/SiteHeader/NavBar/utils": "./dist/components/SiteHeader/NavBar/utils/index.js",
161
163
  "./components/SiteHeader/SiteHeader.svelte": "./dist/components/SiteHeader/SiteHeader.svelte",
162
164
  "./components/SiteHeader/data.json": "./dist/components/SiteHeader/data.json",
163
- "./components/SiteHeader/scss/_breakpoints.scss": "./dist/components/SiteHeader/scss/_breakpoints.scss",
164
- "./components/SiteHeader/scss/_colors.scss": "./dist/components/SiteHeader/scss/_colors.scss",
165
- "./components/SiteHeader/scss/_eases.scss": "./dist/components/SiteHeader/scss/_eases.scss",
166
- "./components/SiteHeader/scss/_grids.scss": "./dist/components/SiteHeader/scss/_grids.scss",
167
- "./components/SiteHeader/scss/_z-indexes.scss": "./dist/components/SiteHeader/scss/_z-indexes.scss",
165
+ "./components/SiteHeader/scss/breakpoints": "./dist/components/SiteHeader/scss/_breakpoints.scss",
166
+ "./components/SiteHeader/scss/colors": "./dist/components/SiteHeader/scss/_colors.scss",
167
+ "./components/SiteHeader/scss/eases": "./dist/components/SiteHeader/scss/_eases.scss",
168
+ "./components/SiteHeader/scss/grids": "./dist/components/SiteHeader/scss/_grids.scss",
169
+ "./components/SiteHeader/scss/z-indexes": "./dist/components/SiteHeader/scss/_z-indexes.scss",
168
170
  "./components/SiteHeader/svgs/Close.svelte": "./dist/components/SiteHeader/svgs/Close.svelte",
169
171
  "./components/SiteHeader/svgs/Menu.svelte": "./dist/components/SiteHeader/svgs/Menu.svelte",
170
172
  "./components/Spinner/Spinner.svelte": "./dist/components/Spinner/Spinner.svelte",
@@ -177,34 +179,35 @@
177
179
  "./components/Video/Controls.svelte": "./dist/components/Video/Controls.svelte",
178
180
  "./components/Video/Video.svelte": "./dist/components/Video/Video.svelte",
179
181
  "./components/Visible/Visible.svelte": "./dist/components/Visible/Visible.svelte",
180
- "./scss/_mixins.scss": "./dist/scss/_mixins.scss",
181
- "./scss/_variables.scss": "./dist/scss/_variables.scss",
182
- "./scss/bootstrap/_main.scss": "./dist/scss/bootstrap/_main.scss",
183
- "./scss/bootstrap/_variables.scss": "./dist/scss/bootstrap/_variables.scss",
184
- "./scss/colours/thematic/_nord.scss": "./dist/scss/colours/thematic/_nord.scss",
185
- "./scss/colours/thematic/_tr.scss": "./dist/scss/colours/thematic/_tr.scss",
186
- "./scss/components/_hero-title.scss": "./dist/scss/components/_hero-title.scss",
187
- "./scss/fonts/_font-faces.scss": "./dist/scss/fonts/_font-faces.scss",
188
- "./scss/fonts/_mixins.scss": "./dist/scss/fonts/_mixins.scss",
189
- "./scss/fonts/_rules.scss": "./dist/scss/fonts/_rules.scss",
190
- "./scss/fonts/_variables.scss": "./dist/scss/fonts/_variables.scss",
191
- "./scss/main.scss": "./dist/scss/main.scss",
192
- "./scss/mixins/_block.scss": "./dist/scss/mixins/_block.scss",
193
- "./scss/mixins/_body-text.scss": "./dist/scss/mixins/_body-text.scss",
194
- "./scss/mixins/_graphic.scss": "./dist/scss/mixins/_graphic.scss",
195
- "./scss/mixins/_note-text.scss": "./dist/scss/mixins/_note-text.scss",
196
- "./scss/mixins/_visually-hidden.scss": "./dist/scss/mixins/_visually-hidden.scss",
197
- "./scss/spacers/_rules.scss": "./dist/scss/spacers/_rules.scss",
198
- "./scss/spacers/_variables.scss": "./dist/scss/spacers/_variables.scss",
199
- "./scss/typography/_box-shadow.scss": "./dist/scss/typography/_box-shadow.scss",
200
- "./scss/typography/_font-size.scss": "./dist/scss/typography/_font-size.scss",
201
- "./scss/typography/_letter-spacing.scss": "./dist/scss/typography/_letter-spacing.scss",
202
- "./scss/typography/_main.scss": "./dist/scss/typography/_main.scss",
203
- "./scss/typography/_mixins.scss": "./dist/scss/typography/_mixins.scss",
204
- "./scss/typography/_rules.scss": "./dist/scss/typography/_rules.scss",
205
- "./scss/typography/_text-shadow.scss": "./dist/scss/typography/_text-shadow.scss",
206
- "./scss/typography/_transform.scss": "./dist/scss/typography/_transform.scss",
207
- "./scss/typography/_variables.scss": "./dist/scss/typography/_variables.scss",
182
+ "./scss/mixins": "./dist/scss/_mixins.scss",
183
+ "./scss/variables": "./dist/scss/_variables.scss",
184
+ "./scss/bootstrap/main": "./dist/scss/bootstrap/_main.scss",
185
+ "./scss/bootstrap/variables": "./dist/scss/bootstrap/_variables.scss",
186
+ "./scss/colours/thematic/nord": "./dist/scss/colours/thematic/_nord.scss",
187
+ "./scss/colours/thematic/tr": "./dist/scss/colours/thematic/_tr.scss",
188
+ "./scss/components/hero-title": "./dist/scss/components/_hero-title.scss",
189
+ "./scss/fonts/font-faces": "./dist/scss/fonts/_font-faces.scss",
190
+ "./scss/fonts/mixins": "./dist/scss/fonts/_mixins.scss",
191
+ "./scss/fonts/rules": "./dist/scss/fonts/_rules.scss",
192
+ "./scss/fonts/variables": "./dist/scss/fonts/_variables.scss",
193
+ "./scss/main": "./dist/scss/main.scss",
194
+ "./scss/mixins/block": "./dist/scss/mixins/_block.scss",
195
+ "./scss/mixins/body-text": "./dist/scss/mixins/_body-text.scss",
196
+ "./scss/mixins/graphic": "./dist/scss/mixins/_graphic.scss",
197
+ "./scss/mixins/note-text": "./dist/scss/mixins/_note-text.scss",
198
+ "./scss/mixins/visually-hidden": "./dist/scss/mixins/_visually-hidden.scss",
199
+ "./scss/spacers/rules": "./dist/scss/spacers/_rules.scss",
200
+ "./scss/spacers/variables": "./dist/scss/spacers/_variables.scss",
201
+ "./scss/typography/box-shadow": "./dist/scss/typography/_box-shadow.scss",
202
+ "./scss/typography/font-size": "./dist/scss/typography/_font-size.scss",
203
+ "./scss/typography/letter-spacing": "./dist/scss/typography/_letter-spacing.scss",
204
+ "./scss/typography/main": "./dist/scss/typography/_main.scss",
205
+ "./scss/typography/mixins": "./dist/scss/typography/_mixins.scss",
206
+ "./scss/typography/rules": "./dist/scss/typography/_rules.scss",
207
+ "./scss/typography/text-shadow": "./dist/scss/typography/_text-shadow.scss",
208
+ "./scss/typography/transform": "./dist/scss/typography/_transform.scss",
209
+ "./scss/typography/variables": "./dist/scss/typography/_variables.scss",
208
210
  ".": "./dist/index.js"
209
- }
211
+ },
212
+ "svelte": "./dist/index.js"
210
213
  }