@thecb/components 10.4.0-beta.4 → 10.4.0-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.4.0-beta.4",
3
+ "version": "10.4.0-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",
@@ -28,6 +28,6 @@ const color = {
28
28
  };
29
29
 
30
30
  export const fallbackValues = {
31
- background: background,
32
- color: color
31
+ background,
32
+ color
33
33
  };
@@ -1,5 +1,6 @@
1
- import React from "react";
1
+ import React, { Fragment, useState } from "react";
2
2
  import { text, select, boolean } from "@storybook/addon-knobs";
3
+ import { Box } from "../layouts";
3
4
  import ButtonWithAction from "./ButtonWithAction";
4
5
  import page from "../../../../.storybook/page";
5
6
 
@@ -14,21 +15,38 @@ const variants = {
14
15
  smallGhost: "smallGhost",
15
16
  tertiary: "tertiary",
16
17
  danger: "danger",
18
+ dangerSecondary: "dangerSecondary",
19
+ whiteSecondary: "whiteSecondary",
20
+ whitePrimary: "whitePrimary",
17
21
  None: undefined
18
22
  };
19
23
  const defaultValue = "primary";
20
24
  const groupId = "props";
21
25
 
22
- const buttonHandler = () => console.log("Button selected");
26
+ const buttonHandler = () => window.alert("Button click!");
23
27
 
24
28
  export const buttonWithAction = () => (
25
- <ButtonWithAction
26
- variant={select(variantsLabel, variants, defaultValue, groupId)}
27
- disabled={boolean("disabled", false, "props")}
28
- text={text("text", "button", "props")}
29
- isLoading={boolean("isLoading", false, "props")}
30
- action={text("action", buttonHandler, "props")}
31
- />
29
+ <Fragment>
30
+ {/* Uncomment to view buttons on a dark background */}
31
+ {/* <Box extraStyles="background-color: #000;">
32
+ <ButtonWithAction
33
+ variant={select(variantsLabel, variants, defaultValue, groupId)}
34
+ disabled={boolean("disabled", false, "props")}
35
+ text={text("text", "button", "props")}
36
+ isLoading={boolean("isLoading", false, "props")}
37
+ action={text("action", buttonHandler, "props")}
38
+ />
39
+ </Box> */}
40
+ <Box extraStyles="background-color: #fff;">
41
+ <ButtonWithAction
42
+ variant={select(variantsLabel, variants, defaultValue, groupId)}
43
+ disabled={boolean("disabled", false, "props")}
44
+ text={text("text", "button", "props")}
45
+ isLoading={boolean("isLoading", false, "props")}
46
+ action={text("action", buttonHandler, "props")}
47
+ />
48
+ </Box>
49
+ </Fragment>
32
50
  );
33
51
 
34
52
  const story = page({
@@ -8,25 +8,24 @@ const {
8
8
  MANATEE_GREY,
9
9
  MATISSE_BLUE,
10
10
  RASPBERRY,
11
- ERROR_COLOR,
12
- STORM_GREY
11
+ ERROR_COLOR
13
12
  } = colors;
14
13
 
15
14
  const { LINK_TEXT_DECORATION } = styleConstants;
16
15
 
17
16
  const disabledBorderColor = {
18
- primary: STORM_GREY,
19
- secondary: STORM_GREY,
17
+ primary: MANATEE_GREY,
18
+ secondary: MANATEE_GREY,
20
19
  back: TRANSPARENT,
21
- smallPrimary: STORM_GREY,
22
- smallSecondary: STORM_GREY,
20
+ smallPrimary: MANATEE_GREY,
21
+ smallSecondary: MANATEE_GREY,
23
22
  smallGhost: TRANSPARENT,
24
23
  ghost: TRANSPARENT,
25
24
  tertiary: TRANSPARENT,
26
- danger: STORM_GREY,
27
- dangerSecondary: STORM_GREY,
28
- whiteSecondary: TRANSPARENT,
29
- whitePrimary: TRANSPARENT
25
+ danger: MANATEE_GREY,
26
+ dangerSecondary: MANATEE_GREY,
27
+ whiteSecondary: MANATEE_GREY,
28
+ whitePrimary: MANATEE_GREY
30
29
  };
31
30
 
32
31
  const disabledColor = {
@@ -17,7 +17,6 @@ import {
17
17
  PaymentMethodAddIcon
18
18
  } from "../icons";
19
19
  import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
20
- import { noop } from "../../../util/general";
21
20
 
22
21
  const getLargeIcon = iconName => {
23
22
  switch (iconName) {
@@ -37,27 +36,21 @@ const PlaceholderContentWrapper = ({
37
36
  action,
38
37
  destination,
39
38
  children,
40
- dataQa,
41
- disabled = false
39
+ dataQa
42
40
  }) =>
43
41
  isLink ? (
44
42
  <Link to={destination} data-qa={dataQa} style={{ textDecoration: "none" }}>
45
- <Box
46
- padding="0"
47
- minHeight="100%"
48
- extraStyles={disabled ? `cursor: default;` : `cursor: pointer;`}
49
- >
43
+ <Box padding="0" minHeight="100%" extraStyles={`cursor: pointer;`}>
50
44
  {children}
51
45
  </Box>
52
46
  </Link>
53
47
  ) : (
54
48
  <Box
55
- onClick={disabled ? noop : action}
49
+ onClick={action}
56
50
  padding="0"
57
51
  minHeight="100%"
52
+ extraStyles={`cursor: pointer;`}
58
53
  dataQa={dataQa}
59
- aria-disabled={disabled}
60
- extraStyles={disabled ? "cursor: default;" : "cursor: pointer;"}
61
54
  >
62
55
  {children}
63
56
  </Box>
@@ -72,26 +65,21 @@ const Placeholder = ({
72
65
  variant,
73
66
  largeIcon,
74
67
  themeValues,
75
- dataQa,
76
- disabled = false
77
- }) => {
78
- const tintedColor = `${tint(0.9, themeValues.color)}`;
79
-
80
- return (
81
- <PlaceholderContentWrapper
82
- isLink={isLink}
83
- action={action}
84
- destination={destination}
85
- dataQa={dataQa}
86
- disabled={disabled}
87
- >
88
- <Box
89
- padding="0"
90
- borderRadius="4px"
91
- border="none"
92
- minHeight={themeValues.height}
93
- hiddenStyles={!visible}
94
- extraStyles={`
68
+ dataQa
69
+ }) => (
70
+ <PlaceholderContentWrapper
71
+ isLink={isLink}
72
+ action={action}
73
+ destination={destination}
74
+ dataQa={dataQa}
75
+ >
76
+ <Box
77
+ padding="0"
78
+ borderRadius="4px"
79
+ border="none"
80
+ minHeight={themeValues.height}
81
+ hiddenStyles={!visible}
82
+ extraStyles={`
95
83
  background: linear-gradient(
96
84
  to right,
97
85
  ${variant === "large" ? STORM_GREY : themeValues.color} 40%,
@@ -112,22 +100,22 @@ const Placeholder = ({
112
100
  display: flex;
113
101
  justify-content: center;
114
102
  align-items:center;`}
115
- hoverStyles={`background-color: ${
116
- variant === "large" ? GRECIAN_GREY : tintedColor
117
- };`}
118
- >
119
- <Center maxWidth="300px">
120
- <Box
121
- padding="0"
122
- tabIndex="0"
123
- onKeyPress={e => e.key === "Enter" && !disabled && action()}
124
- >
125
- <Cluster justify="center" align="center" minHeight="100%">
126
- <Switcher maxChildren={2} childGap="0">
127
- {variant === "large" && <div></div>}
128
- <Box
129
- padding="0"
130
- extraStyles={`.fill {
103
+ hoverStyles={`background-color: ${
104
+ variant === "large" ? GRECIAN_GREY : tint(0.9, themeValues.color)
105
+ };`}
106
+ >
107
+ <Center maxWidth="300px">
108
+ <Box
109
+ padding="0"
110
+ tabIndex="0"
111
+ onKeyPress={e => e.key === "Enter" && action()}
112
+ >
113
+ <Cluster justify="center" align="center" minHeight="100%">
114
+ <Switcher maxChildren={2} childGap="0">
115
+ {variant === "large" && <div></div>}
116
+ <Box
117
+ padding="0"
118
+ extraStyles={`.fill {
131
119
  fill: ${
132
120
  variant === "large" ? CHARADE_GREY : themeValues.color
133
121
  };
@@ -136,45 +124,44 @@ const Placeholder = ({
136
124
  variant === "large" ? CHARADE_GREY : themeValues.color
137
125
  };
138
126
  }`}
139
- >
140
- {variant === "large" ? (
141
- <Center intrinsic>
142
- {getLargeIcon(largeIcon)}
143
- <Text
144
- variant="pS"
145
- color={themeValues.color}
146
- weight={FONT_WEIGHT_REGULAR}
147
- extraStyles={`text-align: center;`}
148
- >
149
- {text}
150
- </Text>
151
- </Center>
152
- ) : (
153
- <Cover singleChild minHeight="100%">
154
- <Cluster justify="center" align="center">
155
- <IconAdd />
156
- <Center intrinsic>
157
- <Text
158
- variant="pS"
159
- color={themeValues.color}
160
- weight={FONT_WEIGHT_REGULAR}
161
- extraStyles={`padding: 0 0 0 8px; text-align: center;`}
162
- >
163
- {text}
164
- </Text>
165
- </Center>
166
- </Cluster>
167
- </Cover>
168
- )}
169
- </Box>
170
- </Switcher>
171
- </Cluster>
172
- </Box>
173
- </Center>
174
- </Box>
175
- </PlaceholderContentWrapper>
176
- );
177
- };
127
+ >
128
+ {variant === "large" ? (
129
+ <Center intrinsic>
130
+ {getLargeIcon(largeIcon)}
131
+ <Text
132
+ variant="pS"
133
+ color={themeValues.color}
134
+ weight={FONT_WEIGHT_REGULAR}
135
+ extraStyles={`text-align: center;`}
136
+ >
137
+ {text}
138
+ </Text>
139
+ </Center>
140
+ ) : (
141
+ <Cover singleChild minHeight="100%">
142
+ <Cluster justify="center" align="center">
143
+ <IconAdd />
144
+ <Center intrinsic>
145
+ <Text
146
+ variant="pS"
147
+ color={themeValues.color}
148
+ weight={FONT_WEIGHT_REGULAR}
149
+ extraStyles={`padding: 0 0 0 8px; text-align: center;`}
150
+ >
151
+ {text}
152
+ </Text>
153
+ </Center>
154
+ </Cluster>
155
+ </Cover>
156
+ )}
157
+ </Box>
158
+ </Switcher>
159
+ </Cluster>
160
+ </Box>
161
+ </Center>
162
+ </Box>
163
+ </PlaceholderContentWrapper>
164
+ );
178
165
 
179
166
  export default themeComponent(
180
167
  Placeholder,