Skip to content

Commit 85339d0

Browse files
authored
Merge pull request #1482 from basedosdados/feat/bdpro-lp
feat: implement forwardRef for text components, update Next.js Link usage
2 parents 37ed5ec + 5849b6b commit 85339d0

5 files changed

Lines changed: 26 additions & 10 deletions

File tree

next/components/atoms/Text/BodyText.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { forwardRef } from "react";
12
import { Text } from "@chakra-ui/react";
23

34
const typographyStyles = {
@@ -15,11 +16,12 @@ const typographyStyles = {
1516
},
1617
};
1718

18-
export default function BodyText ({ children, typography = "medium", ...props }) {
19+
const BodyText = forwardRef(({ children, typography = "medium", ...props }, ref) => {
1920
const { fontSize, lineHeight } = typographyStyles[typography];
2021

2122
return (
2223
<Text
24+
ref={ref}
2325
fontFamily="Roboto"
2426
fontWeight="400"
2527
fontSize={fontSize}
@@ -30,4 +32,6 @@ export default function BodyText ({ children, typography = "medium", ...props })
3032
{children}
3133
</Text>
3234
);
33-
};
35+
});
36+
37+
export default BodyText;

next/components/atoms/Text/Display.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { forwardRef } from "react";
12
import { Text } from "@chakra-ui/react";
23

34
const typographyStyles = {
@@ -15,11 +16,12 @@ const typographyStyles = {
1516
},
1617
};
1718

18-
export default function Display ({ children, typography = "medium", ...props }) {
19+
const Display = forwardRef(({ children, typography = "medium", ...props }, ref) => {
1920
const { fontSize, lineHeight } = typographyStyles[typography];
2021

2122
return (
2223
<Text
24+
ref={ref}
2325
fontFamily="Roboto"
2426
fontWeight="500"
2527
fontSize={fontSize}
@@ -30,4 +32,6 @@ export default function Display ({ children, typography = "medium", ...props })
3032
{children}
3133
</Text>
3234
);
33-
};
35+
});
36+
37+
export default Display;

next/components/atoms/Text/LabelText.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { forwardRef } from "react";
12
import { Text } from "@chakra-ui/react";
23

34
const typographyStyles = {
@@ -23,11 +24,12 @@ const typographyStyles = {
2324
}
2425
};
2526

26-
export default function LabelText ({ children, typography = "medium", ...props }) {
27+
const LabelText = forwardRef(({ children, typography = "medium", ...props }, ref) => {
2728
const { fontSize, lineHeight } = typographyStyles[typography];
2829

2930
return (
3031
<Text
32+
ref={ref}
3133
fontFamily="Roboto"
3234
fontWeight="500"
3335
fontSize={fontSize}
@@ -38,4 +40,6 @@ export default function LabelText ({ children, typography = "medium", ...props }
3840
{children}
3941
</Text>
4042
);
41-
};
43+
});
44+
45+
export default LabelText;

next/components/atoms/Text/TitleText.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { forwardRef } from "react";
12
import { Text } from "@chakra-ui/react";
23

34
const typographyStyles = {
@@ -15,11 +16,12 @@ const typographyStyles = {
1516
}
1617
};
1718

18-
export default function TitleText ({ children, typography = "medium", ...props }) {
19+
const TitleText = forwardRef(({ children, typography = "medium", ...props }, ref) => {
1920
const { fontSize, lineHeight } = typographyStyles[typography];
2021

2122
return (
2223
<Text
24+
ref={ref}
2325
fontFamily="Roboto"
2426
fontWeight="500"
2527
fontSize={fontSize}
@@ -30,4 +32,6 @@ export default function TitleText ({ children, typography = "medium", ...props }
3032
{children}
3133
</Text>
3234
);
33-
};
35+
});
36+
37+
export default TitleText;

next/pages/prices.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,11 +204,11 @@ export const CardPrice = ({
204204
) : (
205205
<Link
206206
href={button.href || '#'}
207-
width="100%"
208-
style={{ textDecoration: 'none' }}
207+
passHref
209208
>
210209
<Box
211210
id={button?.id}
211+
as="a"
212212
display="flex"
213213
alignItems="center"
214214
justifyContent="center"

0 commit comments

Comments
 (0)