@xsolla/xui-notification 0.99.0 → 0.101.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.
Files changed (2) hide show
  1. package/README.md +170 -22
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,40 +1,188 @@
1
- # @xsolla/xui-notification
1
+ # Notification
2
2
 
3
- Inline and toast-style notification banner with tone variants and optional action.
3
+ A cross-platform React notification component for displaying alerts, success messages, warnings, and errors. Supports both toast and inline display modes.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
+ npm install @xsolla/xui-notification
9
+ # or
8
10
  yarn add @xsolla/xui-notification
9
11
  ```
10
12
 
11
- ## Usage
13
+ ## Demo
14
+
15
+ ### Basic Notification
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { Notification } from '@xsolla/xui-notification';
20
+
21
+ export default function BasicNotification() {
22
+ return (
23
+ <Notification
24
+ title="Success"
25
+ message="Your changes have been saved."
26
+ tone="success"
27
+ />
28
+ );
29
+ }
30
+ ```
31
+
32
+ ### Notification Tones
33
+
34
+ ```tsx
35
+ import * as React from 'react';
36
+ import { Notification } from '@xsolla/xui-notification';
37
+
38
+ export default function NotificationTones() {
39
+ return (
40
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
41
+ <Notification tone="neutral" title="Info" message="This is an informational message." />
42
+ <Notification tone="success" title="Success" message="Operation completed successfully." />
43
+ <Notification tone="warning" title="Warning" message="Please review before proceeding." />
44
+ <Notification tone="alert" title="Error" message="Something went wrong." />
45
+ </div>
46
+ );
47
+ }
48
+ ```
49
+
50
+ ### Notification Types (Toast vs Inline)
51
+
52
+ ```tsx
53
+ import * as React from 'react';
54
+ import { Notification } from '@xsolla/xui-notification';
55
+
56
+ export default function NotificationTypes() {
57
+ return (
58
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
59
+ <Notification
60
+ type="toast"
61
+ tone="success"
62
+ title="Toast Notification"
63
+ message="This is a toast-style notification."
64
+ />
65
+ <Notification
66
+ type="inline"
67
+ tone="warning"
68
+ title="Inline Notification"
69
+ message="This is an inline-style notification."
70
+ />
71
+ </div>
72
+ );
73
+ }
74
+ ```
75
+
76
+ ### Dismissible Notification
77
+
78
+ ```tsx
79
+ import * as React from 'react';
80
+ import { Notification } from '@xsolla/xui-notification';
81
+
82
+ export default function DismissibleNotification() {
83
+ const [visible, setVisible] = React.useState(true);
84
+
85
+ if (!visible) return null;
86
+
87
+ return (
88
+ <Notification
89
+ title="Notification"
90
+ message="Click the X to dismiss this notification."
91
+ onClose={() => setVisible(false)}
92
+ />
93
+ );
94
+ }
95
+ ```
96
+
97
+ ### Notification with Action
98
+
99
+ ```tsx
100
+ import * as React from 'react';
101
+ import { Notification } from '@xsolla/xui-notification';
102
+
103
+ export default function ActionNotification() {
104
+ return (
105
+ <Notification
106
+ tone="alert"
107
+ title="Session Expiring"
108
+ message="Your session will expire in 5 minutes."
109
+ actionLabel="Extend Session"
110
+ onAction={() => console.log('Session extended')}
111
+ onClose={() => console.log('Dismissed')}
112
+ />
113
+ );
114
+ }
115
+ ```
116
+
117
+ ### Hide Close Button
12
118
 
13
119
  ```tsx
120
+ import * as React from 'react';
14
121
  import { Notification } from '@xsolla/xui-notification';
15
122
 
16
- const Example = () => (
17
- <Notification
18
- tone="success"
19
- type="inline"
20
- title="Changes saved"
21
- message="Your profile has been updated."
22
- onClose={() => console.log('closed')}
23
- />
24
- );
123
+ export default function PersistentNotification() {
124
+ return (
125
+ <Notification
126
+ tone="warning"
127
+ title="Important"
128
+ message="This notification cannot be dismissed."
129
+ showClose={false}
130
+ />
131
+ );
132
+ }
25
133
  ```
26
134
 
27
- ## Props
135
+ ## API Reference
28
136
 
29
137
  ### Notification
30
138
 
139
+ **Notification Props:**
140
+
31
141
  | Prop | Type | Default | Description |
32
- |------|------|---------|-------------|
33
- | `tone` | `"neutral" \| "success" \| "warning" \| "alert"` | `"neutral"` | Colour theme of the notification |
34
- | `type` | `"toast" \| "inline"` | `"toast"` | Layout style; `inline` is single-row, `toast` is stacked |
35
- | `title` | `string` | | Bold heading text |
36
- | `message` | `string` | | Secondary body text |
37
- | `actionLabel` | `string` | | Label for the inline action link |
38
- | `onAction` | `() => void` | | Called when the action link is pressed |
39
- | `onClose` | `() => void` | | Called when the close button is pressed |
40
- | `showClose` | `boolean` | `true` | Whether to render the close button |
142
+ | :--- | :--- | :------ | :---------- |
143
+ | tone | `"neutral" \| "success" \| "warning" \| "alert"` | `"neutral"` | Semantic color tone of the notification. |
144
+ | type | `"toast" \| "inline"` | `"toast"` | Display mode - toast for floating notifications, inline for embedded. |
145
+ | title | `string` | - | Notification title text. |
146
+ | message | `string` | - | Notification message/description text. |
147
+ | actionLabel | `string` | - | Text for the action button (optional). |
148
+ | onAction | `() => void` | - | Callback when action button is clicked. |
149
+ | onClose | `() => void` | - | Callback when close button is clicked. |
150
+ | showClose | `boolean` | `true` | Whether to show the close button. |
151
+
152
+ ### Tone Values
153
+
154
+ | Tone | Use Case |
155
+ | :--- | :------- |
156
+ | `neutral` | General information, default state |
157
+ | `success` | Positive outcomes, confirmations |
158
+ | `warning` | Caution, requires attention |
159
+ | `alert` | Errors, critical issues |
160
+
161
+ ### Type Values
162
+
163
+ | Type | Description |
164
+ | :--- | :---------- |
165
+ | `toast` | Floating notification style, typically used for temporary messages |
166
+ | `inline` | Embedded notification style, integrated into the page layout |
167
+
168
+ ## Theming
169
+
170
+ ```typescript
171
+ // Tone-specific colors accessed via theme
172
+ theme.colors.background.neutral.secondary // Neutral background
173
+ theme.colors.background.success.secondary // Success background
174
+ theme.colors.background.warning.secondary // Warning background
175
+ theme.colors.background.alert.secondary // Alert/error background
176
+
177
+ theme.colors.content.neutral.primary // Neutral icon color
178
+ theme.colors.content.success.primary // Success icon color
179
+ theme.colors.content.warning.primary // Warning icon color
180
+ theme.colors.content.alert.primary // Alert icon color
181
+ ```
182
+
183
+ ## Accessibility
184
+
185
+ - Uses semantic color tones for visual distinction
186
+ - Close button is keyboard accessible
187
+ - Icons are decorative and hidden from screen readers
188
+ - Action buttons are focusable and clickable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-notification",
3
- "version": "0.99.0",
3
+ "version": "0.101.0",
4
4
  "main": "./web/index.js",
5
5
  "module": "./web/index.mjs",
6
6
  "types": "./web/index.d.ts",
@@ -10,9 +10,9 @@
10
10
  "build:native": "PLATFORM=native tsup"
11
11
  },
12
12
  "dependencies": {
13
- "@xsolla/xui-core": "0.99.0",
14
- "@xsolla/xui-icons": "0.99.0",
15
- "@xsolla/xui-primitives-core": "0.99.0"
13
+ "@xsolla/xui-core": "0.101.0",
14
+ "@xsolla/xui-icons": "0.101.0",
15
+ "@xsolla/xui-primitives-core": "0.101.0"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": ">=16.8.0",