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