@thecb/components 7.7.0-beta.4 → 7.7.0
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/dist/index.cjs.js +37 -37
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +37 -37
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/formatted-credit-card/FormattedCreditCard.js +1 -1
- package/src/util/formats.js +53 -0
- package/src/util/general.js +1 -52
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import Text from "../text";
|
|
|
5
5
|
import { Box, Stack } from "../layouts";
|
|
6
6
|
import { fallbackValues } from "./FormattedCreditCard.theme";
|
|
7
7
|
import { themeComponent } from "../../../util/themeUtils";
|
|
8
|
-
import { renderCardStatus } from "../../../util/
|
|
8
|
+
import { renderCardStatus } from "../../../util/formats";
|
|
9
9
|
|
|
10
10
|
export const CreditCardWrapper = styled.div`
|
|
11
11
|
display: flex;
|
package/src/util/formats.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import { createFormat } from "formatted-input";
|
|
3
|
+
import Text from "../components/atoms/text";
|
|
4
|
+
import { ASH_GREY, FIRE_YELLOW } from "../constants/colors";
|
|
2
5
|
export const formatDelimiter = "_";
|
|
3
6
|
|
|
4
7
|
export const phoneFormats = [
|
|
@@ -80,3 +83,53 @@ export const expirationDateFormat = createFormat(
|
|
|
80
83
|
);
|
|
81
84
|
export const phoneFormat = createFormat(phoneFormats, formatDelimiter);
|
|
82
85
|
export const moneyFormat = createFormat(moneyFormats, formatDelimiter);
|
|
86
|
+
|
|
87
|
+
export const renderCardStatus = (
|
|
88
|
+
expirationStatus,
|
|
89
|
+
expireDate,
|
|
90
|
+
textAlign = "right",
|
|
91
|
+
as = "span"
|
|
92
|
+
) => {
|
|
93
|
+
const ACTIVE = "ACTIVE";
|
|
94
|
+
const EXPIRING_SOON = "EXPIRING_SOON";
|
|
95
|
+
const EXPIRED = "EXPIRED";
|
|
96
|
+
const textMargin = textAlign === "right" ? "auto" : "0";
|
|
97
|
+
|
|
98
|
+
switch (expirationStatus) {
|
|
99
|
+
case ACTIVE:
|
|
100
|
+
return (
|
|
101
|
+
<Text
|
|
102
|
+
as={as}
|
|
103
|
+
variant="pXS"
|
|
104
|
+
color={ASH_GREY}
|
|
105
|
+
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
106
|
+
>
|
|
107
|
+
Exp Date {expireDate}
|
|
108
|
+
</Text>
|
|
109
|
+
);
|
|
110
|
+
case EXPIRING_SOON:
|
|
111
|
+
return (
|
|
112
|
+
<Text
|
|
113
|
+
as={as}
|
|
114
|
+
variant="pXS"
|
|
115
|
+
color={FIRE_YELLOW}
|
|
116
|
+
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
117
|
+
>
|
|
118
|
+
Expiring Soon {expireDate}
|
|
119
|
+
</Text>
|
|
120
|
+
);
|
|
121
|
+
case EXPIRED:
|
|
122
|
+
return (
|
|
123
|
+
<Text
|
|
124
|
+
as={as}
|
|
125
|
+
variant="pXS"
|
|
126
|
+
color={ASH_GREY}
|
|
127
|
+
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
128
|
+
>
|
|
129
|
+
Expired
|
|
130
|
+
</Text>
|
|
131
|
+
);
|
|
132
|
+
default:
|
|
133
|
+
null;
|
|
134
|
+
}
|
|
135
|
+
};
|
package/src/util/general.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { Fragment } from "react";
|
|
2
2
|
import numeral from "numeral";
|
|
3
|
-
import { CHARADE_GREY
|
|
4
|
-
import Text from "../components/atoms/text";
|
|
3
|
+
import { CHARADE_GREY } from "../constants/colors";
|
|
5
4
|
|
|
6
5
|
export const noop = () => {};
|
|
7
6
|
|
|
@@ -160,53 +159,3 @@ export const titleCaseString = string => {
|
|
|
160
159
|
)
|
|
161
160
|
.join(" ");
|
|
162
161
|
};
|
|
163
|
-
|
|
164
|
-
export const renderCardStatus = (
|
|
165
|
-
expirationStatus,
|
|
166
|
-
expireDate,
|
|
167
|
-
textAlign = "right",
|
|
168
|
-
as = "span"
|
|
169
|
-
) => {
|
|
170
|
-
const ACTIVE = "ACTIVE";
|
|
171
|
-
const EXPIRING_SOON = "EXPIRING_SOON";
|
|
172
|
-
const EXPIRED = "EXPIRED";
|
|
173
|
-
const textMargin = textAlign === "right" ? "auto" : "0";
|
|
174
|
-
|
|
175
|
-
switch (expirationStatus) {
|
|
176
|
-
case ACTIVE:
|
|
177
|
-
return (
|
|
178
|
-
<Text
|
|
179
|
-
as={as}
|
|
180
|
-
variant="pXS"
|
|
181
|
-
color={ASH_GREY}
|
|
182
|
-
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
183
|
-
>
|
|
184
|
-
Exp Date {expireDate}
|
|
185
|
-
</Text>
|
|
186
|
-
);
|
|
187
|
-
case EXPIRING_SOON:
|
|
188
|
-
return (
|
|
189
|
-
<Text
|
|
190
|
-
as={as}
|
|
191
|
-
variant="pXS"
|
|
192
|
-
color={FIRE_YELLOW}
|
|
193
|
-
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
194
|
-
>
|
|
195
|
-
Expiring Soon {expireDate}
|
|
196
|
-
</Text>
|
|
197
|
-
);
|
|
198
|
-
case EXPIRED:
|
|
199
|
-
return (
|
|
200
|
-
<Text
|
|
201
|
-
as={as}
|
|
202
|
-
variant="pXS"
|
|
203
|
-
color={ASH_GREY}
|
|
204
|
-
extraStyles={`text-align: ${textAlign}; margin: ${textMargin};`}
|
|
205
|
-
>
|
|
206
|
-
Expired
|
|
207
|
-
</Text>
|
|
208
|
-
);
|
|
209
|
-
default:
|
|
210
|
-
null;
|
|
211
|
-
}
|
|
212
|
-
};
|