import classNames from "classnames"; import React, {Fragment} from "react"; import ErrProtecter from "../../utils/errProtect"; import "./JDbox.scss"; import JDIcon, {IIcons} from "../icons/Icons"; import {IDiv} from "../../types/interface"; import JDLabel from "../label/JDLabel"; import Tooltip from "../tooltip/Tooltip"; import {s4} from "../../utils/utils"; import {TextAlign, JDColor} from "../../types/enum"; import {textAlignClass, colorClass} from "../../utils/autoClasses"; export interface IJDboxProps extends IDiv { className?: string; mode?: "table" | "border" | "photoFrame" | "dashBorder"; thema?: JDColor | null; label?: JSX.Element | string; icon?: IIcons; photo?: string; topLabel?: string; iconHover?: boolean; standard?: boolean; size?: "small"; tooltip?: string; tooltipDirection?: "top" | "left" | "bottom" | "right"; clickable?: boolean; onClick?: (e: React.MouseEvent) => void; iconOnClick?: any; align?: "flex" | "flexVcenter"; textAlign?: TextAlign; float?: boolean; } const JDbox: React.FC = ({ children, className, label, tooltip, tooltipDirection, clickable, iconOnClick, icon, iconHover, mode, float, topLabel, standard, photo, size, align, textAlign, onClick, thema, ...props }) => { const classes = classNames("JDbox", className, { "JDbox--normal": mode === undefined, "JDbox--table": mode === "table", "JDbox--dashBorder": mode === "dashBorder", "JDbox--photoFrame": mode === "photoFrame", "JDbox--border": mode === "border", ...textAlignClass("JDbox", textAlign), "JDbox--flexVcenter": align === "flexVcenter", "JDbox--center": textAlign === "center", "JDbox--clickable": clickable, ...colorClass("JDbox", thema), "JDbox--standard": standard, "JDbox--withIcon": typeof icon === "string", "JDbox--small": size === "small", "JDbox--float": float }); const newId = s4(); return ( {topLabel && }
{label &&
{label}
}
{photo && } {children} {icon && ( )} {tooltip && ( {tooltip} )}
); }; export default ErrProtecter(JDbox);