Skip to content

Commit b0d1135

Browse files
author
ci-bot
committed
remove log and doc
1 parent d2cf4f0 commit b0d1135

File tree

2 files changed

+147
-4
lines changed

2 files changed

+147
-4
lines changed

libs/remix-ui/toaster/README.md

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Toaster Plugin Usage Guide
2+
3+
This guide explains how to use the Remix Toaster notification system in your plugin.
4+
5+
## Overview
6+
7+
The toaster system provides a simple way to display temporary notification messages to users. It's accessible through the `notification` plugin API.
8+
9+
## Basic Usage
10+
11+
### Displaying a Toast
12+
13+
To display a simple toast notification:
14+
15+
```typescript
16+
const id = await remix.call('notification' as any, 'toast', 'Your message here')
17+
```
18+
19+
The `toast` method returns a unique ID (timestamp) that can be used to dismiss the toast later.
20+
21+
### Displaying a Toast with Custom Timeout
22+
23+
By default, toasts disappear after 2000ms (2 seconds). You can specify a custom duration:
24+
25+
```typescript
26+
// Show toast for 10 seconds
27+
const id = await remix.call('notification' as any, 'toast', 'This message will stay longer', 10000)
28+
```
29+
30+
**Timeout Behavior:**
31+
- **Default:** 2000ms (2 seconds)
32+
- **> 2000ms:** Displays a loading spinner icon
33+
- **> 5000ms:** Displays both a loading spinner icon and a close button
34+
35+
### Hiding a Toast Manually
36+
37+
You can dismiss a toast before its timeout expires using the ID returned from the `toast` call:
38+
39+
```typescript
40+
const id = await remix.call('notification' as any, 'toast', 'Processing...')
41+
42+
// Do some work...
43+
await doSomeWork()
44+
45+
// Hide the toast when done
46+
await remix.call('notification' as any, 'hideToaster', id)
47+
```
48+
49+
## API Reference
50+
51+
### `toast(message: string | JSX.Element, timeout?: number, timestamp?: number): Promise<number>`
52+
53+
Displays a toast notification.
54+
55+
**Parameters:**
56+
- `message` - The message to display (string or JSX element)
57+
- `timeout` (optional) - Duration in milliseconds before the toast auto-dismisses (default: 2000)
58+
- `timestamp` (optional) - Custom ID for the toast (auto-generated if not provided)
59+
60+
**Returns:** A unique ID (number) that can be used to dismiss the toast
61+
62+
### `hideToaster(id: number): Promise<void>`
63+
64+
Manually dismisses a specific toast notification.
65+
66+
**Parameters:**
67+
- `id` - The toast ID returned by the `toast` method
68+
69+
## Examples
70+
71+
### Example 1: Simple Notification
72+
73+
```typescript
74+
await remix.call('notification' as any, 'toast', 'File saved successfully!')
75+
```
76+
77+
### Example 2: Long-Running Operation
78+
79+
```typescript
80+
// Show a persistent toast with spinner
81+
const id = await remix.call('notification' as any, 'toast', 'Compiling contracts...', 30000)
82+
83+
try {
84+
await compileContracts()
85+
// Hide the toast when done
86+
await remix.call('notification' as any, 'hideToaster', id)
87+
// Show success message
88+
await remix.call('notification' as any, 'toast', 'Compilation completed!')
89+
} catch (error) {
90+
await remix.call('notification' as any, 'hideToaster', id)
91+
await remix.call('notification' as any, 'toast', 'Compilation failed!')
92+
}
93+
```
94+
95+
### Example 3: Multiple Sequential Toasts
96+
97+
```typescript
98+
const id1 = await remix.call('notification' as any, 'toast', 'Step 1: Initializing...')
99+
await step1()
100+
101+
const id2 = await remix.call('notification' as any, 'toast', 'Step 2: Processing...')
102+
await step2()
103+
104+
const id3 = await remix.call('notification' as any, 'toast', 'Step 3: Finalizing...')
105+
await step3()
106+
107+
await remix.call('notification' as any, 'toast', 'All steps completed!')
108+
```
109+
110+
## Best Practices
111+
112+
1. **Keep messages concise** - Toast notifications should be brief and to the point
113+
2. **Use appropriate timeouts** - Short messages (< 10 words) can use the default timeout, longer messages should have extended timeouts
114+
3. **Clean up long-running toasts** - Always hide toasts for long-running operations once they complete
115+
4. **Provide feedback** - Use toasts to confirm user actions (saves, deletions, etc.)
116+
5. **Don't overuse** - Too many toasts can be overwhelming; use them for important notifications only
117+
118+
## UI Features
119+
120+
- **Position:** Top-right corner of the screen
121+
- **Styling:** Uses Bootstrap alert classes (`alert-info`)
122+
- **Loading indicator:** Automatically shown for toasts with timeout > 2000ms
123+
- **Close button:** Automatically shown for toasts with timeout > 5000ms
124+
- **Auto-dismiss:** Toasts automatically disappear after the specified timeout
125+
- **Manual dismiss:** Toasts can be dismissed early using `hideToaster`
126+
127+
## TypeScript Types
128+
129+
```typescript
130+
interface ToasterProps {
131+
message: string | JSX.Element
132+
timeout?: number
133+
handleHide?: () => void
134+
timestamp?: number
135+
id?: string | number
136+
onToastCreated?: (toastId: string | number) => void
137+
}
138+
```
139+
140+
## Related APIs
141+
142+
The notification plugin also provides other methods for user interaction:
143+
144+
- `modal()` - Display a modal dialog
145+
- `alert()` - Display an alert dialog
146+
147+
For more information, see the notification plugin documentation.

libs/remix-ui/toaster/src/lib/toaster.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const ToastTrigger = (props: ToasterProps) => {
5959
}
6060
}
6161
)
62-
console.log('toastId', toastId, props.id)
6362
} else {
6463
// For JSX elements, use toast.custom
6564
const toastId = toast.custom(
@@ -85,7 +84,6 @@ export const ToastTrigger = (props: ToasterProps) => {
8584
}
8685
}
8786
)
88-
console.log('toastId', toastId, props.id)
8987
}
9088
}
9189
}, [])
@@ -152,7 +150,6 @@ export const Toaster = (props: ToasterProps) => {
152150
}
153151
}
154152
)
155-
console.log('toastId', toastId, props.id)
156153
} else {
157154
// For JSX elements, use toast.custom
158155
toastId = toast.custom(
@@ -178,7 +175,6 @@ export const Toaster = (props: ToasterProps) => {
178175
}
179176
}
180177
)
181-
console.log('toastId', toastId, props.id)
182178
}
183179

184180
// Call the callback with the toast ID so caller can dismiss it later

0 commit comments

Comments
 (0)