Merge branch 'migrate-to-svelte5' into mf-seo
This commit is contained in:
commit
95b08c9fa3
52 changed files with 897 additions and 581 deletions
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
|
@ -12,7 +12,7 @@
|
|||
"editor.wordWrap": "on"
|
||||
},
|
||||
"[svelte]": {
|
||||
"editor.defaultFormatter": "svelte.svelte-vscode"
|
||||
},
|
||||
"editor.defaultFormatter": "svelte.svelte-vscode"
|
||||
},
|
||||
"typescript.tsdk": "node_modules/typescript/lib"
|
||||
}
|
||||
|
|
|
|||
20
src/app.html
20
src/app.html
|
|
@ -1,11 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body>
|
||||
%sveltekit.body%
|
||||
</body>
|
||||
</html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body>
|
||||
%sveltekit.body%
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<div data-freestar-ad={dataFreestarAd || null} id={adId}></div>
|
||||
<div data-freestar-ad="{dataFreestarAd || null}" id="{adId}"></div>
|
||||
|
||||
<style>
|
||||
:global(div.freestar-adslot:has(.unfulfilled-ad)) {
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ You may add **up to three** inline ads per page, but must set the `n` prop on mu
|
|||
|
||||
```svelte
|
||||
<!-- First inline ad on the page -->
|
||||
<InlineAd n={1} />
|
||||
<InlineAd n="{1}" />
|
||||
<!-- ... second ... -->
|
||||
<InlineAd n={2} />
|
||||
<InlineAd n="{2}" />
|
||||
<!-- ... third and final. -->
|
||||
<InlineAd n={3} />
|
||||
<InlineAd n="{3}" />
|
||||
```
|
||||
|
||||
<Canvas of={InlineAdStories.Demo} />
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
<svelte:window bind:innerWidth={windowWidth} />
|
||||
<svelte:window bind:innerWidth="{windowWidth}" />
|
||||
|
||||
<div
|
||||
class="freestar-adslot leaderboard__sticky {cls}"
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
let adType = $derived(getAdType(placementName));
|
||||
</script>
|
||||
|
||||
<svelte:window bind:innerWidth={windowWidth} />
|
||||
<svelte:window bind:innerWidth="{windowWidth}" />
|
||||
|
||||
{#if windowWidth}
|
||||
{#key placementName}
|
||||
|
|
|
|||
|
|
@ -40,13 +40,13 @@ When combined with the `Block` component, you can set custom column widths by pa
|
|||
|
||||
```svelte
|
||||
<Article
|
||||
columnWidths={{
|
||||
columnWidths="{{
|
||||
narrower: 310,
|
||||
narrow: 450,
|
||||
normal: 550,
|
||||
wide: 675,
|
||||
wider: 1400,
|
||||
}}
|
||||
}}"
|
||||
>
|
||||
<Block width="narrower" />
|
||||
<Block width="narrow" />
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Venison shoulder *ham hock ham leberkas*. Flank beef ribs fatback, jerky meatbal
|
|||
|
||||
## Using with ArchieML docs
|
||||
|
||||
With the graphics kit, you'll likely get your text value from an ArchieML doc.
|
||||
With the Graphics Kit, you'll likely get your text value from an ArchieML doc...
|
||||
|
||||
```yaml
|
||||
# ArchieML doc
|
||||
|
|
|
|||
53
src/components/Byline/Byline.mdx
Normal file
53
src/components/Byline/Byline.mdx
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import { Meta, Canvas } from '@storybook/blocks';
|
||||
|
||||
import * as BylineStories from './Byline.stories.svelte';
|
||||
|
||||
<Meta of={BylineStories} />
|
||||
|
||||
# Byline
|
||||
|
||||
The `Byline` component adds a byline, published and updated datelines to your page.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { Byline } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<Byline
|
||||
authors={[
|
||||
'Dea Bankova',
|
||||
'Prasanta Kumar Dutta',
|
||||
'Anurag Rao',
|
||||
'Mariano Zafra',
|
||||
]}
|
||||
publishTime="2021-09-12T00:00:00.000Z"
|
||||
updateTime="2021-09-12T12:57:00.000Z"
|
||||
/>
|
||||
```
|
||||
|
||||
<Canvas of={BylineStories.Demo} />
|
||||
|
||||
## Cutomisation
|
||||
|
||||
Use [snippets](https://svelte.dev/docs/svelte/snippet) to customise the byline, published and updated datelines.
|
||||
|
||||
```svelte
|
||||
<Byline publishTime="2021-09-12T00:00:00Z" updateTime="2021-09-12T13:57:00Z">
|
||||
<!-- Optional custom byline -->
|
||||
{#snippet byline()}
|
||||
<strong>BY REUTERS GRAPHICS</strong>
|
||||
{/snippet}
|
||||
|
||||
<!-- Optional custom published dateline -->
|
||||
{#snippet published()}
|
||||
PUBLISHED on some custom date and time
|
||||
{/snippet}
|
||||
|
||||
<!-- Optional custom updated dateline -->
|
||||
{#snippet updated()}
|
||||
<em>Updated every 5 minutes</em>
|
||||
{/snippet}
|
||||
</Byline>
|
||||
```
|
||||
|
||||
<Canvas of={BylineStories.Customised} />
|
||||
|
|
@ -1,17 +1,11 @@
|
|||
<script module lang="ts">
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
import Byline from './Byline.svelte';
|
||||
// @ts-ignore raw
|
||||
import componentDocs from './stories/docs/component.md?raw';
|
||||
|
||||
import { withComponentDocs } from '$docs/utils/withParams.js';
|
||||
|
||||
import type { ComponentProps } from 'svelte';
|
||||
|
||||
const { Story } = defineMeta({
|
||||
title: 'Components/Text elements/Byline',
|
||||
component: Byline,
|
||||
...withComponentDocs(componentDocs),
|
||||
tags: ['autodocs'],
|
||||
argTypes: {
|
||||
align: {
|
||||
control: 'select',
|
||||
|
|
@ -21,17 +15,12 @@
|
|||
});
|
||||
</script>
|
||||
|
||||
{#snippet template(args: ComponentProps<Byline>)}
|
||||
<Byline {...args} />
|
||||
{/snippet}
|
||||
|
||||
<Story
|
||||
name="Default"
|
||||
name="Demo"
|
||||
args={{
|
||||
align: 'left',
|
||||
authors: [
|
||||
'Dea Bankova',
|
||||
'Aditi Bhandari',
|
||||
'Prasanta Kumar Dutta',
|
||||
'Anurag Rao',
|
||||
'Mariano Zafra',
|
||||
|
|
@ -39,5 +28,18 @@
|
|||
publishTime: new Date('2021-09-12').toISOString(),
|
||||
updateTime: new Date('2021-09-12T13:57:00').toISOString(),
|
||||
}}
|
||||
children={template}
|
||||
/>
|
||||
|
||||
<Story name="Customised" tags={['!autodocs', '!dev']}>
|
||||
<Byline publishTime="2021-09-12T00:00:00Z" updateTime="2021-09-12T13:57:00Z">
|
||||
{#snippet byline()}
|
||||
<strong>BY REUTERS GRAPHICS</strong>
|
||||
{/snippet}
|
||||
{#snippet published()}
|
||||
PUBLISHED on some custom date and time
|
||||
{/snippet}
|
||||
{#snippet updated()}
|
||||
<em>Updated every 5 minutes</em>
|
||||
{/snippet}
|
||||
</Byline>
|
||||
</Story>
|
||||
|
|
|
|||
|
|
@ -4,63 +4,91 @@
|
|||
import Block from '../Block/Block.svelte';
|
||||
import slugify from 'slugify';
|
||||
import { apdate } from 'journalize';
|
||||
import type { Snippet } from 'svelte';
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
* Array of author names, which will be slugified to create links to Reuters author pages
|
||||
*/
|
||||
authors?: string[];
|
||||
/**
|
||||
* Publish time as a datetime string.
|
||||
*/
|
||||
publishTime: string;
|
||||
/**
|
||||
* Update time as a datetime string.
|
||||
* @type {string}
|
||||
*/
|
||||
updateTime: string;
|
||||
/**
|
||||
* Alignment of the byline.
|
||||
* @type {string}
|
||||
*/
|
||||
align?: 'left' | 'center';
|
||||
/**
|
||||
* Add an id to to target with custom CSS.
|
||||
* @type {string}
|
||||
*/
|
||||
id?: string;
|
||||
/**
|
||||
* Add extra classes to target with custom CSS.
|
||||
* @type {string}
|
||||
*/
|
||||
cls?: string;
|
||||
/**
|
||||
* Custom function that returns an author page URL.
|
||||
*/
|
||||
getAuthorPage?: (author: string) => string;
|
||||
/**
|
||||
* Optional snippet for a custom byline.
|
||||
*/
|
||||
byline?: Snippet | null;
|
||||
/**
|
||||
* Optional snippet for a custom published dateline.
|
||||
*/
|
||||
// Specify that this prop should have the type of a Svelte snippet, i.e. basic html
|
||||
published?: Snippet | null;
|
||||
/**
|
||||
* Optional snippet for a custom updated dateline.
|
||||
*/
|
||||
updated?: Snippet | null;
|
||||
}
|
||||
|
||||
let {
|
||||
authors = [],
|
||||
publishTime,
|
||||
updateTime,
|
||||
align = 'left',
|
||||
id = '',
|
||||
cls = '',
|
||||
getAuthorPage = (author: string): string => {
|
||||
const authorSlug = slugify(author.trim(), { lower: true });
|
||||
return `https://www.reuters.com/authors/${authorSlug}/`;
|
||||
},
|
||||
byline = null,
|
||||
published = null,
|
||||
updated = null,
|
||||
}: Props = $props();
|
||||
|
||||
let alignmentClass = $derived(align === 'left' ? 'text-left' : 'text-center');
|
||||
|
||||
/**
|
||||
* Array of author names, which will be slugified to create links to Reuters author pages
|
||||
/* Date validation and formatter functions
|
||||
*/
|
||||
export let authors: string[] = [];
|
||||
/**
|
||||
* Publish time as a datetime string.
|
||||
* @type {string}
|
||||
*/
|
||||
export let publishTime: string = '';
|
||||
/**
|
||||
* Update time as a datetime string.
|
||||
* @type {string}
|
||||
*/
|
||||
export let updateTime: string = '';
|
||||
/**
|
||||
* Alignment of the byline.
|
||||
* @type {string}
|
||||
*/
|
||||
export let align: 'left' | 'center' = 'left';
|
||||
/**
|
||||
* Add an id to to target with custom CSS.
|
||||
* @type {string}
|
||||
*/
|
||||
export let id: string = '';
|
||||
/**
|
||||
* Add extra classes to target with custom CSS.
|
||||
* @type {string}
|
||||
*/
|
||||
let cls: string = '';
|
||||
export { cls as class };
|
||||
|
||||
/**
|
||||
* Custom function that returns an author page URL.
|
||||
* @param author
|
||||
*/
|
||||
export let getAuthorPage = (author: string): string => {
|
||||
const authorSlug = slugify(author.trim(), { lower: true });
|
||||
return `https://www.reuters.com/authors/${authorSlug}/`;
|
||||
};
|
||||
|
||||
$: alignmentClass = align === 'left' ? 'text-left' : 'text-center';
|
||||
|
||||
const isValidDate = (datetime) => {
|
||||
const isValidDate = (datetime: string) => {
|
||||
if (!datetime) return false;
|
||||
if (!Date.parse(datetime)) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
const formatTime = (datetime) =>
|
||||
const formatTime = (datetime: string) =>
|
||||
new Date(datetime).toLocaleTimeString([], {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
timeZoneName: 'short',
|
||||
});
|
||||
|
||||
const areSameDay = (first, second) =>
|
||||
const areSameDay = (first: Date, second: Date) =>
|
||||
first.getFullYear() === second.getFullYear() &&
|
||||
first.getMonth() === second.getMonth() &&
|
||||
first.getDate() === second.getDate();
|
||||
|
|
@ -69,16 +97,16 @@
|
|||
<Block {id} class="byline-container {alignmentClass} {cls}" width="normal">
|
||||
<aside class="article-metadata font-subhed">
|
||||
<div class="byline body-caption fmb-1">
|
||||
{#if $$slots.byline}
|
||||
{#if byline}
|
||||
<!-- Custom byline -->
|
||||
<slot name="byline" />
|
||||
{@render byline()}
|
||||
{:else}
|
||||
By
|
||||
{#if authors.length > 0}
|
||||
{#each authors as author, i}
|
||||
<a
|
||||
class="no-underline whitespace-nowrap text-primary font-bold"
|
||||
href="{getAuthorPage(author)}"
|
||||
href={getAuthorPage(author)}
|
||||
rel="author"
|
||||
>
|
||||
{author.trim()}</a
|
||||
|
|
@ -95,15 +123,17 @@
|
|||
{/if}
|
||||
</div>
|
||||
<div class="dateline body-caption fmt-0">
|
||||
{#if $$slots.published}
|
||||
{#if published}
|
||||
<div class="whitespace-nowrap inline-block">
|
||||
<!-- Custom published dateline -->
|
||||
<slot name="published" />
|
||||
<!-- Custom published dateline snippet -->
|
||||
<time datetime={publishTime}>
|
||||
{@render published()}
|
||||
</time>
|
||||
</div>
|
||||
{:else if isValidDate(publishTime)}
|
||||
<div class="whitespace-nowrap inline-block">
|
||||
Published
|
||||
<time datetime="{publishTime}">
|
||||
<time datetime={publishTime}>
|
||||
{#if isValidDate(updateTime)}
|
||||
{apdate(new Date(publishTime))}
|
||||
{:else}
|
||||
|
|
@ -114,15 +144,17 @@
|
|||
</time>
|
||||
</div>
|
||||
{/if}
|
||||
{#if $$slots.updated}
|
||||
{#if updated}
|
||||
<div class="whitespace-nowrap inline-block">
|
||||
<!-- Custom updated dateline -->
|
||||
<slot name="updated" />
|
||||
<!-- Custom updated dateline snippet -->
|
||||
<time datetime={updateTime}>
|
||||
{@render updated()}
|
||||
</time>
|
||||
</div>
|
||||
{:else if isValidDate(publishTime) && isValidDate(updateTime)}
|
||||
<div class="whitespace-nowrap inline-block">
|
||||
Last updated
|
||||
<time datetime="{updateTime}">
|
||||
<time datetime={updateTime}>
|
||||
{#if areSameDay(new Date(publishTime), new Date(updateTime))}
|
||||
{formatTime(updateTime)}
|
||||
{:else}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
Byline and dateline.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { Byline } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<Byline
|
||||
authors="{[
|
||||
'Dea Bankova',
|
||||
'Aditi Bhandari',
|
||||
'Prasanta Kumar Dutta',
|
||||
'Anurag Rao',
|
||||
'Mariano Zafra',
|
||||
]}"
|
||||
publishTime="2021-09-12T00:00:00.000Z"
|
||||
updateTime="2021-09-12T12:57:00.000Z"
|
||||
/>
|
||||
```
|
||||
|
|
@ -17,18 +17,18 @@
|
|||
|
||||
<Story
|
||||
name="Demo"
|
||||
args={{
|
||||
args="{{
|
||||
src: 'https://reuters.com/graphics/USA-ABORTION/lgpdwggnwvo/media-embed.html',
|
||||
id: 'abortion-rights-map',
|
||||
ariaLabel: 'map',
|
||||
frameTitle: 'Global abortion access',
|
||||
}}
|
||||
}}"
|
||||
/>
|
||||
|
||||
<Story
|
||||
name="With chatter"
|
||||
tags={['!autodocs']}
|
||||
args={{
|
||||
tags="{['!autodocs']}"
|
||||
args="{{
|
||||
frameTitle: 'Global abortion access',
|
||||
ariaLabel: 'map',
|
||||
id: 'abortion-rights-map',
|
||||
|
|
@ -37,5 +37,5 @@
|
|||
description: 'A map of worldwide access to abortion.',
|
||||
notes:
|
||||
'Note: Different indicators and additional restrictions, including different gestational limits, apply in some countries. Refer to source for full classification. Current as of May 4, 2022.\n\nSource: Center for Reproductive Rights',
|
||||
}}
|
||||
}}"
|
||||
/>
|
||||
|
|
|
|||
19
src/components/EmbedPreviewerLink/EmbedPreviewerLink.mdx
Normal file
19
src/components/EmbedPreviewerLink/EmbedPreviewerLink.mdx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { Meta } from '@storybook/blocks';
|
||||
|
||||
import * as EmbedPreviewerLinkStories from './EmbedPreviewerLink.stories.svelte';
|
||||
|
||||
<Meta of={EmbedPreviewerLinkStories} />
|
||||
|
||||
# EmbedPreviewerLink
|
||||
|
||||
The `EmbedPreviewerLink` component is a tool for previewing the embeds in development. It adds an icon at the bottom of the page that, when clicked, opens a previewer with the embeds.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { EmbedPreviewerLink } from '@reuters-graphics/graphics-components';
|
||||
|
||||
import { dev } from '$app/env';
|
||||
</script>
|
||||
|
||||
<EmbedPreviewerLink {dev} />
|
||||
```
|
||||
|
|
@ -1,30 +1,17 @@
|
|||
<script module lang="ts">
|
||||
import EmbedPreviewerLink from './EmbedPreviewerLink.svelte';
|
||||
// @ts-ignore raw
|
||||
import componentDocs from './stories/docs/component.md?raw';
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
|
||||
import { withComponentDocs } from '$lib/docs/utils/withParams.js';
|
||||
|
||||
export const meta = {
|
||||
const { Story } = defineMeta({
|
||||
title: 'Components/Utilities/EmbedPreviewerLink',
|
||||
component: EmbedPreviewerLink,
|
||||
...withComponentDocs(componentDocs),
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { Template, Story } from '@storybook/addon-svelte-csf';
|
||||
</script>
|
||||
|
||||
<Template >
|
||||
{#snippet children({ args })}
|
||||
<EmbedPreviewerLink {...args} />
|
||||
{/snippet}
|
||||
</Template>
|
||||
|
||||
<Story
|
||||
name="Default"
|
||||
args="{{
|
||||
name="Demo"
|
||||
tags={['!autodocs', '!dev']}
|
||||
args={{
|
||||
dev: true,
|
||||
}}"
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<script lang="ts">
|
||||
|
||||
import Fa from 'svelte-fa/src/fa.svelte';
|
||||
import { faWindowRestore } from '@fortawesome/free-regular-svg-icons';
|
||||
interface Props {
|
||||
|
|
@ -12,7 +11,7 @@
|
|||
{#if dev}
|
||||
<div>
|
||||
<a rel="external" href="/embed-previewer">
|
||||
<Fa icon="{faWindowRestore}" />
|
||||
<Fa icon={faWindowRestore} />
|
||||
</a>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
An embed tool for development in graphics kit.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { EmbedPreviewerLink } from '@reuters-graphics/graphics-components';
|
||||
|
||||
import { dev } from '$app/env';
|
||||
</script>
|
||||
|
||||
<EmbedPreviewerLink dev="{dev}" />
|
||||
```
|
||||
67
src/components/EndNotes/EndNotes.mdx
Normal file
67
src/components/EndNotes/EndNotes.mdx
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
import { Meta, Canvas } from '@storybook/blocks';
|
||||
|
||||
import * as EndNotesStories from './EndNotes.stories.svelte';
|
||||
|
||||
<Meta of={EndNotesStories} />
|
||||
|
||||
# EndNotes
|
||||
|
||||
The `EndNotes` component adds notes such as sources, clarifiying notes and minor corrections that come at the end of a story.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { EndNotes } from '@reuters-graphics/graphics-components';
|
||||
|
||||
const notes = [
|
||||
{
|
||||
title: 'Note',
|
||||
text: 'Data is current as of today.',
|
||||
},
|
||||
{
|
||||
title: 'Sources',
|
||||
text: 'Data, Inc.',
|
||||
},
|
||||
{
|
||||
title: 'Edited by',
|
||||
text: '<a href="https://www.reuters.com/graphics/">Editor</a>, Copyeditor',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<EndNotes {notes} />
|
||||
```
|
||||
|
||||
<Canvas of={EndNotesStories.Demo} />
|
||||
|
||||
## Using with ArchieML docs
|
||||
|
||||
With the Graphics Kit, you'll likely get your text value from an ArchieML doc...
|
||||
|
||||
```yaml
|
||||
# ArchieML doc
|
||||
[endNotes]
|
||||
title: Note
|
||||
text: Data is current as of today
|
||||
|
||||
title: Sources
|
||||
text: Data, Inc.
|
||||
|
||||
title: Edited by
|
||||
text: Editor, Copyeditor
|
||||
[]
|
||||
```
|
||||
|
||||
... which you'll pass to the `EndNotes` component.
|
||||
|
||||
```svelte
|
||||
<!-- Graphics Kit -->
|
||||
<script>
|
||||
import { EndNotes } from '@reuters-graphics/graphics-components';
|
||||
|
||||
import content from '$locales/en/content.json';
|
||||
</script>
|
||||
|
||||
<EndNotes notes={content.endNotes} />
|
||||
```
|
||||
|
||||
<Canvas of={EndNotesStories.Demo} />
|
||||
|
|
@ -1,20 +1,15 @@
|
|||
<script module lang="ts">
|
||||
import EndNotes from './EndNotes.svelte';
|
||||
// @ts-ignore raw
|
||||
import componentDocs from './stories/docs/component.md?raw';
|
||||
|
||||
import { withComponentDocs } from '$lib/docs/utils/withParams.js';
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
|
||||
export const meta = {
|
||||
const { Story } = defineMeta({
|
||||
title: 'Components/Text elements/EndNotes',
|
||||
component: EndNotes,
|
||||
...withComponentDocs(componentDocs),
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { Template, Story } from '@storybook/addon-svelte-csf';
|
||||
|
||||
const notes = [
|
||||
{
|
||||
title: 'Note',
|
||||
|
|
@ -31,10 +26,4 @@
|
|||
];
|
||||
</script>
|
||||
|
||||
<Template >
|
||||
{#snippet children({ args })}
|
||||
<EndNotes {...args} />
|
||||
{/snippet}
|
||||
</Template>
|
||||
|
||||
<Story name="Default" args="{{ notes }}" />
|
||||
<Story name="Demo" args={{ notes }} />
|
||||
|
|
|
|||
|
|
@ -7,40 +7,33 @@
|
|||
title: string;
|
||||
/**
|
||||
* Contents of the note as a markdown string
|
||||
* @required
|
||||
*/
|
||||
text: string;
|
||||
}
|
||||
|
||||
|
||||
|
||||
import Block from '../Block/Block.svelte';
|
||||
import Markdown from '../Markdown/Markdown.svelte';
|
||||
interface Props {
|
||||
/**
|
||||
* An array of endnote items.
|
||||
* @required
|
||||
*/
|
||||
notes?: EndNote[];
|
||||
* An array of endnote items.
|
||||
*/
|
||||
notes: EndNote[];
|
||||
}
|
||||
|
||||
let { notes = [] }: Props = $props();
|
||||
let { notes }: Props = $props();
|
||||
</script>
|
||||
|
||||
<Block class="notes fmt-6 fmb-8">
|
||||
{#if notes}
|
||||
{#each notes as note}
|
||||
<div class="note-title">
|
||||
<Markdown source="{note.title}" />
|
||||
</div>
|
||||
<div class="note-content">
|
||||
<Markdown source="{note.text}" />
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
{#each notes as note}
|
||||
<div class="note-title">
|
||||
<Markdown source={note.title} />
|
||||
</div>
|
||||
<div class="note-content">
|
||||
<Markdown source={note.text} />
|
||||
</div>
|
||||
{/each}
|
||||
</Block>
|
||||
|
||||
<!-- svelte-ignore css_unused_selector -->
|
||||
<style lang="scss">
|
||||
@use '../../scss/mixins' as mixins;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
End notes includes notes to the main article — usually things like sources, clarifiying notes and minor corrections at the end of a story.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { EndNotes } from '@reuters-graphics/graphics-components';
|
||||
|
||||
const notes = [
|
||||
{
|
||||
title: 'Note',
|
||||
text: 'Data is current as of today.',
|
||||
},
|
||||
{
|
||||
title: 'Sources',
|
||||
text: 'Data, Inc.',
|
||||
},
|
||||
{
|
||||
title: 'Edited by',
|
||||
text: '<a href="https://www.reuters.com/graphics/">Editor</a>, Copyeditor',
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<EndNotes notes="{notes}" />
|
||||
```
|
||||
|
|
@ -11,7 +11,11 @@
|
|||
minFrameWidth?: number;
|
||||
}
|
||||
|
||||
let { breakpoints = [330, 510, 660, 930, 1200], maxFrameWidth = 1200, minFrameWidth = 320 }: Props = $props();
|
||||
let {
|
||||
breakpoints = [330, 510, 660, 930, 1200],
|
||||
maxFrameWidth = 1200,
|
||||
minFrameWidth = 320,
|
||||
}: Props = $props();
|
||||
|
||||
let container = $state();
|
||||
|
||||
|
|
@ -91,9 +95,9 @@
|
|||
</script>
|
||||
|
||||
<svelte:window
|
||||
onmousemove={move}
|
||||
onmouseup={end}
|
||||
onkeydown={handleKeyDown}
|
||||
onmousemove="{move}"
|
||||
onmouseup="{end}"
|
||||
onkeydown="{handleKeyDown}"
|
||||
bind:innerWidth="{windowInnerWidth}"
|
||||
/>
|
||||
|
||||
|
|
@ -105,10 +109,10 @@
|
|||
<button
|
||||
class="icon left"
|
||||
disabled="{$width === minWidth}"
|
||||
onclick={decrement}
|
||||
onfocus={onFocus}
|
||||
onmouseover={onFocus}
|
||||
onmouseleave={onBlur}
|
||||
onclick="{decrement}"
|
||||
onfocus="{onFocus}"
|
||||
onmouseover="{onFocus}"
|
||||
onmouseleave="{onBlur}"
|
||||
>
|
||||
<Fa icon="{faMobileAlt}" fw />
|
||||
</button>
|
||||
|
|
@ -119,18 +123,18 @@
|
|||
tabindex="0"
|
||||
role="button"
|
||||
style="left: calc({offset * 100}% - 5px);"
|
||||
onmousedown={start}
|
||||
onfocus={onFocus}
|
||||
onblur={onBlur}
|
||||
onmousedown="{start}"
|
||||
onfocus="{onFocus}"
|
||||
onblur="{onBlur}"
|
||||
></div>
|
||||
</div>
|
||||
<button
|
||||
class="icon right"
|
||||
disabled="{$width === maxWidth}"
|
||||
onclick={increment}
|
||||
onfocus={onFocus}
|
||||
onmouseover={onFocus}
|
||||
onmouseleave={onBlur}
|
||||
onclick="{increment}"
|
||||
onfocus="{onFocus}"
|
||||
onmouseover="{onFocus}"
|
||||
onmouseleave="{onBlur}"
|
||||
>
|
||||
<Fa icon="{faDesktop}" fw />
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
<script lang="ts">
|
||||
|
||||
// For demo purposes only, hard-wiring img paths from Vite
|
||||
// @ts-ignore img
|
||||
import chartXs from '../imgs/ai-chart-xs.png';
|
||||
|
|
|
|||
122
src/components/InfoBox/InfoBox.mdx
Normal file
122
src/components/InfoBox/InfoBox.mdx
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
import { Meta, Canvas } from '@storybook/blocks';
|
||||
|
||||
import * as InfoBoxStories from './InfoBox.stories.svelte';
|
||||
|
||||
<Meta of={InfoBoxStories} />
|
||||
|
||||
# InfoBox
|
||||
|
||||
The `InfoBox` component creates a stylised text box that provides additional information that needs to be visually separate from the main content flow, such as methodology, detailed notes about data and extra context.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { InfoBox } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<InfoBox
|
||||
title="About this data"
|
||||
text={'Reuters is collecting daily COVID-19 infections and deaths data for 240 countries and territories around the world, updated regularly throughout each day. \n\n Every country reports those figures a little differently and, inevitably, misses undiagnosed infections and deaths. With this project we are focusing on the trends within countries as they try to contain the virus’ spread, whether they are approaching or past peak infection rates, or if they are seeing a resurgence of infections or deaths.'}
|
||||
notes={'[Read more about our methodology](https://www.reuters.com/world-coronavirus-tracker-and-maps/en/methodology/)'}
|
||||
/>
|
||||
```
|
||||
|
||||
<Canvas of={InfoBoxStories.Demo} />
|
||||
|
||||
## Using with ArchieML docs
|
||||
|
||||
With the graphics kit, you'll likely get your text value from an ArchieML doc...
|
||||
|
||||
```yaml
|
||||
# Archie ML doc
|
||||
[blocks]
|
||||
|
||||
type: info-box
|
||||
title: What you need to know about the war
|
||||
text: Reuters is collecting daily COVID-19 infections and deaths data for 240 countries and territories around the world, updated regularly throughout each day.
|
||||
|
||||
Every country reports those figures a little differently and, inevitably, misses undiagnosed infections and deaths. With this project we are focusing on the trends within countries as they try to contain the virus’ spread, whether they are approaching or past peak infection rates, or if they are seeing a resurgence of infections or deaths.
|
||||
:end
|
||||
notes: [Read more about our methodology](https://www.reuters.com/world-coronavirus-tracker-and-maps/en/methodology/)
|
||||
[]
|
||||
```
|
||||
|
||||
... which you'll parse out of a ArchieML block object before passing to the `InfoBox` component.
|
||||
|
||||
```svelte
|
||||
<!-- Graphics Kit -->
|
||||
<script>
|
||||
import { InfoBox } from '@reuters-graphics/graphics-components';
|
||||
import content from '$locales/en/content.json';
|
||||
</script>
|
||||
|
||||
# Graphics Kit
|
||||
{#each content.blocks as block}
|
||||
{#if block.type === 'info-box'}
|
||||
<InfoBox title={block.title} text={block.text} notes={block.notes} />
|
||||
<!-- ... -->
|
||||
{/if}
|
||||
{/each}
|
||||
```
|
||||
|
||||
<Canvas of={InfoBoxStories.Demo} />
|
||||
|
||||
## Lists
|
||||
|
||||
Use markdown to add lists to `InfoBox`.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { InfoBox } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<InfoBox
|
||||
title="What you need to know about the war"
|
||||
text={"- **Food crisis**: [Russia's invasion of Ukraine](#) in late February dramatically worsened the outlook for already inflated global food prices.\n- **Under fire**: Civillian homes destroyed in the conflict and Russia accused of war crimes.\n- **Nordstream sabotage**: A series of clandestine bombings and subsequent underwater gas leaks occurred on the Nord Stream 1 and Nord Stream 2 natural gas pipelines."}
|
||||
notes={'[Read more about our methodology](https://www.reuters.com/world-coronavirus-tracker-and-maps/en/methodology/)'}
|
||||
/>
|
||||
```
|
||||
|
||||
<Canvas of={InfoBoxStories.Lists} />
|
||||
## Customisation
|
||||
|
||||
Use [snippets](https://svelte.dev/docs/svelte/snippet) to customise the `InfoBox`, such as adding tables, icons and thumbnail images.
|
||||
|
||||
```svelte
|
||||
<InfoBox title="About this data">
|
||||
<!-- Optional custom header -->
|
||||
{#snippet header()}
|
||||
<h3>Global video game market</h3>
|
||||
{/snippet}
|
||||
<!-- Optional custom body -->
|
||||
{#snippet body()}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Year</th>
|
||||
<th>Market size ($bln)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>2024</td>
|
||||
<td>274.63</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2023</td>
|
||||
<td>281.77</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2022</td>
|
||||
<td>249.55</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{/snippet}
|
||||
<!-- Optional custom footer -->
|
||||
{#snippet updated()}
|
||||
<div class="text-xs font-note">Source: Precedence Research</div>
|
||||
{/snippet}
|
||||
</InfoBox>
|
||||
```
|
||||
|
||||
<Canvas of={InfoBoxStories.Customised} />
|
||||
|
|
@ -1,15 +1,12 @@
|
|||
<script module lang="ts">
|
||||
// @ts-ignore raw
|
||||
import componentDocs from './stories/docs/component.md?raw';
|
||||
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
import InfoBox from './InfoBox.svelte';
|
||||
import BodyText from '../BodyText/BodyText.svelte';
|
||||
|
||||
import { withComponentDocs } from '$lib/docs/utils/withParams.js';
|
||||
|
||||
export const meta = {
|
||||
const { Story } = defineMeta({
|
||||
title: 'Components/Text elements/InfoBox',
|
||||
component: InfoBox,
|
||||
...withComponentDocs(componentDocs),
|
||||
tags: ['autodocs'],
|
||||
argTypes: {
|
||||
theme: {
|
||||
control: 'select',
|
||||
|
|
@ -20,38 +17,82 @@
|
|||
options: ['normal', 'wide', 'wider', 'widest', 'fluid'],
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { Template, Story } from '@storybook/addon-svelte-csf';
|
||||
|
||||
import BodyText from '../BodyText/BodyText.svelte';
|
||||
</script>
|
||||
|
||||
<Template >
|
||||
{#snippet children({ args })}
|
||||
<InfoBox {...args} />
|
||||
{/snippet}
|
||||
</Template>
|
||||
|
||||
<Story name="Default">
|
||||
<Story name="Demo">
|
||||
<BodyText
|
||||
text="If you haven't seen Game of Thrones, go watch it right now. If you have then you'll totally get why this Hodor themed lorem ipsum generator is just brilliant."
|
||||
text="Bacon ipsum dolor amet turducken buffalo beef ribs bresaola pancetta ribeye pork belly doner hamburger biltong cupim porchetta chuck ham tenderloin. Turducken bresaola jerky chicken."
|
||||
/>
|
||||
<InfoBox
|
||||
title="About this data"
|
||||
text="{'Reuters is collecting daily COVID-19 infections and deaths data for 240 countries and territories around the world, updated regularly throughout each day. \n\n Every country reports those figures a little differently and, inevitably, misses undiagnosed infections and deaths. With this project we are focusing on the trends within countries as they try to contain the virus’ spread, whether they are approaching or past peak infection rates, or if they are seeing a resurgence of infections or deaths.'}"
|
||||
notes="{'[Read more about our methodology](https://www.reuters.com/world-coronavirus-tracker-and-maps/en/methodology/)'}"
|
||||
text={'Reuters is collecting daily COVID-19 infections and deaths data for 240 countries and territories around the world, updated regularly throughout each day. \n\n Every country reports those figures a little differently and, inevitably, misses undiagnosed infections and deaths. With this project we are focusing on the trends within countries as they try to contain the virus’ spread, whether they are approaching or past peak infection rates, or if they are seeing a resurgence of infections or deaths.'}
|
||||
notes={'[Read more about our methodology](https://www.reuters.com/world-coronavirus-tracker-and-maps/en/methodology/)'}
|
||||
/>
|
||||
<BodyText
|
||||
text="In case you don't read Twitter, the news, or just can't get enough of The Apprentice host's legendary oration, try this Trump lorem ipsum generator on for size."
|
||||
text="Ham drumstick tail ribeye pancetta, leberkas hamburger chicken spare ribs buffalo jerky sausage ground round meatball. Leberkas kevin short loin, tri-tip shank spare ribs buffalo beef pork belly corned beef chislic tongue."
|
||||
/>
|
||||
</Story>
|
||||
<Story
|
||||
name="Lists"
|
||||
tags={['!autodocs', '!dev']}
|
||||
args={{
|
||||
title: 'What you need to know about the war',
|
||||
text: "- **Food crisis**: [Russia's invasion of Ukraine](#) in late February dramatically worsened the outlook for already inflated global food prices. \n- **Under fire**: Civillian homes destroyed in the conflict and Russia accused of war crimes. \n- **Nordstream sabotage**: A series of clandestine bombings and subsequent underwater gas leaks occurred on the Nord Stream 1 and Nord Stream 2 natural gas pipelines. ",
|
||||
}}
|
||||
/>
|
||||
<Story name="Customised" tags={['!autodocs', '!dev']}>
|
||||
<InfoBox>
|
||||
{#snippet header()}
|
||||
<h3>Global video game market</h3>
|
||||
{/snippet}
|
||||
{#snippet body()}
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Year</th>
|
||||
<th>Market size ($bln)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>2024</td>
|
||||
<td>274.63</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2023</td>
|
||||
<td>281.77</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2022</td>
|
||||
<td>249.55</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
{/snippet}
|
||||
{#snippet footer()}
|
||||
<div class="text-xs font-note">Source: Precedence Research</div>
|
||||
{/snippet}
|
||||
</InfoBox>
|
||||
</Story>
|
||||
|
||||
<Story name="List">
|
||||
<InfoBox
|
||||
title="What you need to know about the war"
|
||||
text="{"- **Food crisis**: [Russia's invasion of Ukraine](#) in late February dramatically worsened the outlook for already inflated global food prices. \n- **Under fire**: Civillian homes destroyed in the conflict and Russia accused of war crimes. \n- **Nordstream sabotage**: A series of clandestine bombings and subsequent underwater gas leaks occurred on the Nord Stream 1 and Nord Stream 2 natural gas pipelines. "}"
|
||||
/>
|
||||
</Story>
|
||||
<style lang="scss">
|
||||
h3 {
|
||||
margin: 0;
|
||||
}
|
||||
// Style the table nicely
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
||||
th,
|
||||
td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
th {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,47 +1,59 @@
|
|||
<!-- @migration-task Error while migrating Svelte code: Cannot set properties of undefined (setting 'next') -->
|
||||
<!-- @component `InfoBox` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-text-elements-infobox--docs) -->
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { ContainerWidth } from '../@types/global';
|
||||
|
||||
type Theme = 'light' | 'dark';
|
||||
|
||||
/**
|
||||
* Title of the box
|
||||
*/
|
||||
export let title: string | null = null;
|
||||
interface Props {
|
||||
/**
|
||||
* Title of the box
|
||||
*/
|
||||
title?: string | null;
|
||||
/**
|
||||
* Contents of the note as a markdown string
|
||||
*/
|
||||
text?: string;
|
||||
/**
|
||||
* Additional footnotes
|
||||
*/
|
||||
notes?: string | null;
|
||||
/**
|
||||
* Width of the component within the text well.
|
||||
*/
|
||||
width?: ContainerWidth;
|
||||
/**
|
||||
* Add extra classes to the block tag to target it with custom CSS.
|
||||
*/
|
||||
class?: string;
|
||||
/**
|
||||
* Add an id to the block tag to target it with custom CSS.
|
||||
*/
|
||||
id?: string;
|
||||
/**
|
||||
* Page theme
|
||||
*/
|
||||
theme?: Theme;
|
||||
/** Optional custom header snippet */
|
||||
header?: Snippet;
|
||||
/** Optional custom body snippet */
|
||||
body?: Snippet;
|
||||
/** Optional custom footer snippet */
|
||||
footer?: Snippet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contents of the note as a markdown string
|
||||
*/
|
||||
export let text: string = '';
|
||||
|
||||
/**
|
||||
* Additional footnotes
|
||||
*/ export let notes: string | null = null;
|
||||
|
||||
/**
|
||||
* Width of the component within the text well.
|
||||
* @type {string}
|
||||
*/
|
||||
export let width: ContainerWidth = 'normal';
|
||||
|
||||
/**
|
||||
* Add extra classes to the block tag to target it with custom CSS.
|
||||
* @type {string}
|
||||
*/
|
||||
let cls: string = '';
|
||||
export { cls as class };
|
||||
|
||||
/**
|
||||
* Add an id to the block tag to target it with custom CSS.
|
||||
* @type {string}
|
||||
*/
|
||||
export let id: string = '';
|
||||
|
||||
/**
|
||||
* Page theme
|
||||
*/
|
||||
export let theme: Theme = 'light';
|
||||
let {
|
||||
title = null,
|
||||
text,
|
||||
notes = null,
|
||||
width = 'normal',
|
||||
class: cls = '',
|
||||
id = '',
|
||||
theme = 'light',
|
||||
header,
|
||||
body,
|
||||
footer,
|
||||
}: Props = $props();
|
||||
|
||||
import Block from '../Block/Block.svelte';
|
||||
import Markdown from '../Markdown/Markdown.svelte';
|
||||
|
|
@ -53,36 +65,36 @@
|
|||
{id}
|
||||
class="{cls} fmy-6 fpx-6 fpy-5 border border-solid rounded"
|
||||
>
|
||||
{#if $$slots.header}
|
||||
{#if header}
|
||||
<div class="header fmb-2">
|
||||
<!-- Custom title content -->
|
||||
<slot name="header" />
|
||||
<!-- Custom header content -->
|
||||
{@render header()}
|
||||
</div>
|
||||
{:else if title}
|
||||
<div class="header fmb-2">
|
||||
<Markdown source="{title}" />
|
||||
<Markdown source={title} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if $$slots.body}
|
||||
{#if body}
|
||||
<div class="body">
|
||||
<!-- Custom content -->
|
||||
<slot name="body" />
|
||||
<!-- Custom body content -->
|
||||
{@render body()}
|
||||
</div>
|
||||
{:else}
|
||||
<div class="body">
|
||||
<Markdown source="{text}" />
|
||||
<Markdown source={text} />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if $$slots.footer}
|
||||
{#if footer}
|
||||
<div class="footer fmt-2">
|
||||
<!-- Custom footer content -->
|
||||
<slot name="footer" />
|
||||
{@render footer()}
|
||||
</div>
|
||||
{:else if notes}
|
||||
<div class="footer fmt-2">
|
||||
<Markdown source="{notes}" />
|
||||
<Markdown source={notes} />
|
||||
</div>
|
||||
{/if}
|
||||
</Block>
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
InfoBox is used to provide additional information that needs to be visually set aside from the main content flow. e.g. Methodology, Detailed notes about data, Extra context as text stories.
|
||||
|
||||
Switch the theme prop to `dark` for a dark page infobox.
|
||||
|
||||
Use the slots to customize the content as needed, e.g. adding icons and thumbnail images etc.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { InfoBox } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<InfoBox
|
||||
title="About this data"
|
||||
text="{'Reuters is collecting daily COVID-19 infections and deaths data for 240 countries and territories around the world, updated regularly throughout each day. \n\n Every country reports those figures a little differently and, inevitably, misses undiagnosed infections and deaths. With this project we are focusing on the trends within countries as they try to contain the virus’ spread, whether they are approaching or past peak infection rates, or if they are seeing a resurgence of infections or deaths.'}"
|
||||
notes="{'[Read more about our methodology](https://www.reuters.com/world-coronavirus-tracker-and-maps/en/methodology/)'}"
|
||||
/>
|
||||
```
|
||||
|
|
@ -4,9 +4,6 @@
|
|||
import { marked } from 'marked';
|
||||
import { staticMarkdown } from './stores';
|
||||
|
||||
|
||||
|
||||
|
||||
interface Props {
|
||||
/** A Markdown formatted string */
|
||||
source?: string;
|
||||
|
|
@ -16,7 +13,9 @@
|
|||
|
||||
let { source = '', parseInline = false }: Props = $props();
|
||||
|
||||
let markdown = $derived(parseInline ? marked.parseInline(source) : marked.parse(source));
|
||||
let markdown = $derived(
|
||||
parseInline ? marked.parseInline(source) : marked.parse(source)
|
||||
);
|
||||
|
||||
const setInnerHTML: Action<HTMLElement, string> = (node, html) => {
|
||||
node.innerHTML = html;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
<!-- @component `PymChild` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-utilities-pymchild--docs) -->
|
||||
<script lang="ts">
|
||||
|
||||
|
||||
import { onMount } from 'svelte';
|
||||
import pym from 'pym.js';
|
||||
import { pymChildStore } from './stores.js';
|
||||
|
|
|
|||
21
src/components/ReutersGraphicsLogo/ReutersGraphicsLogo.mdx
Normal file
21
src/components/ReutersGraphicsLogo/ReutersGraphicsLogo.mdx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Meta, Canvas } from '@storybook/blocks';
|
||||
|
||||
import * as ReutersGraphicsLogoStories from './ReutersGraphicsLogo.stories.svelte';
|
||||
|
||||
<Meta of={ReutersGraphicsLogoStories} />
|
||||
|
||||
# ReutersGraphicsLogo
|
||||
|
||||
The `ReutersGraphicsLogo` component contains the Reuters Graphics team logo.
|
||||
|
||||
> Generally, used only for internal tools. For public pages, use the [ReutersLogo](./?path=/docs/components-logos-reuterslogo--docs) component.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { ReutersGraphicsLogo } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<ReutersGraphicsLogo />
|
||||
```
|
||||
|
||||
<Canvas of={ReutersGraphicsLogoStories.Demo} />
|
||||
|
|
@ -1,26 +1,14 @@
|
|||
<script module lang="ts">
|
||||
// @ts-ignore raw
|
||||
import componentDocs from './stories/docs/component.md?raw';
|
||||
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
import ReutersGraphicsLogo from './ReutersGraphicsLogo.svelte';
|
||||
|
||||
import { withComponentDocs } from '$lib/docs/utils/withParams.js';
|
||||
|
||||
export const meta = {
|
||||
const { Story } = defineMeta({
|
||||
title: 'Components/Logos/ReutersGraphicsLogo',
|
||||
component: ReutersGraphicsLogo,
|
||||
...withComponentDocs(componentDocs),
|
||||
};
|
||||
argTypes: {
|
||||
logoColour: { control: 'color' },
|
||||
textColour: { control: 'color' },
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { Template, Story } from '@storybook/addon-svelte-csf';
|
||||
</script>
|
||||
|
||||
<Template >
|
||||
{#snippet children({ args })}
|
||||
<ReutersGraphicsLogo {...args} />
|
||||
{/snippet}
|
||||
</Template>
|
||||
|
||||
<Story name="Default" args="{{}}" />
|
||||
<Story name="Demo" />
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
Reuters Graphics team logo.
|
||||
|
||||
> Generally, only used for internal tools. For public pages, use the [ReutersLogo](./?path=/docs/components-logos-reuterslogo--docs) component.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { ReutersGraphicsLogo } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<ReutersGraphicsLogo />
|
||||
```
|
||||
19
src/components/ReutersLogo/ReutersLogo.mdx
Normal file
19
src/components/ReutersLogo/ReutersLogo.mdx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { Meta, Canvas } from '@storybook/blocks';
|
||||
|
||||
import * as ReutersLogoStories from './ReutersLogo.stories.svelte';
|
||||
|
||||
<Meta of={ReutersLogoStories} />
|
||||
|
||||
# ReutersLogo
|
||||
|
||||
The `ReutersLogo` component contains the official Reuters logo.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { ReutersLogo } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<ReutersLogo />
|
||||
```
|
||||
|
||||
<Canvas of={ReutersLogoStories.Demo} />
|
||||
|
|
@ -1,30 +1,15 @@
|
|||
<script module lang="ts">
|
||||
// @ts-ignore raw
|
||||
import componentDocs from './stories/docs/component.md?raw';
|
||||
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
import ReutersLogo from './ReutersLogo.svelte';
|
||||
|
||||
import { withComponentDocs } from '$lib/docs/utils/withParams.js';
|
||||
|
||||
export const meta = {
|
||||
const { Story } = defineMeta({
|
||||
title: 'Components/Logos/ReutersLogo',
|
||||
component: ReutersLogo,
|
||||
...withComponentDocs(componentDocs),
|
||||
argTypes: {
|
||||
logoColour: { control: 'color' },
|
||||
textColour: { control: 'color' },
|
||||
},
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { Template, Story } from '@storybook/addon-svelte-csf';
|
||||
</script>
|
||||
|
||||
<Template >
|
||||
{#snippet children({ args })}
|
||||
<ReutersLogo {...args} />
|
||||
{/snippet}
|
||||
</Template>
|
||||
|
||||
<Story name="Default" />
|
||||
<Story name="Demo" />
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
<!-- @component `ReutersLogo` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-logos-reuterslogo--docs) -->
|
||||
<script lang="ts">
|
||||
|
||||
|
||||
|
||||
interface Props {
|
||||
/** "Kinesis" colour */
|
||||
logoColour?: string;
|
||||
|
|
@ -12,7 +9,11 @@
|
|||
width?: string;
|
||||
}
|
||||
|
||||
let { logoColour = '#D64000', textColour = '#212223', width = '100%' }: Props = $props();
|
||||
let {
|
||||
logoColour = '#D64000',
|
||||
textColour = '#212223',
|
||||
width = '100%',
|
||||
}: Props = $props();
|
||||
</script>
|
||||
|
||||
<svg
|
||||
|
|
@ -21,22 +22,6 @@
|
|||
viewBox="0 0 1760.4 558.7"
|
||||
style="width: {width}; --logoColour: {logoColour}; --textColour: {textColour};"
|
||||
>
|
||||
<defs>
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: var(--logoColour);
|
||||
}
|
||||
|
||||
.cls-1,
|
||||
.cls-2 {
|
||||
stroke-width: 0px;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: var(--textColour);
|
||||
}
|
||||
</style>
|
||||
</defs>
|
||||
<g id="Primary_Logo" data-name="Primary Logo">
|
||||
<g>
|
||||
<g>
|
||||
|
|
@ -186,3 +171,18 @@
|
|||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
<style>
|
||||
.cls-1 {
|
||||
fill: var(--logoColour);
|
||||
}
|
||||
|
||||
.cls-1,
|
||||
.cls-2 {
|
||||
stroke-width: 0px;
|
||||
}
|
||||
|
||||
.cls-2 {
|
||||
fill: var(--textColour);
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
The official Reuters logo.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { ReutersLogo } from '@reuters-graphics/graphics-components';
|
||||
</script>
|
||||
|
||||
<ReutersLogo />
|
||||
```
|
||||
|
|
@ -1,10 +1,8 @@
|
|||
<script lang="ts">
|
||||
import type { ContainerWidth, ScrollerStep } from '../../@types/global';
|
||||
|
||||
|
||||
type EmbeddedLayout = 'fb' | 'bf';
|
||||
|
||||
|
||||
import Background from './Background.svelte';
|
||||
import Foreground from './Foreground.svelte';
|
||||
interface Props {
|
||||
|
|
@ -13,7 +11,11 @@
|
|||
backgroundWidth?: ContainerWidth;
|
||||
}
|
||||
|
||||
let { steps = [], embeddedLayout = 'fb', backgroundWidth = 'fluid' }: Props = $props();
|
||||
let {
|
||||
steps = [],
|
||||
embeddedLayout = 'fb',
|
||||
backgroundWidth = 'fluid',
|
||||
}: Props = $props();
|
||||
</script>
|
||||
|
||||
{#each steps as step, index}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<p>The count is {count}</p>
|
||||
|
||||
<button
|
||||
onclick={() => {
|
||||
onclick="{() => {
|
||||
count += 1;
|
||||
}}>Click Me</button
|
||||
}}">Click Me</button
|
||||
>
|
||||
|
|
|
|||
|
|
@ -4,12 +4,11 @@
|
|||
import MagnifyingGlass from './MagnifyingGlass.svelte';
|
||||
import X from './X.svelte';
|
||||
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
* The placeholder text that appears in the search box.
|
||||
* @type {string}
|
||||
*/
|
||||
* The placeholder text that appears in the search box.
|
||||
* @type {string}
|
||||
*/
|
||||
searchPlaceholder?: string;
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +39,7 @@
|
|||
class="search--input body-caption pl-8"
|
||||
type="text"
|
||||
placeholder="{searchPlaceholder}"
|
||||
oninput={input}
|
||||
oninput="{input}"
|
||||
bind:value
|
||||
/>
|
||||
<div
|
||||
|
|
@ -48,8 +47,8 @@
|
|||
role="button"
|
||||
tabindex="0"
|
||||
class:invisible="{!active}"
|
||||
onclick={clear}
|
||||
onkeyup={clear}
|
||||
onclick="{clear}"
|
||||
onkeyup="{clear}"
|
||||
>
|
||||
<X />
|
||||
</div>
|
||||
|
|
|
|||
119
src/components/SimpleTimeline/SimpleTimeline.mdx
Normal file
119
src/components/SimpleTimeline/SimpleTimeline.mdx
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
import { Meta, Canvas } from '@storybook/blocks';
|
||||
|
||||
import * as SimpleTimelineStories from './SimpleTimeline.stories.svelte';
|
||||
|
||||
<Meta of={SimpleTimelineStories} />
|
||||
|
||||
# SimpleTimeline
|
||||
|
||||
The `SimpleTimeline` component creates a basic timeline with dates, titles and descriptions of events.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { SimpleTimeline } from '@reuters-graphics/graphics-components';
|
||||
|
||||
const dates = [
|
||||
{
|
||||
date: 'May 18',
|
||||
events: [
|
||||
{
|
||||
title: 'A title for the event',
|
||||
titleLink: 'https://...', // optional
|
||||
context: 'Lorem ipsum...', // optional
|
||||
},
|
||||
// More events...
|
||||
],
|
||||
},
|
||||
// More dates...
|
||||
];
|
||||
</script>
|
||||
|
||||
<SimpleTimeline {dates} />
|
||||
```
|
||||
|
||||
<Canvas of={SimpleTimelineStories.Demo} />
|
||||
|
||||
## Using with ArchieML docs
|
||||
|
||||
With the graphics kit, you'll likely get your text value from an ArchieML doc.
|
||||
|
||||
```yaml
|
||||
# Archie ML doc
|
||||
|
||||
[timeline]
|
||||
|
||||
# date object with events
|
||||
date: May 18
|
||||
[.events]
|
||||
title: Mariupol defenders surrender to Russia but their fate is uncertain
|
||||
context: More than 250 Ukrainian fighters surrendered to Russian forces at the Azovstal steelworks in Mariupol after weeks of desperate resistance, bringing an end to the most devastating siege of Russia's war in Ukraine and allowing President Vladimir Putin to claim a rare victory in his faltering campaign.
|
||||
titleLink: https://www.reuters.com/world/europe/ukrainian-troops-evacuate-mariupol-ceding-control-russia-2022-05-17/
|
||||
|
||||
# More events...
|
||||
[]
|
||||
|
||||
date: May 10
|
||||
[.events]
|
||||
title: U.S. House passes $40 bln bill to bolster Ukraine against Russian invasion
|
||||
context: The U.S. House of Representatives approved more than $40 billion more aid for Ukraine on Tuesday, as Congress races to keep military aid flowing and boost the government in Kyiv as it grapples with the Russian invasion.
|
||||
titleLink: https://www.reuters.com/world/us-house-vote-40-billion-ukraine-aid-package-tuesday-pelosi-2022-05-10/
|
||||
[]
|
||||
|
||||
# More dates and events...
|
||||
[]
|
||||
```
|
||||
|
||||
... which you'll pass to the `SimpleTimeline` component.
|
||||
|
||||
```svelte
|
||||
<!-- Graphics Kit -->
|
||||
<script>
|
||||
import { SimpleTimeline } from '@reuters-graphics/graphics-components';
|
||||
import content from '$locales/en/content.json';
|
||||
</script>
|
||||
|
||||
<EndNotes SimpleTimeline={content.timeline} />
|
||||
```
|
||||
|
||||
<Canvas of={SimpleTimelineStories.Demo} />
|
||||
|
||||
# Multiple events
|
||||
|
||||
You can add multiple events to a single date by adding objects to the `events` array.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { SimpleTimeline } from '@reuters-graphics/graphics-components';
|
||||
|
||||
const dates = [
|
||||
{
|
||||
date: 'Feb. 25',
|
||||
// Multiple events for this date
|
||||
events: [
|
||||
{
|
||||
title: 'NATO deploys more troops',
|
||||
context:
|
||||
'NATO leaders said on Friday they were deploying more troops to eastern Europe after Russia invaded Ukraine, saying that Moscow had lied about its intentions.',
|
||||
},
|
||||
{
|
||||
title: 'Invasion continues',
|
||||
context:
|
||||
'Missiles pounded the Ukrainian capital as Russian forces pressed their advance and Ukrainian President Volodymyr Zelenskiy pleaded with the international community to do more, saying sanctions announced so far were not enough.\n\nRussian forces battered Ukrainian cities with artillery and cruise missiles but a defiant Zelenskiy said the capital Kyiv remained in Ukrainian hands.',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
date: 'Feb. 24',
|
||||
events: [
|
||||
{
|
||||
title: 'Russia invades Ukraine',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
</script>
|
||||
|
||||
<SimpleTimeline {dates} />
|
||||
```
|
||||
|
||||
<Canvas of={SimpleTimelineStories.MultipleEvents} />
|
||||
|
|
@ -1,25 +1,18 @@
|
|||
<script module lang="ts">
|
||||
// @ts-ignore raw
|
||||
import componentDocs from './stories/docs/component.md?raw';
|
||||
|
||||
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||
import SimpleTimeline from './SimpleTimeline.svelte';
|
||||
|
||||
import { withComponentDocs } from '$lib/docs/utils/withParams.js';
|
||||
|
||||
export const meta = {
|
||||
const { Story } = defineMeta({
|
||||
title: 'Components/Text elements/SimpleTimeline',
|
||||
component: SimpleTimeline,
|
||||
...withComponentDocs(componentDocs),
|
||||
argTypes: {
|
||||
symbolColour: { control: 'color' },
|
||||
dateColour: { control: 'color' },
|
||||
},
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { Template, Story } from '@storybook/addon-svelte-csf';
|
||||
|
||||
<script lang="ts">
|
||||
const dates = [
|
||||
{
|
||||
date: 'May 18',
|
||||
|
|
@ -56,20 +49,9 @@
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
date: 'Feb. 27',
|
||||
events: [
|
||||
{
|
||||
title: 'Russians push into Kharkiv',
|
||||
titleLink:
|
||||
'https://www.reuters.com/world/europe/western-allies-expel-key-russian-banks-global-system-ukraine-fights-2022-02-27/',
|
||||
},
|
||||
{
|
||||
title:
|
||||
'Human rights groups and Ukrainian ambassador accuse Russia of using cluster and vacuum bombs',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const datesMultipleEvents = [
|
||||
{
|
||||
date: 'Feb. 25',
|
||||
events: [
|
||||
|
|
@ -96,15 +78,18 @@
|
|||
];
|
||||
</script>
|
||||
|
||||
<Template >
|
||||
{#snippet children({ args })}
|
||||
<SimpleTimeline {...args} />
|
||||
{/snippet}
|
||||
</Template>
|
||||
<Story
|
||||
name="Demo"
|
||||
args={{
|
||||
dates,
|
||||
}}
|
||||
/>
|
||||
|
||||
<Story
|
||||
name="Default"
|
||||
args="{{
|
||||
dates,
|
||||
}}"
|
||||
name="Multiple events"
|
||||
exportName="MultipleEvents"
|
||||
tags={['!autodocs', '!dev']}
|
||||
args={{
|
||||
dates: datesMultipleEvents,
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
<!-- @migration-task Error while migrating Svelte code: Cannot set properties of undefined (setting 'next') -->
|
||||
<!-- @component `SimpleTimeline` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-text-elements-simpletimeline--docs) -->
|
||||
<script lang="ts">
|
||||
import Fa from 'svelte-fa/src/fa.svelte';
|
||||
import { faLink } from '@fortawesome/free-solid-svg-icons';
|
||||
import Block from '../Block/Block.svelte';
|
||||
import Markdown from '../Markdown/Markdown.svelte';
|
||||
|
||||
interface Event {
|
||||
title: string;
|
||||
titleLink?: string;
|
||||
|
|
@ -10,37 +14,37 @@
|
|||
date: string;
|
||||
events: Event[];
|
||||
}
|
||||
/**
|
||||
* An array of dates with events.
|
||||
* @required
|
||||
*/
|
||||
export let dates: EventDate[];
|
||||
/**
|
||||
* Set a colour for the timeline bullet symbols and line.
|
||||
* @type {string}
|
||||
*/
|
||||
export let symbolColour: string = 'var(--theme-colour-brand-rules)';
|
||||
/**
|
||||
* Set a colour for the date headings in the timeline.
|
||||
* @type {string}
|
||||
*/
|
||||
export let dateColour: string = 'var(--theme-colour-accent, red)';
|
||||
/**
|
||||
* Set a class to target with SCSS.
|
||||
* @type {string}
|
||||
*/
|
||||
let cls: string = '';
|
||||
export { cls as class };
|
||||
/**
|
||||
* Set an ID to target with SCSS.
|
||||
* @type {string}
|
||||
*/
|
||||
export let id: string = '';
|
||||
|
||||
import Block from '../Block/Block.svelte';
|
||||
import Fa from 'svelte-fa/src/fa.svelte';
|
||||
import { faLink } from '@fortawesome/free-solid-svg-icons';
|
||||
import Markdown from '../Markdown/Markdown.svelte';
|
||||
interface Props {
|
||||
/**
|
||||
* An array of dates with events.
|
||||
*/
|
||||
dates: EventDate[];
|
||||
/**
|
||||
* Set a colour for the timeline bullet symbols and line.
|
||||
*/
|
||||
symbolColour?: string;
|
||||
/**
|
||||
* Set a colour for the date headings in the timeline.
|
||||
*/
|
||||
dateColour?: string;
|
||||
/**
|
||||
* Set a class to target with SCSS.
|
||||
*/
|
||||
class?: string;
|
||||
/**
|
||||
* Set an ID to target with SCSS.
|
||||
*/
|
||||
id?: string;
|
||||
}
|
||||
|
||||
let {
|
||||
dates,
|
||||
symbolColour = 'var(--theme-colour-brand-rules)',
|
||||
dateColour = 'var(--theme-colour-accent, red)',
|
||||
class: cls = '',
|
||||
id = '',
|
||||
}: Props = $props();
|
||||
</script>
|
||||
|
||||
<Block width="normal" {id} class="simple-timeline-container fmy-6 {cls}">
|
||||
|
|
@ -52,24 +56,24 @@
|
|||
cx="10"
|
||||
cy="12"
|
||||
r="5"
|
||||
stroke="{symbolColour}"
|
||||
stroke={symbolColour}
|
||||
stroke-width="2"
|
||||
fill="transparent"
|
||||
></circle>
|
||||
</svg>
|
||||
<div
|
||||
class="timeline-date font-note text-xs uppercase font-black tracking-wide fmb-0"
|
||||
style:color="{dateColour}"
|
||||
style:color={dateColour}
|
||||
>
|
||||
{date.date}
|
||||
</div>
|
||||
{#each date.events as event}
|
||||
<div class="event pb-2">
|
||||
{#if event.titleLink}
|
||||
<a href="{event.titleLink}" target="_blank">
|
||||
<a href={event.titleLink} target="_blank">
|
||||
<div class="title h3">
|
||||
{event.title}
|
||||
<span class="text-sm"><Fa fw icon="{faLink}" /></span>
|
||||
<span class="text-sm"><Fa fw icon={faLink} /></span>
|
||||
</div>
|
||||
</a>
|
||||
{:else}
|
||||
|
|
@ -78,7 +82,7 @@
|
|||
</div>
|
||||
{/if}
|
||||
{#if event.context}
|
||||
<Markdown source="{event.context}" />
|
||||
<Markdown source={event.context} />
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
|
|
@ -88,13 +92,13 @@
|
|||
</Block>
|
||||
|
||||
<style lang="scss">
|
||||
@use '../../scss/mixins' as *;
|
||||
@use '../../scss/mixins' as mixins;
|
||||
.timeline {
|
||||
.date {
|
||||
border-left: 1px solid var(--symbol-colour);
|
||||
&:last-child {
|
||||
border-left: 1px solid $theme-colour-background;
|
||||
@include fpb-0;
|
||||
border-left: 1px solid mixins.$theme-colour-background;
|
||||
@include mixins.fpb-0;
|
||||
}
|
||||
}
|
||||
svg {
|
||||
|
|
@ -102,9 +106,9 @@
|
|||
left: -10px;
|
||||
}
|
||||
div.title {
|
||||
@include fmt-2;
|
||||
@include fmb-1;
|
||||
@include font-medium;
|
||||
@include mixins.fmt-2;
|
||||
@include mixins.fmb-1;
|
||||
@include mixins.font-medium;
|
||||
}
|
||||
|
||||
div.event {
|
||||
|
|
@ -123,8 +127,8 @@
|
|||
}
|
||||
}
|
||||
:global(p) {
|
||||
@include body-note;
|
||||
@include font-light;
|
||||
@include mixins.body-note;
|
||||
@include mixins.font-light;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +0,0 @@
|
|||
A simple, clean text timeline.
|
||||
|
||||
```svelte
|
||||
<script>
|
||||
import { SimpleTimeline } from '@reuters-graphics/graphics-components';
|
||||
|
||||
const dates = [
|
||||
{
|
||||
date: 'May 18',
|
||||
events: [
|
||||
{
|
||||
title: 'A title for the event',
|
||||
titleLink: 'https://...', // optional
|
||||
context: 'Lorem ipsum...', // optional
|
||||
},
|
||||
// More events...
|
||||
],
|
||||
},
|
||||
// More dates...
|
||||
];
|
||||
</script>
|
||||
|
||||
<SimpleTimeline dates="{dates}" />
|
||||
```
|
||||
|
|
@ -9,11 +9,10 @@
|
|||
import starterData from './data.json';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
* Set to `false` to remove graphics referrals
|
||||
*/
|
||||
* Set to `false` to remove graphics referrals
|
||||
*/
|
||||
includeReferrals?: boolean;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,11 @@
|
|||
releaseMobileMenu?: any;
|
||||
}
|
||||
|
||||
let { data = [], isMobileMenuOpen = false, releaseMobileMenu = () => {} }: Props = $props();
|
||||
let {
|
||||
data = [],
|
||||
isMobileMenuOpen = false,
|
||||
releaseMobileMenu = () => {},
|
||||
}: Props = $props();
|
||||
</script>
|
||||
|
||||
{#if isMobileMenuOpen}
|
||||
|
|
@ -31,7 +35,7 @@
|
|||
textColour="var(--nav-primary)"
|
||||
/>
|
||||
</div>
|
||||
<button class="button close-button" onclick={releaseMobileMenu}>
|
||||
<button class="button close-button" onclick="{releaseMobileMenu}">
|
||||
<div class="button-container">
|
||||
<CloseIcon />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
|
||||
let { section = {}, headingText } = $props();
|
||||
|
||||
let splitCount =
|
||||
$derived(section.children && section.children.length > 7 ?
|
||||
let splitCount = $derived(
|
||||
section.children && section.children.length > 7 ?
|
||||
Math.ceil(section.children.length / 2)
|
||||
: 0);
|
||||
: 0
|
||||
);
|
||||
</script>
|
||||
|
||||
<NavDropdown {headingText}>
|
||||
|
|
|
|||
|
|
@ -35,27 +35,27 @@
|
|||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<li
|
||||
class="nav-item category link"
|
||||
onmouseenter={() => {
|
||||
onmouseenter="{() => {
|
||||
navTimeout = setTimeout(
|
||||
() => activeSection.set(section.id),
|
||||
timeout
|
||||
);
|
||||
}}
|
||||
onfocus={() => activeSection.set(section.id)}
|
||||
onmouseleave={() => {
|
||||
}}"
|
||||
onfocus="{() => activeSection.set(section.id)}"
|
||||
onmouseleave="{() => {
|
||||
clearTimeout(navTimeout);
|
||||
activeSection.set(null);
|
||||
}}
|
||||
onblur={() => {
|
||||
}}"
|
||||
onblur="{() => {
|
||||
clearTimeout(navTimeout);
|
||||
activeSection.set(null);
|
||||
}}
|
||||
onclick={() => {
|
||||
}}"
|
||||
onclick="{() => {
|
||||
if ($activeSection === section.id) {
|
||||
clearTimeout(navTimeout);
|
||||
activeSection.set(null);
|
||||
}
|
||||
}}
|
||||
}}"
|
||||
>
|
||||
<div
|
||||
class="nav-button link"
|
||||
|
|
@ -88,24 +88,24 @@
|
|||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<li
|
||||
class="nav-item"
|
||||
onmouseenter={() => {
|
||||
onmouseenter="{() => {
|
||||
navTimeout = setTimeout(() => activeSection.set('more'), timeout);
|
||||
}}
|
||||
onfocus={() => activeSection.set('more')}
|
||||
onmouseleave={() => {
|
||||
}}"
|
||||
onfocus="{() => activeSection.set('more')}"
|
||||
onmouseleave="{() => {
|
||||
clearTimeout(navTimeout);
|
||||
activeSection.set(null);
|
||||
}}
|
||||
onblur={() => {
|
||||
}}"
|
||||
onblur="{() => {
|
||||
clearTimeout(navTimeout);
|
||||
activeSection.set(null);
|
||||
}}
|
||||
onclick={() => {
|
||||
}}"
|
||||
onclick="{() => {
|
||||
if ($activeSection === 'more') {
|
||||
clearTimeout(navTimeout);
|
||||
activeSection.set(null);
|
||||
}
|
||||
}}
|
||||
}}"
|
||||
>
|
||||
<div
|
||||
class="nav-button more link"
|
||||
|
|
|
|||
|
|
@ -77,9 +77,9 @@
|
|||
aria-label="Menu"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="{isMobileMenuOpen}"
|
||||
onclick={() => {
|
||||
onclick="{() => {
|
||||
isMobileMenuOpen = !isMobileMenuOpen;
|
||||
}}
|
||||
}}"
|
||||
>
|
||||
<div class="button-container">
|
||||
<MenuIcon />
|
||||
|
|
|
|||
|
|
@ -3,33 +3,26 @@
|
|||
import LeftArrow from './LeftArrow.svelte';
|
||||
import RightArrow from './RightArrow.svelte';
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
* The current page number.
|
||||
* @type {number}
|
||||
*/
|
||||
* The current page number.
|
||||
* @type {number}
|
||||
*/
|
||||
pageNumber?: number;
|
||||
/**
|
||||
* The default page size.
|
||||
* @type {number}
|
||||
*/
|
||||
* The default page size.
|
||||
* @type {number}
|
||||
*/
|
||||
pageSize?: number;
|
||||
/**
|
||||
* The number of records in the current page.
|
||||
* @type {number}
|
||||
*/
|
||||
* The number of records in the current page.
|
||||
* @type {number}
|
||||
*/
|
||||
pageLength?: number;
|
||||
/**
|
||||
* The total number of records in the data set.
|
||||
* @type {number}
|
||||
*/
|
||||
* The total number of records in the data set.
|
||||
* @type {number}
|
||||
*/
|
||||
n?: number;
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +30,7 @@
|
|||
pageNumber = $bindable(1),
|
||||
pageSize = 25,
|
||||
pageLength = null,
|
||||
n = null
|
||||
n = null,
|
||||
}: Props = $props();
|
||||
|
||||
let minRow = $derived(pageNumber * pageSize - pageSize + 1);
|
||||
|
|
@ -58,7 +51,7 @@
|
|||
</script>
|
||||
|
||||
<nav aria-label="pagination" class="pagination fmt-4">
|
||||
<button onclick={goToPreviousPage} disabled="{pageNumber === 1}"
|
||||
<button onclick="{goToPreviousPage}" disabled="{pageNumber === 1}"
|
||||
><div class="icon-wrapper">
|
||||
<LeftArrow />
|
||||
<span class="visually-hidden">Previous page</span>
|
||||
|
|
@ -70,7 +63,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<button
|
||||
onclick={goToNextPage}
|
||||
onclick="{goToNextPage}"
|
||||
disabled="{pageNumber === Math.ceil(n / pageSize)}"
|
||||
><div class="icon-wrapper">
|
||||
<RightArrow />
|
||||
|
|
|
|||
|
|
@ -2,19 +2,16 @@
|
|||
import { createEventDispatcher } from 'svelte';
|
||||
import type { Option } from '../@types/global';
|
||||
|
||||
|
||||
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
* The label that appears above the select input.
|
||||
* @type {string}
|
||||
*/
|
||||
* The label that appears above the select input.
|
||||
* @type {string}
|
||||
*/
|
||||
label?: string;
|
||||
/**
|
||||
* The label that appears above the select input.
|
||||
* @type {Array}
|
||||
*/
|
||||
* The label that appears above the select input.
|
||||
* @type {Array}
|
||||
*/
|
||||
options?: Option[];
|
||||
}
|
||||
|
||||
|
|
@ -36,7 +33,7 @@
|
|||
class="select--input body-caption fpx-2"
|
||||
name="select--input"
|
||||
id="select--input"
|
||||
oninput={input}
|
||||
oninput="{input}"
|
||||
>
|
||||
{#each options as obj}
|
||||
<option value="{obj.value}">{obj.text}</option>
|
||||
|
|
|
|||
|
|
@ -5,13 +5,12 @@
|
|||
*/
|
||||
type SortDirection = 'ascending' | 'descending';
|
||||
|
||||
|
||||
interface Props {
|
||||
sortDirection?: SortDirection;
|
||||
/**
|
||||
* Whether or not this arrow is currently sorting. It is false by default.
|
||||
* @type {boolean}
|
||||
*/
|
||||
* Whether or not this arrow is currently sorting. It is false by default.
|
||||
* @type {boolean}
|
||||
*/
|
||||
active?: boolean;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
controlsBorderOffset,
|
||||
resetCondition,
|
||||
separateReplayIcon,
|
||||
controlsColour
|
||||
controlsColour,
|
||||
} = $props();
|
||||
|
||||
function forwardBtnClick() {
|
||||
|
|
@ -29,7 +29,7 @@
|
|||
</script>
|
||||
|
||||
<button
|
||||
onclick={forwardBtnClick}
|
||||
onclick="{forwardBtnClick}"
|
||||
style="
|
||||
opacity: {controlsOpacity};
|
||||
top: {controlsPosition === 'top left' || controlsPosition === 'top right' ?
|
||||
|
|
|
|||
Loading…
Reference in a new issue