@aleph-alpha/ui-library 1.20.0 → 1.21.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/dist/system/index.d.ts +64 -0
- package/dist/system/lib.js +12723 -12534
- package/package.json +2 -1
- package/src/components/UiCodeBlock/UiCodeBlock.stories.ts +352 -0
- package/src/components/UiCodeBlock/UiCodeBlock.vue +168 -0
- package/src/components/UiCodeBlock/__tests__/UiCodeBlock.test.ts +210 -0
- package/src/components/UiCodeBlock/index.ts +2 -0
- package/src/components/UiCodeBlock/types.ts +60 -0
- package/src/components/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aleph-alpha/ui-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/system/lib.js",
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
"lucide-vue-next": "^0.556.0",
|
|
104
104
|
"radix-vue": "^1.9.17",
|
|
105
105
|
"reka-ui": "^2.7.0",
|
|
106
|
+
"shiki": "^3.0.0",
|
|
106
107
|
"tailwind-merge": "^3.4.0"
|
|
107
108
|
},
|
|
108
109
|
"scripts": {
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import UiCodeBlock from './UiCodeBlock.vue';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof UiCodeBlock> = {
|
|
5
|
+
title: 'Components/UiCodeBlock',
|
|
6
|
+
component: UiCodeBlock,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
code: {
|
|
10
|
+
control: false,
|
|
11
|
+
},
|
|
12
|
+
language: {
|
|
13
|
+
control: 'select',
|
|
14
|
+
options: ['text', 'typescript', 'javascript', 'python', 'json', 'html', 'css', 'bash', 'sql'],
|
|
15
|
+
description:
|
|
16
|
+
'Programming language for syntax highlighting. Supports all Shiki languages (200+).',
|
|
17
|
+
},
|
|
18
|
+
filename: {
|
|
19
|
+
control: 'text',
|
|
20
|
+
description: 'Shown in header instead of the language label. Use for file-specific context.',
|
|
21
|
+
},
|
|
22
|
+
showLineNumbers: {
|
|
23
|
+
control: 'boolean',
|
|
24
|
+
},
|
|
25
|
+
showCopyButton: {
|
|
26
|
+
control: 'boolean',
|
|
27
|
+
},
|
|
28
|
+
maxHeight: {
|
|
29
|
+
control: 'text',
|
|
30
|
+
description: 'CSS height value. Code area scrolls when content exceeds this height.',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
args: {
|
|
34
|
+
language: 'typescript',
|
|
35
|
+
showLineNumbers: false,
|
|
36
|
+
showCopyButton: true,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default meta;
|
|
41
|
+
|
|
42
|
+
type Story = StoryObj<typeof UiCodeBlock>;
|
|
43
|
+
|
|
44
|
+
const typescriptExample = `import { ref, computed } from 'vue';
|
|
45
|
+
|
|
46
|
+
interface User {
|
|
47
|
+
id: number;
|
|
48
|
+
name: string;
|
|
49
|
+
email: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const users = ref<User[]>([]);
|
|
53
|
+
|
|
54
|
+
const activeUsers = computed(() =>
|
|
55
|
+
users.value.filter(user => user.email.includes('@'))
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
function addUser(name: string, email: string) {
|
|
59
|
+
users.value.push({
|
|
60
|
+
id: users.value.length + 1,
|
|
61
|
+
name,
|
|
62
|
+
email,
|
|
63
|
+
});
|
|
64
|
+
}`;
|
|
65
|
+
|
|
66
|
+
const defaultTemplateSource = `<script setup lang="ts">
|
|
67
|
+
import { UiCodeBlock } from '@aleph-alpha/ui-library'
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<UiCodeBlock
|
|
72
|
+
:code="code"
|
|
73
|
+
language="typescript"
|
|
74
|
+
/>
|
|
75
|
+
</template>`;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Basic code block with syntax highlighting. Use this for displaying code
|
|
79
|
+
* snippets in documentation, AI assistant responses, or knowledge bases.
|
|
80
|
+
*/
|
|
81
|
+
export const Default: Story = {
|
|
82
|
+
render: (args) => ({
|
|
83
|
+
components: { UiCodeBlock },
|
|
84
|
+
setup() {
|
|
85
|
+
return { args, code: typescriptExample };
|
|
86
|
+
},
|
|
87
|
+
template: `<UiCodeBlock :code="code" :language="args.language" :show-line-numbers="args.showLineNumbers" :show-copy-button="args.showCopyButton" :filename="args.filename" :max-height="args.maxHeight" />`,
|
|
88
|
+
}),
|
|
89
|
+
parameters: {
|
|
90
|
+
docs: {
|
|
91
|
+
source: {
|
|
92
|
+
code: defaultTemplateSource,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const pythonExample = `import pandas as pd
|
|
99
|
+
from sklearn.model_selection import train_test_split
|
|
100
|
+
|
|
101
|
+
def train_model(data_path: str, target_col: str):
|
|
102
|
+
"""Load data, split, and train a simple model."""
|
|
103
|
+
df = pd.read_csv(data_path)
|
|
104
|
+
X = df.drop(columns=[target_col])
|
|
105
|
+
y = df[target_col]
|
|
106
|
+
|
|
107
|
+
X_train, X_test, y_train, y_test = train_test_split(
|
|
108
|
+
X, y, test_size=0.2, random_state=42
|
|
109
|
+
)
|
|
110
|
+
return X_train, X_test, y_train, y_test`;
|
|
111
|
+
|
|
112
|
+
const pythonWithFilenameTemplateSource = `<script setup lang="ts">
|
|
113
|
+
import { UiCodeBlock } from '@aleph-alpha/ui-library'
|
|
114
|
+
</script>
|
|
115
|
+
|
|
116
|
+
<template>
|
|
117
|
+
<UiCodeBlock
|
|
118
|
+
:code="code"
|
|
119
|
+
language="python"
|
|
120
|
+
filename="train.py"
|
|
121
|
+
/>
|
|
122
|
+
</template>`;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Use the filename prop to give users context about which file the code
|
|
126
|
+
* belongs to. The filename replaces the language label in the header.
|
|
127
|
+
*/
|
|
128
|
+
export const WithFilename: Story = {
|
|
129
|
+
render: () => ({
|
|
130
|
+
components: { UiCodeBlock },
|
|
131
|
+
setup() {
|
|
132
|
+
return { code: pythonExample };
|
|
133
|
+
},
|
|
134
|
+
template: `<UiCodeBlock :code="code" language="python" filename="train.py" />`,
|
|
135
|
+
}),
|
|
136
|
+
parameters: {
|
|
137
|
+
docs: {
|
|
138
|
+
source: {
|
|
139
|
+
code: pythonWithFilenameTemplateSource,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const jsonExample = `{
|
|
146
|
+
"name": "@aleph-alpha/ui-library",
|
|
147
|
+
"version": "1.14.0",
|
|
148
|
+
"dependencies": {
|
|
149
|
+
"vue": "^3.4.0",
|
|
150
|
+
"shiki": "^3.0.0"
|
|
151
|
+
},
|
|
152
|
+
"scripts": {
|
|
153
|
+
"build": "vite build",
|
|
154
|
+
"test": "vitest --run"
|
|
155
|
+
}
|
|
156
|
+
}`;
|
|
157
|
+
|
|
158
|
+
const withLineNumbersTemplateSource = `<script setup lang="ts">
|
|
159
|
+
import { UiCodeBlock } from '@aleph-alpha/ui-library'
|
|
160
|
+
</script>
|
|
161
|
+
|
|
162
|
+
<template>
|
|
163
|
+
<UiCodeBlock
|
|
164
|
+
:code="code"
|
|
165
|
+
language="json"
|
|
166
|
+
filename="package.json"
|
|
167
|
+
show-line-numbers
|
|
168
|
+
/>
|
|
169
|
+
</template>`;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Enable line numbers for code that needs to be referenced by line,
|
|
173
|
+
* such as config files, code reviews, or error stack traces.
|
|
174
|
+
*/
|
|
175
|
+
export const WithLineNumbers: Story = {
|
|
176
|
+
render: () => ({
|
|
177
|
+
components: { UiCodeBlock },
|
|
178
|
+
setup() {
|
|
179
|
+
return { code: jsonExample };
|
|
180
|
+
},
|
|
181
|
+
template: `<UiCodeBlock :code="code" language="json" filename="package.json" show-line-numbers />`,
|
|
182
|
+
}),
|
|
183
|
+
parameters: {
|
|
184
|
+
docs: {
|
|
185
|
+
source: {
|
|
186
|
+
code: withLineNumbersTemplateSource,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const longCode = Array.from(
|
|
193
|
+
{ length: 30 },
|
|
194
|
+
(_, i) => `console.log('Line ${i + 1}: Processing item ${i + 1}');`,
|
|
195
|
+
).join('\n');
|
|
196
|
+
|
|
197
|
+
const withMaxHeightTemplateSource = `<script setup lang="ts">
|
|
198
|
+
import { UiCodeBlock } from '@aleph-alpha/ui-library'
|
|
199
|
+
</script>
|
|
200
|
+
|
|
201
|
+
<template>
|
|
202
|
+
<UiCodeBlock
|
|
203
|
+
:code="code"
|
|
204
|
+
language="javascript"
|
|
205
|
+
max-height="200px"
|
|
206
|
+
show-line-numbers
|
|
207
|
+
/>
|
|
208
|
+
</template>`;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Use maxHeight to constrain long code blocks and prevent them from
|
|
212
|
+
* dominating the page layout. The code area becomes scrollable.
|
|
213
|
+
*/
|
|
214
|
+
export const WithMaxHeight: Story = {
|
|
215
|
+
render: () => ({
|
|
216
|
+
components: { UiCodeBlock },
|
|
217
|
+
setup() {
|
|
218
|
+
return { code: longCode };
|
|
219
|
+
},
|
|
220
|
+
template: `<UiCodeBlock :code="code" language="javascript" max-height="200px" show-line-numbers />`,
|
|
221
|
+
}),
|
|
222
|
+
parameters: {
|
|
223
|
+
docs: {
|
|
224
|
+
source: {
|
|
225
|
+
code: withMaxHeightTemplateSource,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
const bashExample = `#!/bin/bash
|
|
232
|
+
set -euo pipefail
|
|
233
|
+
|
|
234
|
+
echo "Deploying application..."
|
|
235
|
+
docker build -t my-app:latest .
|
|
236
|
+
docker push my-app:latest
|
|
237
|
+
kubectl apply -f k8s/deployment.yaml
|
|
238
|
+
echo "Deployment complete!"`;
|
|
239
|
+
|
|
240
|
+
const withoutCopyButtonTemplateSource = `<script setup lang="ts">
|
|
241
|
+
import { UiCodeBlock } from '@aleph-alpha/ui-library'
|
|
242
|
+
</script>
|
|
243
|
+
|
|
244
|
+
<template>
|
|
245
|
+
<UiCodeBlock
|
|
246
|
+
:code="code"
|
|
247
|
+
language="bash"
|
|
248
|
+
:show-copy-button="false"
|
|
249
|
+
/>
|
|
250
|
+
</template>`;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Hide the copy button when the code is for display only and copying
|
|
254
|
+
* is not expected, such as terminal output or read-only logs.
|
|
255
|
+
*/
|
|
256
|
+
export const WithoutCopyButton: Story = {
|
|
257
|
+
render: () => ({
|
|
258
|
+
components: { UiCodeBlock },
|
|
259
|
+
setup() {
|
|
260
|
+
return { code: bashExample };
|
|
261
|
+
},
|
|
262
|
+
template: `<UiCodeBlock :code="code" language="bash" :show-copy-button="false" />`,
|
|
263
|
+
}),
|
|
264
|
+
parameters: {
|
|
265
|
+
docs: {
|
|
266
|
+
source: {
|
|
267
|
+
code: withoutCopyButtonTemplateSource,
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const plainTextExample = `This is plain text output from a command.
|
|
274
|
+
No syntax highlighting is applied.
|
|
275
|
+
Useful for terminal output or log files.`;
|
|
276
|
+
|
|
277
|
+
const plainTextTemplateSource = `<script setup lang="ts">
|
|
278
|
+
import { UiCodeBlock } from '@aleph-alpha/ui-library'
|
|
279
|
+
</script>
|
|
280
|
+
|
|
281
|
+
<template>
|
|
282
|
+
<UiCodeBlock :code="code" />
|
|
283
|
+
</template>`;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Omit the language prop (defaults to 'text') for plain output that
|
|
287
|
+
* doesn't need syntax highlighting, such as CLI output or raw logs.
|
|
288
|
+
*/
|
|
289
|
+
export const PlainText: Story = {
|
|
290
|
+
render: () => ({
|
|
291
|
+
components: { UiCodeBlock },
|
|
292
|
+
setup() {
|
|
293
|
+
return { code: plainTextExample };
|
|
294
|
+
},
|
|
295
|
+
template: `<UiCodeBlock :code="code" />`,
|
|
296
|
+
}),
|
|
297
|
+
parameters: {
|
|
298
|
+
docs: {
|
|
299
|
+
source: {
|
|
300
|
+
code: plainTextTemplateSource,
|
|
301
|
+
},
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const htmlExample = `<template>
|
|
307
|
+
<div class="card">
|
|
308
|
+
<header class="card__header">
|
|
309
|
+
<h2>{{ title }}</h2>
|
|
310
|
+
</header>
|
|
311
|
+
<main class="card__body">
|
|
312
|
+
<slot />
|
|
313
|
+
</main>
|
|
314
|
+
<footer class="card__footer">
|
|
315
|
+
<button @click="$emit('confirm')">Confirm</button>
|
|
316
|
+
</footer>
|
|
317
|
+
</div>
|
|
318
|
+
</template>`;
|
|
319
|
+
|
|
320
|
+
const htmlWithLineNumbersTemplateSource = `<script setup lang="ts">
|
|
321
|
+
import { UiCodeBlock } from '@aleph-alpha/ui-library'
|
|
322
|
+
</script>
|
|
323
|
+
|
|
324
|
+
<template>
|
|
325
|
+
<UiCodeBlock
|
|
326
|
+
:code="code"
|
|
327
|
+
language="html"
|
|
328
|
+
filename="Card.vue"
|
|
329
|
+
show-line-numbers
|
|
330
|
+
/>
|
|
331
|
+
</template>`;
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Combine filename and line numbers for code review or documentation
|
|
335
|
+
* contexts where both the file origin and line references matter.
|
|
336
|
+
*/
|
|
337
|
+
export const HtmlWithLineNumbers: Story = {
|
|
338
|
+
render: () => ({
|
|
339
|
+
components: { UiCodeBlock },
|
|
340
|
+
setup() {
|
|
341
|
+
return { code: htmlExample };
|
|
342
|
+
},
|
|
343
|
+
template: `<UiCodeBlock :code="code" language="html" filename="Card.vue" show-line-numbers />`,
|
|
344
|
+
}),
|
|
345
|
+
parameters: {
|
|
346
|
+
docs: {
|
|
347
|
+
source: {
|
|
348
|
+
code: htmlWithLineNumbersTemplateSource,
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, computed, watch, onMounted, onUnmounted } from 'vue';
|
|
3
|
+
import { useClipboard } from '@vueuse/core';
|
|
4
|
+
import { codeToHtml } from 'shiki';
|
|
5
|
+
import { cn } from '@/lib/utils';
|
|
6
|
+
import { UiIconButton } from '@/components/UiIconButton';
|
|
7
|
+
import { UiIcon } from '@/components/UiIcon';
|
|
8
|
+
import type { UiCodeBlockProps } from './types';
|
|
9
|
+
|
|
10
|
+
defineOptions({
|
|
11
|
+
name: 'UiCodeBlock',
|
|
12
|
+
inheritAttrs: false,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<UiCodeBlockProps>(), {
|
|
16
|
+
language: 'text',
|
|
17
|
+
filename: undefined,
|
|
18
|
+
showLineNumbers: false,
|
|
19
|
+
showCopyButton: true,
|
|
20
|
+
maxHeight: undefined,
|
|
21
|
+
copyLabel: 'Copy code',
|
|
22
|
+
copiedLabel: 'Copied',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const highlightedHtml = ref('');
|
|
26
|
+
const isHighlighted = ref(false);
|
|
27
|
+
const isCopied = ref(false);
|
|
28
|
+
|
|
29
|
+
const { copy } = useClipboard();
|
|
30
|
+
|
|
31
|
+
const headerLabel = computed(() => props.filename || props.language);
|
|
32
|
+
const showHeader = computed(() => headerLabel.value !== 'text' || props.showCopyButton);
|
|
33
|
+
|
|
34
|
+
let highlightRequestId = 0;
|
|
35
|
+
|
|
36
|
+
async function highlightCode() {
|
|
37
|
+
const requestId = ++highlightRequestId;
|
|
38
|
+
isHighlighted.value = false;
|
|
39
|
+
try {
|
|
40
|
+
const html = await codeToHtml(props.code, {
|
|
41
|
+
lang: props.language as Parameters<typeof codeToHtml>[1]['lang'],
|
|
42
|
+
themes: {
|
|
43
|
+
light: 'github-light',
|
|
44
|
+
dark: 'github-dark',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
if (requestId !== highlightRequestId) return;
|
|
48
|
+
highlightedHtml.value = html;
|
|
49
|
+
isHighlighted.value = true;
|
|
50
|
+
} catch {
|
|
51
|
+
if (requestId !== highlightRequestId) return;
|
|
52
|
+
try {
|
|
53
|
+
const html = await codeToHtml(props.code, {
|
|
54
|
+
lang: 'text',
|
|
55
|
+
themes: {
|
|
56
|
+
light: 'github-light',
|
|
57
|
+
dark: 'github-dark',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
if (requestId !== highlightRequestId) return;
|
|
61
|
+
highlightedHtml.value = html;
|
|
62
|
+
isHighlighted.value = true;
|
|
63
|
+
} catch {
|
|
64
|
+
if (requestId !== highlightRequestId) return;
|
|
65
|
+
highlightedHtml.value = '';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
watch(() => [props.code, props.language], highlightCode);
|
|
71
|
+
onMounted(highlightCode);
|
|
72
|
+
|
|
73
|
+
let copyTimerId: ReturnType<typeof setTimeout> | undefined;
|
|
74
|
+
|
|
75
|
+
async function handleCopy() {
|
|
76
|
+
try {
|
|
77
|
+
await copy(props.code);
|
|
78
|
+
isCopied.value = true;
|
|
79
|
+
clearTimeout(copyTimerId);
|
|
80
|
+
copyTimerId = setTimeout(() => {
|
|
81
|
+
isCopied.value = false;
|
|
82
|
+
}, 2000);
|
|
83
|
+
} catch {
|
|
84
|
+
// Clipboard access denied or unsupported - silently ignore
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
onUnmounted(() => {
|
|
89
|
+
highlightRequestId++;
|
|
90
|
+
clearTimeout(copyTimerId);
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<template>
|
|
95
|
+
<div
|
|
96
|
+
v-bind="$attrs"
|
|
97
|
+
:class="cn('ui-code-block overflow-hidden rounded-lg border border-border', $attrs.class ?? '')"
|
|
98
|
+
>
|
|
99
|
+
<div
|
|
100
|
+
v-if="showHeader"
|
|
101
|
+
class="flex items-center justify-between border-b border-border bg-muted px-4 py-2"
|
|
102
|
+
>
|
|
103
|
+
<span class="font-mono text-sm text-muted-foreground">
|
|
104
|
+
{{ headerLabel !== 'text' ? headerLabel : '' }}
|
|
105
|
+
</span>
|
|
106
|
+
<UiIconButton
|
|
107
|
+
v-if="showCopyButton"
|
|
108
|
+
variant="ghost"
|
|
109
|
+
size="icon-sm"
|
|
110
|
+
:ariaLabel="isCopied ? copiedLabel : copyLabel"
|
|
111
|
+
@click="handleCopy"
|
|
112
|
+
>
|
|
113
|
+
<UiIcon :name="isCopied ? 'check' : 'copy'" :size="14" />
|
|
114
|
+
</UiIconButton>
|
|
115
|
+
</div>
|
|
116
|
+
|
|
117
|
+
<div class="overflow-auto" :style="maxHeight ? { maxHeight } : undefined">
|
|
118
|
+
<div
|
|
119
|
+
v-if="isHighlighted && highlightedHtml"
|
|
120
|
+
:class="cn('ui-code-block__content', showLineNumbers && 'ui-code-block__line-numbers')"
|
|
121
|
+
v-html="highlightedHtml"
|
|
122
|
+
/>
|
|
123
|
+
<pre
|
|
124
|
+
v-else
|
|
125
|
+
class="m-0 bg-background p-4 font-mono text-sm leading-relaxed text-foreground"
|
|
126
|
+
><code>{{ code }}</code></pre>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</template>
|
|
130
|
+
|
|
131
|
+
<style scoped>
|
|
132
|
+
/* Dark mode: :global() needed because html.dark is outside component scope */
|
|
133
|
+
:global(html.dark .ui-code-block .shiki),
|
|
134
|
+
:global(html.dark .ui-code-block .shiki span) {
|
|
135
|
+
color: var(--shiki-dark) !important;
|
|
136
|
+
background-color: var(--shiki-dark-bg) !important;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* :deep() needed to style v-html content */
|
|
140
|
+
.ui-code-block__content :deep(.shiki) {
|
|
141
|
+
margin: 0;
|
|
142
|
+
padding: 1rem;
|
|
143
|
+
font-size: 0.875rem;
|
|
144
|
+
line-height: 1.625;
|
|
145
|
+
overflow-x: auto;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.ui-code-block__content :deep(.shiki code) {
|
|
149
|
+
display: block;
|
|
150
|
+
font-family:
|
|
151
|
+
ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* Line numbers via CSS counter */
|
|
155
|
+
.ui-code-block__line-numbers :deep(.shiki code) {
|
|
156
|
+
counter-reset: line;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.ui-code-block__line-numbers :deep(.shiki code .line::before) {
|
|
160
|
+
counter-increment: line;
|
|
161
|
+
content: counter(line);
|
|
162
|
+
display: inline-block;
|
|
163
|
+
width: 2rem;
|
|
164
|
+
margin-right: 1rem;
|
|
165
|
+
text-align: right;
|
|
166
|
+
opacity: 0.4;
|
|
167
|
+
}
|
|
168
|
+
</style>
|