UNPKG

@brizy/ui

Version:
18 lines (17 loc) 1.17 kB
import React, { useCallback } from "react"; import { classNames } from "../classNamesFn"; import AntTypographyText from "antd/lib/typography/Text"; import { getFontSize, getTypographyTextColor, getItalic } from "./utils"; export const TypographyText = props => { const { code, strong, color, hoverColor, mark, underline, size = "middle", children, ellipsis, italic, onClick, } = props; const className = classNames(getFontSize(size), getItalic(italic))("typography__text", { "typography__text__color-inherit": color === "inherit", "typography__text__hoverColor-inherit": hoverColor === "inherit", typography__text__hoverColor: color === "inherit" && hoverColor, typography__hoverColor: hoverColor, }); const _onClick = useCallback(() => { onClick === null || onClick === void 0 ? void 0 : onClick(); }, [onClick]); return (React.createElement(AntTypographyText, { className: className, code: code, strong: strong, mark: mark, underline: underline, ellipsis: ellipsis, style: getTypographyTextColor(color, hoverColor) }, onClick ? React.createElement("span", { onClick: _onClick }, children) : children)); };