@thecb/components 6.4.2 → 7.0.0-beta.10

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.
Files changed (58) hide show
  1. package/README.md +43 -0
  2. package/dist/index.cjs.js +12073 -11823
  3. package/dist/index.cjs.js.map +1 -1
  4. package/dist/index.d.ts +308 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.esm.js +4178 -3931
  7. package/dist/index.esm.js.map +1 -1
  8. package/package.json +6 -2
  9. package/src/components/atoms/button-with-action/index.d.ts +17 -0
  10. package/src/components/atoms/button-with-link/index.d.ts +14 -0
  11. package/src/components/atoms/card/Card.js +87 -0
  12. package/src/components/atoms/card/Card.theme.js +14 -0
  13. package/src/components/atoms/card/CardHeader.js +28 -0
  14. package/src/components/atoms/card/CardImage.styled.js +9 -0
  15. package/src/components/atoms/card/CardText.js +46 -0
  16. package/src/components/atoms/card/CardText.theme.js +12 -0
  17. package/src/components/atoms/card/index.d.ts +32 -0
  18. package/src/components/atoms/card/index.js +3 -0
  19. package/src/components/atoms/{welcome-card/Card.theme.js → card-registry/CardRegistry.theme.js} +0 -0
  20. package/src/components/atoms/{welcome-card/Card.js → card-registry/CardRegistryCard.js} +7 -3
  21. package/src/components/atoms/{welcome-card → card-registry}/index.js +4 -4
  22. package/src/components/atoms/display-card/DisplayCard.js +1 -1
  23. package/src/components/atoms/index.d.ts +11 -0
  24. package/src/components/atoms/index.js +3 -1
  25. package/src/components/atoms/layouts/Box.d.ts +32 -0
  26. package/src/components/atoms/layouts/Center.d.ts +11 -0
  27. package/src/components/atoms/layouts/Cluster.d.ts +19 -0
  28. package/src/components/atoms/layouts/Cover.d.ts +14 -0
  29. package/src/components/atoms/layouts/Stack.d.ts +27 -0
  30. package/src/components/atoms/layouts/Switcher.d.ts +17 -0
  31. package/src/components/atoms/layouts/index.d.ts +6 -0
  32. package/src/components/atoms/link/ExternalLink.d.ts +18 -0
  33. package/src/components/atoms/link/InternalLink.d.ts +19 -0
  34. package/src/components/atoms/link/index.d.ts +2 -0
  35. package/src/components/atoms/nav-footer/index.d.ts +17 -0
  36. package/src/components/atoms/nav-header/index.d.ts +16 -0
  37. package/src/components/atoms/nav-tabs/NavTab.js +47 -0
  38. package/src/components/atoms/nav-tabs/NavTab.theme.js +11 -0
  39. package/src/components/atoms/nav-tabs/NavTabs.js +24 -0
  40. package/src/components/atoms/nav-tabs/index.d.ts +10 -0
  41. package/src/components/atoms/nav-tabs/index.js +3 -0
  42. package/src/components/atoms/paragraph/index.d.ts +15 -0
  43. package/src/components/atoms/text/index.d.ts +16 -0
  44. package/src/components/atoms/title/index.d.ts +17 -0
  45. package/src/components/index.d.ts +3 -0
  46. package/src/components/molecules/footer-with-subfooter/FooterWithSubfooter.js +42 -0
  47. package/src/components/molecules/footer-with-subfooter/FooterWithSubfooter.theme.js +8 -0
  48. package/src/components/molecules/footer-with-subfooter/index.d.ts +14 -0
  49. package/src/components/molecules/footer-with-subfooter/index.js +3 -0
  50. package/src/components/molecules/index.d.ts +1 -0
  51. package/src/components/molecules/index.js +1 -0
  52. package/src/components/molecules/modal/Modal.js +9 -3
  53. package/src/components/templates/default-page-template/DefaultPageTemplate.js +7 -2
  54. package/src/components/templates/default-page-template/index.d.ts +16 -0
  55. package/src/components/templates/index.d.ts +1 -0
  56. package/src/index.d.ts +1 -0
  57. package/src/util/expand.d.ts +3 -0
  58. package/src/.DS_Store +0 -0
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "6.4.2",
3
+ "version": "7.0.0-beta.10",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
+ "typings": "dist/index.d.ts",
6
7
  "module": "dist/index.esm.js",
7
8
  "source": "src/index.js",
8
9
  "scripts": {
@@ -57,12 +58,15 @@
57
58
  "rollup": "^1.21.4",
58
59
  "rollup-plugin-babel": "^4.3.3",
59
60
  "rollup-plugin-commonjs": "^10.0.0",
61
+ "rollup-plugin-dts": "^4.2.2",
60
62
  "rollup-plugin-json": "^4.0.0",
61
63
  "rollup-plugin-node-resolve": "^5.1.0",
64
+ "rollup-plugin-ts": "^3.0.2",
62
65
  "rollup-plugin-visualizer": "^4.0.4",
63
66
  "storybook": "^6.4.22",
64
67
  "styled-components": "^5.3.5",
65
- "styled-theming": "^2.2.0"
68
+ "styled-theming": "^2.2.0",
69
+ "typescript": "^4.8.2"
66
70
  },
67
71
  "peerDependencies": {
68
72
  "react": "^16.13.1",
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface ButtonWithActionProps {
5
+ action?: React.SyntheticEvent;
6
+ variant?: string;
7
+ text?: string;
8
+ textWrap?: boolean;
9
+ isLoading?: boolean;
10
+ textExtraStyles?: string;
11
+ contentOverride?: boolean;
12
+ extraStyles?: string;
13
+ tabIndex?: string;
14
+ }
15
+
16
+ export const ButtonWithAction: React.FC<Expand<ButtonWithActionProps> &
17
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+ import { ButtonWithActionProps } from "../button-with-action";
4
+
5
+ export interface ButtonWithLinkProps extends ButtonWithActionProps {
6
+ linkExtraStyles?: string;
7
+ url: string;
8
+ disabled?: boolean;
9
+ fileLink?: boolean;
10
+ newTab?: boolean;
11
+ }
12
+
13
+ export const ButtonWithLink: React.FC<Expand<ButtonWithLinkProps> &
14
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,87 @@
1
+ import React, { Fragment } from "react";
2
+
3
+ import { themeComponent } from "../../../util/themeUtils";
4
+ import withWindowSize from "../../withWindowSize";
5
+
6
+ import { fallbackValues } from "./Card.theme";
7
+
8
+ import BoxWithShadow from "../box-with-shadow";
9
+ import Cover from "../layouts/Cover";
10
+ import Stack from "../layouts/Stack";
11
+
12
+ import CardImage from "./CardImage.styled";
13
+ import CardText from "./CardText";
14
+ import CardHeader from "./CardHeader";
15
+
16
+ const Card = ({
17
+ borderRadius = "4px",
18
+ extraStyles,
19
+ headerAs = "h2",
20
+ headerText,
21
+ headerVariant = "small",
22
+ imgSrc,
23
+ imgHeight = "150px",
24
+ imgObjectFit = "none",
25
+ imgAltText,
26
+ padding = "24px",
27
+ text,
28
+ titleText,
29
+ titleVariant = "small",
30
+ themeValues,
31
+ width = "276px",
32
+ children
33
+ }) => {
34
+ const numberOfChildren =
35
+ (Array.isArray(children) ? children.length : 1) +
36
+ (text ? 1 : 0) +
37
+ (imgSrc ? 1 : 0) +
38
+ (headerText ? 1 : 0);
39
+
40
+ return (
41
+ <BoxWithShadow
42
+ variant="baseStandard"
43
+ background={themeValues.backgroundColor}
44
+ borderRadius={borderRadius}
45
+ padding="0"
46
+ margin="0"
47
+ minWidth={width}
48
+ extraStyles={extraStyles}
49
+ >
50
+ <Cover singleChild fillCenter>
51
+ <Stack fullHeight childGap="0" bottomItem={numberOfChildren}>
52
+ {headerText && (
53
+ <CardHeader
54
+ headerText={headerText}
55
+ headerColor={themeValues.headerColor}
56
+ headerVariant={headerVariant}
57
+ backgroundColor={themeValues.headerBackgroundColor}
58
+ borderRadius={borderRadius}
59
+ padding={padding}
60
+ as={headerAs}
61
+ ></CardHeader>
62
+ )}
63
+ {imgSrc && (
64
+ <CardImage
65
+ height={imgHeight}
66
+ objectFit={imgObjectFit}
67
+ backgroundColor={themeValues.imageBackgroundColor}
68
+ src={imgSrc}
69
+ alt={imgAltText}
70
+ />
71
+ )}
72
+ {text && (
73
+ <CardText
74
+ padding={padding}
75
+ titleText={titleText}
76
+ text={text}
77
+ titleVariant={titleVariant}
78
+ />
79
+ )}
80
+ {children}
81
+ </Stack>
82
+ </Cover>
83
+ </BoxWithShadow>
84
+ );
85
+ };
86
+
87
+ export default themeComponent(withWindowSize(Card), "Card", fallbackValues);
@@ -0,0 +1,14 @@
1
+ import { INFO_BLUE, STORM_GREY, WHITE } from "../../../constants/colors";
2
+
3
+ const backgroundColor = WHITE;
4
+ const imageBackgroundColor = INFO_BLUE;
5
+
6
+ const headerBackgroundColor = STORM_GREY;
7
+ const headerColor = WHITE;
8
+
9
+ export const fallbackValues = {
10
+ backgroundColor,
11
+ imageBackgroundColor,
12
+ headerBackgroundColor,
13
+ headerColor
14
+ };
@@ -0,0 +1,28 @@
1
+ import React from "react";
2
+
3
+ import Box from "../layouts/Box";
4
+ import Title from "../title";
5
+
6
+ export const CardHeader = ({
7
+ backgroundColor,
8
+ borderRadius,
9
+ as,
10
+ headerText,
11
+ headerColor,
12
+ headerVariant,
13
+ padding
14
+ }) => {
15
+ return (
16
+ <Box
17
+ padding={padding}
18
+ background={backgroundColor}
19
+ borderRadius={`${borderRadius} ${borderRadius} 0 0`}
20
+ >
21
+ <Title as={as} variant={headerVariant} color={headerColor}>
22
+ {headerText}
23
+ </Title>
24
+ </Box>
25
+ );
26
+ };
27
+
28
+ export default CardHeader;
@@ -0,0 +1,9 @@
1
+ import styled from "styled-components";
2
+
3
+ const CardImage = styled.img`
4
+ background: ${({ backgroundColor }) => backgroundColor};
5
+ object-fit: ${({ objectFit }) => objectFit};
6
+ height: ${({ height }) => height};
7
+ `;
8
+
9
+ export default CardImage;
@@ -0,0 +1,46 @@
1
+ import React from "react";
2
+
3
+ import { themeComponent } from "../../../util/themeUtils";
4
+ import withWindowSize from "../../withWindowSize";
5
+
6
+ import { fallbackValues } from "./CardText.theme";
7
+
8
+ import Box from "../layouts/Box";
9
+ import Cover from "../layouts/Cover";
10
+ import Paragraph from "../paragraph";
11
+ import Stack from "../layouts/Stack";
12
+ import Title from "../title";
13
+
14
+ export const CardText = ({
15
+ padding,
16
+ text,
17
+ titleText,
18
+ titleVariant = "small",
19
+ themeValues
20
+ }) => {
21
+ return (
22
+ <Box padding={padding}>
23
+ <Cover>
24
+ <Stack>
25
+ {titleText && (
26
+ <Title
27
+ as="p"
28
+ variant={titleVariant}
29
+ color={themeValues.titleColor}
30
+ weight={themeValues.titleWeight}
31
+ >
32
+ {titleText}
33
+ </Title>
34
+ )}
35
+ <Paragraph color={themeValues.textColor}>{text}</Paragraph>
36
+ </Stack>
37
+ </Cover>
38
+ </Box>
39
+ );
40
+ };
41
+
42
+ export default themeComponent(
43
+ withWindowSize(CardText),
44
+ "CardText",
45
+ fallbackValues
46
+ );
@@ -0,0 +1,12 @@
1
+ import { BRIGHT_GREY } from "../../../constants/colors";
2
+
3
+ import { FONT_WEIGHT_BOLD } from "../../../constants/style_constants";
4
+ const titleColor = BRIGHT_GREY;
5
+ const titleWeight = FONT_WEIGHT_BOLD;
6
+ const textColor = BRIGHT_GREY;
7
+
8
+ export const fallbackValues = {
9
+ titleColor,
10
+ titleWeight,
11
+ textColor
12
+ };
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface CardProps {
5
+ text?: string;
6
+ titleText?: string;
7
+ titleVariant?: string;
8
+ extraStyles?: string;
9
+ imgSrc?: string;
10
+ imgHeight?: string;
11
+ imgAltText?: string;
12
+ imgObjectFit?:
13
+ | "contain"
14
+ | "cover"
15
+ | "fill"
16
+ | "none"
17
+ | "scale-down"
18
+ | "inherit"
19
+ | "initial"
20
+ | "revert"
21
+ | "revert-layer"
22
+ | "unset";
23
+ headerAs?: string;
24
+ headerText?: string;
25
+ headerVariant?: string;
26
+ borderRadius?: string;
27
+ width?: string;
28
+ padding?: string;
29
+ }
30
+
31
+ export const Card: React.FC<Expand<CardProps> &
32
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,3 @@
1
+ import Card from "./Card";
2
+
3
+ export default Card;
@@ -5,7 +5,7 @@ import { Box, Stack, Cover } from "../layouts";
5
5
  import Text from "../text";
6
6
  import Paragraph from "../paragraph";
7
7
  import ButtonWithAction from "../button-with-action";
8
- import { fallbackValues } from "./Card.theme";
8
+ import { fallbackValues } from "./CardRegistry.theme";
9
9
  import { themeComponent } from "../../../util/themeUtils";
10
10
  import {
11
11
  AccountsAddIcon,
@@ -26,7 +26,7 @@ const CardVariantSwitcher = ({ variant, children }) => {
26
26
  );
27
27
  };
28
28
 
29
- const Card = ({
29
+ const CardRegistryCard = ({
30
30
  themeValues,
31
31
  icon,
32
32
  heading,
@@ -123,4 +123,8 @@ const Card = ({
123
123
  );
124
124
  };
125
125
 
126
- export default themeComponent(withWindowSize(Card), "Card", fallbackValues);
126
+ export default themeComponent(
127
+ withWindowSize(CardRegistryCard),
128
+ "CardRegistryCard",
129
+ fallbackValues
130
+ );
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
- import Card from "./Card";
2
+ import CardRegistryCard from "./CardRegistryCard";
3
3
 
4
4
  export const cardRegistry = {
5
5
  accounts: props => (
6
- <Card
6
+ <CardRegistryCard
7
7
  icon="accounts"
8
8
  heading="Find Your Account"
9
9
  buttonText="Find Account"
@@ -13,7 +13,7 @@ export const cardRegistry = {
13
13
  />
14
14
  ),
15
15
  properties: props => (
16
- <Card
16
+ <CardRegistryCard
17
17
  icon="properties"
18
18
  heading="Find Your Property"
19
19
  buttonText="Find Property"
@@ -23,7 +23,7 @@ export const cardRegistry = {
23
23
  />
24
24
  ),
25
25
  payment: props => (
26
- <Card
26
+ <CardRegistryCard
27
27
  icon="payment"
28
28
  heading="Manage Your Wallet"
29
29
  buttonText="Go to Wallet"
@@ -7,7 +7,7 @@ import Cluster from "../layouts/Cluster";
7
7
  import ButtonWithAction from "../button-with-action";
8
8
  import ButtonWithLink from "../button-with-link";
9
9
  import { WHITE, CHARADE_GREY, STORM_GREY } from "../../../constants/colors";
10
- import { Popover } from "../../molecules";
10
+ import Popover from "../../molecules/popover";
11
11
 
12
12
  const DisplayCard = ({
13
13
  title,
@@ -0,0 +1,11 @@
1
+ export * from "./card";
2
+ export * from "./button-with-action";
3
+ export * from "./button-with-link";
4
+ export * from "./layouts";
5
+ export * from "./link";
6
+ export * from "./nav-footer";
7
+ export * from "./nav-header";
8
+ export * from "./nav-tabs";
9
+ export * from "./paragraph";
10
+ export * from "./text";
11
+ export * from "./title";
@@ -5,7 +5,7 @@ export { default as BoxWithShadow } from "./box-with-shadow";
5
5
  export { default as Breadcrumb } from "./breadcrumb";
6
6
  export { default as ButtonWithAction } from "./button-with-action";
7
7
  export { default as ButtonWithLink } from "./button-with-link";
8
- export { default as cardRegistry } from "./welcome-card";
8
+ export { default as cardRegistry } from "./card-registry";
9
9
  export { default as Checkbox } from "./checkbox";
10
10
  export { default as CheckboxList } from "./checkbox-list";
11
11
  export { default as CountryDropdown } from "./country-dropdown";
@@ -41,4 +41,6 @@ export { default as Text } from "./text";
41
41
  export { default as Title } from "./title";
42
42
  export { default as ToggleSwitch } from "./toggle-switch";
43
43
  export { default as TypeaheadInput } from "./typeahead-input";
44
+ export { default as Card } from "./card";
45
+ export { default as NavTabs } from "./nav-tabs";
44
46
  export { default as LoadingLine } from "./loading-line";
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface BoxProps {
5
+ padding?: string;
6
+ borderSize?: string;
7
+ borderColor?: string;
8
+ borderRadius?: string;
9
+ boxShadow?: string;
10
+ background?: string;
11
+ color?: string;
12
+ minHeight?: string;
13
+ width?: string;
14
+ minWidth?: string;
15
+ maxWidth?: string;
16
+ borderWidthOverride?: string;
17
+ border?: string;
18
+ textAlign?: string;
19
+ hoverStyles?: string;
20
+ activeStyles?: string;
21
+ disabledStyles?: string;
22
+ variant?: string;
23
+ as?: string;
24
+ theme?: string;
25
+ hiddenStyles?: string;
26
+ extraStyles?: string;
27
+ srOnly?: boolean;
28
+ dataQa?: string;
29
+ }
30
+
31
+ export const Box: React.FC<Expand<BoxProps> &
32
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface CenterProps {
5
+ maxWidth?: string;
6
+ gutters?: string;
7
+ intrinsic?: boolean;
8
+ }
9
+
10
+ export const Center: React.FC<Expand<CenterProps> &
11
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface ClusterProps {
5
+ childGap?: string;
6
+ extraStyles?: string;
7
+ align?: string;
8
+ justify?: string;
9
+ minHeight?: string;
10
+ minWidth?: string;
11
+ nowrap?: boolean;
12
+ overflow?: boolean;
13
+ justifySelf?: string;
14
+ alignSelf?: string;
15
+ flexGrow?: string;
16
+ }
17
+
18
+ export const Cluster: React.FC<Expand<ClusterProps> &
19
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface CoverProps {
5
+ minHeight?: string;
6
+ childGap?: string;
7
+ padding?: string;
8
+ fillCenter?: boolean;
9
+ singleChild?: boolean;
10
+ centerOverride?: boolean;
11
+ }
12
+
13
+ export const Cover: React.FC<Expand<CoverProps> &
14
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface StackProps {
5
+ childGap?: string;
6
+ bottomItem?: number;
7
+ fullHeight?: boolean;
8
+ direction?:
9
+ | "row"
10
+ | "row-reverse"
11
+ | "column"
12
+ | "column-reverse"
13
+ | "initial"
14
+ | "inherit";
15
+ justify?:
16
+ | "flex-start"
17
+ | "flex-end"
18
+ | "center"
19
+ | "space-between"
20
+ | "space-around"
21
+ | "space-evenly"
22
+ | "initial"
23
+ | "inherit";
24
+ }
25
+
26
+ export const Stack: React.FC<Expand<StackProps> &
27
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface SwitcherProps {
5
+ breakpoint?: string;
6
+ childGap?: string;
7
+ largeChild?: string;
8
+ largeChildSize?: string;
9
+ maxChildren?: string;
10
+ maxChildrenOnly?: boolean;
11
+ padding?: string;
12
+ extraStyles?: string;
13
+ constrainMobile?: boolean;
14
+ }
15
+
16
+ export const Switcher: React.FC<Expand<SwitcherProps> &
17
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,6 @@
1
+ export * from "./Box";
2
+ export * from "./Center";
3
+ export * from "./Cluster";
4
+ export * from "./Cover";
5
+ export * from "./Stack";
6
+ export * from "./Switcher";
@@ -0,0 +1,18 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface ExternalLinkProps {
5
+ href: string;
6
+ newTab?: boolean;
7
+ size?: string;
8
+ lineHeight?: string;
9
+ weight?: string;
10
+ extraStyles?: string;
11
+ variant?: string;
12
+ tabIndex?: string;
13
+ dataQa?: string;
14
+ ariaLabel?: string;
15
+ }
16
+
17
+ export const ExternalLink: React.FC<Expand<ExternalLinkProps> &
18
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface InternalLinkProps {
5
+ to: string;
6
+ color?: string;
7
+ active?: boolean;
8
+ fontSize?: string;
9
+ lineheight?: string;
10
+ fontWeight?: string;
11
+ variant?: string;
12
+ margin?: string;
13
+ tabIndex?: string;
14
+ dataQa?: string;
15
+ extraStyles?: string;
16
+ }
17
+
18
+ export const InternalLink: React.FC<Expand<InternalLinkProps> &
19
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,2 @@
1
+ export * from "./ExternalLink";
2
+ export * from "./InternalLink";
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface NavFooterProps {
5
+ leftContent?: JSX.Element;
6
+ rightContent?: JSX.Element;
7
+ footerMinHeight?: string;
8
+ backgroundColor?: string;
9
+ largeSide?: "left" | "right";
10
+ largeSideSize?: string;
11
+ footerPadding?: string;
12
+ isMobile?: boolean;
13
+ footerWidth?: string;
14
+ }
15
+
16
+ export const NavFooter: React.FC<Expand<NavFooterProps> &
17
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import Expand from "../../../util/expand";
3
+
4
+ export interface NavHeaderProps {
5
+ headerHeight?: string;
6
+ headerWith?: string;
7
+ backgroundColor?: string;
8
+ leftContent?: JSX.Element;
9
+ rightContent?: JSX.Element;
10
+ margin?: string;
11
+ extraStyles?: string;
12
+ isMobile?: boolean;
13
+ }
14
+
15
+ export const NavHeader: React.FC<Expand<NavHeaderProps> &
16
+ React.HTMLAttributes<HTMLElement>>;
@@ -0,0 +1,47 @@
1
+ import React, { useContext, useState, useEffect } from "react";
2
+ import { useLocation } from "react-router-dom";
3
+ import { ThemeContext } from "styled-components";
4
+
5
+ import { themeComponent } from "../../../util/themeUtils";
6
+ import { fallbackValues } from "./NavTab.theme";
7
+
8
+ import InternalLink from "../link/InternalLink";
9
+ import Box from "../layouts/Box";
10
+
11
+ const NavTab = ({ path, label, themeValues }) => {
12
+ const { isMobile } = useContext(ThemeContext);
13
+
14
+ const [isActive, setIsActive] = useState(false);
15
+ const location = useLocation();
16
+
17
+ useEffect(() => {
18
+ setIsActive(location.pathname.includes(path));
19
+ }, [location.pathname]);
20
+
21
+ const border = `border-bottom: 3px solid ${themeValues.activeColor}`;
22
+
23
+ return (
24
+ <Box padding={0}>
25
+ <InternalLink
26
+ color={isActive ? themeValues.activeColor : themeValues.linkColor}
27
+ to={path}
28
+ extraStyles={`
29
+ border-bottom: 3px solid transparent;
30
+ font-family: ${themeValues.fontFamily};
31
+ text-decoration: none;
32
+ ${isActive && !isMobile ? border : "none"};
33
+ &:hover {
34
+ text-decoration: none;
35
+ color: ${themeValues.activeColor};
36
+ ${isMobile ? "" : `${border}`}
37
+ };
38
+ padding: 1.25rem 0.1rem;
39
+ `}
40
+ >
41
+ {label}
42
+ </InternalLink>
43
+ </Box>
44
+ );
45
+ };
46
+
47
+ export default themeComponent(NavTab, "NavTab", fallbackValues);