/components/prose/code

import { prose } from "@hedia/hexui/components/prose";
import { json } from "@hedia/hexui/html/json";
import { element } from "@hedia/html";
import { code, kbd, p, pre, samp } from "@hedia/html/elements";

export default {
  InlineCode,
  CodeBlock,
  JsonSyntaxHighlighting,
  KeyboardInput,
  SampleOutput,
  Variable,
};

export function InlineCode() {
  return prose(p("Use the ", code("console.log()"), " method to print values to the console."));
}

export function CodeBlock() {
  return prose(pre(code("function greet(name) {\n  return `Hello, ${name}!`;\n}")));
}

export function JsonSyntaxHighlighting() {
  return prose(
    pre(
      code(
        ...json({
          array: [1, 6, 15, 28, 45, 66, 91, 120],
          bool: true,
          number: 3.1415926535,
          object: {
            array: [],
            bool: false,
            number: 0,
            null: null,
            string: "",
            object: {},
          },
          string: "Dorothy Hodgkin",
        }),
      ),
    ),
  );
}

export function KeyboardInput() {
  return prose(
    p("Press ", kbd("Ctrl + C"), " to copy."),
    p("Use ", kbd("Cmd + Shift + P"), " to open the command palette."),
  );
}

export function SampleOutput() {
  return prose(p("Message from my computer:"), pre(samp("File not found.\nPress F1 to continue")));
}

export function Variable() {
  return prose(
    p("If ", element("var", "count"), " exceeds ", element("var", "maxRetries"), ", the request is aborted."),
  );
}