{
  "$schema": "../manifest.schema.json",
  "schemaVersion": "1.2.0",
  "name": "ds-codeblock",
  "description": "Preformatted code display block with optional caption",
  "docUrl": "https://design.soracom.io/design-system/elements/codeblock/",
  "category": "elements",
  "htmlElements": [
    "figure",
    "div"
  ],
  "isWebComponent": false,
  "usageNotes": [
    "Place ds-codeblock on a figure or div containing pre > code. The code-pane styles require a descendant pre; applying ds-codeblock directly to pre is not supported.",
    "Use --color-* and --background-* on the wrapper to set the code foreground and background independently. The same classes on a nested pre override that pane only. Explicit --color and --background-color values work on either element. Choose foreground and background colors as a pair.",
    "Captions keep the theme foreground unless colored directly on figcaption. Caption text prefers its local --color-text, then --color. Wrapper palette colors affect the code pane, not the caption.",
    "Nested .ds-icon elements inside figcaption default to the surrounding caption text color through --ds-icon-color. Set --color-* or --ds-icon-color on an icon to override its foreground. Shaped icons retain their normal inversion behavior.",
    "Each pane prefers its local color and background overrides, then the wrapper’s overrides, then the variant defaults. Values are resolved locally and forwarded through private properties because the global overrides do not inherit.",
    "Use --indent-* and --gap-* for the code inset and caption spacing, or --no-indent and --no-gap to remove them. The pane has top and left padding only. Axis-specific spacing modifiers do not change this layout; use padding on the pre for individual edges.",
    "Only --ds-codeblock-height and --ds-codeblock-min-height are public component properties. Spacing, color defaults, and scrollbar styling are private. The former component spacing and color properties are no longer consumed; use spacing and color classes instead. The minimum height defaults to twice the code inset plus --space-medium."
  ],
  "cssCustomProperties": [
    {
      "name": "--ds-codeblock-height",
      "default": "160px",
      "description": "Initial code-pane height; --auto sets it to auto on the pane."
    },
    {
      "name": "--ds-codeblock-min-height",
      "default": "calc(var(--_codeblock-indent) * 2 + var(--space-medium))",
      "description": "Minimum code-pane height, including when resized. The default follows the inset selected by --indent-*."
    }
  ],
  "modifiers": {
    "color": {
      "support": "all"
    },
    "variant": {
      "support": "custom",
      "values": [
        "--wrap",
        "--auto",
        "--light"
      ]
    },
    "indent": {
      "support": "all"
    },
    "gap": {
      "support": "all"
    }
  },
  "structure": {
    "parts": {
      "caption": {
        "element": "figcaption",
        "optional": true,
        "position": [
          "before code"
        ]
      },
      "tag": {
        "element": "span",
        "selector": ".ds-tag.--pinned",
        "optional": true,
        "position": [
          "before code"
        ]
      },
      "preformatted": {
        "element": "pre",
        "required": true
      },
      "code": {
        "element": "code",
        "required": true
      }
    },
    "patterns": {
      "figure": "<figure class=\"ds-codeblock\"><pre><code>{content}</code></pre></figure>",
      "with-caption": "<figure class=\"ds-codeblock\"><figcaption>{caption}</figcaption><pre><code>{content}</code></pre></figure>",
      "div": "<div class=\"ds-codeblock\"><pre><code>{content}</code></pre></div>"
    }
  },
  "attributes": {},
  "dataAttributes": [],
  "examples": [
    {
      "name": "basic",
      "html": "<figure class=\"ds-codeblock\"><pre><code>const greeting = 'Hello, world!';\nconsole.log(greeting);</code></pre></figure>"
    },
    {
      "name": "light",
      "html": "<figure class=\"ds-codeblock --light\"><pre><code>const greeting = 'Hello, world!';\nconsole.log(greeting);</code></pre></figure>"
    },
    {
      "name": "wrap",
      "html": "<figure class=\"ds-codeblock --wrap\"><pre><code>This is a long line of code that will wrap instead of scrolling horizontally when it exceeds the container width.</code></pre></figure>"
    },
    {
      "name": "auto",
      "html": "<figure class=\"ds-codeblock --auto\"><pre><code>// Auto-height adjusts to content\nconst a = 1;\nconst b = 2;</code></pre></figure>"
    },
    {
      "name": "with-caption",
      "html": "<figure class=\"ds-codeblock\"><figcaption>example.js</figcaption><pre><code>function add(a, b) {\n  return a + b;\n}</code></pre></figure>"
    },
    {
      "name": "with-tag",
      "html": "<figure class=\"ds-codeblock\"><span class=\"ds-tag --pinned\"><span>JavaScript</span></span><pre><code>const items = [1, 2, 3];\nitems.forEach(item => console.log(item));</code></pre></figure>"
    }
  ]
}
