updates infobox

This commit is contained in:
MinamiFunakoshiTR 2025-03-06 13:45:17 -08:00
parent c545d2bc2f
commit 2d0d0263e3
Failed to extract signature
4 changed files with 88 additions and 89 deletions

View file

@ -0,0 +1,19 @@
# InfoBox
InfoBox is used to provide additional information that needs to be visually set aside from the main content flowm, such as methodology, detailed notes about data, and extra context as text stories.
Switch the theme prop to `dark` for a dark page infobox.
Use [snippets](https://svelte.dev/docs/svelte/snippet) to customise the content as needed, e.g. adding icons and thumbnail images.
```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/)'}
/>
```

View file

@ -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,29 +17,17 @@
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."
/>
<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."
@ -52,6 +37,6 @@
<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. "}"
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>

View file

@ -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>

View file

@ -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/)'}"
/>
```