@ducor/react
Version:
admin template ui interface
37 lines (36 loc) • 2.02 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 React from "react";
import { twMerge } from "tailwind-merge";
import colors from "../helpers/colors";
const Divider = React.forwardRef((_a, ref) => {
var { className, direction = "horizontal", thickness = "border", margin, dashed = false, color = "default", height, width } = _a, props = __rest(_a, ["className", "direction", "thickness", "margin", "dashed", "color", "height", "width"]);
const borderColorClass = colors.borders[color] || colors.borders.default;
const isHorizontal = direction === "horizontal";
// Width & Height classes based on direction
const sizeClasses = twMerge(isHorizontal
? `${height ? `h-${height}` : ""} ${width ? `w-${width}` : "w-full"}`
: `${height ? `h-${height}` : "h-full"} ${width ? `w-${width}` : ""}`);
// Border side and thickness
const borderClasses = isHorizontal
? `border-t border-${thickness}`
: `border-l border-${thickness}`;
const dashClass = dashed ? "border-dashed" : "border-solid";
const marginClass = isHorizontal
? `my-${margin ? margin : "4"}`
: `mx-${margin ? margin : "4"}`;
const baseClasses = twMerge("border-0", borderClasses, dashClass, borderColorClass, sizeClasses, marginClass, isHorizontal ? "block" : "inline-block", className);
return (_jsx("hr", Object.assign({ ref: ref, className: baseClasses, role: 'separator', "aria-orientation": direction }, props)));
});
Divider.displayName = "Divider";
export default Divider;