@reuters-graphics/graphics-components 2.0.1 → 2.0.2

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.
@@ -3,10 +3,16 @@ import customLayoutsDocs from "./stories/docs/customLayouts.md?raw";
3
3
  import snapWidthsDocs from "./stories/docs/snapWidths.md?raw";
4
4
  import Block from "./Block.svelte";
5
5
  import { withComponentDocs, withStoryDocs } from "$docs/utils/withParams.js";
6
+ import { toId } from "@storybook/csf";
6
7
  export const meta = {
7
8
  title: "Components/Page layout/Block",
8
9
  component: Block,
9
- ...withComponentDocs(componentDocs),
10
+ parameters: {
11
+ ...withComponentDocs(componentDocs).parameters,
12
+ canvasDocs: {
13
+ [toId("Components/Page layout/Block", "default")]: componentDocs
14
+ }
15
+ },
10
16
  argTypes: {
11
17
  width: {
12
18
  control: "select",
@@ -1,16 +1,19 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  export declare const meta: {
3
+ title: string;
4
+ component: typeof Block;
5
+ parameters: {
6
+ canvasDocs: {
7
+ [x: string]: any;
8
+ };
9
+ docs: any;
10
+ };
3
11
  argTypes: {
4
12
  width: {
5
13
  control: string;
6
14
  options: string[];
7
15
  };
8
16
  };
9
- parameters: {
10
- docs: any;
11
- };
12
- title: string;
13
- component: typeof Block;
14
17
  };
15
18
  declare const __propDef: {
16
19
  props: Record<string, never>;
@@ -31,7 +31,9 @@ const getReferrals = async () => {
31
31
  })
32
32
  );
33
33
  const data = await response.json();
34
- const articles = data.result.articles.filter((a) => a?.headline_category || a?.kicker?.name).filter((a) => a?.thumbnail?.renditions?.landscape?.["240w"]).filter((a) => !a?.content?.third_party).filter(articleIsNotCurrentPage).slice(0, number);
34
+ const articles = data.result.articles.filter((a) => a?.headline_category || a?.kicker?.name).filter(
35
+ (a) => a?.thumbnail?.renditions?.landscape?.["240w"] || a?.thumbnail?.resizer_url
36
+ ).filter((a) => !a?.content?.third_party).filter(articleIsNotCurrentPage).slice(0, number);
35
37
  referrals = articles;
36
38
  } catch {
37
39
  console.warn("Unable to fetch referral links.");
@@ -95,13 +97,24 @@ onMount(getReferrals);
95
97
  class="image-container block m-0 overflow-hidden relative"
96
98
  class:xs="{clientWidth && clientWidth < 450}"
97
99
  >
98
- <img
99
- class="block object-cover m-0 w-full"
100
- data-chromatic="ignore"
101
- src="{referral.thumbnail.renditions.landscape['240w']}"
102
- alt="{referral.thumbnail.caption ||
103
- referral.thumbnail.alt_text}"
104
- />
100
+ {#if referral.thumbnail.resizer_url}
101
+ <img
102
+ class="block object-cover m-0 w-full"
103
+ data-chromatic="ignore"
104
+ src="{referral.thumbnail
105
+ .resizer_url}&width=120&quality=80"
106
+ alt="{referral.thumbnail.caption ||
107
+ referral.thumbnail.alt_text}"
108
+ />
109
+ {:else}
110
+ <img
111
+ class="block object-cover m-0 w-full"
112
+ data-chromatic="ignore"
113
+ src="{referral.thumbnail.renditions.landscape['240w']}"
114
+ alt="{referral.thumbnail.caption ||
115
+ referral.thumbnail.alt_text}"
116
+ />
117
+ {/if}
105
118
  </div>
106
119
  </div>
107
120
  </a>
@@ -40,85 +40,3 @@ A more detailed example of using `Scroller` with graphics created by [ai2svelte]
40
40
  embedded="{false}"
41
41
  />
42
42
  ```
43
-
44
- When working with a ArchieML doc, here's an example of how you can tie your text into your steps.
45
-
46
- ```yaml
47
- # Google doc block
48
- Type: scroller
49
- ID: map-scrolly
50
- Step1Text: #### Step 1
51
-
52
- Lorem Ipsum
53
- :end
54
- AltText1: A map showing the Upper West side in New York City.
55
- :end
56
-
57
- Step2Text: #### Step 2
58
-
59
- Lorem Ipsum
60
- :end
61
- AltText2: The same map now highlights 98th Street.
62
- :end
63
-
64
- Step3Text: #### Step 3
65
-
66
- Lorem Ipsum
67
- :end
68
- AltText3: The same map now highlights three locations near 98th Street where something particulary important happened.
69
- :end
70
- ```
71
-
72
- ```svelte
73
- <!-- App.svelte -->
74
- <script>
75
- // Previos imports and stuff...
76
-
77
- // This should be already imported for you.
78
- import content from '$locales/en/content.json';
79
-
80
- // Get the data for the block in content by its ID
81
- const scrollerBlock = content.blocks.find(
82
- (block) => block.ID === 'map-scrolly'
83
- );
84
-
85
- // Now plug your text into your step foregrounds
86
- const steps = [
87
- {
88
- background: MyAiMap1,
89
- backgroundProps: { basePath: assets },
90
- foreground: scrollerBlock.Step1Text,
91
- altText: scrollerBlock.AltText1,
92
- },
93
- {
94
- background: MyAiMap2,
95
- backgroundProps: { basePath: assets },
96
- foreground: scrollerBlock.Step2Text,
97
- altText: scrollerBlock.AltText2,
98
- },
99
- {
100
- background: MyAiMap3,
101
- backgroundProps: { basePath: assets },
102
- foreground: scrollerBlock.Step3Text,
103
- altText: scrollerBlock.AltText3,
104
- },
105
- ];
106
- </script>
107
-
108
- {#each content.blocks as block}
109
- {#if block.Type === 'text'}
110
- <!-- ... other blocks -->
111
-
112
- <!-- Copy/paste into your blocks loop! -->
113
- {:else if block.Type === 'scroller' && block.ID === 'map-scrolly'}
114
- <Scroller
115
- steps="{steps}"
116
- backgroundWidth="fluid"
117
- foregroundPosition="middle"
118
- stackBackground="{true}"
119
- embedded="{false}"
120
- />
121
- <!-- END copy/paste -->
122
- {/if}
123
- {/each}
124
- ```
@@ -75,7 +75,7 @@ stackBackground: true
75
75
  stackBackground="{block.stackBackground === 'true'}"
76
76
  steps="{block.steps.map((step) => ({
77
77
  background: aiCharts[step.background],
78
- backgroundProps: assets || '/',
78
+ backgroundProps: { assetsPath: assets || '/' },
79
79
  foreground: step.text,
80
80
  altText: step.altText,
81
81
  }))}"
@@ -13,12 +13,19 @@
13
13
  <span>{story.title}</span>
14
14
  <time datetime="{story.display_time}">{getTime(story.display_time)}</time>
15
15
  </div>
16
- {#if thumbnail}
16
+ {#if thumbnail && (thumbnail.resizer_url || thumbnail?.renditions?.square?.['120w'])}
17
17
  <div class="thumbnail">
18
- <img
19
- src="{thumbnail.renditions.square['120w']}"
20
- alt="{thumbnail.alt_text}"
21
- />
18
+ {#if thumbnail.resizer_url}
19
+ <img
20
+ src="{thumbnail.resizer_url}&width=120&quality=80"
21
+ alt="{thumbnail.alt_text}"
22
+ />
23
+ {:else}
24
+ <img
25
+ src="{thumbnail.renditions.square['120w']}"
26
+ alt="{thumbnail.alt_text}"
27
+ />
28
+ {/if}
22
29
  </div>
23
30
  {/if}
24
31
  </a>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reuters-graphics/graphics-components",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "homepage": "https://reuters-graphics.github.io/graphics-components",
@@ -42,6 +42,7 @@
42
42
  "@storybook/blocks": "^8.4.4",
43
43
  "@storybook/builder-vite": "^8.4.4",
44
44
  "@storybook/components": "^8.4.4",
45
+ "@storybook/csf": "^0.1.12",
45
46
  "@storybook/manager-api": "^8.4.4",
46
47
  "@storybook/mdx2-csf": "^1.1.0",
47
48
  "@storybook/svelte": "^8.4.4",