@thecb/components 10.2.4-beta.3 → 10.2.4-beta.5

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": "10.2.4-beta.3",
3
+ "version": "10.2.4-beta.5",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -9,7 +9,8 @@ const variants = {
9
9
  info: "info",
10
10
  warn: "warn",
11
11
  primary: "primary",
12
- success: "success"
12
+ success: "success",
13
+ disabled: "disabled"
13
14
  };
14
15
 
15
16
  const defaultValue = "success";
@@ -1,5 +1,7 @@
1
1
  import {
2
+ ATHENS_GREY,
2
3
  CORNFLOWER_BLUE,
4
+ GHOST_GREY,
3
5
  HALF_COLONIAL_WHITE,
4
6
  HINT_GREEN,
5
7
  INFO_BLUE,
@@ -13,17 +15,19 @@ const background = {
13
15
  info: `${INFO_BLUE}`,
14
16
  warn: `${HALF_COLONIAL_WHITE}`,
15
17
  primary: `${CORNFLOWER_BLUE}`,
16
- success: `${HINT_GREEN}`
18
+ success: `${HINT_GREEN}`,
19
+ disabled: `${ATHENS_GREY}`
17
20
  };
18
21
 
19
22
  const color = {
20
23
  info: `${MATISSE_BLUE}`,
21
24
  warn: `${ZEST_ORANGE}`,
22
25
  primary: `${ROYAL_BLUE_VIVID}`,
23
- success: `${SEA_GREEN}`
26
+ success: `${SEA_GREEN}`,
27
+ disabled: `${GHOST_GREY}`
24
28
  };
25
29
 
26
30
  export const fallbackValues = {
27
- background,
28
- color
31
+ background: background,
32
+ color: color
29
33
  };
@@ -4,8 +4,10 @@ import { themeComponent } from "../../../util/themeUtils";
4
4
  import { fallbackValues } from "./LinkCard.theme";
5
5
  import { ThemeContext } from "styled-components";
6
6
  import * as Styled from "./LinkCard.styled";
7
+ import { noop } from "../../../util/general";
7
8
 
8
9
  const LinkCard = ({
10
+ variant = "primary",
9
11
  title = "Test Workflow",
10
12
  subtitle = "Link your benefit plan",
11
13
  showLeft,
@@ -17,7 +19,8 @@ const LinkCard = ({
17
19
  extraHoverStyles = "",
18
20
  extraActiveStyles = "",
19
21
  themeValues,
20
- titleVariant = "h3"
22
+ titleVariant = "h3",
23
+ disabled = false
21
24
  }) => {
22
25
  const { isMobile } = useContext(ThemeContext);
23
26
  const regex = /\W/g;
@@ -36,7 +39,8 @@ const LinkCard = ({
36
39
  extraStyles={extraStyles}
37
40
  hoverStyles={extraHoverStyles}
38
41
  activeStyles={extraActiveStyles}
39
- onClick={onClick}
42
+ onClick={variant === "disabled" || disabled ? noop : onClick}
43
+ aria-disabled={disabled}
40
44
  >
41
45
  <Stack
42
46
  childGap={0}
@@ -73,4 +77,4 @@ const LinkCard = ({
73
77
  );
74
78
  };
75
79
 
76
- export default themeComponent(LinkCard, "LinkCard", fallbackValues);
80
+ export default themeComponent(LinkCard, "LinkCard", fallbackValues, "primary");
@@ -1,49 +1,87 @@
1
- import React from "react";
1
+ import page from "../../../../.storybook/page";
2
+ import { boolean, select, text } from "@storybook/addon-knobs";
3
+ import React, { useContext } from "react";
4
+ import { ThemeContext } from "styled-components";
5
+ import { createThemeValues } from "../../../util/themeUtils";
6
+ import { fallbackValues } from "./LinkCard.theme";
2
7
  import LinkCard from "./LinkCard";
3
8
  import Box from "../../atoms/layouts/Box";
4
9
  import Stack from "../../atoms/layouts/Stack";
5
10
  import Text from "../../atoms/text/Text";
6
- import page from "../../../../.storybook/page";
7
- import { text } from "@storybook/addon-knobs";
8
11
  import Badge from "../../atoms/badge/Badge";
9
12
  import PlusCircleIcon from "../../atoms/icons/PlusCircleIcon";
10
13
  import AutopayIcon from "../../atoms/icons/AutopayIcon";
11
- import { CORNFLOWER_BLUE, ROYAL_BLUE_VIVID } from "../../../constants/colors";
12
- const groupId = "props";
13
14
 
14
- export const linkCard = () => (
15
- <LinkCard
16
- title={text("title", "Link Card Title", "props")}
17
- subtitle={text("subtitle", "Link card description", groupId)}
18
- path={text("path", "/service/animal-care-and-control", "props")}
19
- showLeft={true}
20
- leftContent={
21
- <Box background="transparent" borderWidthOverride="0 0 0 0" padding="0">
22
- <Badge label="Autopay Available" Icon={AutopayIcon} />
23
- </Box>
24
- }
25
- showRight={true}
26
- rightContent={
27
- <Stack direction="row" childGap="6px">
28
- <Text
29
- variant="pS"
30
- color={ROYAL_BLUE_VIVID}
31
- extraStyles="text-align: right; color: transparent;"
32
- className="show-on-hover"
33
- >
34
- Find
35
- </Text>
36
- <PlusCircleIcon color={ROYAL_BLUE_VIVID} />
37
- </Stack>
38
- }
39
- extraHoverStyles={`
40
- .show-on-hover {color: ${ROYAL_BLUE_VIVID};}
15
+ import {
16
+ ATHENS_GREY,
17
+ CORNFLOWER_BLUE,
18
+ ROYAL_BLUE_VIVID,
19
+ GHOST_GREY
20
+ } from "../../../constants/colors";
21
+
22
+ const groupId = "props";
23
+ const variant = "primary";
24
+ const variants = { primary: "primary", disabled: "disabled" };
25
+ const disabled = false;
26
+ const showLeft = true;
27
+ const LeftContent = ({ parentVariant }) => {
28
+ return (
29
+ <Box background="transparent" borderWidthOverride="0 0 0 0" padding="0">
30
+ <Badge
31
+ label="Autopay Available"
32
+ Icon={AutopayIcon}
33
+ variant={parentVariant === "disabled" ? "disabled" : "success"}
34
+ />
35
+ </Box>
36
+ );
37
+ };
38
+ export const linkCard = () => {
39
+ /* const themeContext = useContext(ThemeContext);
40
+ const themeValues = createThemeValues(
41
+ themeContext,
42
+ fallbackValues,
43
+ "Link",
44
+ variant
45
+ ); */
46
+ const leftContent = <LeftContent parentVariant={variant} />;
47
+ return (
48
+ <LinkCard
49
+ variant={select("variant", variants, variant, groupId)}
50
+ disabled={boolean("disabled", disabled, groupId)}
51
+ title={text("title", "Link Card Title", groupId)}
52
+ subtitle={text("subtitle", "Link card description", groupId)}
53
+ path={text("path", "/service/animal-care-and-control", groupId)}
54
+ showLeft={boolean("showLeft", showLeft, groupId)}
55
+ onClick={() => window.alert("Click event!")}
56
+ leftContent={leftContent}
57
+ showRight={boolean("showRight", true, groupId)}
58
+ rightContent={
59
+ <Stack direction="row" childGap="6px">
60
+ <Text
61
+ variant="pS"
62
+ className="show-on-hover"
63
+ extraStyles={`text-align: right; color: transparent; ${
64
+ !showLeft || (showLeft && !leftContent)
65
+ ? "margin-left: auto;"
66
+ : ""
67
+ }`}
68
+ >
69
+ Find
70
+ </Text>
71
+ <PlusCircleIcon
72
+ color={variant === "disabled" ? GHOST_GREY : ROYAL_BLUE_VIVID}
73
+ />
74
+ </Stack>
75
+ }
76
+ extraHoverStyles={`
77
+ .show-on-hover {color: ${disabled ? ATHENS_GREY : ROYAL_BLUE_VIVID};}
41
78
  `}
42
- extraActiveStyles={`
43
- background-color: ${CORNFLOWER_BLUE};
79
+ extraActiveStyles={`
80
+ background-color: ${disabled ? ATHENS_GREY : CORNFLOWER_BLUE};
44
81
  `}
45
- />
46
- );
82
+ />
83
+ );
84
+ };
47
85
 
48
86
  const story = page({
49
87
  title: "Components|Molecules/LinkCard",
@@ -1,18 +1,33 @@
1
1
  import {
2
+ ATHENS_GREY,
2
3
  CORNFLOWER_BLUE,
4
+ GHOST_GREY,
3
5
  LINK_WATER,
4
6
  MOON_RAKER,
5
- ROYAL_BLUE_VIVID
7
+ ROYAL_BLUE_VIVID,
8
+ STORM_GREY
6
9
  } from "../../../constants/colors";
7
10
 
8
- const activeBackgroundColor = CORNFLOWER_BLUE;
9
- const backgroundColor = LINK_WATER;
10
- const borderColor = MOON_RAKER;
11
- const color = ROYAL_BLUE_VIVID;
11
+ const activeBackgroundColor = {
12
+ primary: `${CORNFLOWER_BLUE}`,
13
+ disabled: `${GHOST_GREY}`
14
+ };
15
+ const backgroundColor = {
16
+ primary: `${LINK_WATER}`,
17
+ disabled: `${ATHENS_GREY}`
18
+ };
19
+ const borderColor = {
20
+ primary: `${MOON_RAKER}`,
21
+ disabled: `${STORM_GREY}`
22
+ };
23
+ const color = {
24
+ primary: `${ROYAL_BLUE_VIVID}`,
25
+ disabled: `${GHOST_GREY}`
26
+ };
12
27
 
13
28
  export const fallbackValues = {
14
- activeBackgroundColor,
15
- backgroundColor,
16
- borderColor,
17
- color
29
+ activeBackgroundColor: activeBackgroundColor,
30
+ backgroundColor: backgroundColor,
31
+ borderColor: borderColor,
32
+ color: color
18
33
  };