@xsolla/xui-link 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.
Files changed (2) hide show
  1. package/README.md +182 -16
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,34 +1,200 @@
1
- # @xsolla/xui-link
1
+ ---
2
+ title: Link
3
+ subtitle: A styled anchor element.
4
+ description: A cross-platform React link component with accessible navigation and customizable styling.
5
+ ---
2
6
 
3
- A styled anchor component with support for disabled state, underline, and secure external link handling.
7
+ # Link
8
+
9
+ A cross-platform React link component that provides accessible navigation with customizable styling. Supports external links with proper security attributes.
4
10
 
5
11
  ## Installation
6
12
 
7
13
  ```bash
14
+ npm install @xsolla/xui-link
15
+ # or
8
16
  yarn add @xsolla/xui-link
9
17
  ```
10
18
 
11
- ## Usage
19
+ ## Demo
20
+
21
+ ### Basic Link
22
+
23
+ ```tsx
24
+ import * as React from 'react';
25
+ import { Link } from '@xsolla/xui-link';
26
+
27
+ export default function BasicLink() {
28
+ return (
29
+ <Link href="https://example.com">
30
+ Visit Example
31
+ </Link>
32
+ );
33
+ }
34
+ ```
35
+
36
+ ### With Click Handler
37
+
38
+ ```tsx
39
+ import * as React from 'react';
40
+ import { Link } from '@xsolla/xui-link';
41
+
42
+ export default function ClickableLink() {
43
+ return (
44
+ <Link onClick={() => console.log('Link clicked')}>
45
+ Click me
46
+ </Link>
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### External Link
12
52
 
13
53
  ```tsx
14
- import { Link } from "@xsolla/xui-link";
54
+ import * as React from 'react';
55
+ import { Link } from '@xsolla/xui-link';
15
56
 
16
- <Link href="https://xsolla.com" target="_blank">
17
- Visit Xsolla
57
+ export default function ExternalLink() {
58
+ return (
59
+ <Link
60
+ href="https://external-site.com"
61
+ target="_blank"
62
+ >
63
+ Open in new tab
64
+ </Link>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ### Underlined Link
70
+
71
+ ```tsx
72
+ import * as React from 'react';
73
+ import { Link } from '@xsolla/xui-link';
74
+
75
+ export default function UnderlinedLink() {
76
+ return (
77
+ <Link href="/about" underline={true}>
78
+ About Us
79
+ </Link>
80
+ );
81
+ }
82
+ ```
83
+
84
+ ## Anatomy
85
+
86
+ ```jsx
87
+ import { Link } from '@xsolla/xui-link';
88
+
89
+ <Link
90
+ href="/path" // Link URL
91
+ onClick={handleClick} // Click handler
92
+ target="_blank" // Link target
93
+ rel="noopener" // Link relationship
94
+ size="md" // Size variant
95
+ underline={false} // Show underline
96
+ disabled={false} // Disabled state
97
+ color="#007bff" // Custom text color
98
+ >
99
+ Link Text
18
100
  </Link>
19
101
  ```
20
102
 
21
- ## Props
103
+ ## Examples
104
+
105
+ ### Link Sizes
106
+
107
+ ```tsx
108
+ import * as React from 'react';
109
+ import { Link } from '@xsolla/xui-link';
110
+
111
+ export default function LinkSizes() {
112
+ return (
113
+ <div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
114
+ <Link size="sm" href="#">Small Link</Link>
115
+ <Link size="md" href="#">Medium Link</Link>
116
+ <Link size="lg" href="#">Large Link</Link>
117
+ </div>
118
+ );
119
+ }
120
+ ```
121
+
122
+ ### Disabled Link
123
+
124
+ ```tsx
125
+ import * as React from 'react';
126
+ import { Link } from '@xsolla/xui-link';
127
+
128
+ export default function DisabledLink() {
129
+ return (
130
+ <Link href="/disabled" disabled={true}>
131
+ Disabled Link
132
+ </Link>
133
+ );
134
+ }
135
+ ```
136
+
137
+ ### Custom Colored Link
138
+
139
+ ```tsx
140
+ import * as React from 'react';
141
+ import { Link } from '@xsolla/xui-link';
142
+
143
+ export default function ColoredLink() {
144
+ return (
145
+ <Link href="/custom" color="#ff6600">
146
+ Custom Colored Link
147
+ </Link>
148
+ );
149
+ }
150
+ ```
151
+
152
+ ### Inline Links
153
+
154
+ ```tsx
155
+ import * as React from 'react';
156
+ import { Link } from '@xsolla/xui-link';
157
+
158
+ export default function InlineLinks() {
159
+ return (
160
+ <p>
161
+ Read our <Link href="/terms">Terms of Service</Link> and{' '}
162
+ <Link href="/privacy">Privacy Policy</Link> for more information.
163
+ </p>
164
+ );
165
+ }
166
+ ```
167
+
168
+ ## API Reference
22
169
 
23
170
  ### Link
24
171
 
172
+ **Link Props:**
173
+
25
174
  | Prop | Type | Default | Description |
26
- |------|------|---------|-------------|
27
- | `href` | `string` | | URL or path for the link |
28
- | `size` | `"sm" \| "md" \| "lg"` | `"md"` | Font size variant |
29
- | `disabled` | `boolean` | `false` | Prevents navigation and applies disabled styling |
30
- | `underline` | `boolean` | `false` | Adds text underline decoration |
31
- | `onClick` | `() => void` | | Click handler; prevents default navigation when provided |
32
- | `target` | `string` | | Anchor `target` attribute (e.g. `"_blank"`) |
33
- | `rel` | `string` | — | Anchor `rel` attribute; `noopener noreferrer` is merged automatically for `target="_blank"` |
34
- | `color` | `string` | | Overrides the default link colour |
175
+ | :--- | :--- | :------ | :---------- |
176
+ | children | `ReactNode` | - | **Required.** Link content. |
177
+ | href | `string` | - | Link URL. |
178
+ | onClick | `() => void` | - | Click handler. |
179
+ | target | `string` | - | Link target (e.g., "_blank"). |
180
+ | rel | `string` | - | Link relationship attribute. |
181
+ | size | `"sm" \| "md" \| "lg"` | `"md"` | Size variant. |
182
+ | underline | `boolean` | `false` | Show text underline. |
183
+ | disabled | `boolean` | `false` | Disabled state. |
184
+ | color | `string` | Theme link color | Custom text color. |
185
+ | testID | `string` | - | Test identifier. |
186
+
187
+ ## Behavior
188
+
189
+ - External links (`target="_blank"`) automatically add `rel="noopener noreferrer"`
190
+ - Disabled links prevent navigation and show reduced cursor
191
+ - Click handler prevents default navigation when provided
192
+ - Hover state reduces opacity
193
+
194
+ ## Accessibility
195
+
196
+ - Uses native `<a>` element for semantic HTML
197
+ - `role="link"` explicitly set
198
+ - `tabIndex="-1"` when disabled
199
+ - Focus styles with visible outline
200
+ - Disabled links not focusable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-link",
3
- "version": "0.99.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.99.0",
14
- "@xsolla/xui-primitives-core": "0.99.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"