basic-tool.stories.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // @ts-nocheck
  2. import { createSignal } from "solid-js"
  3. import * as mod from "./basic-tool"
  4. import { create } from "../storybook/scaffold"
  5. const docs = `### Overview
  6. Expandable tool panel with a structured trigger and optional details.
  7. Use structured triggers for consistent layout; custom triggers allowed.
  8. ### API
  9. - Required: \`icon\` and \`trigger\` (structured or custom JSX).
  10. - Optional: \`status\`, \`defaultOpen\`, \`forceOpen\`, \`defer\`, \`locked\`.
  11. ### Variants and states
  12. - Pending/running status animates the title via TextShimmer.
  13. ### Behavior
  14. - Uses Collapsible; can defer content rendering until open.
  15. - Locked state prevents closing.
  16. ### Accessibility
  17. - TODO: confirm trigger semantics and aria labeling.
  18. ### Theming/tokens
  19. - Uses \`data-component="tool-trigger"\` and related slots.
  20. `
  21. const story = create({
  22. title: "UI/Basic Tool",
  23. mod,
  24. args: {
  25. icon: "mcp",
  26. defaultOpen: true,
  27. trigger: {
  28. title: "Basic Tool",
  29. subtitle: "Example subtitle",
  30. args: ["--flag", "value"],
  31. },
  32. children: "Details content",
  33. },
  34. })
  35. export default {
  36. title: "UI/Basic Tool",
  37. id: "components-basic-tool",
  38. component: story.meta.component,
  39. tags: ["autodocs"],
  40. parameters: {
  41. docs: {
  42. description: {
  43. component: docs,
  44. },
  45. },
  46. },
  47. }
  48. export const Basic = story.Basic
  49. export const Pending = {
  50. args: {
  51. status: "pending",
  52. trigger: {
  53. title: "Running tool",
  54. subtitle: "Working...",
  55. },
  56. children: "Progress details",
  57. },
  58. }
  59. export const Locked = {
  60. args: {
  61. locked: true,
  62. trigger: {
  63. title: "Locked tool",
  64. subtitle: "Cannot close",
  65. },
  66. children: "Locked details",
  67. },
  68. }
  69. export const Deferred = {
  70. args: {
  71. defer: true,
  72. defaultOpen: false,
  73. trigger: {
  74. title: "Deferred tool",
  75. subtitle: "Content mounts on open",
  76. },
  77. children: "Deferred content",
  78. },
  79. }
  80. export const ForceOpen = {
  81. args: {
  82. forceOpen: true,
  83. trigger: {
  84. title: "Forced open",
  85. subtitle: "Cannot close",
  86. },
  87. children: "Forced content",
  88. },
  89. }
  90. export const HideDetails = {
  91. args: {
  92. hideDetails: true,
  93. trigger: {
  94. title: "Summary only",
  95. subtitle: "Details hidden",
  96. },
  97. children: "Hidden content",
  98. },
  99. }
  100. export const SubtitleAction = {
  101. render: () => {
  102. const [message, setMessage] = createSignal("Subtitle not clicked")
  103. return (
  104. <div style={{ display: "grid", gap: "8px" }}>
  105. <div style={{ "font-size": "12px", color: "var(--text-weak)" }}>{message()}</div>
  106. <mod.BasicTool
  107. icon="mcp"
  108. trigger={{ title: "Clickable subtitle", subtitle: "Click me" }}
  109. onSubtitleClick={() => setMessage("Subtitle clicked")}
  110. >
  111. Subtitle action details
  112. </mod.BasicTool>
  113. </div>
  114. )
  115. },
  116. }