import { CSSProperties, ReactNode } from "react"; import { DeepOmit } from "../types"; export type TextType = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "a" | "p" | "span"; export type TextAlignment = "left" |"center" | "end"; export interface TextProperties extends DeepOmit { children: ReactNode, type?: TextType, maxLine?: number, alignment?: TextAlignment, [key: string]: any; } export function Text(p: TextProperties) { const style: CSSProperties = {...p, ...{ display: "-webkit-box", WebkitBoxOrient: "vertical", WebkitLineClamp: p.maxLine, textAlign: p.alignment, overflow: "hidden" } as CSSProperties} switch (p.type) { case "h1": return

{p.children}

case "h2": return

{p.children}

case "h3": return

{p.children}

case "h4": return

{p.children}

case "h5": return
{p.children}
case "h6": return
{p.children}
case "a": return {p.children} case "p": return

{p.children}

case "span": return {p.children} default: return
{p.children}
} } export namespace Text { type P = DeepOmit; export function h1(p: P) { p = {...p, ...{type: "h1"}}; return } export function h2(p: P) { p = {...p, ...{type: "h2"}}; return } export function h3(p: P) { p = {...p, ...{type: "h3"}}; return } export function h4(p: P) { p = {...p, ...{type: "h4"}}; return } export function h5(p: P) { p = {...p, ...{type: "h5"}}; return } export function h6(p: P) { p = {...p, ...{type: "h6"}}; return } export function a(p: P) { p = {...p, ...{type: "a"}}; return } export function p(p: P) { p = {...p, ...{type: "p"}}; return } export function span(p: P) { p = {...p, ...{type: "span"}}; return } }