forked from deriv-com/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.tsx
70 lines (64 loc) · 1.52 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import React, { CSSProperties,ComponentProps, ElementType, ReactNode } from "react";
import clsx from "clsx";
import "./Text.scss";
type TextColors =
| "prominent"
| "less-prominent"
| "general"
| "primary"
| "success"
| "warning"
| "error"
| "red"
| "blue"
| "green"
| "white";
type TGenericSizes =
| "2xl"
| "2xs"
| "3xl"
| "3xs"
| "4xl"
| "5xl"
| "6xl"
| "lg"
| "md"
| "sm"
| "xl"
| "xs";
export interface TextProps extends ComponentProps<ElementType> {
align?: CSSProperties["textAlign"];
as?: ElementType;
children: ReactNode;
color?: TextColors;
fontStyle?: CSSProperties["fontStyle"];
lineHeight?: TGenericSizes;
size?: Exclude<TGenericSizes, "3xs" | "6xl" | "7xl">;
weight?: Exclude<CSSProperties["fontWeight"], "bolder" | "lighter">;
className?: string;
}
export const Text = ({
align = "left",
as = "span",
children,
color = "general",
fontStyle = "normal",
lineHeight,
size = "md",
weight = "normal",
className,
...rest
}: TextProps) => {
const textClassNames = clsx(
"deriv-text",
`derivs-text__size--${size}`,
`derivs-text__weight--${weight}`,
`derivs-text__align--${align}`,
`derivs-text__color--${color}`,
`derivs-text__line-height--${lineHeight}`,
`derivs-text__font-style--${fontStyle}`,
className,
);
const Tag = as;
return <Tag className={textClassNames} {...rest}>{children}</Tag>;
};