updates infobox
This commit is contained in:
parent
c545d2bc2f
commit
2d0d0263e3
4 changed files with 88 additions and 89 deletions
19
src/components/InfoBox/InfoBox.stories.mdx
Normal file
19
src/components/InfoBox/InfoBox.stories.mdx
Normal 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/)'}
|
||||||
|
/>
|
||||||
|
```
|
||||||
|
|
@ -1,15 +1,12 @@
|
||||||
<script module lang="ts">
|
<script module lang="ts">
|
||||||
// @ts-ignore raw
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
||||||
import componentDocs from './stories/docs/component.md?raw';
|
|
||||||
|
|
||||||
import InfoBox from './InfoBox.svelte';
|
import InfoBox from './InfoBox.svelte';
|
||||||
|
import BodyText from '../BodyText/BodyText.svelte';
|
||||||
|
|
||||||
import { withComponentDocs } from '$lib/docs/utils/withParams.js';
|
const { Story } = defineMeta({
|
||||||
|
|
||||||
export const meta = {
|
|
||||||
title: 'Components/Text elements/InfoBox',
|
title: 'Components/Text elements/InfoBox',
|
||||||
component: InfoBox,
|
component: InfoBox,
|
||||||
...withComponentDocs(componentDocs),
|
tags: ['autodocs'],
|
||||||
argTypes: {
|
argTypes: {
|
||||||
theme: {
|
theme: {
|
||||||
control: 'select',
|
control: 'select',
|
||||||
|
|
@ -20,29 +17,17 @@
|
||||||
options: ['normal', 'wide', 'wider', 'widest', 'fluid'],
|
options: ['normal', 'wide', 'wider', 'widest', 'fluid'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script>
|
<Story name="Demo">
|
||||||
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">
|
|
||||||
<BodyText
|
<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="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
|
<InfoBox
|
||||||
title="About this data"
|
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.'}"
|
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/)'}"
|
notes={'[Read more about our methodology](https://www.reuters.com/world-coronavirus-tracker-and-maps/en/methodology/)'}
|
||||||
/>
|
/>
|
||||||
<BodyText
|
<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="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">
|
<Story name="List">
|
||||||
<InfoBox
|
<InfoBox
|
||||||
title="What you need to know about the war"
|
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>
|
</Story>
|
||||||
|
|
|
||||||
|
|
@ -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) -->
|
<!-- @component `InfoBox` [Read the docs.](https://reuters-graphics.github.io/graphics-components/?path=/docs/components-text-elements-infobox--docs) -->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { Snippet } from 'svelte';
|
||||||
import type { ContainerWidth } from '../@types/global';
|
import type { ContainerWidth } from '../@types/global';
|
||||||
|
|
||||||
type Theme = 'light' | 'dark';
|
type Theme = 'light' | 'dark';
|
||||||
|
|
||||||
/**
|
interface Props {
|
||||||
* Title of the box
|
/**
|
||||||
*/
|
* Title of the box
|
||||||
export let title: string | null = null;
|
*/
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
let {
|
||||||
* Contents of the note as a markdown string
|
title = null,
|
||||||
*/
|
text,
|
||||||
export let text: string = '';
|
notes = null,
|
||||||
|
width = 'normal',
|
||||||
/**
|
class: cls = '',
|
||||||
* Additional footnotes
|
id = '',
|
||||||
*/ export let notes: string | null = null;
|
theme = 'light',
|
||||||
|
header,
|
||||||
/**
|
body,
|
||||||
* Width of the component within the text well.
|
footer,
|
||||||
* @type {string}
|
}: Props = $props();
|
||||||
*/
|
|
||||||
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';
|
|
||||||
|
|
||||||
import Block from '../Block/Block.svelte';
|
import Block from '../Block/Block.svelte';
|
||||||
import Markdown from '../Markdown/Markdown.svelte';
|
import Markdown from '../Markdown/Markdown.svelte';
|
||||||
|
|
@ -53,36 +65,36 @@
|
||||||
{id}
|
{id}
|
||||||
class="{cls} fmy-6 fpx-6 fpy-5 border border-solid rounded"
|
class="{cls} fmy-6 fpx-6 fpy-5 border border-solid rounded"
|
||||||
>
|
>
|
||||||
{#if $$slots.header}
|
{#if header}
|
||||||
<div class="header fmb-2">
|
<div class="header fmb-2">
|
||||||
<!-- Custom title content -->
|
<!-- Custom header content -->
|
||||||
<slot name="header" />
|
{@render header()}
|
||||||
</div>
|
</div>
|
||||||
{:else if title}
|
{:else if title}
|
||||||
<div class="header fmb-2">
|
<div class="header fmb-2">
|
||||||
<Markdown source="{title}" />
|
<Markdown source={title} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $$slots.body}
|
{#if body}
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<!-- Custom content -->
|
<!-- Custom body content -->
|
||||||
<slot name="body" />
|
{@render body()}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<Markdown source="{text}" />
|
<Markdown source={text} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if $$slots.footer}
|
{#if footer}
|
||||||
<div class="footer fmt-2">
|
<div class="footer fmt-2">
|
||||||
<!-- Custom footer content -->
|
<!-- Custom footer content -->
|
||||||
<slot name="footer" />
|
{@render footer()}
|
||||||
</div>
|
</div>
|
||||||
{:else if notes}
|
{:else if notes}
|
||||||
<div class="footer fmt-2">
|
<div class="footer fmt-2">
|
||||||
<Markdown source="{notes}" />
|
<Markdown source={notes} />
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</Block>
|
</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/)'}"
|
|
||||||
/>
|
|
||||||
```
|
|
||||||
Loading…
Reference in a new issue