UNPKG

@playbooks/ui

Version:

An interface library for Playbooks.

40 lines (39 loc) 1.15 kB
import { jsxs } from "react/jsx-runtime"; import { useMemo } from "react"; import { K as Kbd } from "./index.es-7ZX4yv7W.js"; import { useUI } from "./context.es.js"; const Command = ({ name = "CMD", keys = [], tailwind, className, children, ...props }) => { const context = useUI(); const base = context?.theme?.command(); const computed = { ...base, ...props, tailwind, className, name }; const computedKeys = useMemo(() => { const formattedKeys = []; keys.map((code) => { switch (code) { case "command": case "Command": return formattedKeys.push("⌘"); case "control": case "Control": return formattedKeys.push("^"); case "enter": case "Enter": return formattedKeys.push("↵"); case "option": case "Option": return formattedKeys.push("⌥"); case "shift": case "Shift": return formattedKeys.push("⇧"); } }); return formattedKeys; }, [keys]); return /* @__PURE__ */ jsxs(Kbd, { ...computed, children: [ computedKeys.join(""), children ] }); }; export { Command };