Skip to content

Commit eb006c2

Browse files
Pull request #72: Add toast documentation
Merge in DEV/colibri-docs from feature/EOA4108-add_toast_documentation to release/current * commit 'd1721cbbbd65d32d6988e8f317949a65c21736f3': EOA-4108: update stories naming and dynamic permalink title Fix merge Fix 'show toast' button Add improvements Add toast docuemntation Add improvements Add toast docuemntation
2 parents 2bf4e30 + d1721cb commit eb006c2

File tree

2 files changed

+545
-0
lines changed

2 files changed

+545
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import { Meta, Title, Subtitle, Canvas, Story, ArgTypes } from '@storybook/blocks';
2+
import * as ColToastStories from './col-toast.stories';
3+
import LinkTo from '@storybook/addon-links/react';
4+
5+
<Meta of={ColToastStories} />
6+
7+
<div className="col-doc__wrapper">
8+
<div className="col-doc__container">
9+
10+
<Title>Toast</Title>
11+
12+
The `col-toast` component displays temporary notifications to inform users about recent events, states, or actions.
13+
14+
<Subtitle>Table of contents</Subtitle>
15+
- [How to use it](#how-to-use-it)
16+
- [When to use it](#when-to-use-it)
17+
- [Component preview](#component-preview)
18+
- [Variants](#variants)
19+
- [Types](#types)
20+
- [Using slots](#using-slots)
21+
- [Custom duration](#custom-duration)
22+
- [Accessibility](#accessibility)
23+
- [Properties](#properties)
24+
- [Interact with the component](#interact-with-the-component)
25+
26+
## How to use it
27+
28+
1. Install the package:
29+
```bash
30+
npm install @telesign/colibri
31+
```
32+
33+
2. Import dependencies:
34+
```ts
35+
import { registerColibriComponents, ColToast } from '@telesign/colibri';
36+
import '@telesign/colibri/styles/styles.css';
37+
```
38+
39+
3. Register the component:
40+
```typescript
41+
// Option 1: Register specific components
42+
registerColibriComponents([ColToast]);
43+
44+
// Option 2: Register all Colibri components
45+
registerAllComponents();
46+
```
47+
48+
4. Use it in your HTML:
49+
```html
50+
<col-toast
51+
variant="information"
52+
type="informative"
53+
open
54+
>
55+
<col-typography variant="subheading" slot="title">Notification</col-typography>
56+
<div>This is an informational message.</div>
57+
</col-toast>
58+
```
59+
60+
## When to use it
61+
62+
Use `col-toast` to:
63+
64+
- Show temporary messages that don’t interrupt the user experience.
65+
- Alert about errors, warnings, or important information.
66+
- Confirm actions with visual feedback.
67+
68+
## Component preview
69+
70+
<Canvas of={ColToastStories.Default} />
71+
72+
## Variants
73+
74+
Variants control the visual style and icon:
75+
76+
- **Information**: General informational messages.
77+
- **Success**: Confirm successful actions.
78+
- **Warning**: Alerts that require attention.
79+
- **Danger**: Errors or critical alerts.
80+
81+
<Canvas of={ColToastStories.Default} />
82+
<Canvas of={ColToastStories.Success} />
83+
<Canvas of={ColToastStories.Warning}/>
84+
<Canvas of={ColToastStories.Danger} />
85+
86+
## Types
87+
88+
Control behavior and interaction:
89+
90+
- **Informative**: Automatically closes after the specified `duration` in seconds (clamped between 3 and 6 seconds).
91+
- **Action-close**: Requires manual closing by the user via a close button.
92+
93+
<Canvas of={ColToastStories.Autoclose} />
94+
<Canvas of={ColToastStories.ActionClose} />
95+
96+
## Using slots
97+
98+
`col-toast` provides several slots for customization:
99+
100+
- `icon`: Replaces the default icon.
101+
- `title`: Short title text.
102+
- Default slot: Main content / description.
103+
104+
Example with all slots used:
105+
106+
<Canvas of={ColToastStories.SlotsExample} />
107+
108+
## Custom duration
109+
110+
The `duration` property controls how long the toast stays visible (in seconds). It applies mainly to the `informative` type.
111+
112+
Example custom duration of 10 seconds:
113+
<Canvas of={ColToastStories.InformationCustomDuration} />
114+
115+
## Accessibility
116+
117+
The component is designed with accessibility in mind:
118+
119+
- Uses ARIA roles `alert` for `warning` and `danger` variants to ensure urgent announcements.
120+
- Uses ARIA role `status` for informational variants for polite screen reader updates.
121+
- Supports `aria-live` for dynamic updates.
122+
- Close button includes an accessible `aria-label`.
123+
- Fully keyboard navigable with support for `Enter` and `Space` keys.
124+
125+
## Properties
126+
127+
<ArgTypes of={ColToastStories} />
128+
129+
## Interact with the component
130+
131+
You can test the toast's behavior, variants, types, and slots interactively in the <LinkTo title={ColToastStories.default.title} story="default">Default</LinkTo> section below.
132+
</div>
133+
</div>

0 commit comments

Comments
 (0)