@thecb/components 7.1.3-beta.1 → 7.1.3-beta.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "7.1.3-beta.1",
3
+ "version": "7.1.3-beta.3",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -15,5 +15,4 @@ export interface ExternalLinkProps {
15
15
  }
16
16
 
17
17
  export const ExternalLink: React.FC<Expand<ExternalLinkProps> &
18
- React.HTMLAttributes<HTMLElement> &
19
- React.Ref<HTMLLinkElement>>;
18
+ React.HTMLAttributes<HTMLElement> & { ref?: React.Ref<HTMLLinkElement> }>;
@@ -1,4 +1,4 @@
1
- import React, { useContext } from "react";
1
+ import React, { useContext, forwardRef } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import { fallbackValues } from "./Link.theme";
4
4
  import { createThemeValues } from "../../../util/themeUtils";
@@ -6,51 +6,53 @@ import { StyledExternalLink } from "./ExternalLink.styled";
6
6
  import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
7
7
  import { safeChildren } from "../../../util/general";
8
8
 
9
- const ExternalLink = (
10
- {
11
- href = "",
12
- newTab = false,
13
- size = "1rem",
14
- lineHeight = "1.5rem",
15
- weight = FONT_WEIGHT_REGULAR,
16
- extraStyles = ``,
17
- variant = "primary",
18
- tabIndex = "0",
19
- dataQa,
20
- ariaLabel,
21
- children
22
- },
23
- ref
24
- ) => {
25
- const themeContext = useContext(ThemeContext);
26
- const themeValues = createThemeValues(
27
- themeContext,
28
- fallbackValues,
29
- "Link",
30
- variant
31
- );
9
+ const ExternalLink = forwardRef(
10
+ (
11
+ {
12
+ href = "",
13
+ newTab = false,
14
+ size = "1rem",
15
+ lineHeight = "1.5rem",
16
+ weight = FONT_WEIGHT_REGULAR,
17
+ extraStyles = ``,
18
+ variant = "primary",
19
+ tabIndex = "0",
20
+ dataQa,
21
+ ariaLabel,
22
+ children
23
+ },
24
+ ref
25
+ ) => {
26
+ const themeContext = useContext(ThemeContext);
27
+ const themeValues = createThemeValues(
28
+ themeContext,
29
+ fallbackValues,
30
+ "Link",
31
+ variant
32
+ );
32
33
 
33
- return (
34
- <StyledExternalLink
35
- href={href}
36
- target={newTab ? "_blank" : ""}
37
- color={themeValues.externalLinkColor}
38
- size={size}
39
- lineheight={lineHeight}
40
- weight={weight}
41
- hovercolor={themeValues.hoverColor}
42
- activeColor={themeValues.activeColor}
43
- fontFamily={themeValues.fontFamily}
44
- tabIndex={tabIndex}
45
- extrastyles={extraStyles}
46
- rel={newTab ? "noopener" : ""}
47
- data-qa={dataQa}
48
- aria-label={ariaLabel}
49
- ref={ref}
50
- >
51
- {safeChildren(children, <span />)}
52
- </StyledExternalLink>
53
- );
54
- };
34
+ return (
35
+ <StyledExternalLink
36
+ href={href}
37
+ target={newTab ? "_blank" : ""}
38
+ color={themeValues.externalLinkColor}
39
+ size={size}
40
+ lineheight={lineHeight}
41
+ weight={weight}
42
+ hovercolor={themeValues.hoverColor}
43
+ activeColor={themeValues.activeColor}
44
+ fontFamily={themeValues.fontFamily}
45
+ tabIndex={tabIndex}
46
+ extrastyles={extraStyles}
47
+ rel={newTab ? "noopener" : ""}
48
+ data-qa={dataQa}
49
+ aria-label={ariaLabel}
50
+ ref={ref}
51
+ >
52
+ {safeChildren(children, <span />)}
53
+ </StyledExternalLink>
54
+ );
55
+ }
56
+ );
55
57
 
56
58
  export default ExternalLink;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { forwardRef } from "react";
2
2
  import styled from "styled-components";
3
3
  import { ROYAL_BLUE } from "../../../constants/colors";
4
4
  /*
@@ -8,9 +8,9 @@ import { ROYAL_BLUE } from "../../../constants/colors";
8
8
 
9
9
  /* eslint-disable no-unused-vars */
10
10
  export const StyledExternalLink = styled(
11
- ({ hoverColor, activeColor, extrastyles, ...props }, ref) => (
11
+ forwardRef(({ hoverColor, activeColor, extrastyles, ...props }, ref) => (
12
12
  <a {...props} ref={ref} />
13
- )
13
+ ))
14
14
  )`
15
15
  display: flex;
16
16
  font-size: ${({ size }) => size};
@@ -16,5 +16,4 @@ export interface InternalLinkProps {
16
16
  }
17
17
 
18
18
  export const InternalLink: React.FC<Expand<InternalLinkProps> &
19
- React.HTMLAttributes<HTMLElement> &
20
- React.Ref<HTMLLinkElement>>;
19
+ React.HTMLAttributes<HTMLElement> & { ref?: React.Ref<HTMLLinkElement> }>;
@@ -1,55 +1,57 @@
1
- import React, { useContext } from "react";
1
+ import React, { useContext, forwardRef } from "react";
2
2
  import { ThemeContext } from "styled-components";
3
3
  import { fallbackValues } from "./Link.theme";
4
4
  import { createThemeValues } from "../../../util/themeUtils";
5
5
  import { StyledInternalLink } from "./InternalLink.styled";
6
6
  import { safeChildren } from "../../../util/general";
7
7
 
8
- const InternalLink = (
9
- {
10
- to = "",
11
- color,
12
- children,
13
- active,
14
- fontSize,
15
- lineheight,
16
- fontWeight,
17
- variant = "primary",
18
- margin,
19
- tabIndex = "0",
20
- dataQa,
21
- extraStyles = ``
22
- },
23
- ref
24
- ) => {
25
- const themeContext = useContext(ThemeContext);
26
- const themeValues = createThemeValues(
27
- themeContext,
28
- fallbackValues,
29
- "Link",
30
- variant
31
- );
8
+ const InternalLink = forwardRef(
9
+ (
10
+ {
11
+ to = "",
12
+ color,
13
+ children,
14
+ active,
15
+ fontSize,
16
+ lineheight,
17
+ fontWeight,
18
+ variant = "primary",
19
+ margin,
20
+ tabIndex = "0",
21
+ dataQa,
22
+ extraStyles = ``
23
+ },
24
+ ref
25
+ ) => {
26
+ const themeContext = useContext(ThemeContext);
27
+ const themeValues = createThemeValues(
28
+ themeContext,
29
+ fallbackValues,
30
+ "Link",
31
+ variant
32
+ );
32
33
 
33
- return (
34
- <StyledInternalLink
35
- to={to}
36
- color={color}
37
- lineheight={lineheight}
38
- active={active}
39
- fontWeight={fontWeight}
40
- fontSize={fontSize}
41
- fontFamily={themeValues.fontFamily}
42
- margin={margin}
43
- hoverColor={themeValues.hoverColor}
44
- activeColor={themeValues.activeColor}
45
- tabIndex={tabIndex}
46
- extrastyles={extraStyles}
47
- data-qa={dataQa}
48
- ref={ref}
49
- >
50
- {safeChildren(children, <span />)}
51
- </StyledInternalLink>
52
- );
53
- };
34
+ return (
35
+ <StyledInternalLink
36
+ to={to}
37
+ color={color}
38
+ lineheight={lineheight}
39
+ active={active}
40
+ fontWeight={fontWeight}
41
+ fontSize={fontSize}
42
+ fontFamily={themeValues.fontFamily}
43
+ margin={margin}
44
+ hoverColor={themeValues.hoverColor}
45
+ activeColor={themeValues.activeColor}
46
+ tabIndex={tabIndex}
47
+ extrastyles={extraStyles}
48
+ data-qa={dataQa}
49
+ ref={ref}
50
+ >
51
+ {safeChildren(children, <span />)}
52
+ </StyledInternalLink>
53
+ );
54
+ }
55
+ );
54
56
 
55
57
  export default InternalLink;
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import React, { forwardRef } from "react";
2
2
  import styled from "styled-components";
3
3
  import { Link } from "react-router-dom";
4
4
  import { ROYAL_BLUE } from "../../../constants/colors";
@@ -9,8 +9,11 @@ import { ROYAL_BLUE } from "../../../constants/colors";
9
9
 
10
10
  /* eslint-disable no-unused-vars */
11
11
  export const StyledInternalLink = styled(
12
- ({ hoverColor, activeColor, active, color, extrastyles, ...props }, ref) => (
13
- <Link {...props} ref={ref} />
12
+ forwardRef(
13
+ (
14
+ { hoverColor, activeColor, active, color, extrastyles, ...props },
15
+ ref
16
+ ) => <Link {...props} ref={ref} />
14
17
  )
15
18
  )`
16
19
  display: flex;