You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dotcom-rendering/src/components/Card/components/CardLink.tsx
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -21,16 +21,19 @@ type Props = {
21
21
headlineText: string;
22
22
dataLinkName?: string;
23
23
isExternalLink: boolean;
24
+
trackCardClick?: ()=>void;
24
25
};
25
26
26
27
constInternalLink=({
27
28
linkTo,
28
29
headlineText,
29
30
dataLinkName,
31
+
trackCardClick,
30
32
}: {
31
33
linkTo: string;
32
34
headlineText: string;
33
35
dataLinkName?: string;
36
+
trackCardClick?: ()=>void;
34
37
})=>{
35
38
return(
36
39
// eslint-disable-next-line jsx-a11y/anchor-has-content -- we have an aria-label attribute describing the content
@@ -39,6 +42,7 @@ const InternalLink = ({
39
42
css={fauxLinkStyles}
40
43
data-link-name={dataLinkName}
41
44
aria-label={headlineText}
45
+
onClick={trackCardClick}
42
46
/>
43
47
);
44
48
};
@@ -47,10 +51,12 @@ const ExternalLink = ({
47
51
linkTo,
48
52
headlineText,
49
53
dataLinkName,
54
+
trackCardClick,
50
55
}: {
51
56
linkTo: string;
52
57
headlineText: string;
53
58
dataLinkName?: string;
59
+
trackCardClick?: ()=>void;
54
60
})=>{
55
61
return(
56
62
// eslint-disable-next-line jsx-a11y/anchor-has-content -- we have an aria-label attribute describing the content
@@ -61,6 +67,7 @@ const ExternalLink = ({
61
67
aria-label={headlineText+' (opens in new tab)'}
62
68
target="_blank"
63
69
rel="noreferrer"
70
+
onClick={trackCardClick}
64
71
/>
65
72
);
66
73
};
@@ -70,6 +77,7 @@ export const CardLink = ({
70
77
headlineText,
71
78
dataLinkName ='article',//this makes sense if the link is to an article, but should this say something like "external" if it's an external link? are there any other uses/alternatives?
0 commit comments