@sensiblestats/widget-react 0.7.1 → 0.7.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @sensiblestats/widget-react
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Redesign the betting insight card for clarity. The market/selection is now the visual hero, the odds token is unmistakable (legible `ODDS` label + larger value, boxed and tinted). Stats and scope chips are collapsed by default behind a `Show stats` toggle — the reason-to-bet prose carries the justification, and the numbers are one tap away. When expanded, all stat rows show at once (the old three-row `Show N more` cap is removed) and the `This League / All comps / H2H` scopes render as a segmented control. Add to slip stays visible whether stats are open or closed. Adds `showStats` / `hideStats` UI strings (en + tr) to `UiConfig`.
8
+
3
9
  ## 0.7.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -53,6 +53,8 @@ var STRINGS = {
53
53
  retry: "Retry",
54
54
  showLess: "Show less",
55
55
  showMore: (n) => `Show ${n} more`,
56
+ showStats: "Show stats",
57
+ hideStats: "Hide stats",
56
58
  oddsLabel: "Odds",
57
59
  liveLabel: "Live",
58
60
  addToSlip: "Add to slip",
@@ -77,6 +79,8 @@ var STRINGS = {
77
79
  retry: "Tekrar dene",
78
80
  showLess: "Daha az g\xF6ster",
79
81
  showMore: (n) => `${n} tane daha g\xF6ster`,
82
+ showStats: "\u0130statistikleri g\xF6ster",
83
+ hideStats: "\u0130statistikleri gizle",
80
84
  oddsLabel: "Oran",
81
85
  liveLabel: "Canl\u0131",
82
86
  addToSlip: "Kupona ekle",
@@ -118,6 +122,8 @@ function normalizeUi(cfg) {
118
122
  retry: strings.retry,
119
123
  showLess: strings.showLess,
120
124
  showMore: strings.showMore,
125
+ showStats: strings.showStats,
126
+ hideStats: strings.hideStats,
121
127
  oddsLabel: strings.oddsLabel,
122
128
  liveLabel: strings.liveLabel,
123
129
  addToSlip: strings.addToSlip,
@@ -609,26 +615,40 @@ function AddToSlipButton({ it, slip, ui }) {
609
615
 
610
616
  // src/components/BettingInsightList.tsx
611
617
  var import_jsx_runtime9 = require("react/jsx-runtime");
612
- var MAX_ROWS = 3;
613
- function StatRows({ stats, ui }) {
614
- const [expanded, setExpanded] = (0, import_react5.useState)(false);
615
- const shown = expanded ? stats : stats.slice(0, MAX_ROWS);
616
- const overflow = stats.length - MAX_ROWS;
617
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ss-w-bi-rows", children: [
618
- shown.map((s) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ss-w-bi-row", children: [
619
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ss-w-bi-row-lbl", children: s.label }),
620
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ss-w-bi-row-dots", "aria-hidden": "true" }),
621
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ss-w-bi-row-num", children: s.value })
622
- ] }, `${s.label}:${s.value}`)),
623
- overflow > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: "ss-w-bi-more", onClick: () => setExpanded((v) => !v), children: expanded ? ui?.showLess ?? "Show less" : (ui?.showMore ?? ((n) => `Show ${n} more`))(overflow) }) : null
624
- ] });
618
+ function StatRows({ stats }) {
619
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "ss-w-bi-rows", children: stats.map((s) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ss-w-bi-row", children: [
620
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ss-w-bi-row-lbl", children: s.label }),
621
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "ss-w-bi-row-num", children: s.value })
622
+ ] }, `${s.label}:${s.value}`)) });
625
623
  }
626
- function ScopedStats({ scopes, ui }) {
624
+ function ScopedStats({ scopes }) {
627
625
  const [active, setActive] = (0, import_react5.useState)(0);
628
626
  const current = scopes[active] ?? scopes[0] ?? { key: "", label: "", stats: [] };
629
627
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ss-w-bi-scoped", children: [
630
628
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "ss-w-bi-scopes", role: "group", children: scopes.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { type: "button", className: "ss-w-bi-chip", "aria-pressed": i === active, onClick: () => setActive(i), children: s.label }, s.key)) }),
631
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StatRows, { stats: current.stats, ui }, current.key)
629
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StatRows, { stats: current.stats }, current.key)
630
+ ] });
631
+ }
632
+ function StatsDisclosure({ it, ui }) {
633
+ const [open, setOpen] = (0, import_react5.useState)(false);
634
+ const hasScopes = !!it.scopes && it.scopes.length >= 2;
635
+ const hasStats = hasScopes || it.stats.length > 0;
636
+ if (!hasStats) return null;
637
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "ss-w-bi-stats", children: [
638
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
639
+ "button",
640
+ {
641
+ type: "button",
642
+ className: "ss-w-bi-toggle",
643
+ "aria-expanded": open,
644
+ onClick: () => setOpen((v) => !v),
645
+ children: [
646
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { children: open ? ui?.hideStats ?? "Hide stats" : ui?.showStats ?? "Show stats" }),
647
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: `ss-w-bi-chev${open ? " ss-w-bi-chev-up" : ""}`, "aria-hidden": "true" })
648
+ ]
649
+ }
650
+ ),
651
+ open ? hasScopes ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ScopedStats, { scopes: it.scopes }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StatRows, { stats: it.stats }) : null
632
652
  ] });
633
653
  }
634
654
  function InsightCard({ it, ui, slip }) {
@@ -654,7 +674,7 @@ function InsightCard({ it, ui, slip }) {
654
674
  ] }) : null
655
675
  ] }),
656
676
  it.text ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "ss-w-bi-text", children: it.text }) : null,
657
- it.scopes && it.scopes.length >= 2 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ScopedStats, { scopes: it.scopes, ui }) : it.stats.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StatRows, { stats: it.stats, ui }) : null,
677
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(StatsDisclosure, { it, ui }),
658
678
  it.disclaimer ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "ss-w-bi-disc", children: it.disclaimer }) : null,
659
679
  /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AddToSlipButton, { it, slip, ui })
660
680
  ] });
@@ -913,27 +933,29 @@ var WIDGET_CSS = `.ss-w-root { all: revert; }
913
933
  .ss-w-bi-live { font-size: 8.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: #c0392b; border-radius: 4px; padding: 1px 5px; display: inline-flex; align-items: center; gap: 4px; flex: none; }
914
934
  .ss-w-bi-live-dot { width: 5px; height: 5px; border-radius: 50%; background: #fff; }
915
935
  .ss-w-bi-head { display: flex; align-items: flex-start; gap: 10px; }
916
- .ss-w-bi-mkt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
917
- .ss-w-bi-market { font-size: 13px; font-weight: 660; line-height: 1.3; color: var(--ss-w-ink); }
918
- .ss-w-bi-sel { font-size: 11px; line-height: 1.3; color: var(--ss-w-faint); }
919
- .ss-w-bi-odds { margin-left: auto; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; background: color-mix(in srgb, var(--ss-w-accent) 12%, var(--ss-w-panel)); border: 1px solid color-mix(in srgb, var(--ss-w-accent) 24%, var(--ss-w-line)); border-radius: 8px; padding: 3px 9px; min-width: 56px; }
920
- .ss-w-bi-odds-cap { font-size: 8px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--ss-w-faint); }
921
- .ss-w-bi-odds b { font-size: 15px; font-family: ui-monospace, monospace; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ss-w-accent); line-height: 1.15; }
936
+ .ss-w-bi-mkt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
937
+ .ss-w-bi-market { font-size: 15px; font-weight: 700; line-height: 1.25; color: var(--ss-w-ink); }
938
+ .ss-w-bi-sel { font-size: 12px; line-height: 1.3; color: var(--ss-w-faint); }
939
+ .ss-w-bi-odds { margin-left: auto; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 1px; background: color-mix(in srgb, var(--ss-w-accent) 12%, var(--ss-w-panel)); border: 1px solid color-mix(in srgb, var(--ss-w-accent) 30%, var(--ss-w-line)); border-radius: 10px; padding: 4px 11px; min-width: 62px; }
940
+ .ss-w-bi-odds-cap { font-size: 9px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ss-w-faint); }
941
+ .ss-w-bi-odds b { font-size: 19px; font-family: ui-monospace, monospace; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ss-w-accent); line-height: 1.1; }
922
942
  .ss-w-bi-book { font-size: 9.5px; color: var(--ss-w-faint); }
923
- .ss-w-bi-text { font-size: 12px; color: var(--ss-w-ink); }
943
+ .ss-w-bi-text { font-size: 12px; line-height: 1.45; color: var(--ss-w-ink); }
944
+ .ss-w-bi-stats { display: flex; flex-direction: column; gap: 8px; }
945
+ .ss-w-bi-toggle { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; background: none; border: none; color: var(--ss-w-accent); font: inherit; font-size: 11.5px; font-weight: 600; padding: 2px 0; cursor: pointer; }
946
+ .ss-w-bi-toggle:hover { text-decoration: underline; }
947
+ .ss-w-bi-chev { width: 7px; height: 7px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .15s ease; }
948
+ .ss-w-bi-chev-up { transform: translateY(1px) rotate(-135deg); }
924
949
  .ss-w-bi-rows { display: flex; flex-direction: column; }
925
- .ss-w-bi-row { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-top: 1px solid var(--ss-w-line); }
950
+ .ss-w-bi-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--ss-w-line); }
926
951
  .ss-w-bi-row:first-child { border-top: none; }
927
- .ss-w-bi-row-lbl { font-size: 11px; color: var(--ss-w-faint); min-width: 0; }
928
- .ss-w-bi-row-dots { flex: 1; border-bottom: 1px dotted var(--ss-w-line); transform: translateY(-3px); min-width: 12px; }
929
- .ss-w-bi-row-num { font-family: ui-monospace, monospace; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 12.5px; flex: none; color: var(--ss-w-ink); }
930
- .ss-w-bi-more { align-self: flex-start; background: none; border: none; color: var(--ss-w-accent); font: inherit; font-size: 11px; font-weight: 560; padding: 2px 0; cursor: pointer; }
931
- .ss-w-bi-more:hover { text-decoration: underline; }
952
+ .ss-w-bi-row-lbl { font-size: 11.5px; color: var(--ss-w-faint); min-width: 0; }
953
+ .ss-w-bi-row-num { font-family: ui-monospace, monospace; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; flex: none; color: var(--ss-w-ink); }
932
954
  .ss-w-bi-disc { font-size: 10px; font-style: italic; color: var(--ss-w-faint); }
933
- .ss-w-bi-scoped { display: flex; flex-direction: column; gap: 6px; }
934
- .ss-w-bi-scopes { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
935
- .ss-w-bi-chip { font-size: 11px; font-weight: 550; border: 1px solid var(--ss-w-line); border-radius: 14px; padding: 3px 10px; color: var(--ss-w-ink); background: var(--ss-w-bubble); cursor: pointer; }
936
- .ss-w-bi-chip[aria-pressed="true"] { color: #fff; background: var(--ss-w-accent); border-color: var(--ss-w-accent); }
955
+ .ss-w-bi-scoped { display: flex; flex-direction: column; gap: 8px; }
956
+ .ss-w-bi-scopes { display: inline-flex; align-items: center; gap: 2px; flex-wrap: wrap; align-self: flex-start; background: var(--ss-w-bubble); border: 1px solid var(--ss-w-line); border-radius: 9px; padding: 2px; }
957
+ .ss-w-bi-chip { font-size: 11px; font-weight: 600; border: none; border-radius: 7px; padding: 4px 10px; color: var(--ss-w-faint); background: none; cursor: pointer; }
958
+ .ss-w-bi-chip[aria-pressed="true"] { color: var(--ss-w-ink); background: var(--ss-w-panel); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
937
959
 
938
960
  /* action buttons */
939
961
  .ss-w-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }