1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// @ts-nocheck
import * as mod from "./code"
import { create } from "../storybook/scaffold"
import { code } from "../storybook/fixtures"
const docs = `### Overview
Syntax-highlighted code viewer with selection support and large-file virtualization.
Use alongside \`LineComment\` and \`Diff\` in review workflows.
### API
- Required: \`file\` with file name + contents.
- Optional: \`language\`, \`annotations\`, \`selectedLines\`, \`commentedLines\`.
- Optional callbacks: \`onRendered\`, \`onLineSelectionEnd\`.
### Variants and states
- Supports large-file virtualization automatically.
### Behavior
- Re-renders when \`file\` or rendering options change.
- Optional line selection integrates with selection callbacks.
### Accessibility
- TODO: confirm keyboard find and selection behavior.
### Theming/tokens
- Uses \`data-component="code"\` and Pierre CSS variables from \`styleVariables\`.
`
const story = create({
title: "UI/Code",
mod,
args: {
file: code,
language: "ts",
},
})
export default {
title: "UI/Code",
id: "components-code",
component: story.meta.component,
tags: ["autodocs"],
parameters: {
docs: {
description: {
component: docs,
},
},
},
}
export const Basic = story.Basic
export const SelectedLines = {
args: {
enableLineSelection: true,
selectedLines: { start: 2, end: 4 },
},
}
export const CommentedLines = {
args: {
commentedLines: [
{ start: 1, end: 1 },
{ start: 5, end: 6 },
],
},
}
|