@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.d.mts
CHANGED
|
@@ -567,8 +567,29 @@ interface HeroTrustpilotProps {
|
|
|
567
567
|
reviewCount: number | string;
|
|
568
568
|
/** Trustpilot profile URL the whole band links to. Defaults to Deriv's TrustBox link. */
|
|
569
569
|
href?: string;
|
|
570
|
-
/**
|
|
570
|
+
/**
|
|
571
|
+
* The whole sentence as one translatable string, with `{score}` and
|
|
572
|
+
* `{reviewCount}` placeholders that are replaced with the formatted values.
|
|
573
|
+
* Defaults to "Deriv scores {score} out of 5 based on {reviewCount} reviews".
|
|
574
|
+
* Pass the translated sentence here, e.g.
|
|
575
|
+
* "Deriv obtiene {score} de 5 según {reviewCount} reseñas".
|
|
576
|
+
*/
|
|
577
|
+
text?: string;
|
|
578
|
+
/**
|
|
579
|
+
* @deprecated Use `text`. Leading copy before the score in the default
|
|
580
|
+
* English sentence; ignored when `text` is supplied.
|
|
581
|
+
*/
|
|
571
582
|
label?: string;
|
|
583
|
+
/**
|
|
584
|
+
* BCP 47 locale used to format `score` and a numeric `reviewCount`
|
|
585
|
+
* (e.g. "de-DE" renders 71887 as "71.887" and 4.3 as "4,3"). Defaults to "en-US".
|
|
586
|
+
*/
|
|
587
|
+
locale?: string;
|
|
588
|
+
/**
|
|
589
|
+
* Accessible name for the link. Defaults to the rendered sentence followed
|
|
590
|
+
* by " — Trustpilot". Supply a translated string alongside `text`.
|
|
591
|
+
*/
|
|
592
|
+
ariaLabel?: string;
|
|
572
593
|
}
|
|
573
594
|
interface HeroProps extends HTMLAttributes<HTMLElement> {
|
|
574
595
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -567,8 +567,29 @@ interface HeroTrustpilotProps {
|
|
|
567
567
|
reviewCount: number | string;
|
|
568
568
|
/** Trustpilot profile URL the whole band links to. Defaults to Deriv's TrustBox link. */
|
|
569
569
|
href?: string;
|
|
570
|
-
/**
|
|
570
|
+
/**
|
|
571
|
+
* The whole sentence as one translatable string, with `{score}` and
|
|
572
|
+
* `{reviewCount}` placeholders that are replaced with the formatted values.
|
|
573
|
+
* Defaults to "Deriv scores {score} out of 5 based on {reviewCount} reviews".
|
|
574
|
+
* Pass the translated sentence here, e.g.
|
|
575
|
+
* "Deriv obtiene {score} de 5 según {reviewCount} reseñas".
|
|
576
|
+
*/
|
|
577
|
+
text?: string;
|
|
578
|
+
/**
|
|
579
|
+
* @deprecated Use `text`. Leading copy before the score in the default
|
|
580
|
+
* English sentence; ignored when `text` is supplied.
|
|
581
|
+
*/
|
|
571
582
|
label?: string;
|
|
583
|
+
/**
|
|
584
|
+
* BCP 47 locale used to format `score` and a numeric `reviewCount`
|
|
585
|
+
* (e.g. "de-DE" renders 71887 as "71.887" and 4.3 as "4,3"). Defaults to "en-US".
|
|
586
|
+
*/
|
|
587
|
+
locale?: string;
|
|
588
|
+
/**
|
|
589
|
+
* Accessible name for the link. Defaults to the rendered sentence followed
|
|
590
|
+
* by " — Trustpilot". Supply a translated string alongside `text`.
|
|
591
|
+
*/
|
|
592
|
+
ariaLabel?: string;
|
|
572
593
|
}
|
|
573
594
|
interface HeroProps extends HTMLAttributes<HTMLElement> {
|
|
574
595
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1996,15 +1996,39 @@ var Wordmark = () => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
|
1996
1996
|
]
|
|
1997
1997
|
}
|
|
1998
1998
|
);
|
|
1999
|
-
var
|
|
1999
|
+
var DEFAULT_TRUSTPILOT_TEXT = "Deriv scores {score} out of 5 based on {reviewCount} reviews";
|
|
2000
|
+
var formatCount = (value, locale) => typeof value === "number" ? new Intl.NumberFormat(locale).format(value) : value;
|
|
2001
|
+
var formatScore = (value, locale) => new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(value);
|
|
2002
|
+
var PLACEHOLDER = /(\{score\}|\{reviewCount\})/g;
|
|
2003
|
+
function renderTemplate(template, values) {
|
|
2004
|
+
return template.split(PLACEHOLDER).map((part, i) => {
|
|
2005
|
+
if (part === "{score}") {
|
|
2006
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "hero__trustpilot-text-score", children: values.score }, i);
|
|
2007
|
+
}
|
|
2008
|
+
if (part === "{reviewCount}") {
|
|
2009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "hero__trustpilot-text-count", children: values.reviewCount }, i);
|
|
2010
|
+
}
|
|
2011
|
+
return part;
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
function fillTemplate(template, values) {
|
|
2015
|
+
return template.replace("{score}", values.score).replace("{reviewCount}", values.reviewCount);
|
|
2016
|
+
}
|
|
2000
2017
|
var HeroTrustpilot = ({
|
|
2001
2018
|
score,
|
|
2002
2019
|
reviewCount,
|
|
2003
2020
|
href = DEFAULT_TRUSTPILOT_URL,
|
|
2004
|
-
|
|
2021
|
+
text,
|
|
2022
|
+
label,
|
|
2023
|
+
locale = "en-US",
|
|
2024
|
+
ariaLabel
|
|
2005
2025
|
}) => {
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2026
|
+
const values = {
|
|
2027
|
+
score: formatScore(score, locale),
|
|
2028
|
+
reviewCount: formatCount(reviewCount, locale)
|
|
2029
|
+
};
|
|
2030
|
+
const template = text ?? (label ? `${label} {score} out of 5 based on {reviewCount} reviews` : DEFAULT_TRUSTPILOT_TEXT);
|
|
2031
|
+
const sentence = fillTemplate(template, values);
|
|
2008
2032
|
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("div", { className: "hero__trustpilot home-hero_trustpilot-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2009
2033
|
"a",
|
|
2010
2034
|
{
|
|
@@ -2012,17 +2036,10 @@ var HeroTrustpilot = ({
|
|
|
2012
2036
|
className: "hero__trustpilot-link",
|
|
2013
2037
|
target: "_blank",
|
|
2014
2038
|
rel: "noopener noreferrer",
|
|
2015
|
-
"aria-label": `${
|
|
2039
|
+
"aria-label": ariaLabel ?? `${sentence} \u2014 Trustpilot`,
|
|
2016
2040
|
children: [
|
|
2017
2041
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Stars, { score }),
|
|
2018
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.
|
|
2019
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "hero__trustpilot-text-label", children: label }),
|
|
2020
|
-
" ",
|
|
2021
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "hero__trustpilot-text-score", children: score }),
|
|
2022
|
-
" out of 5 based on ",
|
|
2023
|
-
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "hero__trustpilot-text-count", children: count }),
|
|
2024
|
-
" reviews"
|
|
2025
|
-
] }),
|
|
2042
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "hero__trustpilot-text", "aria-hidden": "true", children: renderTemplate(template, values) }),
|
|
2026
2043
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Wordmark, {})
|
|
2027
2044
|
]
|
|
2028
2045
|
}
|