@xsolla/xui-notification-panel 0.99.0 → 0.100.0
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 +224 -13
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,28 +1,239 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: NotificationPanel
|
|
3
|
+
subtitle: A full-width notification bar for persistent inline feedback.
|
|
4
|
+
description: A cross-platform React notification panel for displaying contextual feedback messages within page layouts.
|
|
5
|
+
---
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
# NotificationPanel
|
|
8
|
+
|
|
9
|
+
A full-width horizontal notification bar designed for persistent inline notifications within page layouts. Unlike the Notification component (designed for toast popups), NotificationPanel is intended for contextual feedback messages that should remain visible until dismissed.
|
|
4
10
|
|
|
5
11
|
## Installation
|
|
6
12
|
|
|
7
13
|
```bash
|
|
14
|
+
npm install @xsolla/xui-notification-panel
|
|
15
|
+
# or
|
|
8
16
|
yarn add @xsolla/xui-notification-panel
|
|
9
17
|
```
|
|
10
18
|
|
|
11
|
-
##
|
|
19
|
+
## Demo
|
|
20
|
+
|
|
21
|
+
### Basic NotificationPanel
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import * as React from 'react';
|
|
25
|
+
import { NotificationPanel } from '@xsolla/xui-notification-panel';
|
|
26
|
+
|
|
27
|
+
export default function BasicNotificationPanel() {
|
|
28
|
+
return (
|
|
29
|
+
<NotificationPanel
|
|
30
|
+
type="success"
|
|
31
|
+
title="Success!"
|
|
32
|
+
description="Your changes have been saved."
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### NotificationPanel Types
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import * as React from 'react';
|
|
42
|
+
import { NotificationPanel } from '@xsolla/xui-notification-panel';
|
|
43
|
+
|
|
44
|
+
export default function NotificationPanelTypes() {
|
|
45
|
+
return (
|
|
46
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
47
|
+
<NotificationPanel type="neutral" title="Info" description="This is an informational message." />
|
|
48
|
+
<NotificationPanel type="success" title="Success" description="Operation completed successfully." />
|
|
49
|
+
<NotificationPanel type="warning" title="Warning" description="Please review before proceeding." />
|
|
50
|
+
<NotificationPanel type="alert" title="Error" description="Something went wrong." />
|
|
51
|
+
<NotificationPanel type="brand" title="Brand" description="A branded notification message." />
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### With Action Button
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import * as React from 'react';
|
|
61
|
+
import { NotificationPanel } from '@xsolla/xui-notification-panel';
|
|
62
|
+
|
|
63
|
+
export default function ActionNotificationPanel() {
|
|
64
|
+
return (
|
|
65
|
+
<NotificationPanel
|
|
66
|
+
type="warning"
|
|
67
|
+
title="Session Expiring"
|
|
68
|
+
description="Your session will expire in 5 minutes."
|
|
69
|
+
actionLabel="Extend Session"
|
|
70
|
+
actionProps={{ onPress: () => console.log('Session extended') }}
|
|
71
|
+
onClose={() => console.log('Dismissed')}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### With Button Icon and Divider
|
|
12
78
|
|
|
13
79
|
```tsx
|
|
80
|
+
import * as React from 'react';
|
|
14
81
|
import { NotificationPanel } from '@xsolla/xui-notification-panel';
|
|
82
|
+
import { ArrowRight } from '@xsolla/xui-icons-base';
|
|
15
83
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
84
|
+
export default function IconButtonNotificationPanel() {
|
|
85
|
+
return (
|
|
86
|
+
<NotificationPanel
|
|
87
|
+
type="neutral"
|
|
88
|
+
description="Check our guide to view all webhooks"
|
|
89
|
+
actionLabel="Open documentation"
|
|
90
|
+
actionProps={{
|
|
91
|
+
iconRight: <ArrowRight />,
|
|
92
|
+
divider: true,
|
|
93
|
+
onPress: () => console.log('Open docs'),
|
|
94
|
+
}}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
24
98
|
```
|
|
25
99
|
|
|
26
|
-
|
|
100
|
+
### Title Only
|
|
101
|
+
|
|
102
|
+
```tsx
|
|
103
|
+
import * as React from 'react';
|
|
104
|
+
import { NotificationPanel } from '@xsolla/xui-notification-panel';
|
|
105
|
+
|
|
106
|
+
export default function TitleOnlyNotificationPanel() {
|
|
107
|
+
return (
|
|
108
|
+
<NotificationPanel
|
|
109
|
+
type="success"
|
|
110
|
+
title="Your payment was successful!"
|
|
111
|
+
/>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Description Only
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import * as React from 'react';
|
|
120
|
+
import { NotificationPanel } from '@xsolla/xui-notification-panel';
|
|
121
|
+
|
|
122
|
+
export default function DescriptionOnlyNotificationPanel() {
|
|
123
|
+
return (
|
|
124
|
+
<NotificationPanel
|
|
125
|
+
type="warning"
|
|
126
|
+
description="Please verify your email address to continue using all features."
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Without Icon
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
import * as React from 'react';
|
|
136
|
+
import { NotificationPanel } from '@xsolla/xui-notification-panel';
|
|
137
|
+
|
|
138
|
+
export default function NoIconNotificationPanel() {
|
|
139
|
+
return (
|
|
140
|
+
<NotificationPanel
|
|
141
|
+
type="neutral"
|
|
142
|
+
title="Notice"
|
|
143
|
+
description="This notification has no icon."
|
|
144
|
+
showIcon={false}
|
|
145
|
+
/>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### Without Close Button
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
import * as React from 'react';
|
|
154
|
+
import { NotificationPanel } from '@xsolla/xui-notification-panel';
|
|
155
|
+
|
|
156
|
+
export default function PersistentNotificationPanel() {
|
|
157
|
+
return (
|
|
158
|
+
<NotificationPanel
|
|
159
|
+
type="alert"
|
|
160
|
+
title="Critical"
|
|
161
|
+
description="This notification cannot be dismissed."
|
|
162
|
+
showCloseButton={false}
|
|
163
|
+
/>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## API Reference
|
|
169
|
+
|
|
170
|
+
### NotificationPanel
|
|
171
|
+
|
|
172
|
+
**NotificationPanel Props:**
|
|
173
|
+
|
|
174
|
+
| Prop | Type | Default | Description |
|
|
175
|
+
| :--- | :--- | :------ | :---------- |
|
|
176
|
+
| type | `"alert" \| "warning" \| "success" \| "neutral" \| "brand"` | `"neutral"` | Visual variant/tone of the notification. |
|
|
177
|
+
| title | `string` | - | Title text (optional). |
|
|
178
|
+
| description | `string` | - | Description text (optional). |
|
|
179
|
+
| showIcon | `boolean` | `true` | Show/hide the icon frame. |
|
|
180
|
+
| icon | `React.ReactNode` | - | Custom icon override (optional). |
|
|
181
|
+
| actionLabel | `string` | - | Action button label (hides button if not provided). |
|
|
182
|
+
| actionProps | `ActionButtonProps` | - | Additional props to pass to the action Button. |
|
|
183
|
+
| showCloseButton | `boolean` | `true` | Show/hide close button. |
|
|
184
|
+
| onClose | `() => void` | - | Close button click handler. |
|
|
185
|
+
| testID | `string` | - | Test ID for testing frameworks. |
|
|
186
|
+
|
|
187
|
+
### ActionButtonProps
|
|
188
|
+
|
|
189
|
+
`ActionButtonProps` extends `ButtonProps` but excludes `children`, `size`, `variant`, and `tone` which are controlled by NotificationPanel.
|
|
190
|
+
|
|
191
|
+
| Prop | Type | Description |
|
|
192
|
+
| :--- | :--- | :---------- |
|
|
193
|
+
| onPress | `() => void` | Button press handler. |
|
|
194
|
+
| iconRight | `React.ReactNode` | Icon to display on the right side of the button. |
|
|
195
|
+
| divider | `boolean` | Show divider between button text and icon. |
|
|
196
|
+
| disabled | `boolean` | Disable the button. |
|
|
197
|
+
|
|
198
|
+
### Type Values
|
|
199
|
+
|
|
200
|
+
| Type | Use Case | Button Tone |
|
|
201
|
+
| :--- | :------- | :---------- |
|
|
202
|
+
| `neutral` | General information, default state | mono |
|
|
203
|
+
| `success` | Positive outcomes, confirmations | brandExtra |
|
|
204
|
+
| `warning` | Caution, requires attention | mono |
|
|
205
|
+
| `alert` | Errors, critical issues | alert |
|
|
206
|
+
| `brand` | Branded messages, promotions | brand |
|
|
207
|
+
|
|
208
|
+
## Theming
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// Type-specific colors accessed via theme
|
|
212
|
+
theme.colors.overlay.alert // Alert background
|
|
213
|
+
theme.colors.overlay.warning // Warning background
|
|
214
|
+
theme.colors.overlay.success // Success background
|
|
215
|
+
theme.colors.overlay.mono // Neutral background
|
|
216
|
+
theme.colors.overlay.brand // Brand background
|
|
217
|
+
|
|
218
|
+
// Icon frame backgrounds
|
|
219
|
+
theme.colors.background.warning.primary // Warning icon frame
|
|
220
|
+
theme.colors.background.success.primary // Success icon frame
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Accessibility
|
|
224
|
+
|
|
225
|
+
- Uses `role="status"` for screen reader announcements
|
|
226
|
+
- Includes `aria-label` with notification type
|
|
227
|
+
- Close button has `aria-label="Close notification"`
|
|
228
|
+
- Action buttons are keyboard accessible and focusable
|
|
229
|
+
- Icons are decorative and hidden from screen readers
|
|
230
|
+
|
|
231
|
+
## Comparison with Notification
|
|
27
232
|
|
|
28
|
-
|
|
233
|
+
| Feature | Notification | NotificationPanel |
|
|
234
|
+
| :------ | :----------- | :---------------- |
|
|
235
|
+
| Use case | Toast popups, temporary messages | Inline banners, persistent messages |
|
|
236
|
+
| Display | Floating overlay | Full-width inline |
|
|
237
|
+
| Layout | Compact, stacked | Horizontal bar |
|
|
238
|
+
| Icon | Inline with text | Separate colored frame |
|
|
239
|
+
| Types | 4 tones (neutral, success, warning, alert) | 5 types (+ brand) |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-notification-panel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.100.0",
|
|
4
4
|
"main": "./web/index.js",
|
|
5
5
|
"module": "./web/index.mjs",
|
|
6
6
|
"types": "./web/index.d.ts",
|
|
@@ -13,10 +13,10 @@
|
|
|
13
13
|
"test:coverage": "vitest run --coverage"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@xsolla/xui-button": "0.
|
|
17
|
-
"@xsolla/xui-core": "0.
|
|
18
|
-
"@xsolla/xui-icons-base": "0.
|
|
19
|
-
"@xsolla/xui-primitives-core": "0.
|
|
16
|
+
"@xsolla/xui-button": "0.100.0",
|
|
17
|
+
"@xsolla/xui-core": "0.100.0",
|
|
18
|
+
"@xsolla/xui-icons-base": "0.100.0",
|
|
19
|
+
"@xsolla/xui-primitives-core": "0.100.0"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"react": ">=16.8.0",
|