@thecb/components 10.2.4-beta.4 → 10.2.4-beta.6

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