@xapp/stentor-chat-widget 1.96.0 → 1.97.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/lib/__clientTheme.d.ts +12 -0
- package/lib/__clientTheme.js +250 -0
- package/lib/__clientTheme.js.map +1 -0
- package/lib/__tests__/color.test.js +59 -0
- package/lib/__tests__/color.test.js.map +1 -1
- package/lib/__tests__/themeParity.test.d.ts +1 -0
- package/lib/__tests__/themeParity.test.js +36 -0
- package/lib/__tests__/themeParity.test.js.map +1 -0
- package/lib/buildChatWidgetChannel.d.ts +15 -5
- package/lib/buildChatWidgetChannel.js +174 -15
- package/lib/buildChatWidgetChannel.js.map +1 -1
- package/lib/color.d.ts +17 -0
- package/lib/color.js +86 -0
- package/lib/color.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type WidgetTheme = any;
|
|
2
|
+
export declare function parseRgb(colorString: string): {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
a?: number;
|
|
7
|
+
} | null;
|
|
8
|
+
export declare function invertColorRgb(rgb: string, bw?: boolean): string;
|
|
9
|
+
export declare function invertColorHEX(hex: string, bw?: boolean): string;
|
|
10
|
+
export declare function invertColor(color: string, bw?: boolean): string;
|
|
11
|
+
export declare function buildDefaultChatTheme(primaryColor: string, secondaryColor?: string): WidgetTheme;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseRgb = parseRgb;
|
|
4
|
+
exports.invertColorRgb = invertColorRgb;
|
|
5
|
+
exports.invertColorHEX = invertColorHEX;
|
|
6
|
+
exports.invertColor = invertColor;
|
|
7
|
+
exports.buildDefaultChatTheme = buildDefaultChatTheme;
|
|
8
|
+
function padZero(str, len = 2) { const zeros = new Array(len).join("0"); return (zeros + str).slice(-len); }
|
|
9
|
+
function parseRgb(colorString) {
|
|
10
|
+
const rgbaRegex = /^rgba?\((\d+),\s*(\d+),\s*(\d+),\s*([\d.]+)\)$/;
|
|
11
|
+
const rgbRegex = /^rgb?\((\d+),\s*(\d+),\s*(\d+)\)$/;
|
|
12
|
+
let match;
|
|
13
|
+
// eslint-disable-next-line no-cond-assign
|
|
14
|
+
if (match = colorString.match(rgbaRegex)) {
|
|
15
|
+
const r = parseInt(match[1]);
|
|
16
|
+
const g = parseInt(match[2]);
|
|
17
|
+
const b = parseInt(match[3]);
|
|
18
|
+
const a = parseFloat(match[4]);
|
|
19
|
+
return { r, g, b, a };
|
|
20
|
+
// eslint-disable-next-line no-cond-assign
|
|
21
|
+
}
|
|
22
|
+
else if (match = colorString.match(rgbRegex)) {
|
|
23
|
+
const r = parseInt(match[1]);
|
|
24
|
+
const g = parseInt(match[2]);
|
|
25
|
+
const b = parseInt(match[3]);
|
|
26
|
+
return { r, g, b };
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function invertColorRgb(rgb, bw) {
|
|
33
|
+
const rgba = parseRgb(rgb);
|
|
34
|
+
if (!rgba) {
|
|
35
|
+
return rgb;
|
|
36
|
+
}
|
|
37
|
+
const { r, g, b } = rgba;
|
|
38
|
+
if (bw) {
|
|
39
|
+
// http://stackoverflow.com/a/3943023/112731
|
|
40
|
+
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? "rgba(0, 0, 0, 1)" : "rgba(255, 255, 255, 1)";
|
|
41
|
+
}
|
|
42
|
+
return `rgba(${255 - r}, ${255 - g}, ${255 - b}, 1)`;
|
|
43
|
+
}
|
|
44
|
+
function invertColorHEX(hex, bw) {
|
|
45
|
+
if (!hex) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
if (hex.indexOf("#") === 0) {
|
|
49
|
+
hex = hex.slice(1);
|
|
50
|
+
}
|
|
51
|
+
// convert 3-digit hex to 6-digits.
|
|
52
|
+
if (hex.length === 3) {
|
|
53
|
+
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
54
|
+
}
|
|
55
|
+
if (hex.length !== 6) {
|
|
56
|
+
throw new Error("Invalid HEX color.");
|
|
57
|
+
}
|
|
58
|
+
const r = parseInt(hex.slice(0, 2), 16);
|
|
59
|
+
const g = parseInt(hex.slice(2, 4), 16);
|
|
60
|
+
const b = parseInt(hex.slice(4, 6), 16);
|
|
61
|
+
if (bw) {
|
|
62
|
+
// http://stackoverflow.com/a/3943023/112731
|
|
63
|
+
return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? "#000000" : "#FFFFFF";
|
|
64
|
+
}
|
|
65
|
+
// pad each with zeros and return
|
|
66
|
+
return "#" + padZero((255 - r).toString(16)) + padZero((255 - g).toString(16)) + padZero((255 - b).toString(16));
|
|
67
|
+
}
|
|
68
|
+
function invertColor(color, bw) {
|
|
69
|
+
return color.startsWith("#") ? invertColorHEX(color, bw) : invertColorRgb(color, bw);
|
|
70
|
+
}
|
|
71
|
+
function buildDefaultChatTheme(primaryColor, secondaryColor) {
|
|
72
|
+
const fontFamily = "RobotoRegular";
|
|
73
|
+
if (!secondaryColor) {
|
|
74
|
+
secondaryColor = invertColor(primaryColor, true);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
zIndex: "10000",
|
|
78
|
+
border: {
|
|
79
|
+
color: primaryColor,
|
|
80
|
+
radius: "10px",
|
|
81
|
+
},
|
|
82
|
+
carousel: {
|
|
83
|
+
button: {
|
|
84
|
+
color: primaryColor,
|
|
85
|
+
},
|
|
86
|
+
subtitle: {
|
|
87
|
+
color: "#979797",
|
|
88
|
+
fontFamily,
|
|
89
|
+
fontSize: "12px",
|
|
90
|
+
fontStyle: "normal",
|
|
91
|
+
fontWeight: "normal",
|
|
92
|
+
},
|
|
93
|
+
title: {
|
|
94
|
+
color: "#000",
|
|
95
|
+
fontFamily,
|
|
96
|
+
fontSize: "14px",
|
|
97
|
+
fontStyle: "normal",
|
|
98
|
+
fontWeight: "bold",
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
chatButton: {
|
|
102
|
+
background: primaryColor,
|
|
103
|
+
margin: {
|
|
104
|
+
bottom: "10px",
|
|
105
|
+
left: "10px",
|
|
106
|
+
right: "10px",
|
|
107
|
+
top: "10px",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
content: {
|
|
111
|
+
background: "#ffffff",
|
|
112
|
+
},
|
|
113
|
+
cta: {
|
|
114
|
+
background: "#e1e2e1",
|
|
115
|
+
text: {
|
|
116
|
+
// Use a dark color that contrasts well with the light grey background
|
|
117
|
+
// instead of primaryColor which may not have sufficient contrast
|
|
118
|
+
color: "#333333",
|
|
119
|
+
fontFamily,
|
|
120
|
+
fontSize: "14px",
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
footer: {
|
|
124
|
+
background: primaryColor,
|
|
125
|
+
border: {
|
|
126
|
+
color: primaryColor,
|
|
127
|
+
radius: "0px",
|
|
128
|
+
width: "0px",
|
|
129
|
+
},
|
|
130
|
+
branding: {
|
|
131
|
+
text: {
|
|
132
|
+
color: "#ffffff",
|
|
133
|
+
fontFamily,
|
|
134
|
+
fontSize: "14px",
|
|
135
|
+
fontWeight: "normal",
|
|
136
|
+
fontStyle: "normal",
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
header: {
|
|
141
|
+
background: primaryColor,
|
|
142
|
+
avatarBackground: "transparent",
|
|
143
|
+
border: {
|
|
144
|
+
color: primaryColor,
|
|
145
|
+
radius: "0px",
|
|
146
|
+
width: "0px",
|
|
147
|
+
},
|
|
148
|
+
text: {
|
|
149
|
+
color: secondaryColor,
|
|
150
|
+
fontFamily,
|
|
151
|
+
fontSize: "16px",
|
|
152
|
+
fontWeight: "normal",
|
|
153
|
+
fontStyle: "normal",
|
|
154
|
+
},
|
|
155
|
+
subtitle: {
|
|
156
|
+
color: secondaryColor,
|
|
157
|
+
fontFamily,
|
|
158
|
+
fontSize: "10px",
|
|
159
|
+
fontWeight: "normal",
|
|
160
|
+
fontStyle: "normal",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
input: {
|
|
164
|
+
background: "#ffffff",
|
|
165
|
+
border: {
|
|
166
|
+
radius: "20px",
|
|
167
|
+
},
|
|
168
|
+
text: {
|
|
169
|
+
color: "#000000",
|
|
170
|
+
fontFamily,
|
|
171
|
+
fontSize: "14px",
|
|
172
|
+
},
|
|
173
|
+
placeholder: {
|
|
174
|
+
color: "#e1e2e1",
|
|
175
|
+
fontFamily,
|
|
176
|
+
fontSize: "14px",
|
|
177
|
+
fontWeight: "normal",
|
|
178
|
+
fontStyle: "normal",
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
textTypingStatus: {
|
|
182
|
+
text: {
|
|
183
|
+
color: "#bfbfbf",
|
|
184
|
+
fontFamily,
|
|
185
|
+
fontSize: "14px",
|
|
186
|
+
fontWeight: "normal",
|
|
187
|
+
fontStyle: "normal",
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
menu: {
|
|
191
|
+
item: {
|
|
192
|
+
height: "24px",
|
|
193
|
+
text: {
|
|
194
|
+
fontSize: "14px",
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
menuButton: {
|
|
199
|
+
color: "#ffffff",
|
|
200
|
+
},
|
|
201
|
+
messages: {
|
|
202
|
+
maxWidth: "400px",
|
|
203
|
+
mine: {
|
|
204
|
+
bubbleColor: "#f2f2f2",
|
|
205
|
+
text: {
|
|
206
|
+
color: "#454545",
|
|
207
|
+
fontFamily,
|
|
208
|
+
fontSize: "18px",
|
|
209
|
+
fontStyle: "normal",
|
|
210
|
+
fontWeight: "normal",
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
others: {
|
|
214
|
+
bubbleColor: "#e1e2e1",
|
|
215
|
+
text: {
|
|
216
|
+
color: "#262726",
|
|
217
|
+
fontFamily,
|
|
218
|
+
fontSize: "18px",
|
|
219
|
+
fontStyle: "normal",
|
|
220
|
+
fontWeight: "normal",
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
padding: {
|
|
224
|
+
bottom: "0px",
|
|
225
|
+
left: "20px",
|
|
226
|
+
right: "16px",
|
|
227
|
+
top: "16px",
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
refreshButton: {
|
|
231
|
+
color: secondaryColor,
|
|
232
|
+
},
|
|
233
|
+
minimizeButton: {
|
|
234
|
+
color: secondaryColor,
|
|
235
|
+
},
|
|
236
|
+
cancelButton: {
|
|
237
|
+
color: secondaryColor,
|
|
238
|
+
},
|
|
239
|
+
primaryColor: primaryColor,
|
|
240
|
+
sendButton: {
|
|
241
|
+
color: "#505050",
|
|
242
|
+
width: "20px",
|
|
243
|
+
},
|
|
244
|
+
size: {
|
|
245
|
+
width: "500px",
|
|
246
|
+
height: "700px",
|
|
247
|
+
},
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=__clientTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"__clientTheme.js","sourceRoot":"","sources":["../src/__clientTheme.ts"],"names":[],"mappings":";;AAGA,4BAwBC;AACD,wCAaC;AAED,wCAyBC;AAED,kCAEC;AACD,sDAoLC;AA3PD,SAAS,OAAO,CAAC,GAAW,EAAE,GAAG,GAAG,CAAC,IAAY,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC5H,SAAgB,QAAQ,CAAC,WAAmB;IACxC,MAAM,SAAS,GAAG,gDAAgD,CAAC;IACnE,MAAM,QAAQ,GAAG,mCAAmC,CAAC;IAErD,IAAI,KAAsB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D,aAAa,EAAE;YACX,KAAK,EAAE,cAAc;SACxB;QACD,cAAc,EAAE;YACZ,KAAK,EAAE,cAAc;SACxB;QACD,YAAY,EAAE;YACV,KAAK,EAAE,cAAc;SACxB;QACD,YAAY,EAAE,YAAY;QAC1B,UAAU,EAAE;YACR,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,MAAM;SAChB;QACD,IAAI,EAAE;YACF,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,OAAO;SAClB;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -95,4 +95,63 @@ describe("isSupportedColor", () => {
|
|
|
95
95
|
expect((0, color_1.isSupportedColor)("")).toEqual(false);
|
|
96
96
|
});
|
|
97
97
|
});
|
|
98
|
+
describe("usableColorOr", () => {
|
|
99
|
+
it("keeps a colour we can compute contrast against", () => {
|
|
100
|
+
expect((0, color_1.usableColorOr)("#f47c4c", "#1AA7DC")).toEqual("#f47c4c");
|
|
101
|
+
expect((0, color_1.usableColorOr)("rgb(20, 52, 204)", "#1AA7DC")).toEqual("rgb(20, 52, 204)");
|
|
102
|
+
});
|
|
103
|
+
it("substitutes the fallback for anything else", () => {
|
|
104
|
+
// Including colours that are perfectly valid CSS. If we cannot work out
|
|
105
|
+
// what text reads on it, we must not use it as a background — the text
|
|
106
|
+
// colour would be a guess paired with an unknown.
|
|
107
|
+
expect((0, color_1.usableColorOr)("orange", "#1AA7DC")).toEqual("#1AA7DC");
|
|
108
|
+
expect((0, color_1.usableColorOr)("hsl(9, 100%, 64%)", "#1AA7DC")).toEqual("#1AA7DC");
|
|
109
|
+
expect((0, color_1.usableColorOr)(undefined, "#1AA7DC")).toEqual("#1AA7DC");
|
|
110
|
+
expect((0, color_1.usableColorOr)("", "#1AA7DC")).toEqual("#1AA7DC");
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
describe("darkenColor", () => {
|
|
114
|
+
it("darkens hex", () => {
|
|
115
|
+
expect((0, color_1.darkenColor)("#1434cc", 20)).toEqual("#0020b8");
|
|
116
|
+
});
|
|
117
|
+
it("darkens rgb without an alpha", () => {
|
|
118
|
+
expect((0, color_1.darkenColor)("rgb(20, 52, 204)", 20)).toEqual("#0020b8");
|
|
119
|
+
});
|
|
120
|
+
it("has no opinion about a missing colour", () => {
|
|
121
|
+
expect((0, color_1.darkenColor)(undefined, 20)).toBeUndefined();
|
|
122
|
+
});
|
|
123
|
+
it("returns unsupported input unchanged", () => {
|
|
124
|
+
expect((0, color_1.darkenColor)("orange", 20)).toEqual("orange");
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Fixed here, and therefore the one place this package deliberately does
|
|
128
|
+
* not match stentor-client.
|
|
129
|
+
*
|
|
130
|
+
* The alpha branch computed luminance on the 0-255 scale the channels use
|
|
131
|
+
* and then clamped it to 0-1, so it collapsed to 1 for every real colour
|
|
132
|
+
* and the ratio crushed the result to near-black: rgba(20, 52, 204, 0.8)
|
|
133
|
+
* darkened by 20% came back rgba(0, 1, 3, 1). Clamping on the right scale
|
|
134
|
+
* makes it do what it says — scale each channel by 1 - amount/100.
|
|
135
|
+
*
|
|
136
|
+
* The client still has the old behaviour, so a form themed from an rgba
|
|
137
|
+
* colour will change appearance when it migrates onto this. That is the
|
|
138
|
+
* intended outcome rather than a regression: near-black was never what
|
|
139
|
+
* anyone asked for, and consolidating these builders is what makes one fix
|
|
140
|
+
* enough.
|
|
141
|
+
*
|
|
142
|
+
* Neither version is reachable from the funnel — Arachne reports
|
|
143
|
+
* site.primaryColor as hex.
|
|
144
|
+
*/
|
|
145
|
+
it("darkens rgba proportionally rather than crushing it", () => {
|
|
146
|
+
// 80% of each channel, which is what "20% darker" should mean.
|
|
147
|
+
expect((0, color_1.darkenColor)("rgba(20, 52, 204, 0.8)", 20)).toEqual("rgba(16, 42, 163, 1)");
|
|
148
|
+
expect((0, color_1.darkenColor)("rgba(255, 0, 0, 0.5)", 20)).toEqual("rgba(204, 0, 0, 0.7)");
|
|
149
|
+
});
|
|
150
|
+
it("leaves the hex and rgb paths exactly as they were", () => {
|
|
151
|
+
// Those branches were correct and are untouched, so the parity tests
|
|
152
|
+
// over hex colours still hold.
|
|
153
|
+
expect((0, color_1.darkenColor)("#1434cc", 20)).toEqual("#0020b8");
|
|
154
|
+
expect((0, color_1.darkenColor)("rgb(20, 52, 204)", 20)).toEqual("#0020b8");
|
|
155
|
+
});
|
|
156
|
+
});
|
|
98
157
|
//# sourceMappingURL=color.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.test.js","sourceRoot":"","sources":["../../src/__tests__/color.test.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"color.test.js","sourceRoot":"","sources":["../../src/__tests__/color.test.ts"],"names":[],"mappings":";;AAAA,oCAAqH;AAErH;;;GAGG;AACH,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAE5B,EAAE,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACxB,MAAM,CAAC,IAAA,sBAAc,EAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACrD,MAAM,CAAC,IAAA,sBAAc,EAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;QAC/B,MAAM,CAAC,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,sBAAc,EAAC,SAAS,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC7C,MAAM,CAAC,IAAA,sBAAc,EAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sEAAsE,EAAE,GAAG,EAAE;QAC5E,qEAAqE;QACrE,6DAA6D;QAC7D,EAAE;QACF,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O,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const __clientTheme_1 = require("../__clientTheme");
|
|
4
|
+
const buildChatWidgetChannel_1 = require("../buildChatWidgetChannel");
|
|
5
|
+
/**
|
|
6
|
+
* The port has to be faithful, or migrating stentor-client to it restyles every
|
|
7
|
+
* widget created afterwards. This compares the two directly rather than
|
|
8
|
+
* trusting that it looks right.
|
|
9
|
+
*
|
|
10
|
+
* `__clientTheme.ts` is stentor-client's function, extracted verbatim with its
|
|
11
|
+
* colour helpers inlined so it can run here. It goes away once the client is
|
|
12
|
+
* migrated and there is only one of these left.
|
|
13
|
+
*/
|
|
14
|
+
describe("parity with stentor-client's buildDefaultChatTheme", () => {
|
|
15
|
+
// Hex is what a crawl actually yields — Arachne reports site.primaryColor
|
|
16
|
+
// as hex — so these are the cases that matter, and they are byte-identical.
|
|
17
|
+
const HEX = ["#f47c4c", "#c1bdb2", "#1434cc", "#1AA7DC", "#000000", "#ffffff"];
|
|
18
|
+
HEX.forEach((primaryColor) => {
|
|
19
|
+
it(`produces the same theme for ${primaryColor}`, () => {
|
|
20
|
+
expect((0, buildChatWidgetChannel_1.buildChatTheme)(primaryColor)).toEqual((0, __clientTheme_1.buildDefaultChatTheme)(primaryColor));
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
it("differs from the client only in notation for rgb input", () => {
|
|
24
|
+
// The one intentional difference. Given rgb, the client's contrast
|
|
25
|
+
// helper answers "rgba(255, 255, 255, 1)" while readableTextOn
|
|
26
|
+
// normalises to "#FFFFFF". Same colour, one shape instead of two — and
|
|
27
|
+
// not reachable from a crawl, which reports hex.
|
|
28
|
+
const mine = JSON.stringify((0, buildChatWidgetChannel_1.buildChatTheme)("rgb(20, 52, 204)"));
|
|
29
|
+
const theirs = JSON.stringify((0, __clientTheme_1.buildDefaultChatTheme)("rgb(20, 52, 204)"));
|
|
30
|
+
expect(mine.replace(/#FFFFFF/g, "rgba(255, 255, 255, 1)")).toEqual(theirs);
|
|
31
|
+
});
|
|
32
|
+
it("produces the same theme when a secondary colour is supplied", () => {
|
|
33
|
+
expect((0, buildChatWidgetChannel_1.buildChatTheme)("#f47c4c", "#ffffff")).toEqual((0, __clientTheme_1.buildDefaultChatTheme)("#f47c4c", "#ffffff"));
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=themeParity.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themeParity.test.js","sourceRoot":"","sources":["../../src/__tests__/themeParity.test.ts"],"names":[],"mappings":";;AAAA,oDAAyD;AACzD,sEAA2D;AAE3D;;;;;;;;GAQG;AACH,QAAQ,CAAC,oDAAoD,EAAE,GAAG,EAAE;IAEhE,0EAA0E;IAC1E,4EAA4E;IAC5E,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAE/E,GAAG,CAAC,OAAO,CAAC,CAAC,YAAY,EAAE,EAAE;QACzB,EAAE,CAAC,+BAA+B,YAAY,EAAE,EAAE,GAAG,EAAE;YACnD,MAAM,CAAC,IAAA,uCAAc,EAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,qCAAqB,EAAC,YAAY,CAAC,CAAC,CAAC;QACtF,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAC9D,mEAAmE;QACnE,+DAA+D;QAC/D,uEAAuE;QACvE,iDAAiD;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAA,uCAAc,EAAC,kBAAkB,CAAC,CAAC,CAAC;QAChE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,IAAA,qCAAqB,EAAC,kBAAkB,CAAC,CAAC,CAAC;QAEzE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,wBAAwB,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,GAAG,EAAE;QACnE,MAAM,CAAC,IAAA,uCAAc,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAA,qCAAqB,EAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IACtG,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -30,6 +30,12 @@ export interface BuildChatWidgetChannelProps {
|
|
|
30
30
|
* guessed foreground is how a widget ships with invisible text.
|
|
31
31
|
*/
|
|
32
32
|
primaryColor?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Colour of text sitting on primaryColor. Computed from it when absent,
|
|
35
|
+
* which is the usual case — a crawl gives us a brand colour, not a
|
|
36
|
+
* matching text colour.
|
|
37
|
+
*/
|
|
38
|
+
secondaryColor?: string;
|
|
33
39
|
/**
|
|
34
40
|
* The form widget channel's key, which the booking button opens.
|
|
35
41
|
*
|
|
@@ -43,10 +49,14 @@ export interface BuildChatWidgetChannelProps {
|
|
|
43
49
|
}
|
|
44
50
|
export declare function buildChatWidgetChannel(props: BuildChatWidgetChannelProps): NewChatWidgetChannel;
|
|
45
51
|
/**
|
|
46
|
-
*
|
|
52
|
+
* The theme a new chat widget starts with, from the business's own colour.
|
|
53
|
+
*
|
|
54
|
+
* A faithful port of stentor-client's buildDefaultChatTheme, deliberately: the
|
|
55
|
+
* point of moving it is that onboarding can call this instead of its own copy,
|
|
56
|
+
* and that migration should not restyle every widget created afterwards. A
|
|
57
|
+
* thinner theme would have quietly dropped the CTA, message, input, footer and
|
|
58
|
+
* button styling that new widgets have today.
|
|
47
59
|
*
|
|
48
|
-
*
|
|
49
|
-
* reads on a given background is arithmetic, and getting it wrong ships a
|
|
50
|
-
* widget nobody can read.
|
|
60
|
+
* The one change is how the contrast colour is derived — see below.
|
|
51
61
|
*/
|
|
52
|
-
export declare function buildChatTheme(primaryColor: string): WidgetTheme;
|
|
62
|
+
export declare function buildChatTheme(primaryColor: string, secondaryColor?: string): WidgetTheme;
|
|
@@ -10,7 +10,7 @@ function buildChatWidgetChannel(props) {
|
|
|
10
10
|
// Only a colour whose contrast can actually be computed, so the background
|
|
11
11
|
// and the text on it are always a matched pair rather than one scraped
|
|
12
12
|
// value and one guess.
|
|
13
|
-
const primaryColor = (0, color_1.
|
|
13
|
+
const primaryColor = (0, color_1.usableColorOr)(props.primaryColor, DEFAULT_PRIMARY);
|
|
14
14
|
return {
|
|
15
15
|
type: "chat-widget",
|
|
16
16
|
// MCP by default. The widget runs on a public page, so homeowner mode
|
|
@@ -24,7 +24,7 @@ function buildChatWidgetChannel(props) {
|
|
|
24
24
|
mode: "homeowner"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
-
theme: buildChatTheme(primaryColor),
|
|
27
|
+
theme: buildChatTheme(primaryColor, props.secondaryColor),
|
|
28
28
|
actionBar: buildActionBar({ apiUrl, primaryColor, formWidgetKey, phoneNumber })
|
|
29
29
|
};
|
|
30
30
|
}
|
|
@@ -75,19 +75,49 @@ function buildActionBar(props) {
|
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
*
|
|
78
|
+
* The theme a new chat widget starts with, from the business's own colour.
|
|
79
79
|
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* widget
|
|
80
|
+
* A faithful port of stentor-client's buildDefaultChatTheme, deliberately: the
|
|
81
|
+
* point of moving it is that onboarding can call this instead of its own copy,
|
|
82
|
+
* and that migration should not restyle every widget created afterwards. A
|
|
83
|
+
* thinner theme would have quietly dropped the CTA, message, input, footer and
|
|
84
|
+
* button styling that new widgets have today.
|
|
85
|
+
*
|
|
86
|
+
* The one change is how the contrast colour is derived — see below.
|
|
83
87
|
*/
|
|
84
|
-
function buildChatTheme(primaryColor) {
|
|
85
|
-
const
|
|
88
|
+
function buildChatTheme(primaryColor, secondaryColor) {
|
|
89
|
+
const fontFamily = "RobotoRegular";
|
|
90
|
+
// secondaryColor is the colour of text sitting ON primaryColor — header
|
|
91
|
+
// title, subtitle, footer branding. Left unset it is computed, which is
|
|
92
|
+
// what makes the theme readable against whatever colour was scraped off
|
|
93
|
+
// the business's own site.
|
|
94
|
+
if (!secondaryColor) {
|
|
95
|
+
secondaryColor = (0, color_1.readableTextOn)(primaryColor);
|
|
96
|
+
}
|
|
86
97
|
return {
|
|
87
98
|
zIndex: "10000",
|
|
88
99
|
border: {
|
|
89
100
|
color: primaryColor,
|
|
90
|
-
radius: "10px"
|
|
101
|
+
radius: "10px",
|
|
102
|
+
},
|
|
103
|
+
carousel: {
|
|
104
|
+
button: {
|
|
105
|
+
color: primaryColor,
|
|
106
|
+
},
|
|
107
|
+
subtitle: {
|
|
108
|
+
color: "#979797",
|
|
109
|
+
fontFamily,
|
|
110
|
+
fontSize: "12px",
|
|
111
|
+
fontStyle: "normal",
|
|
112
|
+
fontWeight: "normal",
|
|
113
|
+
},
|
|
114
|
+
title: {
|
|
115
|
+
color: "#000",
|
|
116
|
+
fontFamily,
|
|
117
|
+
fontSize: "14px",
|
|
118
|
+
fontStyle: "normal",
|
|
119
|
+
fontWeight: "bold",
|
|
120
|
+
},
|
|
91
121
|
},
|
|
92
122
|
chatButton: {
|
|
93
123
|
background: primaryColor,
|
|
@@ -95,18 +125,147 @@ function buildChatTheme(primaryColor) {
|
|
|
95
125
|
bottom: "10px",
|
|
96
126
|
left: "10px",
|
|
97
127
|
right: "10px",
|
|
98
|
-
top: "10px"
|
|
99
|
-
}
|
|
128
|
+
top: "10px",
|
|
129
|
+
},
|
|
100
130
|
},
|
|
101
131
|
content: {
|
|
102
|
-
background: "#ffffff"
|
|
132
|
+
background: "#ffffff",
|
|
133
|
+
},
|
|
134
|
+
cta: {
|
|
135
|
+
background: "#e1e2e1",
|
|
136
|
+
text: {
|
|
137
|
+
// Use a dark color that contrasts well with the light grey background
|
|
138
|
+
// instead of primaryColor which may not have sufficient contrast
|
|
139
|
+
color: "#333333",
|
|
140
|
+
fontFamily,
|
|
141
|
+
fontSize: "14px",
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
footer: {
|
|
145
|
+
background: primaryColor,
|
|
146
|
+
border: {
|
|
147
|
+
color: primaryColor,
|
|
148
|
+
radius: "0px",
|
|
149
|
+
width: "0px",
|
|
150
|
+
},
|
|
151
|
+
branding: {
|
|
152
|
+
text: {
|
|
153
|
+
color: "#ffffff",
|
|
154
|
+
fontFamily,
|
|
155
|
+
fontSize: "14px",
|
|
156
|
+
fontWeight: "normal",
|
|
157
|
+
fontStyle: "normal",
|
|
158
|
+
},
|
|
159
|
+
},
|
|
103
160
|
},
|
|
104
161
|
header: {
|
|
105
162
|
background: primaryColor,
|
|
163
|
+
avatarBackground: "transparent",
|
|
164
|
+
border: {
|
|
165
|
+
color: primaryColor,
|
|
166
|
+
radius: "0px",
|
|
167
|
+
width: "0px",
|
|
168
|
+
},
|
|
106
169
|
text: {
|
|
107
|
-
color:
|
|
108
|
-
|
|
109
|
-
|
|
170
|
+
color: secondaryColor,
|
|
171
|
+
fontFamily,
|
|
172
|
+
fontSize: "16px",
|
|
173
|
+
fontWeight: "normal",
|
|
174
|
+
fontStyle: "normal",
|
|
175
|
+
},
|
|
176
|
+
subtitle: {
|
|
177
|
+
color: secondaryColor,
|
|
178
|
+
fontFamily,
|
|
179
|
+
fontSize: "10px",
|
|
180
|
+
fontWeight: "normal",
|
|
181
|
+
fontStyle: "normal",
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
input: {
|
|
185
|
+
background: "#ffffff",
|
|
186
|
+
border: {
|
|
187
|
+
radius: "20px",
|
|
188
|
+
},
|
|
189
|
+
text: {
|
|
190
|
+
color: "#000000",
|
|
191
|
+
fontFamily,
|
|
192
|
+
fontSize: "14px",
|
|
193
|
+
},
|
|
194
|
+
placeholder: {
|
|
195
|
+
color: "#e1e2e1",
|
|
196
|
+
fontFamily,
|
|
197
|
+
fontSize: "14px",
|
|
198
|
+
fontWeight: "normal",
|
|
199
|
+
fontStyle: "normal",
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
textTypingStatus: {
|
|
203
|
+
text: {
|
|
204
|
+
color: "#bfbfbf",
|
|
205
|
+
fontFamily,
|
|
206
|
+
fontSize: "14px",
|
|
207
|
+
fontWeight: "normal",
|
|
208
|
+
fontStyle: "normal",
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
menu: {
|
|
212
|
+
item: {
|
|
213
|
+
height: "24px",
|
|
214
|
+
text: {
|
|
215
|
+
fontSize: "14px",
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
menuButton: {
|
|
220
|
+
color: "#ffffff",
|
|
221
|
+
},
|
|
222
|
+
messages: {
|
|
223
|
+
maxWidth: "400px",
|
|
224
|
+
mine: {
|
|
225
|
+
bubbleColor: "#f2f2f2",
|
|
226
|
+
text: {
|
|
227
|
+
color: "#454545",
|
|
228
|
+
fontFamily,
|
|
229
|
+
fontSize: "18px",
|
|
230
|
+
fontStyle: "normal",
|
|
231
|
+
fontWeight: "normal",
|
|
232
|
+
},
|
|
233
|
+
},
|
|
234
|
+
others: {
|
|
235
|
+
bubbleColor: "#e1e2e1",
|
|
236
|
+
text: {
|
|
237
|
+
color: "#262726",
|
|
238
|
+
fontFamily,
|
|
239
|
+
fontSize: "18px",
|
|
240
|
+
fontStyle: "normal",
|
|
241
|
+
fontWeight: "normal",
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
padding: {
|
|
245
|
+
bottom: "0px",
|
|
246
|
+
left: "20px",
|
|
247
|
+
right: "16px",
|
|
248
|
+
top: "16px",
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
refreshButton: {
|
|
252
|
+
color: secondaryColor,
|
|
253
|
+
},
|
|
254
|
+
minimizeButton: {
|
|
255
|
+
color: secondaryColor,
|
|
256
|
+
},
|
|
257
|
+
cancelButton: {
|
|
258
|
+
color: secondaryColor,
|
|
259
|
+
},
|
|
260
|
+
primaryColor: primaryColor,
|
|
261
|
+
sendButton: {
|
|
262
|
+
color: "#505050",
|
|
263
|
+
width: "20px",
|
|
264
|
+
},
|
|
265
|
+
size: {
|
|
266
|
+
width: "500px",
|
|
267
|
+
height: "700px",
|
|
268
|
+
},
|
|
110
269
|
};
|
|
111
270
|
}
|
|
112
271
|
//# sourceMappingURL=buildChatWidgetChannel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildChatWidgetChannel.js","sourceRoot":"","sources":["../src/buildChatWidgetChannel.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"buildChatWidgetChannel.js","sourceRoot":"","sources":["../src/buildChatWidgetChannel.ts"],"names":[],"mappings":";;AA2DA,wDAuBC;AAqED,wCAwLC;AA5UD,mCAAwD;AAqDxD,qEAAqE;AACrE,MAAM,eAAe,GAAG,SAAS,CAAC;AAElC,SAAgB,sBAAsB,CAAC,KAAkC;IACrE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACpE,2EAA2E;IAC3E,uEAAuE;IACvE,uBAAuB;IACvB,MAAM,YAAY,GAAG,IAAA,qBAAa,EAAC,KAAK,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;IAExE,OAAO;QACH,IAAI,EAAE,aAAa;QACnB,sEAAsE;QACtE,uEAAuE;QACvE,oEAAoE;QACpE,yCAAyC;QACzC,UAAU,EAAE;YACR,IAAI,EAAE,KAAK;YACX,SAAS,EAAE,GAAG,MAAM,IAAI,KAAK,EAAE;YAC/B,GAAG,EAAE;gBACD,IAAI,EA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UAAU,EAAE,QAAQ;iBACvB;aACJ;YACD,MAAM,EAAE;gBACJ,WAAW,EAAE,SAAS;gBACtB,IAAI,EAAE;oBACF,KAAK,EAAE,SAAS;oBAChB,UAAU;oBACV,QAAQ,EAAE,MAAM;oBAChB,SAAS,EAAE,QAAQ;oBACnB,UAAU,EAAE,QAAQ;iBACvB;aACJ;YACD,OAAO,EAAE;gBACL,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,GAAG,EAAE,MAAM;aACd;SACJ;QACD,aAAa,EAAE;YACX,KAAK,EAAE,cAAc;SACxB;QACD,cAAc,EAAE;YACZ,KAAK,EAAE,cAAc;SACxB;QACD,YAAY,EAAE;YACV,KAAK,EAAE,cAAc;SACxB;QACD,YAAY,EAAE,YAAY;QAC1B,UAAU,EAAE;YACR,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,MAAM;SAChB;QACD,IAAI,EAAE;YACF,KAAK,EAAE,OAAO;YACd,MAAM,EAAE,OAAO;SAClB;KACJ,CAAC;AACN,CAAC"}
|
package/lib/color.d.ts
CHANGED
|
@@ -25,6 +25,17 @@ export declare function invertColor(color: string, bw?: boolean): string | undef
|
|
|
25
25
|
* background whose contrast we cannot compute is one we must not use.
|
|
26
26
|
*/
|
|
27
27
|
export declare function isSupportedColor(color: string | undefined): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* The colour to theme with: the one given, or the fallback when we cannot work
|
|
30
|
+
* out what text reads on it.
|
|
31
|
+
*
|
|
32
|
+
* Every builder needs this and each was doing it by hand, which is how the
|
|
33
|
+
* chat widget ended up guarded and the other two not. A background whose
|
|
34
|
+
* contrast cannot be computed is one we must not use — the foreground would be
|
|
35
|
+
* a guess paired with an unknown, and on a dark unparseable colour that is
|
|
36
|
+
* invisible text.
|
|
37
|
+
*/
|
|
38
|
+
export declare function usableColorOr(color: string | undefined, fallback: string): string;
|
|
28
39
|
/**
|
|
29
40
|
* The text colour that will read on this background: black or white, never
|
|
30
41
|
* anything else.
|
|
@@ -41,3 +52,9 @@ export declare function isSupportedColor(color: string | undefined): boolean;
|
|
|
41
52
|
* guessed foreground with an unknown background.
|
|
42
53
|
*/
|
|
43
54
|
export declare function readableTextOn(background: string | undefined): string;
|
|
55
|
+
/**
|
|
56
|
+
* A shade of the input colour, darkened by `amount` percent (negative
|
|
57
|
+
* lightens). Ported alongside the rest so the form widget's theme does not
|
|
58
|
+
* need its own copy of it.
|
|
59
|
+
*/
|
|
60
|
+
export declare function darkenColor(colorIn: string | undefined, amount: number): string | undefined;
|
package/lib/color.js
CHANGED
|
@@ -6,7 +6,9 @@ exports.invertColorHEX = invertColorHEX;
|
|
|
6
6
|
exports.invertColorRgb = invertColorRgb;
|
|
7
7
|
exports.invertColor = invertColor;
|
|
8
8
|
exports.isSupportedColor = isSupportedColor;
|
|
9
|
+
exports.usableColorOr = usableColorOr;
|
|
9
10
|
exports.readableTextOn = readableTextOn;
|
|
11
|
+
exports.darkenColor = darkenColor;
|
|
10
12
|
/**
|
|
11
13
|
* Colour maths for building a widget theme from a business's own branding.
|
|
12
14
|
*
|
|
@@ -115,6 +117,19 @@ function isSupportedColor(color) {
|
|
|
115
117
|
}
|
|
116
118
|
return parseRgb(color) !== null;
|
|
117
119
|
}
|
|
120
|
+
/**
|
|
121
|
+
* The colour to theme with: the one given, or the fallback when we cannot work
|
|
122
|
+
* out what text reads on it.
|
|
123
|
+
*
|
|
124
|
+
* Every builder needs this and each was doing it by hand, which is how the
|
|
125
|
+
* chat widget ended up guarded and the other two not. A background whose
|
|
126
|
+
* contrast cannot be computed is one we must not use — the foreground would be
|
|
127
|
+
* a guess paired with an unknown, and on a dark unparseable colour that is
|
|
128
|
+
* invisible text.
|
|
129
|
+
*/
|
|
130
|
+
function usableColorOr(color, fallback) {
|
|
131
|
+
return isSupportedColor(color) ? color : fallback;
|
|
132
|
+
}
|
|
118
133
|
/**
|
|
119
134
|
* The text colour that will read on this background: black or white, never
|
|
120
135
|
* anything else.
|
|
@@ -154,4 +169,75 @@ function hexToRgb(hex) {
|
|
|
154
169
|
b: parseInt(value.slice(4, 6), 16)
|
|
155
170
|
};
|
|
156
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* A shade of the input colour, darkened by `amount` percent (negative
|
|
174
|
+
* lightens). Ported alongside the rest so the form widget's theme does not
|
|
175
|
+
* need its own copy of it.
|
|
176
|
+
*/
|
|
177
|
+
function darkenColor(colorIn, amount) {
|
|
178
|
+
if (!colorIn) {
|
|
179
|
+
return colorIn;
|
|
180
|
+
}
|
|
181
|
+
let r, g, b, a;
|
|
182
|
+
let colorOut;
|
|
183
|
+
try {
|
|
184
|
+
// Parse the color format
|
|
185
|
+
if (colorIn.startsWith('#')) {
|
|
186
|
+
// Hex format
|
|
187
|
+
const hexMatch = colorIn.match(/\w\w/g);
|
|
188
|
+
if (hexMatch) {
|
|
189
|
+
[r, g, b] = hexMatch.map(x => parseInt(x, 16));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else if (colorIn.startsWith('rgb')) {
|
|
193
|
+
// RGB or RGBA format
|
|
194
|
+
const rgba = parseRgb(colorIn);
|
|
195
|
+
if (rgba) {
|
|
196
|
+
({ r, g, b, a } = rgba);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (r === undefined || g === undefined || b === undefined) {
|
|
200
|
+
console.error(`Unsupported color format: ${colorIn}`);
|
|
201
|
+
return colorIn;
|
|
202
|
+
}
|
|
203
|
+
if (a !== undefined) {
|
|
204
|
+
// Adjust luminance for RGBA
|
|
205
|
+
// Luminance is on the 0-255 scale the channels are, so the clamp
|
|
206
|
+
// has to be too. Bounding it to 0-1 collapsed it to 1 for every
|
|
207
|
+
// real colour, which made the ratio tiny and crushed the result to
|
|
208
|
+
// near-black instead of darkening it: rgba(20, 52, 204, 0.8) at 20%
|
|
209
|
+
// came back rgba(0, 1, 3, 1).
|
|
210
|
+
const luminance = 0.3 * r + 0.59 * g + 0.11 * b;
|
|
211
|
+
let newLuminance = luminance * (1 - amount / 100);
|
|
212
|
+
newLuminance = Math.max(0, Math.min(255, newLuminance));
|
|
213
|
+
const ratio = newLuminance / (luminance || 1); // no division by zero
|
|
214
|
+
r = Math.round(r * ratio);
|
|
215
|
+
g = Math.round(g * ratio);
|
|
216
|
+
b = Math.round(b * ratio);
|
|
217
|
+
// Adjust alpha
|
|
218
|
+
a = a + amount / 100;
|
|
219
|
+
a = Math.max(0, Math.min(1, a)); // within 0 and 1
|
|
220
|
+
colorOut = `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
// Adjust the color for RGB or Hex
|
|
224
|
+
if (amount > 0) {
|
|
225
|
+
r = Math.max(0, r - amount);
|
|
226
|
+
g = Math.max(0, g - amount);
|
|
227
|
+
b = Math.max(0, b - amount);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
amount = Math.abs(amount); // positive for lightening
|
|
231
|
+
r = Math.min(255, r + amount);
|
|
232
|
+
g = Math.min(255, g + amount);
|
|
233
|
+
b = Math.min(255, b + amount);
|
|
234
|
+
}
|
|
235
|
+
colorOut = `#${r.toString(16).padStart(2, '0')}${g.toString(16).padStart(2, '0')}${b.toString(16).padStart(2, '0')}`;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch (e) {
|
|
239
|
+
console.error(`Unsupported color format: ${colorIn} - Error: ${e}`);
|
|
240
|
+
}
|
|
241
|
+
return colorOut;
|
|
242
|
+
}
|
|
157
243
|
//# sourceMappingURL=color.js.map
|
package/lib/color.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.js","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":";AAAA,kCAAkC;;AA4BlC,4BAoBC;AAqBD,wCAsBC;AAGD,wCAYC;AAGD,kCAKC;AASD,4CAWC;AAiBD,wCAWC;
|
|
1
|
+
{"version":3,"file":"color.js","sourceRoot":"","sources":["../src/color.ts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