File size: 3,406 Bytes
3e05655
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { createSignal } from "solid-js"
import { BasicToolV2 } from "./basic-tool-v2"

const docs = `### Overview
Compact collapsible tool row showing title, subtitle, args, and diff changes, with an expand/collapse chevron.

### API
- \`BasicToolV2\` wraps Kobalte \`Collapsible\`. Pass \`open\`, \`defaultOpen\`, and \`onOpenChange\` for controlled/uncontrolled disclosure.
- \`trigger\` accepts either a \`BasicToolV2TriggerTitle\` object (title, subtitle, args, changes) or arbitrary JSX.
- When \`status\` is \`"pending"\` or \`"running"\`, subtitle/args/chevron hide and the title shows a shimmer animation.
- Pass \`children\` for expandable detail content.

### Theming
- Uses \`data-component="basic-tool-v2"\` and slot attributes; colors via \`--bt-*\` CSS variables.
`

export default {
  title: "UI V2/BasicTool",
  id: "components-basic-tool-v2",
  component: BasicToolV2,
  tags: ["autodocs"],
  parameters: {
    frameBackground: "#fff",
    layout: "padded",
    docs: {
      description: {
        component: docs,
      },
    },
  },
}

export const Default = {
  render: () => (
    <BasicToolV2
      trigger={{
        title: "Read",
        subtitle: "src/index.ts",
        args: ["lines=1-50"],
        changes: { additions: 12, deletions: 3 },
      }}
      defaultOpen={false}
    >
      File content appears here.
    </BasicToolV2>
  ),
}

export const Expanded = {
  render: () => (
    <BasicToolV2
      trigger={{
        title: "Read",
        subtitle: "src/index.ts",
        args: ["lines=1-50"],
        changes: { additions: 12, deletions: 3 },
      }}
      defaultOpen={true}
    >
      File content appears here.
    </BasicToolV2>
  ),
}

export const Pending = {
  render: () => (
    <BasicToolV2
      trigger={{
        title: "Read",
        subtitle: "src/index.ts",
        args: ["lines=1-50"],
        changes: { additions: 12, deletions: 3 },
      }}
      status="pending"
    />
  ),
}

export const NoChildren = {
  render: () => (
    <BasicToolV2
      trigger={{
        title: "Grep",
        subtitle: "pattern=TODO",
        args: ["recursive=true"],
      }}
    />
  ),
}

export const CustomTrigger = {
  render: () => (
    <BasicToolV2
      trigger={
        <span style={{ color: "#161616", "font-size": "13px", "font-weight": "440" }}>Custom trigger content</span>
      }
    >
      Expandable detail for custom trigger.
    </BasicToolV2>
  ),
}

export const Controlled = {
  render: () => {
    const [open, setOpen] = createSignal(false)
    return (
      <div style={{ display: "flex", "flex-direction": "column", gap: "16px", "max-width": "420px" }}>
        <button
          type="button"
          onClick={() => setOpen((o) => !o)}
          style={{
            padding: "4px 10px",
            "font-size": "12px",
            "border-radius": "6px",
            border: "1px solid rgba(0,0,0,0.15)",
            background: "#fff",
            color: "#161616",
            cursor: "pointer",
          }}
        >
          Toggle from outside: {open() ? "Open" : "Closed"}
        </button>
        <BasicToolV2
          trigger={{
            title: "Write",
            subtitle: "src/utils.ts",
            changes: { additions: 8, deletions: 2 },
          }}
          open={open()}
          onOpenChange={setOpen}
        >
          Controlled content.
        </BasicToolV2>
      </div>
    )
  },
}