diff --git a/packages/graphics-components/CHANGELOG.md b/packages/graphics-components/CHANGELOG.md index 4a5fdea..2aa9cd0 100644 --- a/packages/graphics-components/CHANGELOG.md +++ b/packages/graphics-components/CHANGELOG.md @@ -1,5 +1,23 @@ # @reuters-graphics/graphics-components +## 3.3.2 + +### Patch Changes + +- d3c501d: Switch casting as GeoJSON to data property + +## 3.3.1 + +### Patch Changes + +- b924478: Updates to blog component styles + +## 3.3.0 + +### Minor Changes + +- 8abe183: Adds graphics blog components + ## 3.2.1 ### Patch Changes diff --git a/packages/graphics-components/package.json b/packages/graphics-components/package.json index 78e1d85..1cecd04 100644 --- a/packages/graphics-components/package.json +++ b/packages/graphics-components/package.json @@ -1,6 +1,6 @@ { "name": "@reuters-graphics/graphics-components", - "version": "3.2.1", + "version": "3.3.2", "type": "module", "private": false, "homepage": "https://reuters-graphics.github.io/graphics-components", diff --git a/packages/graphics-components/src/components/BlogPost/BlogPost.mdx b/packages/graphics-components/src/components/BlogPost/BlogPost.mdx new file mode 100644 index 0000000..d0a8d1b --- /dev/null +++ b/packages/graphics-components/src/components/BlogPost/BlogPost.mdx @@ -0,0 +1,31 @@ +import { Meta, Canvas } from '@storybook/blocks'; + +import * as BlogPostStories from './BlogPost.stories.svelte'; + + + +# BlogPost + +The `BlogPost` component renders a single entry in a graphics blog page, including a headline, dateline, authors and a divider. Body content is passed as children. + +```svelte + + + + + +``` + +> **Important:** Do not change `slugTitle` after publishing. It is used to generate the post's anchor link — changing it will break any published links to the post. + + diff --git a/packages/graphics-components/src/components/BlogPost/BlogPost.stories.svelte b/packages/graphics-components/src/components/BlogPost/BlogPost.stories.svelte new file mode 100644 index 0000000..8022075 --- /dev/null +++ b/packages/graphics-components/src/components/BlogPost/BlogPost.stories.svelte @@ -0,0 +1,28 @@ + + + + + + + + diff --git a/packages/graphics-components/src/components/BlogPost/BlogPost.svelte b/packages/graphics-components/src/components/BlogPost/BlogPost.svelte new file mode 100644 index 0000000..4e7a7f6 --- /dev/null +++ b/packages/graphics-components/src/components/BlogPost/BlogPost.svelte @@ -0,0 +1,93 @@ + + +
+ + + {@render children?.()} +
+ +{#if !isLastPost} +
+{/if} + + diff --git a/packages/graphics-components/src/components/BlogPost/CopyLink.svelte b/packages/graphics-components/src/components/BlogPost/CopyLink.svelte new file mode 100644 index 0000000..e280d0b --- /dev/null +++ b/packages/graphics-components/src/components/BlogPost/CopyLink.svelte @@ -0,0 +1,128 @@ + + + + + diff --git a/packages/graphics-components/src/components/BlogPost/PostHeadline.svelte b/packages/graphics-components/src/components/BlogPost/PostHeadline.svelte new file mode 100644 index 0000000..3b00018 --- /dev/null +++ b/packages/graphics-components/src/components/BlogPost/PostHeadline.svelte @@ -0,0 +1,173 @@ + + + +
+
+ +
+ +
+ {#if hed} +

+ + {hedMain} + {hedWidow} + + +

+ {/if} +
+ +
+
+ + diff --git a/packages/graphics-components/src/components/BlogPost/utils.ts b/packages/graphics-components/src/components/BlogPost/utils.ts new file mode 100644 index 0000000..c9bc5d7 --- /dev/null +++ b/packages/graphics-components/src/components/BlogPost/utils.ts @@ -0,0 +1,7 @@ +/** + * Converts a date string to a short date format. + * @param d - The date string to be converted. + * @returns The short date format string. + */ +export const getShortDate = (d: string) => + new Date(d).toISOString().split('T')[0]; diff --git a/packages/graphics-components/src/components/BlogTOC/BlogTOC.mdx b/packages/graphics-components/src/components/BlogTOC/BlogTOC.mdx new file mode 100644 index 0000000..2abd80a --- /dev/null +++ b/packages/graphics-components/src/components/BlogTOC/BlogTOC.mdx @@ -0,0 +1,42 @@ +import { Meta, Canvas } from '@storybook/blocks'; + +import * as BlogTOCStories from './BlogTOC.stories.svelte'; + + + +# BlogTOC + +The `BlogTOC` component renders a collapsible table of contents for a graphics blog page, listing all posts sorted chronologically. It only renders when there are two or more posts. + +```svelte + + + +``` + +The `base` prop should be set to your SvelteKit `base` path (e.g. `"/graphics"`) so that post links resolve correctly. + +Each post in the `posts` array must have: + +- `title` — the display title +- `slugTitle` — used to generate the anchor link; **do not change after publishing** +- `publishTime` — an ISO datetime string used for sorting and the dateline + + diff --git a/packages/graphics-components/src/components/BlogTOC/BlogTOC.stories.svelte b/packages/graphics-components/src/components/BlogTOC/BlogTOC.stories.svelte new file mode 100644 index 0000000..e2b9c6d --- /dev/null +++ b/packages/graphics-components/src/components/BlogTOC/BlogTOC.stories.svelte @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + diff --git a/packages/graphics-components/src/components/BlogTOC/BlogTOC.svelte b/packages/graphics-components/src/components/BlogTOC/BlogTOC.svelte new file mode 100644 index 0000000..7dc25b1 --- /dev/null +++ b/packages/graphics-components/src/components/BlogTOC/BlogTOC.svelte @@ -0,0 +1,275 @@ + + +{#if contents.length > 1} + +
+
+
+ +
+ +
+ {#if showContents} +
{ + scrollPos = e.currentTarget.scrollTop; + }} + > + + + {#if scrollPos > 10 && listHeight > maxHeight} +
+ +
+ {/if} + + {#if listHeight > maxHeight && scrollPos < 0.95 * (listHeight - maxHeight)} +
+ +
+ {/if} +
+ {/if} +
+
+
+
+{/if} + + diff --git a/packages/graphics-components/src/components/BlogTOC/TOCList.svelte b/packages/graphics-components/src/components/BlogTOC/TOCList.svelte new file mode 100644 index 0000000..08c87ec --- /dev/null +++ b/packages/graphics-components/src/components/BlogTOC/TOCList.svelte @@ -0,0 +1,121 @@ + + + +
+ {#each dates as date} +
+ + + +
+ {date.date} +
+ {#each date.events as event} + + {/each} +
+ {/each} +
+
+ + diff --git a/packages/graphics-components/src/components/Byline/Byline.svelte b/packages/graphics-components/src/components/Byline/Byline.svelte index c67cb91..1d722e2 100644 --- a/packages/graphics-components/src/components/Byline/Byline.svelte +++ b/packages/graphics-components/src/components/Byline/Byline.svelte @@ -13,7 +13,7 @@ /** * Publish time as a datetime string. */ - publishTime: string; + publishTime?: string; /** * Update time as a datetime string. */ @@ -52,7 +52,7 @@ let { authors = [], - publishTime, + publishTime = '', updateTime, align = 'auto', id = '', diff --git a/packages/graphics-components/src/components/ClockWall/Clock.svelte b/packages/graphics-components/src/components/ClockWall/Clock.svelte new file mode 100644 index 0000000..11c75c3 --- /dev/null +++ b/packages/graphics-components/src/components/ClockWall/Clock.svelte @@ -0,0 +1,264 @@ + + +
+ {#if showClock} + + + + + + + + + + + + + + + + + + + + {#each Array(12) as _, i (i)} + + {/each} + + + + + + + + + + + + + + {/if} +
+

+ {name} +

+

+ {time} +

+
+
+ + diff --git a/packages/graphics-components/src/components/ClockWall/ClockWall.mdx b/packages/graphics-components/src/components/ClockWall/ClockWall.mdx new file mode 100644 index 0000000..a005021 --- /dev/null +++ b/packages/graphics-components/src/components/ClockWall/ClockWall.mdx @@ -0,0 +1,27 @@ +import { Meta, Canvas } from '@storybook/blocks'; + +import * as ClockWallStories from './ClockWall.stories.svelte'; + + + +# ClockWall + +The `ClockWall` component displays a row of analog clocks for different cities and timezones. Use it paired with the overall headline of a graphics blog page to show the time of multiple cities involved in a breaking news event. + +Use the [IANA tz database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) to find valid `tzIdentifier` strings. + +```svelte + + + +``` + + diff --git a/packages/graphics-components/src/components/ClockWall/ClockWall.stories.svelte b/packages/graphics-components/src/components/ClockWall/ClockWall.stories.svelte new file mode 100644 index 0000000..328ffd5 --- /dev/null +++ b/packages/graphics-components/src/components/ClockWall/ClockWall.stories.svelte @@ -0,0 +1,21 @@ + + + diff --git a/packages/graphics-components/src/components/ClockWall/ClockWall.svelte b/packages/graphics-components/src/components/ClockWall/ClockWall.svelte new file mode 100644 index 0000000..d9f3ddd --- /dev/null +++ b/packages/graphics-components/src/components/ClockWall/ClockWall.svelte @@ -0,0 +1,61 @@ + + + +
+ {#each cities as city (city.tzIdentifier)} + + {/each} +
+
+ + diff --git a/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.mdx b/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.mdx new file mode 100644 index 0000000..83bdafd --- /dev/null +++ b/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.mdx @@ -0,0 +1,19 @@ +import { Meta, Canvas } from '@storybook/blocks'; + +import * as KinesisLogoStories from './KinesisLogo.stories.svelte'; + + + +# KinesisLogo + +The `KinesisLogo` component contains the official Kinesis logo. + +```svelte + + + +``` + + diff --git a/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.stories.svelte b/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.stories.svelte new file mode 100644 index 0000000..1d14157 --- /dev/null +++ b/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.stories.svelte @@ -0,0 +1,14 @@ + + + diff --git a/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.svelte b/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.svelte new file mode 100644 index 0000000..52f527b --- /dev/null +++ b/packages/graphics-components/src/components/KinesisLogo/KinesisLogo.svelte @@ -0,0 +1,140 @@ + + + + + + diff --git a/packages/graphics-components/src/components/TileMap/TileMap.mdx b/packages/graphics-components/src/components/TileMap/TileMap.mdx index cee4dbf..4057a4b 100644 --- a/packages/graphics-components/src/components/TileMap/TileMap.mdx +++ b/packages/graphics-components/src/components/TileMap/TileMap.mdx @@ -53,13 +53,16 @@ Disable interaction for static maps: Use the `TileMapLayer` component to add GeoJSON data to your map. You can pass GeoJSON data directly or fetch it from a URL. Layer rendering order will directly correspond to the order in which you add the layers in the code. +> **Note for TypeScript users:** When passing GeoJSON data objects, you'll need to type cast them using `as GeoJSON` to ensure TypeScript recognizes the correct type. This provides better type safety and error messages. See examples below. + ### Basic example with local data ```svelte -