@economic/taco-docs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/components/toast.md +242 -0
- package/package.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# @economic/taco-docs
|
|
2
|
+
|
|
3
|
+
Design-system knowledge files for the e-conomic design system — component, foundation, and UI pattern documentation as plain Markdown.
|
|
4
|
+
|
|
5
|
+
These files are the source-verified "brain" of the design system: structured guidance on how each component, foundation, and pattern should be used, written for humans and AI tools alike. They are not a rendered docs site — they are the content other formats are generated from.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @economic/taco-docs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Contents
|
|
14
|
+
|
|
15
|
+
| Folder | What's in it |
|
|
16
|
+
| -------------- | ------------------------------------------------------------------------------------------------------------- |
|
|
17
|
+
| `components/` | Per-component knowledge files (e.g. `toast.md`) — usage guidance, behaviour, accessibility, known limitations |
|
|
18
|
+
| `foundations/` | Design foundations (color, spacing, typography, etc.) |
|
|
19
|
+
| `patterns/` | UI patterns — how components combine to solve recurring problems |
|
|
20
|
+
|
|
21
|
+
Each file follows a consistent schema, leading with usage guidance.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
The files are Markdown. Read them directly, feed them to an AI tool, or render them however you like. From a Node consumer they resolve under the package root:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
import { readFileSync } from 'node:fs';
|
|
29
|
+
import { createRequire } from 'node:module';
|
|
30
|
+
|
|
31
|
+
const require = createRequire(import.meta.url);
|
|
32
|
+
const dir = require.resolve('@economic/taco-docs/package.json').replace(/package\.json$/, '');
|
|
33
|
+
const toast = readFileSync(`${dir}components/toast.md`, 'utf8');
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## License
|
|
37
|
+
|
|
38
|
+
MIT
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
## 1. Identity
|
|
4
|
+
|
|
5
|
+
**Name:** Toast
|
|
6
|
+
**Category:** Feedback & status
|
|
7
|
+
**Status:** available
|
|
8
|
+
**State:** taco
|
|
9
|
+
**Purpose:** Provides non-blocking, temporary feedback about the outcome of a user action.
|
|
10
|
+
**Figma:** Component set "Toast" in Web components library (ZoGBnO9A5jUExnua0wgCIM)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 2. When to use
|
|
16
|
+
|
|
17
|
+
Toasts communicate tone, not urgency. They acknowledge an outcome quietly — the user should be able to keep working without interruption.
|
|
18
|
+
|
|
19
|
+
**use-when:**
|
|
20
|
+
- Confirming a completed action: "Draft saved", "Invoice sent", "Document uploaded"
|
|
21
|
+
- Providing low-priority system feedback — noticeable but not distracting
|
|
22
|
+
- Reporting a failed action where no user decision is needed: "Export failed"
|
|
23
|
+
- Showing progress on an async operation: "Analysing documents..."
|
|
24
|
+
- Providing an undo opportunity after a reversible action: "Draft deleted" + Undo
|
|
25
|
+
- Feedback does not require a user decision
|
|
26
|
+
|
|
27
|
+
**do-not-use-when:**
|
|
28
|
+
- The message is critical or blocking — use **Banner** instead
|
|
29
|
+
- The user needs to make a decision before continuing — use **AlertDialog** instead
|
|
30
|
+
- The message needs to persist — use **Banner** instead
|
|
31
|
+
- Detailed error messaging is needed — use **Banner** or **Field** validation instead
|
|
32
|
+
- The feedback is contextual to a specific form field — use inline validation instead
|
|
33
|
+
- The content is promotional
|
|
34
|
+
- Multiple sequential confirmations would fire (e.g. bulk operations) — consolidate into a single toast or use a progress indicator
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 3. Design guidance
|
|
39
|
+
|
|
40
|
+
### Choosing a type
|
|
41
|
+
|
|
42
|
+
Types communicate tone, not urgency. Choose based on the emotion you want to convey. Success and Information can communicate similar messages, but signal different intent — positive confirmation vs. neutral information. Avoid overusing Error and Warning toasts.
|
|
43
|
+
|
|
44
|
+
| Type | Purpose | Default duration |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| Success | Confirms a successful operation | 7500ms |
|
|
47
|
+
| Error | Informs about a failed operation | Persistent |
|
|
48
|
+
| Warning | Highlights a potential issue | Persistent |
|
|
49
|
+
| Information | Neutral system feedback or process activity | Persistent |
|
|
50
|
+
| Loading | Indicates an ongoing process | Persistent |
|
|
51
|
+
| Default | Untyped feedback (no icon) | None — set explicitly |
|
|
52
|
+
|
|
53
|
+
**Duration reasoning:**
|
|
54
|
+
- **Success (7.5s):** Confirmations are low-stakes — the user triggered the action and the result is expected. Auto-dismissing after 7.5s is safe.
|
|
55
|
+
- **Error / Warning / Information (persistent):** These require the user's attention. Auto-dismissing risks the message disappearing before the user sees it — for example, an invoice booking failure that clears while the user is away from their screen. The user must dismiss explicitly.
|
|
56
|
+
- **Loading (persistent):** Continues until the operation finishes. If an operation takes a long time, consider an async approach with different feedback.
|
|
57
|
+
|
|
58
|
+
Override the default duration via the `autoClose` option (milliseconds). Omit it or set it to `undefined` for persistent behaviour.
|
|
59
|
+
|
|
60
|
+
### Content guidelines
|
|
61
|
+
|
|
62
|
+
- Keep messages brief and action-focused
|
|
63
|
+
- State the outcome, not system mechanics
|
|
64
|
+
- Do not include instructions or next steps
|
|
65
|
+
- Keep it to one message per toast
|
|
66
|
+
- Aim for messages that span no more than 2 lines (max width is 448px). As a rough target, 80–120 characters of English copy fits comfortably
|
|
67
|
+
- Danish translations of English source copy often run 15–30% longer. Where possible, write source copy short enough that the Danish translation still fits in 2 lines
|
|
68
|
+
|
|
69
|
+
For detailed guidance on formatting and writing system feedback, refer to the content guidelines in `ux-writing.md`.
|
|
70
|
+
|
|
71
|
+
### Best practices
|
|
72
|
+
|
|
73
|
+
**Message quality**
|
|
74
|
+
- Do: "Invoice sent", "Document uploaded" — brief, outcome-focused
|
|
75
|
+
- Don't: Long messages explaining what happened and what to do next
|
|
76
|
+
- Don't: Including instructions in a toast
|
|
77
|
+
|
|
78
|
+
**Toast vs. Dialog**
|
|
79
|
+
- Toasts acknowledge outcomes quietly, without demanding attention or action
|
|
80
|
+
- Do not use toasts while a dialog is open — use error labels, alert banners, or feedback directly tied to the dialog context
|
|
81
|
+
- Do: "Export failed" — simple, low-priority feedback on a user action
|
|
82
|
+
- Don't: Complex errors requiring user decisions — use AlertDialog instead
|
|
83
|
+
|
|
84
|
+
**Frequency**
|
|
85
|
+
- Consider the frequency of an action when adding a toast trigger
|
|
86
|
+
- If a toast appears so often that users expect it, it is probably the wrong pattern
|
|
87
|
+
- Do: Single "Draft saved" after saving
|
|
88
|
+
- Don't: A toast after every minor system event — too many toasts in sequence are disruptive
|
|
89
|
+
|
|
90
|
+
**Async operations: show progress, then outcome**
|
|
91
|
+
- For operations that take more than a moment, start with a loading toast, then update it to success or error. This gives users one continuous piece of feedback instead of a spinner disappearing followed by a separate confirmation
|
|
92
|
+
- Do: "Exporting..." → "Export complete" (or "Export failed")
|
|
93
|
+
- Don't: Trigger a loading toast with no message — always describe what is happening
|
|
94
|
+
|
|
95
|
+
### Actions
|
|
96
|
+
|
|
97
|
+
- Toasts can include buttons or links to help users respond: "Undo", "View document", "Try again", "Read more"
|
|
98
|
+
- Only the `discrete` button appearance is allowed
|
|
99
|
+
- Maximum one action per toast
|
|
100
|
+
|
|
101
|
+
Note: buttons and links are currently being redesigned. To avoid technical debt, avoid adding actions to toasts until that work lands.
|
|
102
|
+
|
|
103
|
+
### Text-id naming
|
|
104
|
+
|
|
105
|
+
When providing an ID for a toast, use the pattern:
|
|
106
|
+
`TOAST_DOMAIN_SUBDOMAIN_ACTION_OR_STATE_PLURAL_TYPE`
|
|
107
|
+
|
|
108
|
+
Not all segments are required, but the order should always stay the same.
|
|
109
|
+
|
|
110
|
+
| Segment | Usage |
|
|
111
|
+
|---|---|
|
|
112
|
+
| TOAST | Starter segment for consistency and searchability |
|
|
113
|
+
| DOMAIN | Identifier for the product area |
|
|
114
|
+
| SUBDOMAIN | Used to specify when there is a clear hierarchy |
|
|
115
|
+
| ACTION_OR_STATE | The action the toast responds to — should reflect the message |
|
|
116
|
+
| PLURAL | Append if a plural version exists |
|
|
117
|
+
| TYPE | Always last. Used if the toast has multiple states. Relates directly to the variant |
|
|
118
|
+
|
|
119
|
+
Examples:
|
|
120
|
+
- `TOAST_INVOICE_SAVE_SUCCESS`
|
|
121
|
+
- `TOAST_DOCUMENT_UPLOAD_FILE_TOO_BIG_ERROR`
|
|
122
|
+
|
|
123
|
+
### Anatomy
|
|
124
|
+
|
|
125
|
+
1. **Badge Icon** — type indicator (tick, close, warning, info) or spinner for loading
|
|
126
|
+
2. **Text** — the message content
|
|
127
|
+
3. **Action** (optional) — a single discrete button or link
|
|
128
|
+
4. **Close button** — always present, dismisses the toast
|
|
129
|
+
5. **Spinner** — replaces badge icon for loading type
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 4. Behaviour
|
|
134
|
+
|
|
135
|
+
### Placement
|
|
136
|
+
Toasts are anchored to the bottom-right corner and overlay page content, except for the top navigation and agreement selector.
|
|
137
|
+
|
|
138
|
+
### Stacking
|
|
139
|
+
- Multiple toasts stack vertically upward, with the most recent toast at the bottom
|
|
140
|
+
- Be mindful of usage — there is currently no limit to the number of visible toasts, which can cause them to extend beyond the viewport
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
### Duration
|
|
144
|
+
- Users should always be able to dismiss a toast
|
|
145
|
+
- Hovering over a toast pauses its auto-close timer. When the mouse leaves, the timer resumes with the remaining time — it does not restart from the full duration
|
|
146
|
+
- Timer resets to the full duration when toast content is updated (e.g. loading-to-result transition)
|
|
147
|
+
|
|
148
|
+
### Text overflow
|
|
149
|
+
Toasts have a maximum width of 448px. Text wraps if it exceeds this width.
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## 5. Accessibility
|
|
154
|
+
|
|
155
|
+
- Action buttons in toasts (e.g. "Undo", "Try again") must include a clear, descriptive label
|
|
156
|
+
- Toast messages are announced to screen readers when they appear — content should be meaningful when read out of context
|
|
157
|
+
- Toasts do not move focus automatically. Users can continue their current task uninterrupted. Pressing Tab navigates to the toast dismiss button
|
|
158
|
+
- Toast does not trap focus
|
|
159
|
+
|
|
160
|
+
**Known gaps:**
|
|
161
|
+
- No `Escape` key handler to dismiss toasts
|
|
162
|
+
- Container uses `role="log"` but lacks `aria-live` and `aria-atomic` attributes — screen reader announcement reliability varies by browser
|
|
163
|
+
- Close button touch target size not verified against AAA minimums (44x44 CSS px)
|
|
164
|
+
- No responsive adaptation for narrow viewports
|
|
165
|
+
- Colour contrast ratios not documented for border colours or icon colours against white background
|
|
166
|
+
|
|
167
|
+
**Open questions for a future replacement:**
|
|
168
|
+
- Should `Escape` dismiss the most recent toast, or all toasts?
|
|
169
|
+
- Is `role="log"` the right ARIA role, or should type determine the role (`role="status"` for success/info, `role="alert"` for error/warning)?
|
|
170
|
+
- What `aria-live` politeness level? `polite` for success/info, `assertive` for error/warning?
|
|
171
|
+
- Should auto-dismiss respect `prefers-reduced-motion`, and should the animation itself fall back to a fade or no animation?
|
|
172
|
+
- Should error toasts be persistent by default rather than 8000ms, given the WCAG 2.2.3 tension?
|
|
173
|
+
- What is the right maximum visible stack count for our context — 1, 3, or some other number?
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## 6. Known limitations
|
|
178
|
+
|
|
179
|
+
**No keyboard dismiss.** No `Escape` key handler. Close button is Tab-reachable but there is no shortcut.
|
|
180
|
+
|
|
181
|
+
**No toast limit.** Rapid-fire operations can stack toasts beyond the viewport. Most established design systems cap visible toasts at 1–3.
|
|
182
|
+
|
|
183
|
+
**No `prefers-reduced-motion` handling.** The Framer Motion entry/exit animations always play, regardless of the user's system setting. Users who have requested reduced motion still see the spring animation.
|
|
184
|
+
|
|
185
|
+
**`role="log"` is non-standard for transient notifications.** WAI-ARIA documents `role="log"` for chat-like or feed-like sequences, not for one-off transient messages. Most design systems use `role="status"` (polite) for non-critical and `role="alert"` (assertive) for errors. Our use of `log` is a known divergence — screen reader behaviour may vary.
|
|
186
|
+
|
|
187
|
+
**Auto-dismiss tension with WCAG 2.2.3.** WAI-ARIA Authoring Practices explicitly discourages auto-dismissing alerts because of WCAG 2.2.3 (sufficient time). We mitigate by pausing the timer on hover and recommending persistent toasts for errors, but this remains an accepted trade-off rather than a resolved issue.
|
|
188
|
+
|
|
189
|
+
**No built-in action slot.** The product has built a `ToastWithAction` wrapper to render toasts with action buttons in a consistent layout.
|
|
190
|
+
|
|
191
|
+
**No multi-message / list support.** The product has built a `useFieldlessErrorToast` wrapper to render multiple errors as a list — a recurring need, not supported natively.
|
|
192
|
+
|
|
193
|
+
**No progress tracking beyond the loading spinner.** Long-running async state needs custom handling (the product has a `usePayFromDocumentsSettingProgressToast` wrapper).
|
|
194
|
+
|
|
195
|
+
**Fixed positioning only.** Bottom-right via portal. The product has a `setToastPosition` workaround that manipulates container styles to align toasts with specific page elements — evidence the fixed model is insufficient for some layouts.
|
|
196
|
+
|
|
197
|
+
**No responsive behaviour.** Max width and positioning are hardcoded. No adaptation for narrow viewports.
|
|
198
|
+
|
|
199
|
+
**All values hardcoded.** No semantic tokens. All colours, spacing, timing, and z-index are Tailwind classes or magic numbers.
|
|
200
|
+
|
|
201
|
+
**Code defaults differ from guidance.** The API is more permissive than the design intent — see duration table notes.
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## 7. Do not extend
|
|
206
|
+
|
|
207
|
+
Toast is a legacy taco component. It is functional and widely adopted, but:
|
|
208
|
+
- All visual values are hardcoded — not on the new token system
|
|
209
|
+
- Accessibility gaps exist (keyboard, focus, ARIA)
|
|
210
|
+
- The fixed positioning model has known workarounds in the product
|
|
211
|
+
|
|
212
|
+
Use it as-is for current product work. A new DS replacement, if planned, should address the gaps documented here.
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 8. Replacement
|
|
217
|
+
|
|
218
|
+
No replacement is currently planned or in progress.
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 9. Related components
|
|
223
|
+
|
|
224
|
+
**Banner** — Both provide feedback, but Banner is persistent and contextual. Use Banner instead when the message is tied to page state rather than a specific action, needs to persist until the user addresses it, or requires detailed explanation.
|
|
225
|
+
|
|
226
|
+
**Dialog** — Both can communicate outcomes, but Dialog blocks interaction. Use Dialog instead when the user needs to make a decision before continuing.
|
|
227
|
+
|
|
228
|
+
**AlertDialog** — Both can communicate problems, but AlertDialog is blocking and confirmatory. Use AlertDialog instead when a destructive or irreversible action needs explicit user confirmation.
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## 10. Implementation notes
|
|
233
|
+
|
|
234
|
+
Only what the code can't tell you:
|
|
235
|
+
|
|
236
|
+
- Toast is imperative and hook-driven — the only component in the design system never rendered as JSX directly
|
|
237
|
+
- Duplicate toasts with identical content are merged, not stacked — the existing toast pulses and its timer resets
|
|
238
|
+
- Updating a toast (e.g. loading to success) removes the original and inserts a new one — this triggers an animation, not an in-place swap
|
|
239
|
+
- Toasts are hidden in print
|
|
240
|
+
- The close button aria-label is localised via the Provider context
|
|
241
|
+
|
|
242
|
+
For API signatures, props, types, and full technical details: see the component source in the taco repo or `sources/engineering/toast.md`.
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@economic/taco-docs",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Design-system knowledge files for the e-conomic design system — component, foundation, and UI pattern documentation as Markdown.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"design-system",
|
|
8
|
+
"documentation",
|
|
9
|
+
"economic",
|
|
10
|
+
"taco"
|
|
11
|
+
],
|
|
12
|
+
"files": [
|
|
13
|
+
"components",
|
|
14
|
+
"foundations",
|
|
15
|
+
"patterns",
|
|
16
|
+
"README.md"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
}
|
|
21
|
+
}
|