@deriv-web-design/ui 0.1.32 → 0.1.33
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/index.d.mts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +30 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1866,15 +1866,39 @@ var Wordmark = () => /* @__PURE__ */ jsxs21(
|
|
|
1866
1866
|
]
|
|
1867
1867
|
}
|
|
1868
1868
|
);
|
|
1869
|
-
var
|
|
1869
|
+
var DEFAULT_TRUSTPILOT_TEXT = "Deriv scores {score} out of 5 based on {reviewCount} reviews";
|
|
1870
|
+
var formatCount = (value, locale) => typeof value === "number" ? new Intl.NumberFormat(locale).format(value) : value;
|
|
1871
|
+
var formatScore = (value, locale) => new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(value);
|
|
1872
|
+
var PLACEHOLDER = /(\{score\}|\{reviewCount\})/g;
|
|
1873
|
+
function renderTemplate(template, values) {
|
|
1874
|
+
return template.split(PLACEHOLDER).map((part, i) => {
|
|
1875
|
+
if (part === "{score}") {
|
|
1876
|
+
return /* @__PURE__ */ jsx23("span", { className: "hero__trustpilot-text-score", children: values.score }, i);
|
|
1877
|
+
}
|
|
1878
|
+
if (part === "{reviewCount}") {
|
|
1879
|
+
return /* @__PURE__ */ jsx23("span", { className: "hero__trustpilot-text-count", children: values.reviewCount }, i);
|
|
1880
|
+
}
|
|
1881
|
+
return part;
|
|
1882
|
+
});
|
|
1883
|
+
}
|
|
1884
|
+
function fillTemplate(template, values) {
|
|
1885
|
+
return template.replace("{score}", values.score).replace("{reviewCount}", values.reviewCount);
|
|
1886
|
+
}
|
|
1870
1887
|
var HeroTrustpilot = ({
|
|
1871
1888
|
score,
|
|
1872
1889
|
reviewCount,
|
|
1873
1890
|
href = DEFAULT_TRUSTPILOT_URL,
|
|
1874
|
-
|
|
1891
|
+
text,
|
|
1892
|
+
label,
|
|
1893
|
+
locale = "en-US",
|
|
1894
|
+
ariaLabel
|
|
1875
1895
|
}) => {
|
|
1876
|
-
const
|
|
1877
|
-
|
|
1896
|
+
const values = {
|
|
1897
|
+
score: formatScore(score, locale),
|
|
1898
|
+
reviewCount: formatCount(reviewCount, locale)
|
|
1899
|
+
};
|
|
1900
|
+
const template = text ?? (label ? `${label} {score} out of 5 based on {reviewCount} reviews` : DEFAULT_TRUSTPILOT_TEXT);
|
|
1901
|
+
const sentence = fillTemplate(template, values);
|
|
1878
1902
|
return /* @__PURE__ */ jsx23("div", { className: "hero__trustpilot home-hero_trustpilot-wrapper", children: /* @__PURE__ */ jsxs21(
|
|
1879
1903
|
"a",
|
|
1880
1904
|
{
|
|
@@ -1882,17 +1906,10 @@ var HeroTrustpilot = ({
|
|
|
1882
1906
|
className: "hero__trustpilot-link",
|
|
1883
1907
|
target: "_blank",
|
|
1884
1908
|
rel: "noopener noreferrer",
|
|
1885
|
-
"aria-label": `${
|
|
1909
|
+
"aria-label": ariaLabel ?? `${sentence} \u2014 Trustpilot`,
|
|
1886
1910
|
children: [
|
|
1887
1911
|
/* @__PURE__ */ jsx23(Stars, { score }),
|
|
1888
|
-
/* @__PURE__ */
|
|
1889
|
-
/* @__PURE__ */ jsx23("span", { className: "hero__trustpilot-text-label", children: label }),
|
|
1890
|
-
" ",
|
|
1891
|
-
/* @__PURE__ */ jsx23("span", { className: "hero__trustpilot-text-score", children: score }),
|
|
1892
|
-
" out of 5 based on ",
|
|
1893
|
-
/* @__PURE__ */ jsx23("span", { className: "hero__trustpilot-text-count", children: count }),
|
|
1894
|
-
" reviews"
|
|
1895
|
-
] }),
|
|
1912
|
+
/* @__PURE__ */ jsx23("span", { className: "hero__trustpilot-text", "aria-hidden": "true", children: renderTemplate(template, values) }),
|
|
1896
1913
|
/* @__PURE__ */ jsx23(Wordmark, {})
|
|
1897
1914
|
]
|
|
1898
1915
|
}
|