/*! Strand UI | MIT License | dillingerstaffing.com */ import type { ComponentChildren, JSX } from "preact"; import { forwardRef } from "preact/compat"; import { cx } from "../../internal/index.js"; export interface DividerProps extends Omit, "label" | "ref"> { /** Separator direction. */ direction?: "horizontal" | "vertical"; /** `gradient` fades the line out at both ends. */ variant?: "line" | "gradient"; /** Content set into the middle of a horizontal line. */ label?: ComponentChildren; className?: string; } /** * Separator line, horizontal or vertical, optionally labelled. * * @example * */ export const Divider = forwardRef(({ direction = "horizontal", variant = "line", label, className = "", ...rest }, ref) => { const classes = cx("strand-divider", `strand-divider--${direction}`, variant === "gradient" && "strand-divider--gradient", label && "strand-divider--labeled", className); if (direction === "vertical") { return
["ref"]} role="separator" aria-orientation="vertical" className={classes} {...rest} />; } if (label) { return (
["ref"]} role="separator" aria-orientation="horizontal" className={classes} {...rest}> {label}
); } return
["ref"]} className={classes} {...rest} />; }); Divider.displayName = "Divider";