File tree 1 file changed +40
-37
lines changed
1 file changed +40
-37
lines changed Original file line number Diff line number Diff line change @@ -11,42 +11,45 @@ export type TextProps = React.HTMLAttributes<
11
11
12
12
export const Text = ( props : TextProps ) => {
13
13
const { variant } = props ;
14
- const variantMapping = {
15
- h1 : {
16
- fontSize : "2em" ,
17
- fontWeight : 700
18
- } ,
19
- h2 : {
20
- fontSize : "1.5em" ,
21
- fontWeight : 600
22
- } ,
23
- h3 : {
24
- fontSize : "1.17em" ,
25
- fontWeight : 600
26
- } ,
27
- h4 : {
28
- fontSize : "1em" ,
29
- fontWeight : 500
30
- } ,
31
- h5 : {
32
- fontSize : "0.83em" ,
33
- fontWeight : 500
34
- } ,
35
- h6 : {
36
- fontSize : "0.67em" ,
37
- fontWeight : 500
38
- } ,
39
- p : {
40
- fontSize : "1em" ,
41
- fontWeight : 400
42
- }
43
- } ;
44
- const TextElement = styled [ variant ?? "p" ] `
45
- font-family: "Poppins", sans-serif;
46
- font-weight: ${ ( props ) => variantMapping [ variant ?? "p" ] . fontWeight } ;
47
- font-size: ${ ( props ) => variantMapping [ variant ?? "p" ] . fontSize } ;
48
- color: ${ ( props ) => props . theme . text } ;
49
- ` ;
50
14
// @ts -ignore
51
- return < TextElement { ...props } /> ;
15
+ return < TextElement as = { variant } { ...props } /> ;
16
+ } ;
17
+
18
+
19
+ const variantMapping = {
20
+ h1 : {
21
+ fontSize : "2em" ,
22
+ fontWeight : 700
23
+ } ,
24
+ h2 : {
25
+ fontSize : "1.5em" ,
26
+ fontWeight : 600
27
+ } ,
28
+ h3 : {
29
+ fontSize : "1.17em" ,
30
+ fontWeight : 600
31
+ } ,
32
+ h4 : {
33
+ fontSize : "1em" ,
34
+ fontWeight : 500
35
+ } ,
36
+ h5 : {
37
+ fontSize : "0.83em" ,
38
+ fontWeight : 500
39
+ } ,
40
+ h6 : {
41
+ fontSize : "0.67em" ,
42
+ fontWeight : 500
43
+ } ,
44
+ p : {
45
+ fontSize : "1em" ,
46
+ fontWeight : 400
47
+ }
52
48
} ;
49
+
50
+ const TextElement = styled . p < TextProps > `
51
+ font-family: "Poppins", sans-serif;
52
+ font-weight: ${ ( props ) => variantMapping [ props . variant ?? "p" ] . fontWeight } ;
53
+ font-size: ${ ( props ) => variantMapping [ props . variant ?? "p" ] . fontSize } ;
54
+ color: ${ ( props ) => props . theme . text } ;
55
+ ` ;
You can’t perform that action at this time.
0 commit comments