@xsolla/xui-toggletip 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 +272 -22
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -1,41 +1,291 @@
1
- # @xsolla/xui-toggletip
1
+ # Toggletip
2
2
 
3
- Click-triggered info popover with optional title, body content, and footer actions.
3
+ A cross-platform React toggletip component that shows rich content (title, body, footer) in a popover when the trigger element is clicked.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
+ npm install @xsolla/xui-toggletip
9
+ # or
8
10
  yarn add @xsolla/xui-toggletip
9
11
  ```
10
12
 
11
- ## Usage
13
+ ## Demo
14
+
15
+ ### Basic Toggletip
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { Toggletip } from '@xsolla/xui-toggletip';
20
+ import { IconButton } from '@xsolla/xui-button';
21
+ import { HelpCircle } from '@xsolla/xui-icons-base';
22
+
23
+ export default function BasicToggletip() {
24
+ return (
25
+ <Toggletip
26
+ title="Help"
27
+ content="Click here to learn more about this feature."
28
+ >
29
+ <IconButton
30
+ icon={<HelpCircle size={20} />}
31
+ variant="secondary"
32
+ tone="mono"
33
+ size="sm"
34
+ aria-label="Help"
35
+ />
36
+ </Toggletip>
37
+ );
38
+ }
39
+ ```
40
+
41
+ ### With Footer Actions
42
+
43
+ ```tsx
44
+ import * as React from 'react';
45
+ import { Toggletip } from '@xsolla/xui-toggletip';
46
+ import { Button } from '@xsolla/xui-button';
47
+ import { Info } from '@xsolla/xui-icons-base';
48
+
49
+ export default function WithFooter() {
50
+ return (
51
+ <Toggletip
52
+ title="Confirmation"
53
+ content="Are you sure you want to proceed with this action?"
54
+ footer={
55
+ <>
56
+ <Button size="sm" variant="secondary">Cancel</Button>
57
+ <Button size="sm">Confirm</Button>
58
+ </>
59
+ }
60
+ >
61
+ <Button size="sm" iconLeft={<Info size={16} />}>
62
+ Details
63
+ </Button>
64
+ </Toggletip>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ### Different Directions
12
70
 
13
71
  ```tsx
72
+ import * as React from 'react';
14
73
  import { Toggletip } from '@xsolla/xui-toggletip';
15
74
  import { Button } from '@xsolla/xui-button';
16
75
 
17
- const Example = () => (
18
- <Toggletip
19
- title="About this feature"
20
- content="This setting controls the visibility of optional UI elements."
21
- footer={<Button size="xs">Got it</Button>}
22
- direction="bottom"
23
- >
24
- <Button variant="secondary" tone="mono" size="xs">Info</Button>
25
- </Toggletip>
26
- );
76
+ export default function Directions() {
77
+ return (
78
+ <div style={{ display: 'flex', gap: 16, padding: 100 }}>
79
+ <Toggletip direction="top" content="Appears above">
80
+ <Button size="sm">Top</Button>
81
+ </Toggletip>
82
+ <Toggletip direction="bottom" content="Appears below">
83
+ <Button size="sm">Bottom</Button>
84
+ </Toggletip>
85
+ <Toggletip direction="left" content="Appears left">
86
+ <Button size="sm">Left</Button>
87
+ </Toggletip>
88
+ <Toggletip direction="right" content="Appears right">
89
+ <Button size="sm">Right</Button>
90
+ </Toggletip>
91
+ </div>
92
+ );
93
+ }
27
94
  ```
28
95
 
29
- ## Props
96
+ ## Anatomy
97
+
98
+ ```jsx
99
+ import { Toggletip } from '@xsolla/xui-toggletip';
100
+
101
+ <Toggletip
102
+ title="Title" // Optional header title
103
+ content="Description" // Main content (string or ReactNode)
104
+ footer={<Actions />} // Optional footer actions
105
+ direction="top" // Placement direction
106
+ autoDirection={true} // Auto-adjust if near edges
107
+ offset={12} // Distance from trigger
108
+ width="288px" // Popover width
109
+ >
110
+ <TriggerElement />
111
+ </Toggletip>
112
+ ```
113
+
114
+ ## Examples
115
+
116
+ ### Feature Explanation
117
+
118
+ ```tsx
119
+ import * as React from 'react';
120
+ import { Toggletip } from '@xsolla/xui-toggletip';
121
+ import { HelpCircle } from '@xsolla/xui-icons-base';
122
+
123
+ export default function FeatureHelp() {
124
+ return (
125
+ <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
126
+ <span>Premium Features</span>
127
+ <Toggletip
128
+ title="Premium Benefits"
129
+ content={
130
+ <ul style={{ margin: 0, paddingLeft: 20 }}>
131
+ <li>Unlimited downloads</li>
132
+ <li>Priority support</li>
133
+ <li>Advanced analytics</li>
134
+ <li>Custom branding</li>
135
+ </ul>
136
+ }
137
+ >
138
+ <HelpCircle size={16} style={{ cursor: 'pointer' }} />
139
+ </Toggletip>
140
+ </div>
141
+ );
142
+ }
143
+ ```
144
+
145
+ ### Info Popover
146
+
147
+ ```tsx
148
+ import * as React from 'react';
149
+ import { Toggletip } from '@xsolla/xui-toggletip';
150
+ import { Button } from '@xsolla/xui-button';
151
+
152
+ export default function InfoPopover() {
153
+ return (
154
+ <Toggletip
155
+ title="Payment Information"
156
+ content="Your payment will be processed securely through our payment provider. You will receive a confirmation email once the transaction is complete."
157
+ footer={
158
+ <Button size="sm" variant="secondary">Learn More</Button>
159
+ }
160
+ direction="bottom"
161
+ width="320px"
162
+ >
163
+ <Button size="sm" variant="secondary">
164
+ Payment Info
165
+ </Button>
166
+ </Toggletip>
167
+ );
168
+ }
169
+ ```
170
+
171
+ ### Quick Actions
172
+
173
+ ```tsx
174
+ import * as React from 'react';
175
+ import { Toggletip } from '@xsolla/xui-toggletip';
176
+ import { Button, IconButton } from '@xsolla/xui-button';
177
+ import { MoreVertical, Edit, Copy, Trash } from '@xsolla/xui-icons-base';
178
+
179
+ export default function QuickActions() {
180
+ return (
181
+ <Toggletip
182
+ content={
183
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
184
+ <Button size="sm" variant="secondary" iconLeft={<Edit size={16} />} fullWidth>
185
+ Edit
186
+ </Button>
187
+ <Button size="sm" variant="secondary" iconLeft={<Copy size={16} />} fullWidth>
188
+ Duplicate
189
+ </Button>
190
+ <Button size="sm" variant="secondary" tone="alert" iconLeft={<Trash size={16} />} fullWidth>
191
+ Delete
192
+ </Button>
193
+ </div>
194
+ }
195
+ direction="bottom-right"
196
+ width="160px"
197
+ >
198
+ <IconButton
199
+ icon={<MoreVertical size={20} />}
200
+ variant="secondary"
201
+ tone="mono"
202
+ size="sm"
203
+ aria-label="More actions"
204
+ />
205
+ </Toggletip>
206
+ );
207
+ }
208
+ ```
209
+
210
+ ### Form Field Help
211
+
212
+ ```tsx
213
+ import * as React from 'react';
214
+ import { Toggletip } from '@xsolla/xui-toggletip';
215
+ import { Input } from '@xsolla/xui-input';
216
+ import { HelpCircle } from '@xsolla/xui-icons-base';
217
+
218
+ export default function FormFieldHelp() {
219
+ return (
220
+ <div>
221
+ <div style={{ display: 'flex', alignItems: 'center', gap: 4, marginBottom: 4 }}>
222
+ <label>API Key</label>
223
+ <Toggletip
224
+ content="Your API key can be found in the Developer Console under Settings > API Keys. Keep this key secure and never share it publicly."
225
+ direction="right"
226
+ >
227
+ <HelpCircle size={14} style={{ cursor: 'pointer', color: '#666' }} />
228
+ </Toggletip>
229
+ </div>
230
+ <Input placeholder="Enter your API key" />
231
+ </div>
232
+ );
233
+ }
234
+ ```
235
+
236
+ ## API Reference
30
237
 
31
238
  ### Toggletip
32
239
 
240
+ **ToggletipProps:**
241
+
33
242
  | Prop | Type | Default | Description |
34
- |------|------|---------|-------------|
35
- | `title` | `ReactNode` | | Heading rendered at the top of the popover |
36
- | `content` | `ReactNode` | | Body content of the popover |
37
- | `footer` | `ReactNode` | | Action buttons rendered at the bottom |
38
- | `direction` | `"top" \| "top-left" \| "top-right" \| "bottom" \| "bottom-left" \| "bottom-right" \| "left" \| "right"` | `"top"` | Placement relative to the trigger |
39
- | `width` | `string` | `"288px"` | Width of the popover |
40
- | `offset` | `number` | `12` | Gap between popover and trigger (px) |
41
- | `autoDirection` | `boolean` | | Automatically flip placement to stay in viewport |
243
+ | :--- | :--- | :------ | :---------- |
244
+ | children | `ReactNode` | - | Trigger element. |
245
+ | title | `string` | - | Optional title in header. |
246
+ | content | `ReactNode` | - | Main content (string or element). |
247
+ | footer | `ReactNode` | - | Optional footer (usually buttons). |
248
+ | direction | `ToggletipPlacement` | `"top"` | Placement relative to trigger. |
249
+ | autoDirection | `boolean` | `true` | Auto-adjust placement near edges. |
250
+ | offset | `number` | `12` | Distance from trigger in pixels. |
251
+ | width | `string` | `"288px"` | Popover width. |
252
+ | data-testid | `string` | - | Test identifier. |
253
+
254
+ **ToggletipPlacement:**
255
+
256
+ ```typescript
257
+ type ToggletipPlacement =
258
+ | "top"
259
+ | "top-left"
260
+ | "top-right"
261
+ | "bottom"
262
+ | "bottom-left"
263
+ | "bottom-right"
264
+ | "left"
265
+ | "right";
266
+ ```
267
+
268
+ ## Behavior
269
+
270
+ - Opens on trigger click
271
+ - Closes on clicking outside
272
+ - Closes on Escape key
273
+ - Auto-adjusts position to stay in viewport (when `autoDirection` is true)
274
+ - Shadow and border from theme for visual elevation
275
+
276
+ ## Toggletip vs Tooltip
277
+
278
+ | Feature | Toggletip | Tooltip |
279
+ | :------ | :-------- | :------ |
280
+ | Trigger | Click | Hover |
281
+ | Content | Rich (title, body, footer) | Simple text |
282
+ | Interaction | Can contain interactive elements | Non-interactive |
283
+ | Use case | Help text, mini forms, actions | Quick hints |
284
+
285
+ ## Accessibility
286
+
287
+ - Click-triggered for keyboard accessibility
288
+ - Escape key closes the popover
289
+ - Focus is managed appropriately
290
+ - Content is accessible to screen readers
291
+ - Use descriptive trigger elements
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-toggletip",
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-button": "0.99.0",
14
- "@xsolla/xui-core": "0.99.0",
15
- "@xsolla/xui-primitives-core": "0.99.0"
13
+ "@xsolla/xui-button": "0.101.0",
14
+ "@xsolla/xui-core": "0.101.0",
15
+ "@xsolla/xui-primitives-core": "0.101.0"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "react": ">=16.8.0",