@xsolla/xui-nav-bar 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 +292 -18
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,48 +1,322 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
title: Nav Bar
|
|
3
|
+
subtitle: Top navigation header.
|
|
4
|
+
description: A cross-platform React navigation bar component with slots for start, center, and end content.
|
|
5
|
+
---
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
# Nav Bar
|
|
8
|
+
|
|
9
|
+
A cross-platform React navigation bar component with a flexible slot-based layout for building application headers.
|
|
4
10
|
|
|
5
11
|
## Installation
|
|
6
12
|
|
|
7
13
|
```bash
|
|
14
|
+
npm install @xsolla/xui-nav-bar
|
|
15
|
+
# or
|
|
8
16
|
yarn add @xsolla/xui-nav-bar
|
|
9
17
|
```
|
|
10
18
|
|
|
11
|
-
##
|
|
19
|
+
## Demo
|
|
20
|
+
|
|
21
|
+
### Basic Nav Bar
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import * as React from 'react';
|
|
25
|
+
import { NavBar } from '@xsolla/xui-nav-bar';
|
|
26
|
+
import { Xsolla } from '@xsolla/xui-logos-xsolla';
|
|
27
|
+
import { Button } from '@xsolla/xui-button';
|
|
28
|
+
|
|
29
|
+
export default function BasicNavBar() {
|
|
30
|
+
return (
|
|
31
|
+
<NavBar>
|
|
32
|
+
<NavBar.StartSlot>
|
|
33
|
+
<Xsolla variant="full" size="sm" />
|
|
34
|
+
</NavBar.StartSlot>
|
|
35
|
+
<NavBar.Center>
|
|
36
|
+
Navigation
|
|
37
|
+
</NavBar.Center>
|
|
38
|
+
<NavBar.EndSlot>
|
|
39
|
+
<Button size="sm">Sign In</Button>
|
|
40
|
+
</NavBar.EndSlot>
|
|
41
|
+
</NavBar>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Different Sizes
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import * as React from 'react';
|
|
50
|
+
import { NavBar } from '@xsolla/xui-nav-bar';
|
|
51
|
+
|
|
52
|
+
export default function Sizes() {
|
|
53
|
+
return (
|
|
54
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
|
|
55
|
+
<NavBar size="sm">
|
|
56
|
+
<NavBar.Center>Small (48px)</NavBar.Center>
|
|
57
|
+
</NavBar>
|
|
58
|
+
<NavBar size="md">
|
|
59
|
+
<NavBar.Center>Medium (64px)</NavBar.Center>
|
|
60
|
+
</NavBar>
|
|
61
|
+
<NavBar size="lg">
|
|
62
|
+
<NavBar.Center>Large (80px)</NavBar.Center>
|
|
63
|
+
</NavBar>
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### With Border
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import * as React from 'react';
|
|
73
|
+
import { NavBar } from '@xsolla/xui-nav-bar';
|
|
74
|
+
|
|
75
|
+
export default function Bordered() {
|
|
76
|
+
return (
|
|
77
|
+
<NavBar bordered>
|
|
78
|
+
<NavBar.Center>Bordered Navigation</NavBar.Center>
|
|
79
|
+
</NavBar>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Anatomy
|
|
85
|
+
|
|
86
|
+
```jsx
|
|
87
|
+
import { NavBar } from '@xsolla/xui-nav-bar';
|
|
88
|
+
|
|
89
|
+
<NavBar
|
|
90
|
+
size="md" // s, m, or l
|
|
91
|
+
bordered={false} // Show bottom border
|
|
92
|
+
backgroundColor={color} // Custom background
|
|
93
|
+
>
|
|
94
|
+
<NavBar.StartSlot> // Left-aligned content
|
|
95
|
+
{logo}
|
|
96
|
+
</NavBar.StartSlot>
|
|
97
|
+
<NavBar.Center> // Center-aligned content
|
|
98
|
+
{navigation}
|
|
99
|
+
</NavBar.Center>
|
|
100
|
+
<NavBar.EndSlot> // Right-aligned content
|
|
101
|
+
{actions}
|
|
102
|
+
</NavBar.EndSlot>
|
|
103
|
+
</NavBar>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Examples
|
|
107
|
+
|
|
108
|
+
### Application Header
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import * as React from 'react';
|
|
112
|
+
import { NavBar } from '@xsolla/xui-nav-bar';
|
|
113
|
+
import { Xsolla } from '@xsolla/xui-logos-xsolla';
|
|
114
|
+
import { Button, IconButton } from '@xsolla/xui-button';
|
|
115
|
+
import { Bell, Menu } from '@xsolla/xui-icons-base';
|
|
116
|
+
|
|
117
|
+
export default function AppHeader() {
|
|
118
|
+
return (
|
|
119
|
+
<NavBar size="md" bordered>
|
|
120
|
+
<NavBar.StartSlot>
|
|
121
|
+
<IconButton
|
|
122
|
+
icon={<Menu size={20} />}
|
|
123
|
+
variant="secondary"
|
|
124
|
+
tone="mono"
|
|
125
|
+
size="sm"
|
|
126
|
+
aria-label="Menu"
|
|
127
|
+
/>
|
|
128
|
+
<Xsolla variant="full" size="sm" />
|
|
129
|
+
</NavBar.StartSlot>
|
|
130
|
+
<NavBar.Center>
|
|
131
|
+
<nav aria-label="Main navigation" style={{ display: 'flex', gap: 24 }}>
|
|
132
|
+
<a href="/dashboard">Dashboard</a>
|
|
133
|
+
<a href="/products">Products</a>
|
|
134
|
+
<a href="/analytics">Analytics</a>
|
|
135
|
+
</nav>
|
|
136
|
+
</NavBar.Center>
|
|
137
|
+
<NavBar.EndSlot>
|
|
138
|
+
<IconButton
|
|
139
|
+
icon={<Bell size={20} />}
|
|
140
|
+
variant="secondary"
|
|
141
|
+
tone="mono"
|
|
142
|
+
size="sm"
|
|
143
|
+
aria-label="Notifications"
|
|
144
|
+
/>
|
|
145
|
+
<Button size="sm">Account</Button>
|
|
146
|
+
</NavBar.EndSlot>
|
|
147
|
+
</NavBar>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Mobile Header
|
|
12
153
|
|
|
13
154
|
```tsx
|
|
155
|
+
import * as React from 'react';
|
|
14
156
|
import { NavBar } from '@xsolla/xui-nav-bar';
|
|
157
|
+
import { IconButton } from '@xsolla/xui-button';
|
|
158
|
+
import { ArrowLeft, MoreVertical } from '@xsolla/xui-icons-base';
|
|
15
159
|
|
|
16
|
-
function
|
|
160
|
+
export default function MobileHeader() {
|
|
17
161
|
return (
|
|
18
|
-
<NavBar
|
|
162
|
+
<NavBar size="sm">
|
|
19
163
|
<NavBar.StartSlot>
|
|
20
|
-
<
|
|
164
|
+
<IconButton
|
|
165
|
+
icon={<ArrowLeft size={20} />}
|
|
166
|
+
variant="secondary"
|
|
167
|
+
tone="mono"
|
|
168
|
+
size="sm"
|
|
169
|
+
aria-label="Back"
|
|
170
|
+
/>
|
|
21
171
|
</NavBar.StartSlot>
|
|
22
172
|
<NavBar.Center>
|
|
23
|
-
<
|
|
173
|
+
<strong>Page Title</strong>
|
|
24
174
|
</NavBar.Center>
|
|
25
175
|
<NavBar.EndSlot>
|
|
26
|
-
<
|
|
176
|
+
<IconButton
|
|
177
|
+
icon={<MoreVertical size={20} />}
|
|
178
|
+
variant="secondary"
|
|
179
|
+
tone="mono"
|
|
180
|
+
size="sm"
|
|
181
|
+
aria-label="More options"
|
|
182
|
+
/>
|
|
27
183
|
</NavBar.EndSlot>
|
|
28
184
|
</NavBar>
|
|
29
185
|
);
|
|
30
186
|
}
|
|
31
187
|
```
|
|
32
188
|
|
|
33
|
-
|
|
189
|
+
### Checkout Header
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import * as React from 'react';
|
|
193
|
+
import { NavBar } from '@xsolla/xui-nav-bar';
|
|
194
|
+
import { Xsolla } from '@xsolla/xui-logos-xsolla';
|
|
195
|
+
import { IconButton } from '@xsolla/xui-button';
|
|
196
|
+
import { Lock, HelpCircle } from '@xsolla/xui-icons-base';
|
|
34
197
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
198
|
+
export default function CheckoutHeader() {
|
|
199
|
+
return (
|
|
200
|
+
<NavBar size="md" backgroundColor="#1a1a1a">
|
|
201
|
+
<NavBar.StartSlot>
|
|
202
|
+
<Xsolla variant="icon" color="brand" size="sm" />
|
|
203
|
+
</NavBar.StartSlot>
|
|
204
|
+
<NavBar.Center>
|
|
205
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
206
|
+
<Lock size={16} color="#4CAF50" />
|
|
207
|
+
<span style={{ color: '#fff' }}>Secure Checkout</span>
|
|
208
|
+
</div>
|
|
209
|
+
</NavBar.Center>
|
|
210
|
+
<NavBar.EndSlot>
|
|
211
|
+
<IconButton
|
|
212
|
+
icon={<HelpCircle size={20} />}
|
|
213
|
+
variant="secondary"
|
|
214
|
+
tone="mono"
|
|
215
|
+
size="sm"
|
|
216
|
+
aria-label="Help"
|
|
217
|
+
/>
|
|
218
|
+
</NavBar.EndSlot>
|
|
219
|
+
</NavBar>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Marketing Header
|
|
225
|
+
|
|
226
|
+
```tsx
|
|
227
|
+
import * as React from 'react';
|
|
228
|
+
import { NavBar } from '@xsolla/xui-nav-bar';
|
|
229
|
+
import { Xsolla } from '@xsolla/xui-logos-xsolla';
|
|
230
|
+
import { Button } from '@xsolla/xui-button';
|
|
231
|
+
|
|
232
|
+
export default function MarketingHeader() {
|
|
233
|
+
return (
|
|
234
|
+
<NavBar size="lg" backgroundColor="transparent">
|
|
235
|
+
<NavBar.StartSlot>
|
|
236
|
+
<Xsolla variant="full" color="white" size="md" />
|
|
237
|
+
</NavBar.StartSlot>
|
|
238
|
+
<NavBar.Center>
|
|
239
|
+
<nav aria-label="Main navigation" style={{ display: 'flex', gap: 32 }}>
|
|
240
|
+
<a href="/products" style={{ color: '#fff' }}>Products</a>
|
|
241
|
+
<a href="/solutions" style={{ color: '#fff' }}>Solutions</a>
|
|
242
|
+
<a href="/pricing" style={{ color: '#fff' }}>Pricing</a>
|
|
243
|
+
<a href="/resources" style={{ color: '#fff' }}>Resources</a>
|
|
244
|
+
</nav>
|
|
245
|
+
</NavBar.Center>
|
|
246
|
+
<NavBar.EndSlot>
|
|
247
|
+
<Button variant="secondary" size="md">Sign In</Button>
|
|
248
|
+
<Button size="md">Get Started</Button>
|
|
249
|
+
</NavBar.EndSlot>
|
|
250
|
+
</NavBar>
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
```
|
|
39
254
|
|
|
40
|
-
##
|
|
255
|
+
## API Reference
|
|
41
256
|
|
|
42
257
|
### NavBar
|
|
43
258
|
|
|
259
|
+
**NavBarProps:**
|
|
260
|
+
|
|
44
261
|
| Prop | Type | Default | Description |
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
262
|
+
| :--- | :--- | :------ | :---------- |
|
|
263
|
+
| children | `ReactNode` | - | Slot components (StartSlot, Center, EndSlot). |
|
|
264
|
+
| size | `"sm" \| "md" \| "lg"` | `"md"` | Navigation bar height. |
|
|
265
|
+
| bordered | `boolean` | `false` | Show bottom border. |
|
|
266
|
+
| backgroundColor | `string` | theme background | Custom background color. |
|
|
267
|
+
| testID | `string` | - | Test identifier. |
|
|
268
|
+
|
|
269
|
+
### NavBar.StartSlot
|
|
270
|
+
|
|
271
|
+
Left-aligned slot for logos and primary actions.
|
|
272
|
+
|
|
273
|
+
**Props:**
|
|
274
|
+
|
|
275
|
+
| Prop | Type | Description |
|
|
276
|
+
| :--- | :--- | :---------- |
|
|
277
|
+
| children | `ReactNode` | Content to display. |
|
|
278
|
+
| testID | `string` | Test identifier. |
|
|
279
|
+
|
|
280
|
+
### NavBar.Center
|
|
281
|
+
|
|
282
|
+
Center-aligned slot for navigation links and titles.
|
|
283
|
+
|
|
284
|
+
**Props:**
|
|
285
|
+
|
|
286
|
+
| Prop | Type | Description |
|
|
287
|
+
| :--- | :--- | :---------- |
|
|
288
|
+
| children | `ReactNode` | Content to display. |
|
|
289
|
+
| testID | `string` | Test identifier. |
|
|
290
|
+
|
|
291
|
+
### NavBar.EndSlot
|
|
292
|
+
|
|
293
|
+
Right-aligned slot for actions and user controls.
|
|
294
|
+
|
|
295
|
+
**Props:**
|
|
296
|
+
|
|
297
|
+
| Prop | Type | Description |
|
|
298
|
+
| :--- | :--- | :---------- |
|
|
299
|
+
| children | `ReactNode` | Content to display. |
|
|
300
|
+
| testID | `string` | Test identifier. |
|
|
301
|
+
|
|
302
|
+
## Size Specifications
|
|
303
|
+
|
|
304
|
+
| Size | Height | Horizontal Padding |
|
|
305
|
+
| :--- | :----- | :----------------- |
|
|
306
|
+
| `sm` | 48px | 12px |
|
|
307
|
+
| `md` | 64px | 16px |
|
|
308
|
+
| `lg` | 80px | 20px |
|
|
309
|
+
|
|
310
|
+
## Layout Behavior
|
|
311
|
+
|
|
312
|
+
- StartSlot and EndSlot share `flex: 1` for equal width
|
|
313
|
+
- Center slot has `flex: 2` for prominent positioning
|
|
314
|
+
- All slots use `flexBasis: 0` for consistent sizing
|
|
315
|
+
- Items within slots have 8px gap by default
|
|
316
|
+
|
|
317
|
+
## Accessibility
|
|
318
|
+
|
|
319
|
+
- Use `<nav>` elements for navigation link groups
|
|
320
|
+
- Provide `aria-label` for navigation regions
|
|
321
|
+
- Ensure interactive elements have proper focus states
|
|
322
|
+
- Mobile menu triggers should have `aria-expanded` state
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsolla/xui-nav-bar",
|
|
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",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"build:native": "PLATFORM=native tsup"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@xsolla/xui-core": "0.
|
|
14
|
-
"@xsolla/xui-primitives-core": "0.
|
|
13
|
+
"@xsolla/xui-core": "0.100.0",
|
|
14
|
+
"@xsolla/xui-primitives-core": "0.100.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"react": ">=16.8.0"
|