@ducor/react
Version:
admin template ui interface
36 lines (35 loc) • 1.65 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef } from "react";
import { twMerge } from "tailwind-merge";
import { getColor } from "../helpers/colors";
const Kbd = forwardRef((_a, ref) => {
var { size = "md", className, children } = _a, props = __rest(_a, ["size", "className", "children"]);
// Define size classes based on the 'size' prop
const sizeClasses = {
xs: "h-3 min-w-3 px-1 text-xs", // Extra small size
sm: "h-4 min-w-4 px-1 text-sm", // Small size
md: "h-6 min-w-6 px-2 text-md", // Medium size
lg: "px-3 py-1.5 px-3 text-lg", // Large size
xl: "px-4 py-2 px-4 text-xl", // Extra large size
};
// Merge default classes with custom classes using twMerge
const kbdClasses = twMerge(`inline-flex items-center justify-center rounded-md border border-opacity-20 px-2`, getColor({
variant: "solid",
color: "default",
}), sizeClasses[size], className // Merging user-supplied className
);
return (_jsx("kbd", Object.assign({ ref: ref, className: kbdClasses }, props, { children: children })));
});
Kbd.displayName = "Kbd";
export default Kbd;