import { codePropDefs } from "@radix-ui/themes/props" import type { Meta, StoryObj } from "@storybook/react" import { Code } from "./Code" const meta = { title: "base/communication/Code", component: Code, tags: ["autodocs"], argTypes: { children: { control: "text", description: "The code content to display", }, size: { control: "select", options: codePropDefs.size.values, description: "The size of the code", }, color: { control: "select", options: codePropDefs.color.values, description: "The color theme of the code", }, variant: { control: "select", options: codePropDefs.variant.values, description: "The visual style of the code", }, highContrast: { control: "boolean", description: "Whether to use high contrast colors", }, }, parameters: { layout: "centered", }, args: { children: "console.log('Hello, World!')", }, } satisfies Meta export default meta type Story = StoryObj /** * Default code with soft variant. */ export const Default: Story = {} /** * Code with different sizes. */ export const Sizes: Story = { render: () => (
const message = "Small code"; const message = "Medium code"; const message = "Large code";
), } /** * Code with different variants. */ export const Variants: Story = { render: () => (
Soft variant code Outline variant code Solid variant code
), } /** * Code with different colors. */ export const Colors: Story = { render: () => (
Gray code example Blue code example Green code example Red code example Yellow code example Purple code example
), } /** * Code with high contrast. */ export const HighContrast: Story = { args: { highContrast: true, children: "High contrast code example", }, } /** * Code with JavaScript syntax. */ export const JavaScriptCode: Story = { args: { children: "function greet(name) { return `Hello, ${name}!`; }", }, } /** * Code with HTML syntax. */ export const HTMLCode: Story = { args: { children: "
Hello World
", }, } /** * Code with CSS syntax. */ export const CSSCode: Story = { args: { children: ".container { display: flex; justify-content: center; }", }, }