import type { Meta, StoryObj } from '@storybook/nextjs'
import CodeBlock from './code-block'
const SAMPLE_CODE = `const greet = (name: string) => {
return \`Hello, \${name}\`
}
console.log(greet('Dify'))`
const CodeBlockDemo = ({
language = 'typescript',
}: {
language?: string
}) => {
return (
)
}
const meta = {
title: 'Base/Data Display/CodeBlock',
component: CodeBlockDemo,
parameters: {
layout: 'centered',
docs: {
description: {
component: 'Syntax highlighted code block with copy button and SVG toggle support.',
},
},
},
argTypes: {
language: {
control: 'radio',
options: ['typescript', 'json', 'mermaid'],
},
},
args: {
language: 'typescript',
},
tags: ['autodocs'],
} satisfies Meta
export default meta
type Story = StoryObj
export const Playground: Story = {}
export const Mermaid: Story = {
args: {
language: 'mermaid',
},
render: ({ language }) => (
{`graph TD
Start --> Decision{User message?}
Decision -->|Tool| ToolCall[Call web search]
Decision -->|Respond| Answer[Compose draft]
`}
),
}