@xsolla/xui-breadcrumbs 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 +180 -17
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,37 +1,200 @@
1
- # @xsolla/xui-breadcrumbs
1
+ # Breadcrumbs
2
2
 
3
- Accessible breadcrumb navigation trail with customisable separator and size variants.
3
+ A cross-platform React breadcrumbs navigation component that displays the current page location within a hierarchical structure. Supports custom separators and click handlers.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
+ npm install @xsolla/xui-breadcrumbs
9
+ # or
8
10
  yarn add @xsolla/xui-breadcrumbs
9
11
  ```
10
12
 
11
- ## Usage
13
+ ## Demo
14
+
15
+ ### Basic Breadcrumbs
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { Breadcrumbs } from '@xsolla/xui-breadcrumbs';
20
+
21
+ export default function BasicBreadcrumbs() {
22
+ return (
23
+ <Breadcrumbs
24
+ items={[
25
+ { label: 'Home', href: '/' },
26
+ { label: 'Products', href: '/products' },
27
+ { label: 'Category', href: '/products/category' },
28
+ { label: 'Current Page' },
29
+ ]}
30
+ />
31
+ );
32
+ }
33
+ ```
34
+
35
+ ### With Click Handlers
36
+
37
+ ```tsx
38
+ import * as React from 'react';
39
+ import { Breadcrumbs } from '@xsolla/xui-breadcrumbs';
40
+
41
+ export default function ClickableBreadcrumbs() {
42
+ const handleNavigate = (path: string) => {
43
+ console.log('Navigate to:', path);
44
+ };
45
+
46
+ return (
47
+ <Breadcrumbs
48
+ items={[
49
+ { label: 'Home', onClick: () => handleNavigate('/') },
50
+ { label: 'Settings', onClick: () => handleNavigate('/settings') },
51
+ { label: 'Profile' },
52
+ ]}
53
+ />
54
+ );
55
+ }
56
+ ```
57
+
58
+ ### Stretched Layout
59
+
60
+ ```tsx
61
+ import * as React from 'react';
62
+ import { Breadcrumbs } from '@xsolla/xui-breadcrumbs';
63
+
64
+ export default function StretchedBreadcrumbs() {
65
+ return (
66
+ <div style={{ width: '100%' }}>
67
+ <Breadcrumbs
68
+ stretched={true}
69
+ items={[
70
+ { label: 'Home', href: '/' },
71
+ { label: 'Dashboard', href: '/dashboard' },
72
+ { label: 'Reports' },
73
+ ]}
74
+ />
75
+ </div>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ## Anatomy
81
+
82
+ ```jsx
83
+ import { Breadcrumbs } from '@xsolla/xui-breadcrumbs';
84
+
85
+ <Breadcrumbs
86
+ items={[ // Array of breadcrumb items
87
+ { label: 'Home', href: '/' },
88
+ { label: 'Current' },
89
+ ]}
90
+ size="md" // Size variant
91
+ stretched={false} // Center and stretch to full width
92
+ separator={<CustomIcon />} // Custom separator element
93
+ backgroundColor="transparent" // Background color
94
+ />
95
+ ```
96
+
97
+ ## Examples
98
+
99
+ ### Breadcrumbs Sizes
12
100
 
13
101
  ```tsx
102
+ import * as React from 'react';
14
103
  import { Breadcrumbs } from '@xsolla/xui-breadcrumbs';
15
104
 
16
- const items = [
17
- { label: 'Home', href: '/' },
18
- { label: 'Products', href: '/products' },
19
- { label: 'Detail' },
20
- ];
105
+ export default function BreadcrumbsSizes() {
106
+ const items = [
107
+ { label: 'Home', href: '/' },
108
+ { label: 'Products', href: '/products' },
109
+ { label: 'Details' },
110
+ ];
111
+
112
+ return (
113
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 16 }}>
114
+ <Breadcrumbs size="sm" items={items} />
115
+ <Breadcrumbs size="md" items={items} />
116
+ <Breadcrumbs size="lg" items={items} />
117
+ </div>
118
+ );
119
+ }
120
+ ```
121
+
122
+ ### Custom Separator
123
+
124
+ ```tsx
125
+ import * as React from 'react';
126
+ import { Breadcrumbs } from '@xsolla/xui-breadcrumbs';
127
+
128
+ export default function CustomSeparator() {
129
+ return (
130
+ <Breadcrumbs
131
+ separator={<span style={{ margin: '0 8px' }}>/</span>}
132
+ items={[
133
+ { label: 'Home', href: '/' },
134
+ { label: 'Category', href: '/category' },
135
+ { label: 'Item' },
136
+ ]}
137
+ />
138
+ );
139
+ }
140
+ ```
141
+
142
+ ### With Disabled Items
143
+
144
+ ```tsx
145
+ import * as React from 'react';
146
+ import { Breadcrumbs } from '@xsolla/xui-breadcrumbs';
21
147
 
22
- function MyComponent() {
23
- return <Breadcrumbs items={items} size="md" />;
148
+ export default function DisabledBreadcrumbs() {
149
+ return (
150
+ <Breadcrumbs
151
+ items={[
152
+ { label: 'Home', href: '/' },
153
+ { label: 'Restricted', disabled: true },
154
+ { label: 'Current Page' },
155
+ ]}
156
+ />
157
+ );
24
158
  }
25
159
  ```
26
160
 
27
- ## Props
161
+ ## API Reference
28
162
 
29
163
  ### Breadcrumbs
30
164
 
165
+ **Breadcrumbs Props:**
166
+
31
167
  | Prop | Type | Default | Description |
32
- |------|------|---------|-------------|
33
- | `items` | `BreadcrumbItem[]` | | Ordered list of breadcrumb items |
34
- | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Font and icon size variant |
35
- | `stretched` | `boolean` | `false` | Stretch to fill container width |
36
- | `separator` | `ReactNode` | | Custom separator; defaults to chevron right |
37
- | `backgroundColor` | `string` | | Custom background colour |
168
+ | :--- | :--- | :------ | :---------- |
169
+ | items | `BreadcrumbItem[]` | - | **Required.** Array of breadcrumb items. |
170
+ | size | `"sm" \| "md" \| "lg"` | `"md"` | Size variant. |
171
+ | stretched | `boolean` | `false` | Center content and stretch to full width. |
172
+ | separator | `ReactNode` | Chevron icon | Custom separator element. |
173
+ | backgroundColor | `string` | - | Background color. |
174
+ | testID | `string` | - | Test identifier. |
175
+
176
+ **BreadcrumbItem Interface:**
177
+
178
+ ```typescript
179
+ interface BreadcrumbItem {
180
+ label: string; // Display text
181
+ href?: string; // Link URL
182
+ onClick?: () => void; // Click handler
183
+ disabled?: boolean; // Disabled state
184
+ }
185
+ ```
186
+
187
+ ## Behavior
188
+
189
+ - Last item is always displayed as active/current page
190
+ - Non-last items are clickable (via href or onClick)
191
+ - Disabled items show reduced opacity and aren't clickable
192
+ - Separator appears between each item
193
+
194
+ ## Accessibility
195
+
196
+ - Uses `<nav>` element with `aria-label="Breadcrumb"`
197
+ - Uses `<ol>` for semantic list structure
198
+ - Current page has `aria-current="page"`
199
+ - Non-active items have proper link/button roles
200
+ - Separators are hidden from screen readers
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-breadcrumbs",
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,8 +10,8 @@
10
10
  "build:native": "PLATFORM=native tsup"
11
11
  },
12
12
  "dependencies": {
13
- "@xsolla/xui-core": "0.99.0",
14
- "@xsolla/xui-primitives-core": "0.99.0"
13
+ "@xsolla/xui-core": "0.101.0",
14
+ "@xsolla/xui-primitives-core": "0.101.0"
15
15
  },
16
16
  "peerDependencies": {
17
17
  "react": ">=16.8.0"