@growth-operations/ui-shared 1.19.0 → 1.19.1

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": "@growth-operations/ui-shared",
3
- "version": "1.19.0",
3
+ "version": "1.19.1",
4
4
  "description": "Shared HubSpot UI-extension modules (Home, Billing) for Growth Operations apps.",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -25,7 +25,10 @@ import { resolveCreditMeter } from "../lib/creditDisplay";
25
25
  // used-of-granted bar would drift to permanently-near-full over multiple
26
26
  // purchases; the remaining level refills on purchase and drains on
27
27
  // spend), colored by ITS OWN level: success above 50% full, warning at
28
- // 20–50%, danger at <=20% (view.bankBarVariant).
28
+ // <=50% (view.bankBarVariant). NO danger on this bar — HubSpot's
29
+ // ProgressBar paints the whole track red in danger, so a low gauge
30
+ // would read as FULL; at <=20% a warning "Running low" StatusTag rides
31
+ // the line instead (bank.bankLow).
29
32
  // Each bar colors by its own fill, NOT the account's threshold state — the
30
33
  // StatusTag keeps the account-state colors. Hosts whose backend predates
31
34
  // top_up_bank_granted degrade gracefully: the bank renders as a text-only
@@ -72,10 +75,15 @@ export function CreditMeter({ entitlement, creditMeter }) {
72
75
  // Bank — level gauge over the granted total (refills on
73
76
  // purchase, drains on spend; never expires).
74
77
  <Flex direction="column" gap="extra-small">
75
- <Text>
76
- Additional credits (never expire): {bank.bankRemaining} of{" "}
77
- {bank.bankGranted} left
78
- </Text>
78
+ <Flex direction="row" gap="extra-small" align="center">
79
+ <Text>
80
+ Additional credits (never expire): {bank.bankRemaining} of{" "}
81
+ {bank.bankGranted} left
82
+ </Text>
83
+ {bank.bankLow && (
84
+ <StatusTag variant="warning">Running low</StatusTag>
85
+ )}
86
+ </Flex>
79
87
  <ProgressBar
80
88
  title={`${bank.bankRemaining} of ${bank.bankGranted} left`}
81
89
  value={bank.bankRemaining}
@@ -70,9 +70,12 @@ export function hasTopUpBank(ent) {
70
70
  // pool (DEPLETION meter, value = poolUsed of poolGrant):
71
71
  // success when used < 80%, warning at >= 80%, danger at >= 95%.
72
72
  // bank (LEVEL gauge, value = bankRemaining of bankGranted):
73
- // success above 50% full, warning at 20–50%, danger at <= 20%
74
- // ("running out") — a draining bank is warning-worthy even though it
75
- // never expires.
73
+ // success above 50% full, warning at <= 50%. NO danger variant:
74
+ // HubSpot's ProgressBar paints the WHOLE TRACK red in danger (not just
75
+ // the filled portion), so a low level gauge would read as a full bar
76
+ // (caught in Jasper's 2026-10-04 screenshot review). Urgency at <= 20%
77
+ // rides the "Running low" tag (bank.bankLow) instead of the bar color.
78
+ // danger stays on the pool bar, where near-full is the truth.
76
79
  function poolBarVariantFor(poolUsed, poolGrant) {
77
80
  if (!(poolGrant > 0)) return "success"; // no grant: nothing to deplete
78
81
  if (poolUsed * 100 >= 95 * poolGrant) return "danger";
@@ -82,7 +85,6 @@ function poolBarVariantFor(poolUsed, poolGrant) {
82
85
 
83
86
  function bankBarVariantFor(bankRemaining, bankGranted) {
84
87
  if (!(bankGranted > 0)) return "success"; // degraded text-only line renders no bar
85
- if (bankRemaining * 100 <= 20 * bankGranted) return "danger";
86
88
  if (bankRemaining * 100 <= 50 * bankGranted) return "warning";
87
89
  return "success";
88
90
  }
@@ -143,6 +145,10 @@ export function resolveCreditMeter(entitlement, creditMeter) {
143
145
  poolRemaining,
144
146
  poolUsed: poolGrant - poolRemaining,
145
147
  };
148
+ // "Running low" tag at <= 20% of the granted total (the bar itself caps
149
+ // at warning — see the header block). False when the total is unknown.
150
+ bank.bankLow =
151
+ bank.bankGranted > 0 && bankRemaining * 100 <= 20 * bank.bankGranted;
146
152
  }
147
153
 
148
154
  let tagVariant;