@xsolla/xui-markdown 0.148.0 → 0.148.2

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 +263 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,263 @@
1
+ # Markdown
2
+
3
+ A React component that renders markdown content with consistent, theme-aware styling. Uses `react-markdown` under the hood.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @xsolla/xui-markdown
9
+ # or
10
+ yarn add @xsolla/xui-markdown
11
+ ```
12
+
13
+ ## Demo
14
+
15
+ ### Basic Markdown
16
+
17
+ ```tsx
18
+ import * as React from 'react';
19
+ import { Markdown } from '@xsolla/xui-markdown';
20
+
21
+ export default function BasicMarkdown() {
22
+ const content = `
23
+ # Hello World
24
+
25
+ This is a paragraph with **bold** and *italic* text.
26
+
27
+ - Item one
28
+ - Item two
29
+ - Item three
30
+ `;
31
+
32
+ return <Markdown>{content}</Markdown>;
33
+ }
34
+ ```
35
+
36
+ ### Headings and Paragraphs
37
+
38
+ ```tsx
39
+ import * as React from 'react';
40
+ import { Markdown } from '@xsolla/xui-markdown';
41
+
42
+ export default function HeadingsDemo() {
43
+ const content = `
44
+ # Heading 1
45
+ ## Heading 2
46
+ ### Heading 3
47
+ #### Heading 4
48
+
49
+ This is a regular paragraph with some text content.
50
+
51
+ Another paragraph following the first one.
52
+ `;
53
+
54
+ return <Markdown>{content}</Markdown>;
55
+ }
56
+ ```
57
+
58
+ ### Code Blocks
59
+
60
+ ```tsx
61
+ import * as React from 'react';
62
+ import { Markdown } from '@xsolla/xui-markdown';
63
+
64
+ export default function CodeDemo() {
65
+ const content = `
66
+ Inline code: \`const x = 1;\`
67
+
68
+ Code block:
69
+ \`\`\`javascript
70
+ function greet(name) {
71
+ return \`Hello, \${name}!\`;
72
+ }
73
+ \`\`\`
74
+ `;
75
+
76
+ return <Markdown>{content}</Markdown>;
77
+ }
78
+ ```
79
+
80
+ ## Anatomy
81
+
82
+ ```jsx
83
+ import { Markdown } from '@xsolla/xui-markdown';
84
+
85
+ <Markdown
86
+ className="custom-markdown" // CSS class
87
+ >
88
+ {markdownContent}
89
+ </Markdown>
90
+ ```
91
+
92
+ ## Examples
93
+
94
+ ### Rich Content
95
+
96
+ ```tsx
97
+ import * as React from 'react';
98
+ import { Markdown } from '@xsolla/xui-markdown';
99
+
100
+ export default function RichContent() {
101
+ const content = `
102
+ # Product Documentation
103
+
104
+ ## Getting Started
105
+
106
+ Follow these steps to integrate our SDK:
107
+
108
+ 1. Install the package
109
+ 2. Configure your API keys
110
+ 3. Initialize the SDK
111
+
112
+ > **Note:** Make sure to keep your API keys secure and never commit them to version control.
113
+
114
+ ### Code Example
115
+
116
+ \`\`\`javascript
117
+ import { SDK } from '@example/sdk';
118
+
119
+ const client = new SDK({
120
+ apiKey: process.env.API_KEY,
121
+ });
122
+
123
+ await client.initialize();
124
+ \`\`\`
125
+
126
+ ### Links and Images
127
+
128
+ Visit our [documentation](https://docs.example.com) for more details.
129
+
130
+ ![Example diagram](https://example.com/diagram.png)
131
+ `;
132
+
133
+ return <Markdown>{content}</Markdown>;
134
+ }
135
+ ```
136
+
137
+ ### Dynamic Content
138
+
139
+ ```tsx
140
+ import * as React from 'react';
141
+ import { Markdown } from '@xsolla/xui-markdown';
142
+
143
+ export default function DynamicContent() {
144
+ const [content, setContent] = React.useState('# Hello\n\nStart typing...');
145
+
146
+ return (
147
+ <div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 16 }}>
148
+ <textarea
149
+ value={content}
150
+ onChange={(e) => setContent(e.target.value)}
151
+ style={{ height: 300, fontFamily: 'monospace' }}
152
+ />
153
+ <div style={{ background: '#1a1a1a', padding: 16, borderRadius: 8 }}>
154
+ <Markdown>{content}</Markdown>
155
+ </div>
156
+ </div>
157
+ );
158
+ }
159
+ ```
160
+
161
+ ### Article Display
162
+
163
+ ```tsx
164
+ import * as React from 'react';
165
+ import { Markdown } from '@xsolla/xui-markdown';
166
+
167
+ export default function ArticleDisplay() {
168
+ const article = `
169
+ # Understanding Game Monetization
170
+
171
+ ## Introduction
172
+
173
+ Game monetization is a critical aspect of game development that determines how a game generates revenue.
174
+
175
+ ## Key Strategies
176
+
177
+ ### In-App Purchases
178
+
179
+ In-app purchases (IAP) allow players to buy virtual goods:
180
+
181
+ - Cosmetic items
182
+ - Power-ups
183
+ - Premium currency
184
+ - Battle passes
185
+
186
+ ### Subscription Models
187
+
188
+ Subscription models provide ongoing value:
189
+
190
+ 1. **Monthly subscriptions** - Regular content updates
191
+ 2. **Season passes** - Time-limited content access
192
+ 3. **Premium tiers** - Enhanced features
193
+
194
+ > "The best monetization strategies provide value to players while generating sustainable revenue."
195
+
196
+ ## Conclusion
197
+
198
+ Choose a monetization strategy that aligns with your game design and player expectations.
199
+ `;
200
+
201
+ return (
202
+ <article style={{ maxWidth: 800, margin: '0 auto' }}>
203
+ <Markdown>{article}</Markdown>
204
+ </article>
205
+ );
206
+ }
207
+ ```
208
+
209
+ ## API Reference
210
+
211
+ ### Markdown
212
+
213
+ **MarkdownProps:**
214
+
215
+ | Prop | Type | Default | Description |
216
+ | :--- | :--- | :------ | :---------- |
217
+ | children | `string` | - | Markdown content to render. |
218
+ | className | `string` | - | CSS class name for the container. |
219
+
220
+ ## Supported Markdown Syntax
221
+
222
+ | Element | Syntax |
223
+ | :------ | :----- |
224
+ | Heading 1 | `# Heading` |
225
+ | Heading 2 | `## Heading` |
226
+ | Heading 3 | `### Heading` |
227
+ | Heading 4 | `#### Heading` |
228
+ | Bold | `**text**` |
229
+ | Italic | `*text*` |
230
+ | Link | `[text](url)` |
231
+ | Image | `![alt](url)` |
232
+ | Inline code | `` `code` `` |
233
+ | Code block | ```` ```language ```` |
234
+ | Blockquote | `> quote` |
235
+ | Unordered list | `- item` |
236
+ | Ordered list | `1. item` |
237
+
238
+ ## Typography Styles
239
+
240
+ | Element | Font Size | Line Height | Weight |
241
+ | :------ | :-------- | :---------- | :----- |
242
+ | h1 | 40px | 48px | 700 |
243
+ | h2 | 32px | 38px | 700 |
244
+ | h3 | 28px | 34px | 700 |
245
+ | h4 | 24px | 28px | 700 |
246
+ | p | 16px | 22px | 400 |
247
+ | li | 16px | 22px | 400 |
248
+
249
+ ## Theming
250
+
251
+ The Markdown component automatically uses theme colors from `XUIProvider`:
252
+
253
+ - Text color from `content.primary`
254
+ - Link color from `control.link.primary`
255
+ - Blockquote border from `border.brand`
256
+ - Code background with subtle transparency
257
+
258
+ ## Accessibility
259
+
260
+ - Headings create a proper document outline
261
+ - Links are styled with visible focus states
262
+ - Images require alt text in markdown syntax
263
+ - Code blocks are contained in `<pre>` elements for proper semantics
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsolla/xui-markdown",
3
- "version": "0.148.0",
3
+ "version": "0.148.2",
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.148.0",
14
- "@xsolla/xui-primitives-core": "0.148.0",
13
+ "@xsolla/xui-core": "0.148.2",
14
+ "@xsolla/xui-primitives-core": "0.148.2",
15
15
  "react-markdown": "^9.0.0"
16
16
  },
17
17
  "peerDependencies": {