bertui-code 1.0.0 → 2.0.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 +248 -228
- package/dist/index.js +2 -2
- package/package.json +13 -10
- package/dist/bertui-code.css +0 -275
- package/dist/index.d.ts +0 -38
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# 📁 **README.md - v1.0.1 Release**
|
|
2
|
+
|
|
1
3
|
# 🎨 bertui-code
|
|
2
4
|
|
|
3
5
|
**Zero-config syntax highlighting for React. Built exclusively for the BertUI ecosystem.**
|
|
@@ -5,10 +7,11 @@
|
|
|
5
7
|
[](https://bertui.dev)
|
|
6
8
|
[](package.json)
|
|
7
9
|
[](LICENSE)
|
|
10
|
+
[](package.json)
|
|
8
11
|
|
|
9
12
|
The simplest way to add beautiful, functional code blocks to your BertUI applications. Dark theme by default, copy button included, zero configuration required.
|
|
10
13
|
|
|
11
|
-
> ⚠️ **BertUI Compatibility Note:** bertui-code
|
|
14
|
+
> ⚠️ **BertUI Compatibility Note:** bertui-code v1.0.1 is tested with BertUI's strict transpiler. See the [BertUI Compatibility](#-bertui-compatibility) section for details.
|
|
12
15
|
|
|
13
16
|
## ✨ Features
|
|
14
17
|
|
|
@@ -18,22 +21,25 @@ The simplest way to add beautiful, functional code blocks to your BertUI applica
|
|
|
18
21
|
- **Line numbers** - Optional, beautifully aligned
|
|
19
22
|
- **Inline code snippets** - Perfect for documentation
|
|
20
23
|
- **20+ language support** - Auto-detection included
|
|
21
|
-
- **
|
|
24
|
+
- **Multi-variant tabs** - Toggle between npm/pnpm/bun/yarn and more
|
|
22
25
|
- **Zero dependencies** - Except React (peer dependency)
|
|
23
|
-
- **
|
|
26
|
+
- **BertUI-certified** - Tested with BertUI's strict transpiler
|
|
24
27
|
|
|
25
28
|
## 📦 Installation
|
|
26
29
|
|
|
27
|
-
|
|
28
|
-
bun add bertui-code
|
|
29
|
-
|
|
30
|
+
|
|
31
|
+
bun add bertui-code@1.0.1
|
|
32
|
+
# or
|
|
33
|
+
npm install bertui-code@1.0.1
|
|
34
|
+
# or
|
|
35
|
+
|
|
30
36
|
|
|
31
37
|
## 🚀 Quick Start
|
|
32
38
|
|
|
33
|
-
```jsx
|
|
34
|
-
import { Code, InlineCode } from 'bertui-code';
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
import { Code, InlineCode, CodeVariants, CodeVariant } from 'bertui-code';
|
|
41
|
+
|
|
42
|
+
// Basic code block
|
|
37
43
|
<Code>
|
|
38
44
|
const hello = "world";
|
|
39
45
|
console.log(hello);
|
|
@@ -46,299 +52,309 @@ import { Code, InlineCode } from 'bertui-code';
|
|
|
46
52
|
}
|
|
47
53
|
</Code>
|
|
48
54
|
|
|
49
|
-
//
|
|
55
|
+
// Package manager variants (NEW in v1.0.1!)
|
|
56
|
+
<CodeVariants>
|
|
57
|
+
<CodeVariant label="npm">npm install bertui-code</CodeVariant>
|
|
58
|
+
<CodeVariant label="pnpm">pnpm add bertui-code</CodeVariant>
|
|
59
|
+
<CodeVariant label="bun">bun add bertui-code</CodeVariant>
|
|
60
|
+
<CodeVariant label="yarn">yarn add bertui-code</CodeVariant>
|
|
61
|
+
</CodeVariants>
|
|
62
|
+
|
|
63
|
+
// Inline code
|
|
50
64
|
<p>
|
|
51
65
|
Use the <InlineCode>useState</InlineCode> hook for state management.
|
|
52
66
|
</p>
|
|
53
67
|
```
|
|
54
68
|
|
|
55
|
-
|
|
69
|
+
---
|
|
56
70
|
|
|
57
|
-
|
|
71
|
+
## 🎯 **NEW IN v1.0.1: Multi-Variant Code Blocks**
|
|
72
|
+
|
|
73
|
+
Toggle between different versions of the same code snippet with zero config:
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
<CodeVariants theme="dark" defaultVariant="bun">
|
|
77
|
+
<CodeVariant label="npm">npm run dev</CodeVariant>
|
|
78
|
+
<CodeVariant label="pnpm">pnpm dev</CodeVariant>
|
|
79
|
+
<CodeVariant label="bun">bun dev</CodeVariant>
|
|
80
|
+
<CodeVariant label="yarn">yarn dev</CodeVariant>
|
|
58
81
|
|
|
59
|
-
### ✅ **DO: Use simple strings in JSX**
|
|
60
|
-
```jsx
|
|
61
|
-
// ✅ GOOD - Plain strings work perfectly
|
|
62
|
-
<Code>
|
|
63
|
-
console.log("Hello BertUI!");
|
|
64
|
-
</Code>
|
|
65
82
|
|
|
66
|
-
|
|
67
|
-
|
|
83
|
+
**Features:**
|
|
84
|
+
- ✅ Auto-generates tabs from labels
|
|
85
|
+
- ✅ Theme-aware styling (dark/light/pink)
|
|
86
|
+
- ✅ Sticky tabs for long docs (`stickyTabs={true}`)
|
|
87
|
+
- ✅ Configurable tab position (`tabPosition="bottom"`)
|
|
88
|
+
- ✅ Keyboard accessible, ARIA compliant
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## ⚠️ **BertUI Compatibility (CRITICAL)**
|
|
93
|
+
|
|
94
|
+
bertui-code v1.0.1 is **certified for BertUI's strict transpiler**. Follow these rules and it will **never crash**:
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// ✅ GOOD - BertUI never looks inside string variables
|
|
98
|
+
const myCode =
|
|
99
|
+
'function hello(name) {\n' +
|
|
100
|
+
' return "Hello " + name + "!";\n' +
|
|
101
|
+
'}';
|
|
102
|
+
|
|
68
103
|
<Code>{myCode}</Code>
|
|
69
|
-
```
|
|
70
104
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
105
|
+
// ✅ GOOD - Even JSX/TypeScript works in strings!
|
|
106
|
+
const tsCode =
|
|
107
|
+
'interface User {\n' +
|
|
108
|
+
' id: string;\n' +
|
|
109
|
+
' name: string;\n' +
|
|
110
|
+
'}\n';
|
|
111
|
+
|
|
112
|
+
<Code language="typescript">{tsCode}</Code>
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
### ❌ **NEVER: Use template literals in JSX (ALWAYS CRASHES)**
|
|
116
|
+
|
|
117
|
+
// ❌ BAD - BertUI WILL crash with "Expected } but found :"
|
|
74
118
|
<Code>
|
|
75
|
-
{`function
|
|
76
|
-
return
|
|
119
|
+
{`function hello() {
|
|
120
|
+
return "world";
|
|
77
121
|
}`}
|
|
78
122
|
</Code>
|
|
79
|
-
|
|
80
|
-
// ✅ GOOD - Escape properly or use variables
|
|
81
|
-
const code = 'function test() {\n return `template literal`;\n}';
|
|
82
|
-
<Code>{code}</Code>
|
|
83
123
|
```
|
|
84
124
|
|
|
85
|
-
### ✅ **
|
|
86
|
-
```jsx
|
|
87
|
-
// Store complex code in variables
|
|
88
|
-
const exampleCode = `function complex() {
|
|
89
|
-
const data = { key: "value" };
|
|
90
|
-
return \`Template: \${data.key}\`;
|
|
91
|
-
}`;
|
|
92
|
-
|
|
93
|
-
// Then use in JSX
|
|
94
|
-
<Code>{exampleCode}</Code>
|
|
95
|
-
```
|
|
125
|
+
### ✅ **DO: Use React.createElement pattern**
|
|
96
126
|
|
|
97
|
-
|
|
127
|
+
// ✅ GOOD - Works in BertUI
|
|
128
|
+
import React from 'react';
|
|
98
129
|
|
|
99
|
-
|
|
130
|
+
export default function Page() {
|
|
131
|
+
return React.createElement(Code, {
|
|
132
|
+
language: 'javascript',
|
|
133
|
+
showLineNumbers: true
|
|
134
|
+
}, 'const x = 1;');
|
|
100
135
|
|
|
101
|
-
```jsx
|
|
102
|
-
// Dark (default)
|
|
103
|
-
<Code theme="dark">console.log("Dark theme");</Code>
|
|
104
136
|
|
|
105
|
-
// Light
|
|
106
|
-
<Code theme="light">// Perfect for docs</Code>
|
|
107
137
|
|
|
108
|
-
//
|
|
109
|
-
<
|
|
138
|
+
// ✅ GOOD - Always use ={true}
|
|
139
|
+
<CodeVariants stickyTabs={true}>
|
|
140
|
+
|
|
141
|
+
// ❌ BAD - BertUI crashes on shorthand
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
### 📋 **BertUI Compatibility Checklist**
|
|
145
|
+
|
|
146
|
+
| Pattern | Status | Why |
|
|
147
|
+
|---------|--------|-----|
|
|
148
|
+
| `const code = '...'` | ✅ **SAFE** | Strings are opaque to BertUI |
|
|
149
|
+
| `` <Code>{`code`}</Code> `` | ❌ **CRASH** | BertUI parses template literal content |
|
|
150
|
+
| `language="typescript"` | ⚠️ **MAY CRASH** | Only safe if code is in string variable |
|
|
151
|
+
| `stickyTabs={true}` | ✅ **SAFE** | Explicit value works |
|
|
152
|
+
| `stickyTabs` | ❌ **CRASH** | Shorthand props not supported |
|
|
153
|
+
| `React.createElement` | ✅ **SAFE** | No JSX transform needed |
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 🎨 **Themes & Colors**
|
|
158
|
+
|
|
159
|
+
### Built-in Themes
|
|
160
|
+
```jsx
|
|
161
|
+
<Code theme="dark"> // Default
|
|
162
|
+
<Code theme="light"> // Light mode
|
|
163
|
+
<Code theme="pink"> // Pink mode
|
|
110
164
|
```
|
|
111
165
|
|
|
112
166
|
### Custom Colors
|
|
113
167
|
|
|
114
|
-
|
|
115
|
-
<Code
|
|
116
|
-
theme="custom"
|
|
168
|
+
<Code
|
|
117
169
|
colors={{
|
|
118
170
|
background: '#0a0a0a',
|
|
119
171
|
text: '#00ff00',
|
|
120
172
|
header: '#1a1a1a',
|
|
121
173
|
border: '#00ff00',
|
|
122
174
|
meta: '#00ff00',
|
|
123
|
-
button: '#00ff00'
|
|
124
|
-
buttonText: '#0a0a0a',
|
|
125
|
-
success: '#00ff00'
|
|
175
|
+
button: '#00ff00'
|
|
126
176
|
}}
|
|
127
177
|
>
|
|
128
178
|
// Custom hacker theme
|
|
129
179
|
</Code>
|
|
130
|
-
```
|
|
131
180
|
|
|
132
|
-
|
|
181
|
+
---
|
|
133
182
|
|
|
134
|
-
|
|
183
|
+
## 📖 **API Reference**
|
|
135
184
|
|
|
185
|
+
### `<Code />` Component
|
|
136
186
|
| Prop | Type | Default | Description |
|
|
137
187
|
|------|------|---------|-------------|
|
|
138
188
|
| `children` | `string` | **Required** | The code to display |
|
|
139
|
-
| `language` | `string` | `'javascript'` | Programming language
|
|
140
|
-
| `theme` | `'dark' \| 'light' \| 'pink'
|
|
141
|
-
| `colors` | `Object` | `{}` | Custom
|
|
189
|
+
| `language` | `string` | `'javascript'` | Programming language |
|
|
190
|
+
| `theme` | `'dark' \| 'light' \| 'pink'` | `'dark'` | Color theme |
|
|
191
|
+
| `colors` | `Object` | `{}` | Custom color overrides |
|
|
142
192
|
| `showLineNumbers` | `boolean` | `false` | Show line numbers |
|
|
143
|
-
| `showCopyButton` | `boolean` | `true` | Show copy
|
|
193
|
+
| `showCopyButton` | `boolean` | `true` | Show copy button |
|
|
144
194
|
| `className` | `string` | `''` | Additional CSS classes |
|
|
145
195
|
|
|
146
|
-
### `<
|
|
196
|
+
### `<CodeVariants />` Component (NEW)
|
|
197
|
+
| Prop | Type | Default | Description |
|
|
198
|
+
|------|------|---------|-------------|
|
|
199
|
+
| `children` | `CodeVariant[]` | **Required** | Array of variants |
|
|
200
|
+
| `theme` | `'dark' \| 'light' \| 'pink'` | `'dark'` | Color theme |
|
|
201
|
+
| `defaultVariant` | `number \| string` | `0` | Default tab by index or label |
|
|
202
|
+
| `stickyTabs` | `boolean` | `false` | Make tabs sticky on scroll |
|
|
203
|
+
| `tabPosition` | `'top' \| 'bottom'` | `'top'` | Tab bar position |
|
|
204
|
+
| `showCopyButton` | `boolean` | `true` | Show copy button |
|
|
205
|
+
| `colors` | `Object` | `{}` | Custom colors for code |
|
|
206
|
+
| `tabColors` | `Object` | `{}` | Custom colors for tabs |
|
|
207
|
+
|
|
208
|
+
### `<CodeVariant />` Component (NEW)
|
|
209
|
+
| Prop | Type | Default | Description |
|
|
210
|
+
|------|------|---------|-------------|
|
|
211
|
+
| `children` | `string` | **Required** | The code for this variant |
|
|
212
|
+
| `label` | `string` | **Required** | Tab label (npm, pnpm, etc) |
|
|
213
|
+
| `language` | `string` | `'javascript'` | Language for this variant |
|
|
214
|
+
| `showLineNumbers` | `boolean` | `false` | Show line numbers |
|
|
147
215
|
|
|
216
|
+
### `<InlineCode />` Component
|
|
148
217
|
| Prop | Type | Default | Description |
|
|
149
218
|
|------|------|---------|-------------|
|
|
150
219
|
| `children` | `string` | **Required** | The inline code |
|
|
151
220
|
| `theme` | `'dark' \| 'light' \| 'pink'` | `'dark'` | Color theme |
|
|
152
221
|
|
|
153
|
-
|
|
222
|
+
---
|
|
154
223
|
|
|
155
|
-
|
|
224
|
+
## 💡 **Best Practices for BertUI**
|
|
156
225
|
|
|
157
|
-
|
|
226
|
+
### 1. **Store all code examples in string variables**
|
|
158
227
|
|
|
159
|
-
|
|
228
|
+
// code-examples.js
|
|
229
|
+
export const npmExample = 'npm install bertui-code';
|
|
230
|
+
export const jsExample =
|
|
231
|
+
'function add(a, b) {\n' +
|
|
232
|
+
' return a + b;\n' +
|
|
233
|
+
'}';
|
|
160
234
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
- **Shell**: Bash, Shell, PowerShell
|
|
165
|
-
- **Other**: Markdown, Swift, Kotlin, Dart
|
|
235
|
+
// page.jsx
|
|
236
|
+
import { jsExample } from './code-examples.js';
|
|
237
|
+
<Code>{jsExample}</Code>
|
|
166
238
|
|
|
167
|
-
```jsx
|
|
168
|
-
// Auto-detection
|
|
169
|
-
<Code language="auto">
|
|
170
|
-
def hello():
|
|
171
|
-
print("Auto-detected as Python!")
|
|
172
|
-
</Code>
|
|
173
239
|
|
|
174
|
-
|
|
175
|
-
<Code language="rust">
|
|
176
|
-
fn main() {
|
|
177
|
-
println!("Hello Rust!");
|
|
178
|
-
}
|
|
179
|
-
</Code>
|
|
180
|
-
```
|
|
240
|
+
### 2. **Use string concatenation for readability**
|
|
181
241
|
|
|
182
|
-
|
|
242
|
+
const longCode =
|
|
243
|
+
'import React from "react";\n' +
|
|
244
|
+
'\n' +
|
|
245
|
+
'export function Button({ children }) {\n' +
|
|
246
|
+
' return (\n' +
|
|
247
|
+
' <button className="btn">\n' +
|
|
248
|
+
' {children}\n' +
|
|
249
|
+
' </button>\n' +
|
|
250
|
+
' );\n' +
|
|
251
|
+
'}\n';
|
|
183
252
|
|
|
184
|
-
### Documentation Page (BertUI-safe)
|
|
185
|
-
```jsx
|
|
186
|
-
import React from 'react';
|
|
187
|
-
import { Code, InlineCode } from 'bertui-code';
|
|
188
253
|
|
|
189
|
-
|
|
190
|
-
const apiExample = 'function fetchData(url) {\n return fetch(url).then(r => r.json());\n}';
|
|
254
|
+
### 3. **Keep TypeScript in .ts files**
|
|
191
255
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
error: string | null;
|
|
195
|
-
}
|
|
256
|
+
// ✅ GOOD - In a .ts file
|
|
257
|
+
export const tsCode = 'const name: string = "John";';
|
|
196
258
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const response = await fetch('/api/user');
|
|
200
|
-
return { data: await response.json(), error: null };
|
|
201
|
-
} catch (error) {
|
|
202
|
-
return { data: null, error: error.message };
|
|
203
|
-
}
|
|
204
|
-
}`;
|
|
205
|
-
|
|
206
|
-
export default function Documentation() {
|
|
207
|
-
return (
|
|
208
|
-
<article style={{ padding: '2rem' }}>
|
|
209
|
-
<h1>API Reference</h1>
|
|
210
|
-
|
|
211
|
-
<p>
|
|
212
|
-
Import the component: <InlineCode>import {'{ Code }'} from 'bertui-code'</InlineCode>
|
|
213
|
-
</p>
|
|
214
|
-
|
|
215
|
-
<h2>Basic Example</h2>
|
|
216
|
-
<Code showLineNumbers>
|
|
217
|
-
{apiExample}
|
|
218
|
-
</Code>
|
|
219
|
-
|
|
220
|
-
<h2>Error Handling</h2>
|
|
221
|
-
<Code language="typescript" theme="light">
|
|
222
|
-
{errorHandling}
|
|
223
|
-
</Code>
|
|
224
|
-
</article>
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
```
|
|
259
|
+
// ❌ BAD - In a .jsx file
|
|
260
|
+
const tsCode = 'const name: string = "John";'; // BertUI may crash!
|
|
228
261
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
262
|
+
|
|
263
|
+
### 4. **Test your code blocks**
|
|
264
|
+
|
|
265
|
+
// test-page.jsx - Create a test page to verify BertUI compatibility
|
|
232
266
|
import { Code } from 'bertui-code';
|
|
267
|
+
const testCode = 'console.log("Hello BertUI!");';
|
|
233
268
|
|
|
234
|
-
export default function
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
// Store dynamic code in variable
|
|
238
|
-
const dynamicCode = `// Current theme: ${theme}
|
|
239
|
-
const user = {
|
|
240
|
-
name: "Developer",
|
|
241
|
-
preferences: {
|
|
242
|
-
theme: "${theme}",
|
|
243
|
-
timestamp: new Date().toISOString()
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
console.log(\`Hello \${user.name}!\`);`;
|
|
248
|
-
|
|
249
|
-
return (
|
|
250
|
-
<div style={{ padding: '1rem' }}>
|
|
251
|
-
<div style={{ marginBottom: '1rem' }}>
|
|
252
|
-
<label>
|
|
253
|
-
Select Theme:
|
|
254
|
-
<select
|
|
255
|
-
value={theme}
|
|
256
|
-
onChange={(e) => setTheme(e.target.value)}
|
|
257
|
-
style={{ marginLeft: '0.5rem', padding: '0.25rem' }}
|
|
258
|
-
>
|
|
259
|
-
<option value="dark">Dark</option>
|
|
260
|
-
<option value="light">Light</option>
|
|
261
|
-
<option value="pink">Pink</option>
|
|
262
|
-
</select>
|
|
263
|
-
</label>
|
|
264
|
-
</div>
|
|
265
|
-
|
|
266
|
-
<Code theme={theme} showLineNumbers>
|
|
267
|
-
{dynamicCode}
|
|
268
|
-
</Code>
|
|
269
|
-
</div>
|
|
270
|
-
);
|
|
269
|
+
export default function TestPage() {
|
|
270
|
+
return React.createElement(Code, {}, testCode);
|
|
271
271
|
}
|
|
272
|
-
```
|
|
273
272
|
|
|
274
|
-
## 🛠️ Troubleshooting BertUI Issues
|
|
275
273
|
|
|
276
|
-
|
|
277
|
-
**Solution:** BertUI's transpiler sometimes struggles with:
|
|
278
|
-
- Nested template literals in JSX
|
|
279
|
-
- Complex string interpolation
|
|
280
|
-
- Certain JavaScript syntax in JSX attributes
|
|
274
|
+
---
|
|
281
275
|
|
|
282
|
-
**
|
|
283
|
-
```jsx
|
|
284
|
-
// ❌ Problematic
|
|
285
|
-
<Code>
|
|
286
|
-
{`function test() {
|
|
287
|
-
return \`Complex \${expression}\`;
|
|
288
|
-
}`}
|
|
289
|
-
</Code>
|
|
276
|
+
## 📚 **Examples**
|
|
290
277
|
|
|
291
|
-
|
|
292
|
-
const safeCode = 'function test() {\n return `Complex ${expression}`;\n}';
|
|
293
|
-
<Code>{safeCode}</Code>
|
|
294
|
-
```
|
|
278
|
+
### Package Manager Installers
|
|
295
279
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
280
|
+
<CodeVariants theme="dark" defaultVariant="bun">
|
|
281
|
+
<CodeVariant label="npm">npm install bertui-code</CodeVariant>
|
|
282
|
+
<CodeVariant label="pnpm">pnpm add bertui-code</CodeVariant>
|
|
283
|
+
<CodeVariant label="bun">bun add bertui-code</CodeVariant>
|
|
284
|
+
<CodeVariant label="yarn">yarn add bertui-code</CodeVariant>
|
|
285
|
+
</CodeVariants>
|
|
301
286
|
|
|
302
|
-
### Problem: Colors not applying
|
|
303
|
-
**Solution:** Ensure custom colors object has all required properties:
|
|
304
|
-
```jsx
|
|
305
|
-
// Complete custom colors object
|
|
306
|
-
colors={{
|
|
307
|
-
background: '#...',
|
|
308
|
-
text: '#...',
|
|
309
|
-
header: '#...',
|
|
310
|
-
border: '#...',
|
|
311
|
-
meta: '#...',
|
|
312
|
-
button: '#...',
|
|
313
|
-
buttonHover: '#...',
|
|
314
|
-
buttonText: '#...',
|
|
315
|
-
success: '#...'
|
|
316
|
-
}}
|
|
317
|
-
```
|
|
318
287
|
|
|
319
|
-
|
|
288
|
+
### Language Comparison
|
|
289
|
+
|
|
290
|
+
<CodeVariants theme="light">
|
|
291
|
+
<CodeVariant label="JavaScript" language="javascript">
|
|
292
|
+
{javascriptExample}
|
|
293
|
+
</CodeVariant>
|
|
294
|
+
<CodeVariant label="TypeScript" language="typescript">
|
|
295
|
+
{typescriptExample}
|
|
296
|
+
</CodeVariant>
|
|
297
|
+
<CodeVariant label="Python" language="python">
|
|
298
|
+
{pythonExample}
|
|
299
|
+
</CodeVariant>
|
|
300
|
+
</CodeVariants>
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
### API Examples
|
|
304
|
+
|
|
305
|
+
<CodeVariants theme="dark" tabPosition="bottom" stickyTabs={true}>
|
|
306
|
+
<CodeVariant label="cURL" language="bash">{curlExample}</CodeVariant>
|
|
307
|
+
<CodeVariant label="fetch" language="javascript">{fetchExample}</CodeVariant>
|
|
308
|
+
<CodeVariant label="axios" language="javascript">{axiosExample}</CodeVariant>
|
|
309
|
+
</CodeVariants>
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
## 🐛 **Known Issues & Workarounds**
|
|
315
|
+
|
|
316
|
+
### Issue: BertUI crashes with `Expected "}" but found ":"`
|
|
317
|
+
**Cause:** TypeScript syntax in .jsx file or template literal in JSX
|
|
318
|
+
**Fix:** Move code to string variable outside component
|
|
319
|
+
|
|
320
|
+
### Issue: React/jsx-dev-runtime not found
|
|
321
|
+
**Cause:** BertUI doesn't support React 18 automatic JSX runtime
|
|
322
|
+
**Fix:** Use `React.createElement` or add `/** @jsx React.createElement */`
|
|
323
|
+
|
|
324
|
+
### Issue: Shorthand props crash
|
|
325
|
+
**Cause:** BertUI doesn't support `{stickyTabs}` shorthand
|
|
326
|
+
**Fix:** Always use `stickyTabs={true}`
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
## 📦 **Project Structure**
|
|
320
331
|
|
|
321
|
-
```
|
|
322
332
|
bertui-code/
|
|
323
333
|
├── src/
|
|
324
|
-
│ ├── Code.js
|
|
325
|
-
│ ├──
|
|
326
|
-
│ ├──
|
|
327
|
-
│
|
|
328
|
-
├──
|
|
329
|
-
│
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
334
|
+
│ ├── Code.js # Main code block component
|
|
335
|
+
│ ├── CodeVariants.js # Multi-variant tabs (NEW)
|
|
336
|
+
│ ├── CodeVariant.js # Individual variant (NEW)
|
|
337
|
+
│ ├── CopyButton.js # Copy button component
|
|
338
|
+
│ ├── InlineCode.js # Inline code component
|
|
339
|
+
│ ├── ThemeProvider.js # Theme context (optional)
|
|
340
|
+
│ └── index.js # Main exports
|
|
341
|
+
├── dist/ # Built files
|
|
342
|
+
├── package.json # v1.0.1
|
|
343
|
+
└── README.md # You are here
|
|
344
|
+
|
|
333
345
|
|
|
334
|
-
|
|
346
|
+
---
|
|
335
347
|
|
|
336
|
-
|
|
348
|
+
## 🤝 **Compatibility**
|
|
349
|
+
|
|
350
|
+
- **BertUI**: ✅ v1.0.1 certified - Tested with strict transpiler
|
|
337
351
|
- **React**: ✅ 18.0.0+ (peer dependency)
|
|
338
|
-
- **Browsers**: ✅ Chrome, Firefox, Safari, Edge
|
|
339
|
-
- **
|
|
352
|
+
- **Browsers**: ✅ Chrome, Firefox, Safari, Edge
|
|
353
|
+
- **Bun**: ✅ Recommended package manager
|
|
354
|
+
|
|
355
|
+
---
|
|
340
356
|
|
|
341
|
-
## 📄 License
|
|
357
|
+
## 📄 **License**
|
|
342
358
|
|
|
343
359
|
MIT © Pease Ernest
|
|
344
360
|
|
|
@@ -347,13 +363,17 @@ MIT © Pease Ernest
|
|
|
347
363
|
<div align="center">
|
|
348
364
|
<p>
|
|
349
365
|
<strong>Part of the BertUI ecosystem</strong><br/>
|
|
350
|
-
Built with ❤️ for developers who value simplicity and
|
|
366
|
+
Built with ❤️ for developers who value simplicity and speed
|
|
367
|
+
</p>
|
|
368
|
+
|
|
369
|
+
<p>
|
|
370
|
+
<a href="https://github.com/yourusername/bertui-code">GitHub</a> •
|
|
371
|
+
<a href="https://npmjs.com/package/bertui-code">npm</a> •
|
|
372
|
+
<a href="#-bertui-compatibility">BertUI Compatibility</a>
|
|
351
373
|
</p>
|
|
352
374
|
|
|
353
375
|
<p>
|
|
354
|
-
<
|
|
355
|
-
<a href="https://github.com/BunElysiaReact/bertui-code.git">GitHub</a> •
|
|
356
|
-
<a href="https://npmjs.com/package/bertui-code">npm</a>
|
|
376
|
+
<sub>v1.0.1 • Zero-config • BertUI-certified</sub>
|
|
357
377
|
</p>
|
|
358
378
|
</div>
|
|
359
379
|
```
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
`).length
|
|
1
|
+
import d from"react";import I,{useState as S}from"react";function y({code:e}){let[r,o]=S(!1),s=async()=>{try{await navigator.clipboard.writeText(e),o(!0),setTimeout(()=>o(!1),2000)}catch(n){let a=document.createElement("textarea");a.value=e,a.style.position="fixed",a.style.opacity="0",document.body.appendChild(a),a.select(),document.execCommand("copy"),document.body.removeChild(a),o(!0),setTimeout(()=>o(!1),2000)}};return I.createElement("button",{onClick:s,className:`bertui-copy-button ${r?"copied":""}`,title:r?"Copied!":"Copy code"},r?"✓":"\uD83D\uDCCB")}function f({children:e,language:r="javascript",showLineNumbers:o=!1,showCopyButton:s=!0,className:n="",theme:a}){let t=e.split(`
|
|
2
|
+
`).length;return d.createElement("div",{className:`bertui-code ${n}`,"data-theme":a,style:{borderRadius:"8px",fontFamily:"Menlo, Monaco, monospace",fontSize:"14px",margin:"1rem 0",overflow:"hidden"}},[d.createElement("div",{key:"header",className:"bertui-code-header",style:{padding:"8px 16px",display:"flex",justifyContent:"space-between",alignItems:"center"}},[d.createElement("span",{key:"language",className:"bertui-code-language",style:{fontSize:"12px",fontWeight:"500"}},r),s&&d.createElement(y,{key:"copy",code:e})].filter(Boolean)),d.createElement("div",{key:"content",style:{display:"flex",padding:"16px 0"}},[o&&d.createElement("div",{key:"lines",className:"bertui-line-numbers",style:{padding:"0 16px",textAlign:"right",userSelect:"none",minWidth:"40px"}},Array.from({length:t}).map((p,u)=>d.createElement("span",{key:u,style:{display:"block",paddingRight:"8px"}},u+1))),d.createElement("pre",{key:"pre",className:"bertui-code-pre",style:{margin:0,padding:"0 16px",flex:1,overflowX:"auto"}},d.createElement("code",{className:`language-${r}`,style:{background:"transparent",fontFamily:"inherit"}},e))].filter(Boolean))])}function j(e){let r={javascript:/(\bconsole\.|\bfunction\b|\bconst\b|\blet\b|\bvar\b|\bimport\b|\bexport\b)/,typescript:/(:\s*\w+\s*[=;]|\binterface\b|\btype\b|\bnamespace\b)/,python:/(\bdef\b|\bclass\b|\bimport\b|\bfrom\b|\bprint\b|:\s*$)/,html:/(<!DOCTYPE|<\/?\w+[^>]*>|&[a-z]+;)/,css:/({[^}]*}|\.\w+\s*{|#\w+\s*{|\bcolor:\s*)/,rust:/(\bfn\b|\blet\b|\bmut\b|\bimpl\b|->\s*\w+)/,cpp:/(#include|std::|cout\s*<<|->\s*\w+)/,java:/(public\s+class|System\.out\.println|\bvoid\b\s+\w+\s*\()/,go:/(\bfunc\b|\bpackage\b|:=|fmt\.Println)/,php:/(<\?php|\$\w+\s*=|echo\s+)/,sql:/(\bSELECT\b|\bFROM\b|\bWHERE\b|\bJOIN\b)/,shell:/(^\s*#!|\$\w+|mkdir\s+|cd\s+)/,json:/^\s*[{[]/,yaml:/(^[\w-]+:\s|^- )/,markdown:/(^#+|^-{3,}|^\s*\[)/,xml:/(<\?xml|<\/?[\w:]+>)/,ruby:/(\bdef\b|\bend\b|\bputs\b|:\w+=>)/,swift:/(\bfunc\b|\bvar\b|\blet\b|:\s*\w+\s*{)/,kotlin:/(\bfun\b|\bval\b|\bvar\b|:\s*\w+\s*[=;])/},o=e.toLowerCase();for(let[s,n]of Object.entries(r))if(n.test(o))return s;return"plaintext"}import L from"react";function $({children:e,theme:r}){return L.createElement("code",{className:"bertui-inline-code","data-theme":r,style:{padding:"2px 6px",borderRadius:"4px",fontFamily:"Menlo, Monaco, monospace",fontSize:"0.9em"}},e)}import b,{useState as P,Children as M,isValidElement as V}from"react";function A({children:e,theme:r="dark",showCopyButton:o=!0,className:s="",defaultVariant:n=0,stickyTabs:a=!1,tabPosition:l="top"}){let t=M.toArray(e).filter((i)=>V(i)&&i.type?.isCodeVariant);if(t.length===0)return b.createElement(f,{theme:r,showCopyButton:o,className:s,children:e});if(t.length===1){let i=t[0];return b.createElement(f,{theme:r,showCopyButton:o,className:s,language:i.props.language||"javascript",showLineNumbers:i.props.showLineNumbers||!1,children:i.props.children})}let[p,u]=P(()=>{if(typeof n==="number")return Math.min(n,t.length-1);if(typeof n==="string"){let i=t.findIndex((c)=>c.props.label===n);return i!==-1?i:0}return 0}),T=t[p],{children:R,language:F="javascript",showLineNumbers:O=!1}=T.props,g=b.useMemo(()=>`bertui-variants-${Math.random().toString(36).substr(2,9)}`,[]),N=(i)=>{let c=i===p,E={padding:"8px 16px",fontSize:"13px",fontWeight:"500",border:"none",cursor:"pointer",transition:"all 0.2s",fontFamily:"inherit",borderRadius:"4px 4px 0 0"};if(c)return{...E,background:"var(--bertui-tab-active, #1e1e1e)",color:"var(--bertui-tab-active-text, #ffffff)",borderBottom:"2px solid var(--bertui-tab-accent, #3b82f6)"};return{...E,background:"transparent",color:"var(--bertui-tab-inactive, #858585)",borderBottom:"2px solid transparent"}},v=b.createElement("div",{key:"tabs",role:"tablist","aria-label":"Code variants",style:{display:"flex",flexWrap:"wrap",gap:"4px",padding:"12px 16px",background:"var(--bertui-tab-bar, #2d2d2d)",borderBottom:l==="top"?"1px solid var(--bertui-border, #3d3d3d)":"none",borderTop:l==="bottom"?"1px solid var(--bertui-border, #3d3d3d)":"none",position:a?"sticky":"relative",top:a&&l==="top"?0:"auto",bottom:a&&l==="bottom"?0:"auto",zIndex:a?10:"auto"}},t.map((i,c)=>{let E=i.props.label||`Option ${c+1}`,h=c===p;return b.createElement("button",{key:c,role:"tab","aria-selected":h,"aria-controls":`${g}-panel`,id:`${g}-tab-${c}`,onClick:()=>u(c),style:N(c),onMouseEnter:(m)=>{if(!h)m.currentTarget.style.background="var(--bertui-tab-hover, #3d3d3d)",m.currentTarget.style.color="var(--bertui-tab-active-text, #ffffff)"},onMouseLeave:(m)=>{if(!h)m.currentTarget.style.background="transparent",m.currentTarget.style.color="var(--bertui-tab-inactive, #858585)"}},E)})),x=[];if(l==="top")x.push(v);if(x.push(b.createElement("div",{key:"code",id:`${g}-panel`,role:"tabpanel","aria-labelledby":`${g}-tab-${p}`,style:{padding:"4px 0"}},b.createElement(f,{theme:r,showCopyButton:o,className:s,language:F,showLineNumbers:O,children:R}))),l==="bottom")x.push(v);return b.createElement("div",{className:`bertui-code-variants ${s}`,"data-theme":r,style:{margin:"1rem 0",borderRadius:"8px",overflow:"hidden",border:"1px solid var(--bertui-border, #3d3d3d)",background:"var(--bertui-bg, #1e1e1e)"}},x)}import re from"react";function C({children:e,label:r,language:o="javascript",showLineNumbers:s=!1,className:n=""}){return null}C.isCodeVariant=!0;import X,{useEffect as w,createContext as Y,useContext as z}from"react";import{jsxDEV as q}from"react/jsx-dev-runtime";var k=Y({theme:"dark",setTheme:()=>{},toggleTheme:()=>{}});function B({children:e,initialTheme:r="dark",enableSystemPreference:o=!0,storageKey:s="bertui-theme"}){let[n,a]=X.useState(()=>{if(typeof window<"u"){let t=localStorage.getItem(s);if(t)return t}return r});w(()=>{if(typeof window>"u")return;document.documentElement.setAttribute("data-bertui-theme",n),localStorage.setItem(s,n)},[n,s]),w(()=>{if(!o||typeof window>"u")return;let t=window.matchMedia("(prefers-color-scheme: dark)"),p=(u)=>{if(n==="system")document.documentElement.setAttribute("data-bertui-theme",u.matches?"dark":"light")};return t.addEventListener("change",p),()=>t.removeEventListener("change",p)},[n,o]);let l=()=>{a((t)=>{if(t==="dark")return"light";if(t==="light")return"pink";if(t==="pink")return"dark";return"dark"})};return q(k.Provider,{value:{theme:n,setTheme:a,toggleTheme:l},children:e},void 0,!1,void 0,this)}function W(){let e=z(k);if(!e)throw Error("useCodeTheme must be used within CodeThemeProvider");return e}var ie="./bertui-code.css",ce="2.0.0";export{ce as version,W as useCodeTheme,j as detectLanguage,ie as css,$ as InlineCode,y as CopyButton,A as CodeVariants,C as CodeVariant,B as CodeThemeProvider,f as Code};
|
package/package.json
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "bertui-code",
|
|
3
|
-
"version": "
|
|
2
|
+
"name": "bertui-code",
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.js",
|
|
10
11
|
"types": "./dist/index.d.ts"
|
|
11
12
|
},
|
|
12
13
|
"./bertui-code.css": {
|
|
13
14
|
"import": "./dist/bertui-code.css",
|
|
14
|
-
"
|
|
15
|
+
"require": "./dist/bertui-code.css"
|
|
15
16
|
}
|
|
16
17
|
},
|
|
17
18
|
"files": ["dist"],
|
|
18
|
-
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "bun build src/index.js --outdir dist --target browser --format esm --
|
|
21
|
-
"dev": "bun build src/index.js --outdir dist --target browser --format esm --
|
|
20
|
+
"build": "bun build src/index.js --outdir dist --target browser --format esm --external react --external react/jsx-runtime --external react/jsx-dev-runtime --splitting --minify",
|
|
21
|
+
"dev": "bun build src/index.js --outdir dist --target browser --format esm --external react --external react/jsx-runtime --external react/jsx-dev-runtime --watch"
|
|
22
22
|
},
|
|
23
|
-
|
|
24
23
|
"keywords": ["react", "syntax-highlighting", "bertui", "code"],
|
|
25
24
|
"author": "Your Name",
|
|
26
25
|
"license": "MIT",
|
|
27
26
|
"peerDependencies": {
|
|
28
|
-
"react": "^18.0.0"
|
|
27
|
+
"react": "^18.0.0",
|
|
28
|
+
"react-dom": "^18.0.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"react": "^18.2.0",
|
|
32
|
+
"react-dom": "^18.2.0"
|
|
29
33
|
}
|
|
30
|
-
}
|
|
31
|
-
|
|
34
|
+
}
|
package/dist/bertui-code.css
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
/* bertui-code - Zero-config syntax highlighting for BertUI */
|
|
2
|
-
|
|
3
|
-
/* Container */
|
|
4
|
-
.bertui-code {
|
|
5
|
-
background: #1e1e1e;
|
|
6
|
-
border-radius: 8px;
|
|
7
|
-
font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
|
|
8
|
-
font-size: 14px;
|
|
9
|
-
line-height: 1.6;
|
|
10
|
-
margin: 1rem 0;
|
|
11
|
-
overflow: hidden;
|
|
12
|
-
color: #d4d4d4;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/* Header */
|
|
16
|
-
.bertui-code-header {
|
|
17
|
-
background: #2d2d2d;
|
|
18
|
-
padding: 8px 16px;
|
|
19
|
-
display: flex;
|
|
20
|
-
justify-content: space-between;
|
|
21
|
-
align-items: center;
|
|
22
|
-
border-bottom: 1px solid #3d3d3d;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.bertui-code-language {
|
|
26
|
-
color: #858585;
|
|
27
|
-
font-size: 13px;
|
|
28
|
-
font-weight: 500;
|
|
29
|
-
text-transform: lowercase;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/* Copy button */
|
|
33
|
-
.bertui-copy-button {
|
|
34
|
-
background: #3d3d3d;
|
|
35
|
-
border: none;
|
|
36
|
-
color: #d4d4d4;
|
|
37
|
-
cursor: pointer;
|
|
38
|
-
padding: 4px 12px;
|
|
39
|
-
border-radius: 4px;
|
|
40
|
-
font-size: 12px;
|
|
41
|
-
transition: all 0.2s;
|
|
42
|
-
display: flex;
|
|
43
|
-
align-items: center;
|
|
44
|
-
gap: 6px;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.bertui-copy-button:hover {
|
|
48
|
-
background: #4d4d4d;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.bertui-copy-button.copied {
|
|
52
|
-
background: #2e7d32;
|
|
53
|
-
color: white;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/* Code content */
|
|
57
|
-
.bertui-code-content {
|
|
58
|
-
display: flex;
|
|
59
|
-
overflow-x: auto;
|
|
60
|
-
padding: 16px 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/* Line numbers */
|
|
64
|
-
.bertui-line-numbers {
|
|
65
|
-
color: #858585;
|
|
66
|
-
padding: 0 16px;
|
|
67
|
-
text-align: right;
|
|
68
|
-
user-select: none;
|
|
69
|
-
border-right: 1px solid #3d3d3d;
|
|
70
|
-
min-width: 40px;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.bertui-line-numbers span {
|
|
74
|
-
display: block;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/* Code block */
|
|
78
|
-
.bertui-code-pre {
|
|
79
|
-
margin: 0;
|
|
80
|
-
padding: 0 16px;
|
|
81
|
-
flex: 1;
|
|
82
|
-
overflow-x: auto;
|
|
83
|
-
white-space: pre;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/* Syntax highlighting tokens (users can override) */
|
|
87
|
-
.token.keyword {
|
|
88
|
-
color: #569cd6;
|
|
89
|
-
font-weight: bold;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.token.string {
|
|
93
|
-
color: #ce9178;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.token.comment {
|
|
97
|
-
color: #6a9955;
|
|
98
|
-
font-style: italic;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.token.function {
|
|
102
|
-
color: #dcdcaa;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.token.number {
|
|
106
|
-
color: #b5cea8;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.token.operator {
|
|
110
|
-
color: #d4d4d4;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.token.punctuation {
|
|
114
|
-
color: #d4d4d4;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.token.class-name {
|
|
118
|
-
color: #4ec9b0;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.token.parameter {
|
|
122
|
-
color: #9cdcfe;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/* Inline code */
|
|
126
|
-
.bertui-inline-code {
|
|
127
|
-
background: #2d2d2d;
|
|
128
|
-
color: #d4d4d4;
|
|
129
|
-
padding: 2px 6px;
|
|
130
|
-
border-radius: 4px;
|
|
131
|
-
font-family: 'Menlo', 'Monaco', monospace;
|
|
132
|
-
font-size: 0.9em;
|
|
133
|
-
line-height: 1.4;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/* Light theme variant */
|
|
137
|
-
.bertui-code.light-theme,
|
|
138
|
-
.bertui-code[data-theme="light"] {
|
|
139
|
-
background: #ffffff;
|
|
140
|
-
color: #374151;
|
|
141
|
-
border: 1px solid #e5e7eb;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.bertui-code.light-theme .bertui-code-header,
|
|
145
|
-
.bertui-code[data-theme="light"] .bertui-code-header {
|
|
146
|
-
background: #f3f4f6;
|
|
147
|
-
border-bottom: 1px solid #d1d5db;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.bertui-code.light-theme .bertui-code-language,
|
|
151
|
-
.bertui-code[data-theme="light"] .bertui-code-language {
|
|
152
|
-
color: #6b7280;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.bertui-code.light-theme .bertui-copy-button,
|
|
156
|
-
.bertui-code[data-theme="light"] .bertui-copy-button {
|
|
157
|
-
background: #e5e7eb;
|
|
158
|
-
color: #374151;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.bertui-code.light-theme .bertui-copy-button:hover,
|
|
162
|
-
.bertui-code[data-theme="light"] .bertui-copy-button:hover {
|
|
163
|
-
background: #d1d5db;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.bertui-code.light-theme .bertui-line-numbers,
|
|
167
|
-
.bertui-code[data-theme="light"] .bertui-line-numbers {
|
|
168
|
-
color: #6b7280;
|
|
169
|
-
border-right: 1px solid #d1d5db;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
.bertui-code.light-theme .bertui-inline-code,
|
|
173
|
-
.bertui-code[data-theme="light"] .bertui-inline-code {
|
|
174
|
-
background: #e5e7eb;
|
|
175
|
-
color: #374151;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/* Pink theme variant */
|
|
179
|
-
.bertui-code.pink-theme,
|
|
180
|
-
.bertui-code[data-theme="pink"] {
|
|
181
|
-
background: #fdf2f8;
|
|
182
|
-
color: #831843;
|
|
183
|
-
border: 1px solid #fbcfe8;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.bertui-code.pink-theme .bertui-code-header,
|
|
187
|
-
.bertui-code[data-theme="pink"] .bertui-code-header {
|
|
188
|
-
background: #fce7f3;
|
|
189
|
-
border-bottom: 1px solid #f9a8d4;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
.bertui-code.pink-theme .bertui-code-language,
|
|
193
|
-
.bertui-code[data-theme="pink"] .bertui-code-language {
|
|
194
|
-
color: #be185d;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
.bertui-code.pink-theme .bertui-copy-button,
|
|
198
|
-
.bertui-code[data-theme="pink"] .bertui-copy-button {
|
|
199
|
-
background: #f472b6;
|
|
200
|
-
color: white;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
.bertui-code.pink-theme .bertui-copy-button:hover,
|
|
204
|
-
.bertui-code[data-theme="pink"] .bertui-copy-button:hover {
|
|
205
|
-
background: #ec4899;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
.bertui-code.pink-theme .bertui-line-numbers,
|
|
209
|
-
.bertui-code[data-theme="pink"] .bertui-line-numbers {
|
|
210
|
-
color: #db2777;
|
|
211
|
-
border-right: 1px solid #f9a8d4;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.bertui-code.pink-theme .bertui-inline-code,
|
|
215
|
-
.bertui-code[data-theme="pink"] .bertui-inline-code {
|
|
216
|
-
background: #fce7f3;
|
|
217
|
-
color: #831843;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/* Light theme syntax */
|
|
221
|
-
.bertui-code.light-theme .token.keyword,
|
|
222
|
-
.bertui-code[data-theme="light"] .token.keyword {
|
|
223
|
-
color: #059669;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
.bertui-code.light-theme .token.string,
|
|
227
|
-
.bertui-code[data-theme="light"] .token.string {
|
|
228
|
-
color: #dc2626;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
.bertui-code.light-theme .token.comment,
|
|
232
|
-
.bertui-code[data-theme="light"] .token.comment {
|
|
233
|
-
color: #6b7280;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/* Pink theme syntax */
|
|
237
|
-
.bertui-code.pink-theme .token.keyword,
|
|
238
|
-
.bertui-code[data-theme="pink"] .token.keyword {
|
|
239
|
-
color: #db2777;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
.bertui-code.pink-theme .token.string,
|
|
243
|
-
.bertui-code[data-theme="pink"] .token.string {
|
|
244
|
-
color: #ea580c;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
.bertui-code.pink-theme .token.comment,
|
|
248
|
-
.bertui-code[data-theme="pink"] .token.comment {
|
|
249
|
-
color: #a855f7;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/* Mobile responsiveness */
|
|
253
|
-
@media (max-width: 640px) {
|
|
254
|
-
.bertui-code {
|
|
255
|
-
font-size: 13px;
|
|
256
|
-
border-radius: 6px;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
.bertui-code-content {
|
|
260
|
-
padding: 12px 0;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
.bertui-code-header {
|
|
264
|
-
padding: 6px 12px;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
.bertui-line-numbers {
|
|
268
|
-
padding: 0 12px;
|
|
269
|
-
min-width: 36px;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
.bertui-code-pre {
|
|
273
|
-
padding: 0 12px;
|
|
274
|
-
}
|
|
275
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CSS module declaration for bertui-code styles
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
declare module 'bertui-code/bertui-code.css' {
|
|
6
|
-
const styles: {
|
|
7
|
-
/** bertui-code container class */
|
|
8
|
-
readonly 'bertui-code': string;
|
|
9
|
-
/** Code block header */
|
|
10
|
-
readonly 'bertui-code-header': string;
|
|
11
|
-
/** Language label */
|
|
12
|
-
readonly 'bertui-code-language': string;
|
|
13
|
-
/** Copy button */
|
|
14
|
-
readonly 'bertui-copy-button': string;
|
|
15
|
-
/** Copy button copied state */
|
|
16
|
-
readonly 'copied': string;
|
|
17
|
-
/** Code content wrapper */
|
|
18
|
-
readonly 'bertui-code-content': string;
|
|
19
|
-
/** Line numbers container */
|
|
20
|
-
readonly 'bertui-line-numbers': string;
|
|
21
|
-
/** Individual line number */
|
|
22
|
-
readonly 'bertui-line-number': string;
|
|
23
|
-
/** Preformatted code block */
|
|
24
|
-
readonly 'bertui-code-pre': string;
|
|
25
|
-
/** Inline code element */
|
|
26
|
-
readonly 'bertui-inline-code': string;
|
|
27
|
-
/** Syntax highlighting tokens */
|
|
28
|
-
readonly 'token': string;
|
|
29
|
-
readonly 'keyword': string;
|
|
30
|
-
readonly 'string': string;
|
|
31
|
-
readonly 'comment': string;
|
|
32
|
-
readonly 'function': string;
|
|
33
|
-
readonly 'number': string;
|
|
34
|
-
readonly 'operator': string;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default styles;
|
|
38
|
-
}
|