UNPKG

@ducor/react

Version:

admin template ui interface

39 lines (38 loc) 1.8 kB
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 { createElement, forwardRef } from "react"; import { twMerge } from "tailwind-merge"; import colors from "../../helpers/colors"; const Heading = forwardRef((_a, ref) => { var { as: Component = "h1", align = "start", className, color = "default", children } = _a, props = __rest(_a, ["as", "align", "className", "color", "children"]); const baseClasses = { start: "text-start", center: "text-center", end: "text-end", }; // Define styles for different heading elements const elementClass = { h1: "group text-3xl font-extrabold ", h2: "group text-2xl font-bold ", h3: "group text-xl font-semibold ", h4: "group text-lg font-medium ", h5: "group text-base font-normal ", h6: "group text-sm font-normal ", }; return createElement(Component, Object.assign(Object.assign({}, props), { ref, className: twMerge("flex", // Flex to align elements properly, you can customize if needed baseClasses[align], colors.textColor[color], // Default color if not specified elementClass[Component], // Add the specific heading styles className // Merge any additional classes ) }), children); }); Heading.displayName = "Heading"; // Set display name for better debugging export default Heading;