beem-component 2.1.28 → 2.1.29
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/Dockerfile +4 -2
- package/dist/components/BmSelector/BmSelector.js +16 -2
- package/dist/components/Card_v2/Card.js +16 -2
- package/dist/components/InfoPanel/InfoPanel.js +18 -4
- package/dist/components/ProgressIndicator/ProgressIndicator.js +17 -3
- package/dist/components/SelectionNotice/SelectionNotice.js +17 -3
- package/nginx.conf +26 -12
- package/package.json +1 -1
- package/src/lib/components/BmSelector/BmSelector.js +20 -1
- package/src/lib/components/Card_v2/Card.js +19 -1
- package/src/lib/components/InfoPanel/InfoPanel.js +20 -1
- package/src/lib/components/ProgressIndicator/ProgressIndicator.js +19 -1
- package/src/lib/components/SelectionNotice/SelectionNotice.js +19 -1
package/Dockerfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM node:
|
|
1
|
+
FROM node:16 AS build
|
|
2
2
|
|
|
3
3
|
WORKDIR /app
|
|
4
4
|
|
|
@@ -23,7 +23,9 @@ COPY --from=build /app/storybook-static /usr/share/nginx/html
|
|
|
23
23
|
|
|
24
24
|
RUN rm /etc/nginx/conf.d/default.conf
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
# Replace the default NGINX config with your custom one
|
|
27
|
+
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
28
|
+
|
|
27
29
|
|
|
28
30
|
EXPOSE 3000
|
|
29
31
|
|
|
@@ -6,8 +6,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var _convertToRGBA = _interopRequireDefault(require("../../../util/convertToRGBA"));
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const hexToRgba = function (hex) {
|
|
11
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
|
|
12
|
+
try {
|
|
13
|
+
const normalizedHex = hex === null || hex === void 0 ? void 0 : hex.replace('#', '');
|
|
14
|
+
if (!normalizedHex || normalizedHex.length !== 6 || !/^[0-9a-fA-F]{6}$/.test(normalizedHex)) {
|
|
15
|
+
throw new Error('Invalid hex');
|
|
16
|
+
}
|
|
17
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
18
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
19
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
20
|
+
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return "rgba(0, 0, 0, ".concat(opacity, ")");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
11
25
|
const CustomRadio = _styledComponents.default.span.withConfig({
|
|
12
26
|
displayName: "BmSelector__CustomRadio"
|
|
13
27
|
})(["display:inline-block;width:0.2143rem;height:0.2143rem;border-radius:714.2143rem;transition:all 0.1s ease-in-out;flex-shrink:0;", " @media (max-width:42.8571rem){width:0.0714rem;height:0.0714rem;}"], _ref => {
|
|
@@ -33,7 +47,7 @@ const TimeSlotCard = _styledComponents.default.div.withConfig({
|
|
|
33
47
|
selected,
|
|
34
48
|
themeColor
|
|
35
49
|
} = _ref3;
|
|
36
|
-
return selected ? (
|
|
50
|
+
return selected ? hexToRgba(themeColor, 0.08) : 'transparent';
|
|
37
51
|
}, _ref4 => {
|
|
38
52
|
let {
|
|
39
53
|
themeColor
|
|
@@ -6,20 +6,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.BmCardv2 = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var _convertToRGBA = _interopRequireDefault(require("../../../util/convertToRGBA"));
|
|
10
9
|
const _excluded = ["className", "children", "borderColor", "borderWidth"];
|
|
11
10
|
/* eslint-disable func-style */
|
|
12
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
12
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
14
13
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
15
14
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
15
|
+
const hexToRgba = function (hex) {
|
|
16
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
|
|
17
|
+
try {
|
|
18
|
+
const normalizedHex = hex === null || hex === void 0 ? void 0 : hex.replace('#', '');
|
|
19
|
+
if (!normalizedHex || normalizedHex.length !== 6 || !/^[0-9a-fA-F]{6}$/.test(normalizedHex)) {
|
|
20
|
+
throw new Error('Invalid hex');
|
|
21
|
+
}
|
|
22
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
23
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
24
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
25
|
+
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return "rgba(0, 0, 0, ".concat(opacity, ")");
|
|
28
|
+
}
|
|
29
|
+
};
|
|
16
30
|
const StyledCard = _styledComponents.default.div.withConfig({
|
|
17
31
|
displayName: "Card__StyledCard"
|
|
18
32
|
})(["background-color:var(--card,#fff);color:var(--card-foreground,#000);display:flex;flex-direction:column;gap:1.5rem;border-radius:0.75rem;border-style:solid;border-color:", ";border-width:", ";width:100%;"], _ref => {
|
|
19
33
|
let {
|
|
20
34
|
borderColor
|
|
21
35
|
} = _ref;
|
|
22
|
-
return (
|
|
36
|
+
return hexToRgba(borderColor || '#ccc', 0.1);
|
|
23
37
|
}, _ref2 => {
|
|
24
38
|
let {
|
|
25
39
|
borderWidth
|
|
@@ -6,8 +6,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var _convertToRGBA = _interopRequireDefault(require("../../../util/convertToRGBA"));
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const hexToRgba = function (hex) {
|
|
11
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
|
|
12
|
+
try {
|
|
13
|
+
const normalizedHex = hex === null || hex === void 0 ? void 0 : hex.replace('#', '');
|
|
14
|
+
if (!normalizedHex || normalizedHex.length !== 6 || !/^[0-9a-fA-F]{6}$/.test(normalizedHex)) {
|
|
15
|
+
throw new Error('Invalid hex');
|
|
16
|
+
}
|
|
17
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
18
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
19
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
20
|
+
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return "rgba(0, 0, 0, ".concat(opacity, ")");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
11
25
|
const Panel = _styledComponents.default.div.withConfig({
|
|
12
26
|
displayName: "InfoPanel__Panel"
|
|
13
27
|
})(["border:0.0714rem solid rgba(51,177,186,0.1);border-radius:0.5rem;overflow:hidden;"]);
|
|
@@ -21,7 +35,7 @@ const IconBox = _styledComponents.default.div.withConfig({
|
|
|
21
35
|
iconBackgroundColor,
|
|
22
36
|
iconColor
|
|
23
37
|
} = _ref;
|
|
24
|
-
return iconBackgroundColor && (
|
|
38
|
+
return iconBackgroundColor && hexToRgba(iconColor, 0.1);
|
|
25
39
|
}, _ref2 => {
|
|
26
40
|
let {
|
|
27
41
|
iconColor
|
|
@@ -45,7 +59,7 @@ const SummarySubtitle = _styledComponents.default.p.withConfig({
|
|
|
45
59
|
let {
|
|
46
60
|
textColor
|
|
47
61
|
} = _ref4;
|
|
48
|
-
return (
|
|
62
|
+
return hexToRgba(textColor || '#000000', 0.6);
|
|
49
63
|
});
|
|
50
64
|
const SectionContainer = _styledComponents.default.div.withConfig({
|
|
51
65
|
displayName: "InfoPanel__SectionContainer"
|
|
@@ -53,7 +67,7 @@ const SectionContainer = _styledComponents.default.div.withConfig({
|
|
|
53
67
|
let {
|
|
54
68
|
backgroundColor
|
|
55
69
|
} = _ref5;
|
|
56
|
-
return backgroundColor && "\n background-color: ".concat((
|
|
70
|
+
return backgroundColor && "\n background-color: ".concat(hexToRgba(backgroundColor, 0.05), ";\n ");
|
|
57
71
|
});
|
|
58
72
|
const SectionTitle = _styledComponents.default.h3.withConfig({
|
|
59
73
|
displayName: "InfoPanel__SectionTitle"
|
|
@@ -6,8 +6,22 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var _convertToRGBA = _interopRequireDefault(require("../../../util/convertToRGBA"));
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const hexToRgba = function (hex) {
|
|
11
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
|
|
12
|
+
try {
|
|
13
|
+
const normalizedHex = hex === null || hex === void 0 ? void 0 : hex.replace('#', '');
|
|
14
|
+
if (!normalizedHex || normalizedHex.length !== 6 || !/^[0-9a-fA-F]{6}$/.test(normalizedHex)) {
|
|
15
|
+
throw new Error('Invalid hex');
|
|
16
|
+
}
|
|
17
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
18
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
19
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
20
|
+
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return "rgba(0, 0, 0, ".concat(opacity, ")");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
11
25
|
const Container = _styledComponents.default.div.withConfig({
|
|
12
26
|
displayName: "ProgressIndicator__Container"
|
|
13
27
|
})(["margin-bottom:1rem;--primary-color:", ";--primary-light:", ";--primary-lighter:", ";--muted-color:", ";--muted-foreground-color:", ";@media (min-width:45.7143rem){margin-bottom:1.5rem;}"], _ref => {
|
|
@@ -19,12 +33,12 @@ const Container = _styledComponents.default.div.withConfig({
|
|
|
19
33
|
let {
|
|
20
34
|
primaryColor
|
|
21
35
|
} = _ref2;
|
|
22
|
-
return (
|
|
36
|
+
return hexToRgba(primaryColor, 0.2);
|
|
23
37
|
}, _ref3 => {
|
|
24
38
|
let {
|
|
25
39
|
primaryColor
|
|
26
40
|
} = _ref3;
|
|
27
|
-
return (
|
|
41
|
+
return hexToRgba(primaryColor, 0.4);
|
|
28
42
|
}, _ref4 => {
|
|
29
43
|
let {
|
|
30
44
|
mutedColor
|
|
@@ -6,20 +6,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
9
|
-
var _convertToRGBA = _interopRequireDefault(require("../../../util/convertToRGBA"));
|
|
10
9
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const hexToRgba = function (hex) {
|
|
11
|
+
let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.6;
|
|
12
|
+
try {
|
|
13
|
+
const normalizedHex = hex === null || hex === void 0 ? void 0 : hex.replace('#', '');
|
|
14
|
+
if (!normalizedHex || normalizedHex.length !== 6 || !/^[0-9a-fA-F]{6}$/.test(normalizedHex)) {
|
|
15
|
+
throw new Error('Invalid hex');
|
|
16
|
+
}
|
|
17
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
18
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
19
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
20
|
+
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return "rgba(0, 0, 0, ".concat(opacity, ")");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
11
25
|
const Container = _styledComponents.default.div.withConfig({
|
|
12
26
|
displayName: "SelectionNotice__Container"
|
|
13
27
|
})(["background-color:", ";border:0.0714rem solid ", ";padding:0.5rem;border-radius:0.5rem;text-align:center;animation:fadeIn 0.3s ease-in;@media (min-width:45.7143rem){padding:0.75rem;}@keyframes fadeIn{from{opacity:0;}to{opacity:1;}}"], _ref => {
|
|
14
28
|
let {
|
|
15
29
|
color
|
|
16
30
|
} = _ref;
|
|
17
|
-
return (
|
|
31
|
+
return hexToRgba(color || '#33B1BA', 0.05);
|
|
18
32
|
}, _ref2 => {
|
|
19
33
|
let {
|
|
20
34
|
color
|
|
21
35
|
} = _ref2;
|
|
22
|
-
return (
|
|
36
|
+
return hexToRgba(color || '#33B1BA', 0.2);
|
|
23
37
|
});
|
|
24
38
|
const Text = _styledComponents.default.p.withConfig({
|
|
25
39
|
displayName: "SelectionNotice__Text"
|
package/nginx.conf
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
|
-
server {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# server {
|
|
2
|
+
# listen 8085;
|
|
3
|
+
# root /usr/share/nginx/html;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# index index.html index.htm;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
# include /etc/nginx/mime.types;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
# gzip on;
|
|
10
|
+
# gzip_min_length 1000;
|
|
11
|
+
# gzip_proxied expired no-cache no-store private auth;
|
|
12
|
+
# gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
# location / {
|
|
15
|
+
# try_files $uri $uri/ /index.html;
|
|
16
|
+
# }
|
|
17
|
+
# }
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# nginx.conf
|
|
21
|
+
server {
|
|
22
|
+
listen 3000;
|
|
23
|
+
server_name localhost;
|
|
24
|
+
|
|
25
|
+
root /usr/share/nginx/html;
|
|
26
|
+
index index.html;
|
|
27
|
+
|
|
28
|
+
location / {
|
|
29
|
+
try_files $uri $uri/ /index.html;
|
|
30
|
+
}
|
|
17
31
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const hexToRgba = (hex, opacity = 0.6) => {
|
|
5
|
+
try {
|
|
6
|
+
const normalizedHex = hex?.replace('#', '');
|
|
7
|
+
if (
|
|
8
|
+
!normalizedHex ||
|
|
9
|
+
normalizedHex.length !== 6 ||
|
|
10
|
+
!/^[0-9a-fA-F]{6}$/.test(normalizedHex)
|
|
11
|
+
) {
|
|
12
|
+
throw new Error('Invalid hex');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
16
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
17
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
18
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return `rgba(0, 0, 0, ${opacity})`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
4
23
|
|
|
5
24
|
const CustomRadio = styled.span`
|
|
6
25
|
display: inline-block;
|
|
@@ -2,7 +2,25 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import styled from 'styled-components';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const hexToRgba = (hex, opacity = 0.6) => {
|
|
6
|
+
try {
|
|
7
|
+
const normalizedHex = hex?.replace('#', '');
|
|
8
|
+
if (
|
|
9
|
+
!normalizedHex ||
|
|
10
|
+
normalizedHex.length !== 6 ||
|
|
11
|
+
!/^[0-9a-fA-F]{6}$/.test(normalizedHex)
|
|
12
|
+
) {
|
|
13
|
+
throw new Error('Invalid hex');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
17
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
18
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
19
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return `rgba(0, 0, 0, ${opacity})`;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
6
24
|
|
|
7
25
|
const StyledCard = styled.div`
|
|
8
26
|
background-color: var(--card, #fff);
|
|
@@ -1,6 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const hexToRgba = (hex, opacity = 0.6) => {
|
|
5
|
+
try {
|
|
6
|
+
const normalizedHex = hex?.replace('#', '');
|
|
7
|
+
if (
|
|
8
|
+
!normalizedHex ||
|
|
9
|
+
normalizedHex.length !== 6 ||
|
|
10
|
+
!/^[0-9a-fA-F]{6}$/.test(normalizedHex)
|
|
11
|
+
) {
|
|
12
|
+
throw new Error('Invalid hex');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
16
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
17
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
18
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return `rgba(0, 0, 0, ${opacity})`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
4
23
|
|
|
5
24
|
const Panel = styled.div`
|
|
6
25
|
border: 0.0714rem solid rgba(51, 177, 186, 0.1);
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const hexToRgba = (hex, opacity = 0.6) => {
|
|
5
|
+
try {
|
|
6
|
+
const normalizedHex = hex?.replace('#', '');
|
|
7
|
+
if (
|
|
8
|
+
!normalizedHex ||
|
|
9
|
+
normalizedHex.length !== 6 ||
|
|
10
|
+
!/^[0-9a-fA-F]{6}$/.test(normalizedHex)
|
|
11
|
+
) {
|
|
12
|
+
throw new Error('Invalid hex');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
16
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
17
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
18
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return `rgba(0, 0, 0, ${opacity})`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
5
23
|
|
|
6
24
|
const Container = styled.div`
|
|
7
25
|
margin-bottom: 1rem;
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
const hexToRgba = (hex, opacity = 0.6) => {
|
|
5
|
+
try {
|
|
6
|
+
const normalizedHex = hex?.replace('#', '');
|
|
7
|
+
if (
|
|
8
|
+
!normalizedHex ||
|
|
9
|
+
normalizedHex.length !== 6 ||
|
|
10
|
+
!/^[0-9a-fA-F]{6}$/.test(normalizedHex)
|
|
11
|
+
) {
|
|
12
|
+
throw new Error('Invalid hex');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const r = parseInt(normalizedHex.slice(0, 2), 16);
|
|
16
|
+
const g = parseInt(normalizedHex.slice(2, 4), 16);
|
|
17
|
+
const b = parseInt(normalizedHex.slice(4, 6), 16);
|
|
18
|
+
return `rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return `rgba(0, 0, 0, ${opacity})`;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
5
23
|
|
|
6
24
|
const Container = styled.div`
|
|
7
25
|
background-color: ${({ color }) => hexToRgba(color || '#33B1BA', 0.05)};
|