@hoddy-ui/core 1.0.88 → 1.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,54 +1,61 @@
1
- import React from "react";
2
- import { Text, StyleSheet } from "react-native";
3
- import { moderateScale, scale, verticalScale } from "react-native-size-matters";
1
+ import React, { forwardRef } from "react";
2
+ import { StyleSheet, Text } from "react-native";
3
+ import { moderateScale, verticalScale } from "react-native-size-matters";
4
4
  import { useColors } from "../hooks";
5
5
  import { TypographyProps } from "../types";
6
6
 
7
- const Typography: React.FC<TypographyProps> = ({
8
- children,
9
- color = "dark",
10
- style = {},
11
- textCase = null,
12
- variant = "body1",
13
- align = "left",
14
- gutterBottom = 0,
15
- numberOfLines,
16
- adjustsFontSizeToFit,
17
- fontWeight = 400,
18
- }) => {
19
- const colors: any = useColors();
20
- const fontSize = {
21
- h1: moderateScale(42),
22
- h2: moderateScale(37),
23
- h3: moderateScale(32),
24
- h4: moderateScale(27),
25
- h5: moderateScale(22),
26
- h6: moderateScale(17),
27
- body1: moderateScale(15),
28
- body2: moderateScale(12),
29
- caption: moderateScale(10),
30
- };
31
- const styles: any = StyleSheet.create({
32
- text: {
33
- fontSize: fontSize[variant],
34
- marginBottom: verticalScale(gutterBottom) || 0,
35
- color: colors[color]?.main || color,
36
- textTransform: textCase,
37
- alignItems: "center",
38
- textAlign: align,
39
- fontWeight: fontWeight.toString(),
7
+ const Typography: React.FC<TypographyProps> = forwardRef(
8
+ (
9
+ {
10
+ children,
11
+ color = "dark",
12
+ style = {},
13
+ textCase = null,
14
+ variant = "body1",
15
+ align = "left",
16
+ gutterBottom = 0,
17
+ numberOfLines,
18
+ adjustsFontSizeToFit,
19
+ fontWeight = 400,
20
+ ...props
40
21
  },
41
- });
42
- return (
43
- <Text
44
- numberOfLines={numberOfLines}
45
- adjustsFontSizeToFit={adjustsFontSizeToFit}
46
- style={{ ...styles.text, ...style }}
47
- >
48
- {children}
49
- </Text>
50
- );
51
- };
22
+ ref
23
+ ) => {
24
+ const colors: any = useColors();
25
+ const fontSize = {
26
+ h1: moderateScale(42),
27
+ h2: moderateScale(37),
28
+ h3: moderateScale(32),
29
+ h4: moderateScale(27),
30
+ h5: moderateScale(22),
31
+ h6: moderateScale(17),
32
+ body1: moderateScale(15),
33
+ body2: moderateScale(12),
34
+ caption: moderateScale(10),
35
+ };
36
+ const styles: any = StyleSheet.create({
37
+ text: {
38
+ fontSize: fontSize[variant],
39
+ marginBottom: verticalScale(gutterBottom) || 0,
40
+ color: colors[color]?.main || color,
41
+ textTransform: textCase,
42
+ alignItems: "center",
43
+ textAlign: align,
44
+ fontWeight: fontWeight.toString(),
45
+ },
46
+ });
47
+ return (
48
+ <Text
49
+ ref={ref as any}
50
+ numberOfLines={numberOfLines}
51
+ adjustsFontSizeToFit={adjustsFontSizeToFit}
52
+ style={{ ...styles.text, ...style }}
53
+ {...props}
54
+ >
55
+ {children}
56
+ </Text>
57
+ );
58
+ }
59
+ );
52
60
 
53
- <Typography color="#f90">col</Typography>;
54
61
  export default Typography;