@sensiblestats/widget-react 0.61.1 → 0.61.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.61.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Games: a provider placeholder photo (Sportmonks `placeholder.png`) now shows the player's initials or the crest shield instead of a grey silhouette.
8
+
3
9
  ## 0.61.1
4
10
 
5
11
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -4988,13 +4988,16 @@ function initialsOf(name) {
4988
4988
  if (parts.length === 1 || !last) return first.slice(0, 2).toUpperCase();
4989
4989
  return ((first[0] ?? "") + (last[0] ?? "")).toUpperCase();
4990
4990
  }
4991
+ function isPlaceholderImage(url) {
4992
+ return !!url && /\/placeholder\.(png|jpe?g|svg|webp)(\?|$)/i.test(url);
4993
+ }
4991
4994
  function PlayerAvatar({
4992
4995
  name,
4993
4996
  imagePath,
4994
4997
  className
4995
4998
  }) {
4996
4999
  const [failed, setFailed] = (0, import_react30.useState)(false);
4997
- const showImage = Boolean(imagePath) && !failed;
5000
+ const showImage = Boolean(imagePath) && !isPlaceholderImage(imagePath) && !failed;
4998
5001
  return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className, "aria-hidden": "true", children: showImage ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("img", { src: imagePath, alt: "", loading: "lazy", onError: () => setFailed(true) }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { className: "ss-w-av-initials", children: initialsOf(name) }) });
4999
5002
  }
5000
5003
 
@@ -5491,7 +5494,7 @@ var import_react32 = require("react");
5491
5494
  var import_jsx_runtime69 = require("react/jsx-runtime");
5492
5495
  function CrestShield({ src, name, size = 28 }) {
5493
5496
  const [failed, setFailed] = (0, import_react32.useState)(false);
5494
- if (src && !failed) {
5497
+ if (src && !isPlaceholderImage(src) && !failed) {
5495
5498
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("img", { className: "ss-g-crest", src, alt: name, width: size, height: size, loading: "lazy", onError: () => setFailed(true) });
5496
5499
  }
5497
5500
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("svg", { className: "ss-g-crest ss-g-crest--ph", width: size, height: size * 32 / 28, viewBox: "0 0 28 32", role: "img", "aria-label": name, children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("path", { d: "M2 3h24v12c0 9-6 14-12 17C8 29 2 24 2 15z", fill: "currentColor" }) });