From b65ff1ffdb23e51a4c45e5b5b673f11b5f2525c9 Mon Sep 17 00:00:00 2001 From: MinamiFunakoshiTR Date: Tue, 11 Mar 2025 13:34:43 -0700 Subject: [PATCH 01/47] cleans up old .md files --- src/components/Analytics/Analytics.mdx | 4 +-- src/components/Analytics/Analytics.svelte | 3 +- .../Analytics/stories/docs/component.md | 11 ------- .../Analytics/stories/docs/environments.md | 17 ---------- .../Analytics/stories/docs/multipage.md | 31 ------------------- 5 files changed, 4 insertions(+), 62 deletions(-) delete mode 100644 src/components/Analytics/stories/docs/component.md delete mode 100644 src/components/Analytics/stories/docs/environments.md delete mode 100644 src/components/Analytics/stories/docs/multipage.md diff --git a/src/components/Analytics/Analytics.mdx b/src/components/Analytics/Analytics.mdx index 8b39f502..60e7afd2 100644 --- a/src/components/Analytics/Analytics.mdx +++ b/src/components/Analytics/Analytics.mdx @@ -6,7 +6,7 @@ import * as AnalyticsStories from './Analytics.stories.svelte'; # Analytics -Add Google and Chartbeat analytics to your page. +The `Analytics` component adds Google and Chartbeat analytics to your page. ```svelte - - - -``` diff --git a/src/components/Analytics/stories/docs/environments.md b/src/components/Analytics/stories/docs/environments.md deleted file mode 100644 index 74089219..00000000 --- a/src/components/Analytics/stories/docs/environments.md +++ /dev/null @@ -1,17 +0,0 @@ -Generally, you only want to send page analytics in production environments. - -In a SvelteKit context, you can use `$app` stores to restrict when you send analytics. - -For example, the following excludes analytics from pages in development or hosted on our preview server: - -```svelte - - -{#if !dev && $page.url?.hostname !== 'graphics.thomsonreuters.com'} - -{/if} -``` diff --git a/src/components/Analytics/stories/docs/multipage.md b/src/components/Analytics/stories/docs/multipage.md deleted file mode 100644 index a3223927..00000000 --- a/src/components/Analytics/stories/docs/multipage.md +++ /dev/null @@ -1,31 +0,0 @@ -If you're using analytics to measure a multipage newsapp that uses [client-side routing](https://kit.svelte.dev/docs/glossary#routing), then you may need to trigger analytics after virtual page navigation. - -This component also exports a function you can call to register pageviews. - -For example, here's how you can use SvelteKit's [`afterNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-afternavigate) lifecycle to capture additional pageviews: - -```svelte - - - -``` From f9cce65f66f96ddaff7f8b8c383f10232b39a980 Mon Sep 17 00:00:00 2001 From: MinamiFunakoshiTR Date: Tue, 11 Mar 2025 14:33:50 -0700 Subject: [PATCH 02/47] deletes .md files, clarifies docs --- src/components/Article/Article.mdx | 36 ++++---- src/components/Article/Article.stories.svelte | 56 ++++++------ src/components/Article/Article.svelte | 4 +- .../Article/stories/docs/component.md | 13 --- .../Article/stories/docs/customWellWidths.md | 87 ------------------- 5 files changed, 49 insertions(+), 147 deletions(-) delete mode 100644 src/components/Article/stories/docs/component.md delete mode 100644 src/components/Article/stories/docs/customWellWidths.md diff --git a/src/components/Article/Article.mdx b/src/components/Article/Article.mdx index 9a3970e5..b5defaa4 100644 --- a/src/components/Article/Article.mdx +++ b/src/components/Article/Article.mdx @@ -6,9 +6,9 @@ import * as ArticleStories from './Article.stories.svelte'; # Article -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. +The `Article` component contains all the contents of our story. -> πŸ“Œ In most cases, **you won't need to mess with the `Article` component** because it's already included in our rigs for you! +> πŸ“Œ In most cases, **you don't need to mess with the `Article` component** because it's already set up in the Graphics Kit. ```svelte
- +
``` -## Custom well widths +## Custom column widths -The `Article` component also creates several column dimensions inside our article well. The standard widths of columns follow a basic class scheme: +The `Article` component also establishes the widths of columns that contain individual sections of the story, such as text, photos, and charts. The default column widths follow a basic class scheme: -- `narrower` A bit narrower than narrow... -- `narrow` A bit narrower than the text column -- `normal` **The main width of the body text column** -- `wide` A bit wider than the text column +- `narrower` The narrowest... +- `narrow` A bit narrower than the default body text column +- `normal` **The default width of the body text column** +- `wide` A bit wider - `wider` A bit wider than wide... - `widest` Edge-to-edge, but _excluding_ the left and right padding on `Article` - `fluid` Fully edge-to-edge -When combined with the `Block` component, you can set custom column widths by passing an object to the `columnWidths` prop with pixel values for the `narrower`, `narrow`, `normal`, `wide` and `wider` column widths. +You can set custom column widths by passing an object to the `columnWidths` prop with pixel values for the `narrower`, `narrow`, `normal`, `wide` and `wider` classes. These can then be used by the `Block` component or other elements housed inside `
`. -> **For most pages, you shouldn't customise the column widths.** Other tools, like our AI templates, use our default column widths, so customising those widths here has downstream consequences for graphics made outside your code. The main exception is SREP stories. +> **For most Graphics Kit pages, you shouldn't customise the column widths.** Other Reuters tools, like our AI templates, use our default column widths, so customising those widths here has downstream consequences for graphics made outside Graphics Kit. The main exception is SREP stories. ```svelte +
+ @@ -58,11 +60,11 @@ When combined with the `Block` component, you can set custom column widths by pa
``` -If you're not using our `Block` component, you can still inherit the column widths from `Article` to create your own custom container with the article well dimensions by using [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) like this: +If you're not using our `Block` component, you can still inherit the column widths from `Article` and create your own custom containers by using [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) like this: ```svelte
- +
``` -... or you can make your component entirely configurable within the article well doing something like this: +... or you can make your column widths entirely configurable by adding classes and manually specifying widths: ```svelte
- +
``` -Here's an example of how custom\* `columnWidths` can be used to change the article well columns: +Here's an example of how custom `columnWidths` can be used to change column widths: + + diff --git a/src/components/Article/Article.stories.svelte b/src/components/Article/Article.stories.svelte index c0683455..79d69c36 100644 --- a/src/components/Article/Article.stories.svelte +++ b/src/components/Article/Article.stories.svelte @@ -2,36 +2,25 @@ import { defineMeta } from '@storybook/addon-svelte-csf'; import Block from '../Block/Block.svelte'; import Article from './Article.svelte'; - // @ts-ignore raw - import customWellWidthsDocs from './stories/docs/customWellWidths.md?raw'; - - import { withComponentDocs, withStoryDocs } from '$docs/utils/withParams.js'; const { Story } = defineMeta({ - title: 'Components/Page Layout/Article', + title: 'Components/Page layout/Article', component: Article, }); - - - +
-
Article container
+
Article well
⇀15px padding
- + +

Default column widths

+
narrower @@ -43,22 +32,23 @@ fluid
+

Custom column widths

- narrower* - narrow* - normal* - wide* - wider* + narrower + narrow + normal + wide + wider widest fluid
@@ -66,6 +56,13 @@ -``` - -... or you can make your component entirely configurable within the article well doing something like this: - -```svelte - - -
- -
- - -``` - -Here's an example of how custom\* `columnWidths` can be used to change the article well columns: From 221bb70a000be94b4daeddd9f1ba132141d68b6d Mon Sep 17 00:00:00 2001 From: MinamiFunakoshiTR Date: Wed, 12 Mar 2025 15:53:46 -0700 Subject: [PATCH 03/47] svelte 5 set up but before/after not quite working --- src/components/BeforeAfter/BeforeAfter.mdx | 103 +++++++ .../BeforeAfter/BeforeAfter.stories.svelte | 51 ++-- src/components/BeforeAfter/BeforeAfter.svelte | 256 +++++++++--------- .../{stories => images}/myrne-after.jpg | Bin .../{stories => images}/myrne-before.jpg | Bin .../stories/docs/ariaDescriptions.md | 35 --- .../BeforeAfter/stories/docs/component.md | 15 - .../BeforeAfter/stories/docs/withOverlays.md | 33 --- src/components/Byline/Byline.svelte | 14 +- 9 files changed, 258 insertions(+), 249 deletions(-) create mode 100644 src/components/BeforeAfter/BeforeAfter.mdx rename src/components/BeforeAfter/{stories => images}/myrne-after.jpg (100%) rename src/components/BeforeAfter/{stories => images}/myrne-before.jpg (100%) delete mode 100644 src/components/BeforeAfter/stories/docs/ariaDescriptions.md delete mode 100644 src/components/BeforeAfter/stories/docs/component.md delete mode 100644 src/components/BeforeAfter/stories/docs/withOverlays.md diff --git a/src/components/BeforeAfter/BeforeAfter.mdx b/src/components/BeforeAfter/BeforeAfter.mdx new file mode 100644 index 00000000..dfb459f8 --- /dev/null +++ b/src/components/BeforeAfter/BeforeAfter.mdx @@ -0,0 +1,103 @@ +import { Meta, Canvas } from '@storybook/blocks'; + +import * as BeforeAfterStories from './BeforeAfter.stories.svelte'; + + + +# BeforeAfter + +The `BeforeAfter` component shows a before-and-after comparison of an image. + +```svelte + + + +``` + + + +## Using with overlays + +Add overlays with the `beforeOverlay` and `afterOverlay` slots and a caption to the `caption` slot, then style these elements to match your page design as below. + +```svelte + +
+

July 7, 2020

+

Initially, this site was far smaller.

+
+
+

Oct. 20, 2020

+

But then forces built up.

+
+

Photos by MAXAR Technologies, 2021.

+
+ + +``` + + + +## Adding ARIA descriptions + +Use text elements in your overlays as [ARIA descriptions](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby) for your images by setting an ID on text elements within each overlay with the `description` [slot prop](https://svelte.dev/tutorial/slot-props). + +> **πŸ’‘ TIP:** You must always use the `beforeAlt` / `afterAlt` props to label your image for visually impaired readers, but you can use these descriptions to provide more information or context that the reader might also need. + +```svelte + +
+

July 7, 2020

+

Initially, this site was far smaller.

+
+
+

Oct. 20, 2020

+

But then forces built up.

+
+

Photos by MAXAR Technologies, 2021.

+
+ + +``` + + diff --git a/src/components/BeforeAfter/BeforeAfter.stories.svelte b/src/components/BeforeAfter/BeforeAfter.stories.svelte index d2f79821..4b4ed935 100644 --- a/src/components/BeforeAfter/BeforeAfter.stories.svelte +++ b/src/components/BeforeAfter/BeforeAfter.stories.svelte @@ -1,19 +1,10 @@ - - - - - +
@@ -81,19 +64,19 @@ - + -
+

On July 7, 2020, the base contained only a few transport vehicles.

-
+

diff --git a/src/components/BeforeAfter/BeforeAfter.svelte b/src/components/BeforeAfter/BeforeAfter.svelte index e6229af5..293bb582 100644 --- a/src/components/BeforeAfter/BeforeAfter.svelte +++ b/src/components/BeforeAfter/BeforeAfter.svelte @@ -1,73 +1,92 @@ - {#if beforeSrc && beforeAlt && afterSrc && afterAlt} -

- +
+
+ {afterAlt} - + {beforeAlt} - {#if $$slots.beforeOverlay} + {#if beforeOverlay}
- + {@render beforeOverlay()}
{/if} - {#if $$slots.afterOverlay} + {#if afterOverlay}
- + {@render afterOverlay()}
{/if}
- {#if $$slots.caption} - -