@primer/react
Version:
An implementation of GitHub's Primer Design System using React
69 lines (68 loc) • 1.67 kB
JavaScript
import Text_default from "../Text/Text.js";
import { Sequence } from "./components/Sequence.js";
import KeybindingHint_module_css_default from "./KeybindingHint.module.css.js";
import { c } from "react-compiler-runtime";
import { clsx } from "clsx";
import { jsx } from "react/jsx-runtime";
import { memo } from "react";
//#region src/KeybindingHint/KeybindingHint.tsx
/** `kbd` element with style resets. */
const Kbd = (t0) => {
const $ = c(5);
const { children, className } = t0;
let t1;
if ($[0] !== className) {
t1 = clsx(className, KeybindingHint_module_css_default.KeybindingHint);
$[0] = className;
$[1] = t1;
} else t1 = $[1];
let t2;
if ($[2] !== children || $[3] !== t1) {
t2 = /*#__PURE__*/ jsx(Text_default, {
as: "kbd",
className: t1,
"data-testid": "keybinding-hint",
"data-component": "KeybindingHint",
children
});
$[2] = children;
$[3] = t1;
$[4] = t2;
} else t2 = $[4];
return t2;
};
/** Indicates the presence of an available keybinding. */
const KeybindingHint = /*#__PURE__*/ memo((t0) => {
const $ = c(8);
let className;
let props;
if ($[0] !== t0) {
({className, ...props} = t0);
$[0] = t0;
$[1] = className;
$[2] = props;
} else {
className = $[1];
props = $[2];
}
let t1;
if ($[3] !== props) {
t1 = /*#__PURE__*/ jsx(Sequence, { ...props });
$[3] = props;
$[4] = t1;
} else t1 = $[4];
let t2;
if ($[5] !== className || $[6] !== t1) {
t2 = /*#__PURE__*/ jsx(Kbd, {
className,
children: t1
});
$[5] = className;
$[6] = t1;
$[7] = t2;
} else t2 = $[7];
return t2;
});
KeybindingHint.displayName = "KeybindingHint";
//#endregion
export { KeybindingHint };