adds docs
This commit is contained in:
parent
929dca2fd8
commit
e35904dc45
3 changed files with 132 additions and 44 deletions
|
|
@ -32,3 +32,88 @@ The `SimpleTimeline` component creates a basic timeline with dates, titles and d
|
|||
```
|
||||
|
||||
<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} />
|
||||
|
|
|
|||
|
|
@ -49,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: [
|
||||
|
|
@ -95,3 +84,12 @@
|
|||
dates,
|
||||
}}
|
||||
/>
|
||||
|
||||
<Story
|
||||
name="Multiple events"
|
||||
exportName="MultipleEvents"
|
||||
tags={['!autodocs', '!dev']}
|
||||
args={{
|
||||
dates: datesMultipleEvents,
|
||||
}}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
<!-- @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;
|
||||
|
|
@ -9,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}">
|
||||
|
|
|
|||
Loading…
Reference in a new issue