@ammarkhalidfarooq/dashboard-package 0.6.11 → 0.6.12
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/MetricCard.cjs.js +10 -2
- package/dist/MetricCard.cjs.js.map +1 -1
- package/dist/MetricCard.es.js +10 -2
- package/dist/MetricCard.es.js.map +1 -1
- package/dist/index.cjs.js +10 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +10 -2
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1181,6 +1181,14 @@ var MetricCard$1 = function MetricCard(_ref) {
|
|
|
1181
1181
|
captionSx = _ref$captionSx === void 0 ? {} : _ref$captionSx,
|
|
1182
1182
|
_ref$avatarSx = _ref.avatarSx,
|
|
1183
1183
|
avatarSx = _ref$avatarSx === void 0 ? {} : _ref$avatarSx;
|
|
1184
|
+
var captionText = String(caption !== null && caption !== void 0 ? caption : "");
|
|
1185
|
+
var isPercentCaption = captionText.includes("%");
|
|
1186
|
+
var firstNumberMatch = captionText.match(/-?\d+(\.\d+)?/);
|
|
1187
|
+
var trendValue = firstNumberMatch ? Number(firstNumberMatch[0]) : null;
|
|
1188
|
+
var isNegativeTrend = isPercentCaption && trendValue !== null && trendValue < 0;
|
|
1189
|
+
var isPositiveTrend = isPercentCaption && trendValue !== null && trendValue > 0;
|
|
1190
|
+
var trendPrefix = isNegativeTrend ? "▼ " : isPositiveTrend ? "▲ " : "";
|
|
1191
|
+
var captionColor = captionText.includes("failed") ? "#4F46E5" : error || isNegativeTrend ? "#ef4444" : "#0B8F61";
|
|
1184
1192
|
return /*#__PURE__*/jsxs(Box, {
|
|
1185
1193
|
sx: _objectSpread2({
|
|
1186
1194
|
bgcolor: "#fff",
|
|
@@ -1229,9 +1237,9 @@ var MetricCard$1 = function MetricCard(_ref) {
|
|
|
1229
1237
|
sx: _objectSpread2({
|
|
1230
1238
|
fontSize: 12,
|
|
1231
1239
|
fontWeight: 500,
|
|
1232
|
-
color:
|
|
1240
|
+
color: captionColor
|
|
1233
1241
|
}, captionSx),
|
|
1234
|
-
children:
|
|
1242
|
+
children: "".concat(trendPrefix).concat(captionText)
|
|
1235
1243
|
})]
|
|
1236
1244
|
});
|
|
1237
1245
|
};
|