@simplybusiness/mobius 4.9.0 → 4.10.0

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.
Files changed (55) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/components/Trust/Trust.js +56 -0
  3. package/dist/cjs/components/Trust/Trust.js.map +1 -0
  4. package/dist/cjs/components/Trust/TrustpilotProvider.js +31 -0
  5. package/dist/cjs/components/Trust/TrustpilotProvider.js.map +1 -0
  6. package/dist/cjs/components/Trust/constants.js +44 -0
  7. package/dist/cjs/components/Trust/constants.js.map +1 -0
  8. package/dist/cjs/components/Trust/getDefaultProps.js +34 -0
  9. package/dist/cjs/components/Trust/getDefaultProps.js.map +1 -0
  10. package/dist/cjs/components/Trust/index.js +21 -0
  11. package/dist/cjs/components/Trust/index.js.map +1 -0
  12. package/dist/cjs/components/Trust/types.js +7 -0
  13. package/dist/cjs/components/Trust/types.js.map +1 -0
  14. package/dist/cjs/components/index.js +1 -0
  15. package/dist/cjs/components/index.js.map +1 -1
  16. package/dist/cjs/tsconfig.tsbuildinfo +1 -1
  17. package/dist/esm/components/Trust/Trust.js +41 -0
  18. package/dist/esm/components/Trust/Trust.js.map +1 -0
  19. package/dist/esm/components/Trust/TrustpilotProvider.js +21 -0
  20. package/dist/esm/components/Trust/TrustpilotProvider.js.map +1 -0
  21. package/dist/esm/components/Trust/constants.js +20 -0
  22. package/dist/esm/components/Trust/constants.js.map +1 -0
  23. package/dist/esm/components/Trust/getDefaultProps.js +24 -0
  24. package/dist/esm/components/Trust/getDefaultProps.js.map +1 -0
  25. package/dist/esm/components/Trust/index.js +4 -0
  26. package/dist/esm/components/Trust/index.js.map +1 -0
  27. package/dist/esm/components/Trust/types.js +4 -0
  28. package/dist/esm/components/Trust/types.js.map +1 -0
  29. package/dist/esm/components/index.js +1 -0
  30. package/dist/esm/components/index.js.map +1 -1
  31. package/dist/types/components/Text/Text.stories.d.ts +14 -3
  32. package/dist/types/components/Trust/Trust.d.ts +3 -0
  33. package/dist/types/components/Trust/Trust.stories.d.ts +7 -0
  34. package/dist/types/components/Trust/Trust.test.d.ts +1 -0
  35. package/dist/types/components/Trust/TrustpilotProvider.d.ts +4 -0
  36. package/dist/types/components/Trust/constants.d.ts +16 -0
  37. package/dist/types/components/Trust/getDefaultProps.d.ts +18 -0
  38. package/dist/types/components/Trust/index.d.ts +2 -0
  39. package/dist/types/components/Trust/types.d.ts +22 -0
  40. package/dist/types/components/index.d.ts +1 -0
  41. package/dist/types/yarnpath.test.d.ts +1 -0
  42. package/package.json +2 -2
  43. package/src/components/Text/Text.mdx +59 -11
  44. package/src/components/Text/Text.stories.tsx +95 -68
  45. package/src/components/Trust/Trust.mdx +55 -0
  46. package/src/components/Trust/Trust.stories.tsx +48 -0
  47. package/src/components/Trust/Trust.test.tsx +8 -0
  48. package/src/components/Trust/Trust.tsx +62 -0
  49. package/src/components/Trust/TrustpilotProvider.tsx +20 -0
  50. package/src/components/Trust/constants.ts +21 -0
  51. package/src/components/Trust/getDefaultProps.ts +31 -0
  52. package/src/components/Trust/index.tsx +2 -0
  53. package/src/components/Trust/types.ts +28 -0
  54. package/src/components/index.tsx +1 -0
  55. package/src/yarnpath.test.ts +22 -0
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useRef } from "react";
3
+ import classNames from "classnames/dedupe";
4
+ import { getDefaultProps } from "./getDefaultProps";
5
+ import { REQUIRED_TRUSTPILOT_CLASS_NAME, TRUSTPILOT_WIDGET } from "./constants";
6
+ import { mergeRefs } from "../../utils";
7
+ export const Trust = /*#__PURE__*/ forwardRef((props, ref)=>{
8
+ const { elementType: Element = "div", variant, theme, ...otherProps } = props;
9
+ const trustRef = useRef(null);
10
+ const { link, ...defaultProps } = getDefaultProps(props);
11
+ const { className: variantClassName } = TRUSTPILOT_WIDGET[variant];
12
+ const themeClassName = theme.charAt(0).toUpperCase() + theme.slice(1);
13
+ const classes = classNames("mobius", "mobius/Trust", REQUIRED_TRUSTPILOT_CLASS_NAME, {
14
+ [`mobius/TrustTheme${themeClassName}`]: theme,
15
+ [`mobius/TrustVariant${variantClassName}`]: variant
16
+ }, otherProps.className);
17
+ useEffect(()=>{
18
+ // If window.Trustpilot is available it means that we need to load the TrustBox from our ref.
19
+ if (trustRef.current && window.Trustpilot && window.Trustpilot.loadFromElement) {
20
+ window.Trustpilot.loadFromElement(trustRef.current, true);
21
+ }
22
+ }, []);
23
+ return /*#__PURE__*/ _jsx(Element, {
24
+ ref: mergeRefs([
25
+ trustRef,
26
+ ref
27
+ ]),
28
+ ...defaultProps,
29
+ ...otherProps,
30
+ className: classes,
31
+ children: /*#__PURE__*/ _jsx("a", {
32
+ href: link,
33
+ target: "_blank",
34
+ rel: "noopener noreferrer",
35
+ className: "mobius/TrustLink",
36
+ children: "Trustpilot"
37
+ })
38
+ });
39
+ });
40
+
41
+ //# sourceMappingURL=Trust.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Trust/Trust.tsx"],"sourcesContent":["import { forwardRef, useEffect, useRef } from \"react\";\nimport classNames from \"classnames/dedupe\";\nimport { ForwardedRefComponent } from \"../../types/components\";\nimport { TrustElementType, TrustProps, TrustRef } from \"./types\";\nimport { getDefaultProps } from \"./getDefaultProps\";\nimport { REQUIRED_TRUSTPILOT_CLASS_NAME, TRUSTPILOT_WIDGET } from \"./constants\";\nimport { mergeRefs } from \"../../utils\";\n\nexport const Trust: ForwardedRefComponent<TrustProps, TrustElementType> =\n forwardRef((props: TrustProps, ref: TrustRef) => {\n const {\n elementType: Element = \"div\",\n variant,\n theme,\n ...otherProps\n } = props;\n const trustRef = useRef(null);\n\n const { link, ...defaultProps } = getDefaultProps(props);\n const { className: variantClassName } = TRUSTPILOT_WIDGET[variant];\n const themeClassName = theme.charAt(0).toUpperCase() + theme.slice(1);\n\n const classes = classNames(\n \"mobius\",\n \"mobius/Trust\",\n REQUIRED_TRUSTPILOT_CLASS_NAME,\n {\n [`mobius/TrustTheme${themeClassName}`]: theme,\n [`mobius/TrustVariant${variantClassName}`]: variant,\n },\n otherProps.className,\n );\n\n useEffect(() => {\n // If window.Trustpilot is available it means that we need to load the TrustBox from our ref.\n if (\n trustRef.current &&\n window.Trustpilot &&\n window.Trustpilot.loadFromElement\n ) {\n window.Trustpilot.loadFromElement(trustRef.current, true);\n }\n }, []);\n\n return (\n <Element\n ref={mergeRefs([trustRef, ref])}\n {...defaultProps}\n {...otherProps}\n className={classes}\n >\n <a\n href={link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"mobius/TrustLink\"\n >\n Trustpilot\n </a>\n </Element>\n );\n });\n"],"names":["forwardRef","useEffect","useRef","classNames","getDefaultProps","REQUIRED_TRUSTPILOT_CLASS_NAME","TRUSTPILOT_WIDGET","mergeRefs","Trust","props","ref","elementType","Element","variant","theme","otherProps","trustRef","link","defaultProps","className","variantClassName","themeClassName","charAt","toUpperCase","slice","classes","current","window","Trustpilot","loadFromElement","a","href","target","rel"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAASA,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,QAAQ;AACtD,OAAOC,gBAAgB,oBAAoB;AAG3C,SAASC,eAAe,QAAQ,oBAAoB;AACpD,SAASC,8BAA8B,EAAEC,iBAAiB,QAAQ,cAAc;AAChF,SAASC,SAAS,QAAQ,cAAc;AAExC,OAAO,MAAMC,sBACXR,WAAW,CAACS,OAAmBC;IAC7B,MAAM,EACJC,aAAaC,UAAU,KAAK,EAC5BC,OAAO,EACPC,KAAK,EACL,GAAGC,YACJ,GAAGN;IACJ,MAAMO,WAAWd,OAAO;IAExB,MAAM,EAAEe,IAAI,EAAE,GAAGC,cAAc,GAAGd,gBAAgBK;IAClD,MAAM,EAAEU,WAAWC,gBAAgB,EAAE,GAAGd,iBAAiB,CAACO,QAAQ;IAClE,MAAMQ,iBAAiBP,MAAMQ,MAAM,CAAC,GAAGC,WAAW,KAAKT,MAAMU,KAAK,CAAC;IAEnE,MAAMC,UAAUtB,WACd,UACA,gBACAE,gCACA;QACE,CAAC,CAAC,iBAAiB,EAAEgB,eAAe,CAAC,CAAC,EAAEP;QACxC,CAAC,CAAC,mBAAmB,EAAEM,iBAAiB,CAAC,CAAC,EAAEP;IAC9C,GACAE,WAAWI,SAAS;IAGtBlB,UAAU;QACR,6FAA6F;QAC7F,IACEe,SAASU,OAAO,IAChBC,OAAOC,UAAU,IACjBD,OAAOC,UAAU,CAACC,eAAe,EACjC;YACAF,OAAOC,UAAU,CAACC,eAAe,CAACb,SAASU,OAAO,EAAE;QACtD;IACF,GAAG,EAAE;IAEL,qBACE,KAACd;QACCF,KAAKH,UAAU;YAACS;YAAUN;SAAI;QAC7B,GAAGQ,YAAY;QACf,GAAGH,UAAU;QACdI,WAAWM;kBAEX,cAAA,KAACK;YACCC,MAAMd;YACNe,QAAO;YACPC,KAAI;YACJd,WAAU;sBACX;;;AAKP,GAAG"}
@@ -0,0 +1,21 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ export const TrustpilotProvider = ({ children })=>{
4
+ useEffect(()=>{
5
+ // Required to load Trustpilot widgets
6
+ const script = document.createElement("script");
7
+ script.type = "text/javascript";
8
+ script.className = "optanon-category-C0002";
9
+ script.src = "//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js";
10
+ script.async = true;
11
+ document.head.appendChild(script);
12
+ return ()=>{
13
+ document.head.removeChild(script);
14
+ };
15
+ }, []);
16
+ return /*#__PURE__*/ _jsx("div", {
17
+ children: children
18
+ });
19
+ };
20
+
21
+ //# sourceMappingURL=TrustpilotProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Trust/TrustpilotProvider.tsx"],"sourcesContent":["import { ReactNode, useEffect } from \"react\";\n\nexport const TrustpilotProvider = ({ children }: { children: ReactNode }) => {\n useEffect(() => {\n // Required to load Trustpilot widgets\n const script = document.createElement(\"script\");\n script.type = \"text/javascript\";\n script.className = \"optanon-category-C0002\";\n script.src =\n \"//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js\";\n script.async = true;\n document.head.appendChild(script);\n\n return () => {\n document.head.removeChild(script);\n };\n }, []);\n\n return <div>{children}</div>;\n};\n"],"names":["useEffect","TrustpilotProvider","children","script","document","createElement","type","className","src","async","head","appendChild","removeChild","div"],"rangeMappings":";;;;;;;;;;;;;;;;;;","mappings":";AAAA,SAAoBA,SAAS,QAAQ,QAAQ;AAE7C,OAAO,MAAMC,qBAAqB,CAAC,EAAEC,QAAQ,EAA2B;IACtEF,UAAU;QACR,sCAAsC;QACtC,MAAMG,SAASC,SAASC,aAAa,CAAC;QACtCF,OAAOG,IAAI,GAAG;QACdH,OAAOI,SAAS,GAAG;QACnBJ,OAAOK,GAAG,GACR;QACFL,OAAOM,KAAK,GAAG;QACfL,SAASM,IAAI,CAACC,WAAW,CAACR;QAE1B,OAAO;YACLC,SAASM,IAAI,CAACE,WAAW,CAACT;QAC5B;IACF,GAAG,EAAE;IAEL,qBAAO,KAACU;kBAAKX;;AACf,EAAE"}
@@ -0,0 +1,20 @@
1
+ export const REQUIRED_TRUSTPILOT_CLASS_NAME = "trustpilot-widget";
2
+ export const SIMPLYBUSINESS_UNIT_ID = "5ca35a3da72b330001954cef";
3
+ export const TRUSTPILOT_LINKS = {
4
+ "en-US": "https://www.trustpilot.com/review/simplybusiness.com",
5
+ "en-GB": "https://www.trustpilot.com/review/simplybusiness.co.uk"
6
+ };
7
+ export const TRUSTPILOT_WIDGET = {
8
+ // Keys based on actual widget names
9
+ // https://support.trustpilot.com/hc/en-us/articles/360019826379-TrustBox-widget-overview
10
+ "micro-combo": {
11
+ templateId: "5419b6ffb0d04a076446a9af",
12
+ className: "MicroCombo"
13
+ },
14
+ mini: {
15
+ templateId: "53aa8807dec7e10d38f59f32",
16
+ className: "Mini"
17
+ }
18
+ };
19
+
20
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Trust/constants.ts"],"sourcesContent":["export const REQUIRED_TRUSTPILOT_CLASS_NAME = \"trustpilot-widget\";\n\nexport const SIMPLYBUSINESS_UNIT_ID = \"5ca35a3da72b330001954cef\";\n\nexport const TRUSTPILOT_LINKS = {\n \"en-US\": \"https://www.trustpilot.com/review/simplybusiness.com\",\n \"en-GB\": \"https://www.trustpilot.com/review/simplybusiness.co.uk\",\n};\n\nexport const TRUSTPILOT_WIDGET = {\n // Keys based on actual widget names\n // https://support.trustpilot.com/hc/en-us/articles/360019826379-TrustBox-widget-overview\n \"micro-combo\": {\n templateId: \"5419b6ffb0d04a076446a9af\",\n className: \"MicroCombo\",\n },\n mini: {\n templateId: \"53aa8807dec7e10d38f59f32\",\n className: \"Mini\",\n },\n};\n"],"names":["REQUIRED_TRUSTPILOT_CLASS_NAME","SIMPLYBUSINESS_UNIT_ID","TRUSTPILOT_LINKS","TRUSTPILOT_WIDGET","templateId","className","mini"],"rangeMappings":";;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAO,MAAMA,iCAAiC,oBAAoB;AAElE,OAAO,MAAMC,yBAAyB,2BAA2B;AAEjE,OAAO,MAAMC,mBAAmB;IAC9B,SAAS;IACT,SAAS;AACX,EAAE;AAEF,OAAO,MAAMC,oBAAoB;IAC/B,oCAAoC;IACpC,yFAAyF;IACzF,eAAe;QACbC,YAAY;QACZC,WAAW;IACb;IACAC,MAAM;QACJF,YAAY;QACZC,WAAW;IACb;AACF,EAAE"}
@@ -0,0 +1,24 @@
1
+ import { SIMPLYBUSINESS_UNIT_ID, TRUSTPILOT_LINKS, TRUSTPILOT_WIDGET } from "./constants";
2
+ export const getDefaultProps = (props)=>{
3
+ const { locale, variant, height, width, theme, stars } = props;
4
+ const { templateId } = TRUSTPILOT_WIDGET[variant];
5
+ const link = TRUSTPILOT_LINKS[locale];
6
+ const sharedProps = {
7
+ "data-businessunit-id": SIMPLYBUSINESS_UNIT_ID,
8
+ "data-locale": locale,
9
+ "data-template-id": templateId,
10
+ "data-theme": theme,
11
+ "data-style-width": width || "100%",
12
+ link
13
+ };
14
+ if (variant === "micro-combo") {
15
+ return {
16
+ "data-style-height": height || "40px",
17
+ "data-stars": stars,
18
+ ...sharedProps
19
+ };
20
+ }
21
+ return sharedProps;
22
+ };
23
+
24
+ //# sourceMappingURL=getDefaultProps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Trust/getDefaultProps.ts"],"sourcesContent":["import {\n SIMPLYBUSINESS_UNIT_ID,\n TRUSTPILOT_LINKS,\n TRUSTPILOT_WIDGET,\n} from \"./constants\";\nimport { TrustProps } from \"./types\";\n\nexport const getDefaultProps = (props: TrustProps) => {\n const { locale, variant, height, width, theme, stars } = props;\n const { templateId } = TRUSTPILOT_WIDGET[variant];\n const link = TRUSTPILOT_LINKS[locale];\n\n const sharedProps = {\n \"data-businessunit-id\": SIMPLYBUSINESS_UNIT_ID,\n \"data-locale\": locale,\n \"data-template-id\": templateId,\n \"data-theme\": theme,\n \"data-style-width\": width || \"100%\",\n link,\n };\n\n if (variant === \"micro-combo\") {\n return {\n \"data-style-height\": height || \"40px\",\n \"data-stars\": stars,\n ...sharedProps,\n };\n }\n\n return sharedProps;\n};\n"],"names":["SIMPLYBUSINESS_UNIT_ID","TRUSTPILOT_LINKS","TRUSTPILOT_WIDGET","getDefaultProps","props","locale","variant","height","width","theme","stars","templateId","link","sharedProps"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,SACEA,sBAAsB,EACtBC,gBAAgB,EAChBC,iBAAiB,QACZ,cAAc;AAGrB,OAAO,MAAMC,kBAAkB,CAACC;IAC9B,MAAM,EAAEC,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAGN;IACzD,MAAM,EAAEO,UAAU,EAAE,GAAGT,iBAAiB,CAACI,QAAQ;IACjD,MAAMM,OAAOX,gBAAgB,CAACI,OAAO;IAErC,MAAMQ,cAAc;QAClB,wBAAwBb;QACxB,eAAeK;QACf,oBAAoBM;QACpB,cAAcF;QACd,oBAAoBD,SAAS;QAC7BI;IACF;IAEA,IAAIN,YAAY,eAAe;QAC7B,OAAO;YACL,qBAAqBC,UAAU;YAC/B,cAAcG;YACd,GAAGG,WAAW;QAChB;IACF;IAEA,OAAOA;AACT,EAAE"}
@@ -0,0 +1,4 @@
1
+ export * from "./Trust";
2
+ export * from "./types";
3
+
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Trust/index.tsx"],"sourcesContent":["export * from \"./Trust\";\nexport * from \"./types\";\n"],"names":[],"rangeMappings":";","mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,UAAU"}
@@ -0,0 +1,4 @@
1
+ window.Trustpilot = window.Trustpilot || {};
2
+ export { };
3
+
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Trust/types.ts"],"sourcesContent":["import { Ref, RefAttributes } from \"react\";\nimport { DOMProps } from \"../../types/dom\";\nimport { TRUSTPILOT_WIDGET } from \"./constants\";\n\ndeclare global {\n interface Window {\n Trustpilot: any;\n }\n}\n\nwindow.Trustpilot = window.Trustpilot || {};\n\nexport type TrustElementType = HTMLDivElement;\n\nexport interface TrustProps extends DOMProps, RefAttributes<TrustElementType> {\n /** Custom class name for setting specific CSS */\n className?: string;\n elementType?: string | React.ElementType;\n locale: \"en-US\" | \"en-GB\";\n variant: keyof typeof TRUSTPILOT_WIDGET;\n templateId?: string;\n height?: string;\n width?: string;\n theme: \"dark\" | \"light\";\n stars?: string;\n}\n\nexport type TrustRef = Ref<TrustElementType>;\n"],"names":["window","Trustpilot"],"rangeMappings":";","mappings":"AAUAA,OAAOC,UAAU,GAAGD,OAAOC,UAAU,IAAI,CAAC;AAiB1C,WAA6C"}
@@ -37,6 +37,7 @@ export * from "./TextArea";
37
37
  export * from "./TextAreaInput";
38
38
  export * from "./TextField";
39
39
  export * from "./Title";
40
+ export * from "./Trust";
40
41
  export * from "./VisuallyHidden";
41
42
 
42
43
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/index.tsx"],"sourcesContent":["export * from \"./Accordion\";\nexport * from \"./Alert\";\nexport * from \"./Box\";\nexport * from \"./Breadcrumbs\";\nexport * from \"./Button\";\nexport * from \"./Checkbox\";\nexport * from \"./Container\";\nexport * from \"./Divider\";\nexport * from \"./Drawer\";\nexport * from \"./DropdownMenu\";\nexport * from \"./ErrorMessage\";\nexport * from \"./Fieldset\";\nexport * from \"./Flex\";\nexport * from \"./Grid\";\nexport * from \"./Icon\";\nexport * from \"./Image\";\nexport * from \"./Label\";\nexport * from \"./Link\";\nexport * from \"./LinkButton\";\nexport * from \"./List\";\nexport * from \"./LoadingIndicator\";\nexport * from \"./Logo\";\nexport * from \"./Modal\";\nexport * from \"./NumberField\";\nexport * from \"./Option\";\nexport * from \"./PasswordField\";\nexport * from \"./Popover\";\nexport * from \"./Progress\";\nexport * from \"./Radio\";\nexport * from \"./Segment\";\nexport * from \"./Select\";\nexport * from \"./Slider\";\nexport * from \"./SVG\";\nexport * from \"./Table\";\nexport * from \"./Text\";\nexport * from \"./TextArea\";\nexport * from \"./TextAreaInput\";\nexport * from \"./TextField\";\nexport * from \"./Title\";\nexport * from \"./VisuallyHidden\";\n"],"names":[],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,kBAAkB;AAChC,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,mBAAmB"}
1
+ {"version":3,"sources":["../../../src/components/index.tsx"],"sourcesContent":["export * from \"./Accordion\";\nexport * from \"./Alert\";\nexport * from \"./Box\";\nexport * from \"./Breadcrumbs\";\nexport * from \"./Button\";\nexport * from \"./Checkbox\";\nexport * from \"./Container\";\nexport * from \"./Divider\";\nexport * from \"./Drawer\";\nexport * from \"./DropdownMenu\";\nexport * from \"./ErrorMessage\";\nexport * from \"./Fieldset\";\nexport * from \"./Flex\";\nexport * from \"./Grid\";\nexport * from \"./Icon\";\nexport * from \"./Image\";\nexport * from \"./Label\";\nexport * from \"./Link\";\nexport * from \"./LinkButton\";\nexport * from \"./List\";\nexport * from \"./LoadingIndicator\";\nexport * from \"./Logo\";\nexport * from \"./Modal\";\nexport * from \"./NumberField\";\nexport * from \"./Option\";\nexport * from \"./PasswordField\";\nexport * from \"./Popover\";\nexport * from \"./Progress\";\nexport * from \"./Radio\";\nexport * from \"./Segment\";\nexport * from \"./Select\";\nexport * from \"./Slider\";\nexport * from \"./SVG\";\nexport * from \"./Table\";\nexport * from \"./Text\";\nexport * from \"./TextArea\";\nexport * from \"./TextAreaInput\";\nexport * from \"./TextField\";\nexport * from \"./Title\";\nexport * from \"./Trust\";\nexport * from \"./VisuallyHidden\";\n"],"names":[],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,QAAQ;AACtB,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,aAAa;AAC3B,cAAc,cAAc;AAC5B,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,iBAAiB;AAC/B,cAAc,iBAAiB;AAC/B,cAAc,aAAa;AAC3B,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,eAAe;AAC7B,cAAc,SAAS;AACvB,cAAc,qBAAqB;AACnC,cAAc,SAAS;AACvB,cAAc,UAAU;AACxB,cAAc,gBAAgB;AAC9B,cAAc,WAAW;AACzB,cAAc,kBAAkB;AAChC,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,UAAU;AACxB,cAAc,YAAY;AAC1B,cAAc,WAAW;AACzB,cAAc,WAAW;AACzB,cAAc,QAAQ;AACtB,cAAc,UAAU;AACxB,cAAc,SAAS;AACvB,cAAc,aAAa;AAC3B,cAAc,kBAAkB;AAChC,cAAc,cAAc;AAC5B,cAAc,UAAU;AACxB,cAAc,UAAU;AACxB,cAAc,mBAAmB"}
@@ -2,9 +2,20 @@ import type { Meta, StoryObj } from "@storybook/react";
2
2
  import { Text } from "./Text";
3
3
  type StoryType = StoryObj<typeof Text>;
4
4
  declare const meta: Meta<typeof Text>;
5
- export declare const Normal: StoryType;
5
+ export declare const Heading1: StoryType;
6
+ export declare const Heading2: StoryType;
7
+ export declare const Heading3: StoryType;
8
+ export declare const Heading4: StoryType;
9
+ export declare const Paragraph: StoryType;
10
+ export declare const Small: StoryType;
11
+ export declare const Legal: StoryType;
12
+ export declare const VariantHeading1: StoryType;
13
+ export declare const VariantHeading2: StoryType;
14
+ export declare const VariantHeading3: StoryType;
15
+ export declare const VariantHeading4: StoryType;
16
+ export declare const VariantBody: StoryType;
17
+ export declare const VariantSmall: StoryType;
18
+ export declare const VariantLegal: StoryType;
6
19
  export declare const Themed: StoryType;
7
- export declare const Example: () => import("react/jsx-runtime").JSX.Element;
8
- export declare const ExampleVariant: () => import("react/jsx-runtime").JSX.Element;
9
20
  export declare const ExampleSpacing: () => import("react/jsx-runtime").JSX.Element;
10
21
  export default meta;
@@ -0,0 +1,3 @@
1
+ import { ForwardedRefComponent } from "../../types/components";
2
+ import { TrustElementType, TrustProps } from "./types";
3
+ export declare const Trust: ForwardedRefComponent<TrustProps, TrustElementType>;
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Trust } from "..";
3
+ type StoryType = StoryObj<typeof Trust>;
4
+ declare const meta: Meta<typeof Trust>;
5
+ export declare const MicroCombo: StoryType;
6
+ export declare const Mini: StoryType;
7
+ export default meta;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { ReactNode } from "react";
2
+ export declare const TrustpilotProvider: ({ children }: {
3
+ children: ReactNode;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ export declare const REQUIRED_TRUSTPILOT_CLASS_NAME = "trustpilot-widget";
2
+ export declare const SIMPLYBUSINESS_UNIT_ID = "5ca35a3da72b330001954cef";
3
+ export declare const TRUSTPILOT_LINKS: {
4
+ "en-US": string;
5
+ "en-GB": string;
6
+ };
7
+ export declare const TRUSTPILOT_WIDGET: {
8
+ "micro-combo": {
9
+ templateId: string;
10
+ className: string;
11
+ };
12
+ mini: {
13
+ templateId: string;
14
+ className: string;
15
+ };
16
+ };
@@ -0,0 +1,18 @@
1
+ import { TrustProps } from "./types";
2
+ export declare const getDefaultProps: (props: TrustProps) => {
3
+ "data-businessunit-id": string;
4
+ "data-locale": "en-GB" | "en-US";
5
+ "data-template-id": string;
6
+ "data-theme": "dark" | "light";
7
+ "data-style-width": string;
8
+ link: string;
9
+ } | {
10
+ "data-businessunit-id": string;
11
+ "data-locale": "en-GB" | "en-US";
12
+ "data-template-id": string;
13
+ "data-theme": "dark" | "light";
14
+ "data-style-width": string;
15
+ link: string;
16
+ "data-style-height": string;
17
+ "data-stars": string | undefined;
18
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./Trust";
2
+ export * from "./types";
@@ -0,0 +1,22 @@
1
+ import { Ref, RefAttributes } from "react";
2
+ import { DOMProps } from "../../types/dom";
3
+ import { TRUSTPILOT_WIDGET } from "./constants";
4
+ declare global {
5
+ interface Window {
6
+ Trustpilot: any;
7
+ }
8
+ }
9
+ export type TrustElementType = HTMLDivElement;
10
+ export interface TrustProps extends DOMProps, RefAttributes<TrustElementType> {
11
+ /** Custom class name for setting specific CSS */
12
+ className?: string;
13
+ elementType?: string | React.ElementType;
14
+ locale: "en-US" | "en-GB";
15
+ variant: keyof typeof TRUSTPILOT_WIDGET;
16
+ templateId?: string;
17
+ height?: string;
18
+ width?: string;
19
+ theme: "dark" | "light";
20
+ stars?: string;
21
+ }
22
+ export type TrustRef = Ref<TrustElementType>;
@@ -37,4 +37,5 @@ export * from "./TextArea";
37
37
  export * from "./TextAreaInput";
38
38
  export * from "./TextField";
39
39
  export * from "./Title";
40
+ export * from "./Trust";
40
41
  export * from "./VisuallyHidden";
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@simplybusiness/mobius",
3
3
  "license": "UNLICENSED",
4
- "version": "4.9.0",
4
+ "version": "4.10.0",
5
5
  "description": "Core library of Mobius react components",
6
6
  "repository": {
7
7
  "type": "git",
@@ -86,7 +86,7 @@
86
86
  },
87
87
  "dependencies": {
88
88
  "@floating-ui/react": "^0.26.16",
89
- "@simplybusiness/icons": "^4.8.0",
89
+ "@simplybusiness/icons": "^4.10.0",
90
90
  "classnames": "^2.5.1",
91
91
  "dialog-polyfill": "^0.5.6",
92
92
  "lodash.debounce": "^4.0.8",
@@ -1,4 +1,4 @@
1
- import { Meta, ArgTypes, Story } from "@storybook/blocks";
1
+ import { Meta, ArgTypes, Story, Canvas } from "@storybook/blocks";
2
2
  import { Text } from "./Text";
3
3
  import * as TextStories from "./Text.stories";
4
4
 
@@ -20,13 +20,67 @@ yarn add @simplybusiness/mobius
20
20
  import { Text } from "@simplybusiness/mobius";
21
21
  ```
22
22
 
23
- ## Examples
23
+ ## Use default HTML elements and their theme styles
24
24
 
25
- <TextStories.Example />
25
+ ### Heading 1
26
26
 
27
- ### Normal
27
+ <Canvas of={TextStories.Heading1} />
28
28
 
29
- <Story of={TextStories.Normal} />
29
+ ### Heading 2
30
+
31
+ <Canvas of={TextStories.Heading2} />
32
+
33
+ ### Heading 3
34
+
35
+ <Canvas of={TextStories.Heading3} />
36
+
37
+ ### Heading 4
38
+
39
+ <Canvas of={TextStories.Heading4} />
40
+
41
+ ### Paragraph
42
+
43
+ <Canvas of={TextStories.Paragraph} />
44
+
45
+ ### Small
46
+
47
+ <Canvas of={TextStories.Small} />
48
+
49
+ ### Legal
50
+
51
+ <Canvas of={TextStories.Legal} />
52
+
53
+ ## Style HTML elements (defaults to `<p>` tag) with `variant` prop
54
+
55
+ Make `<p>` tag look like an `<h1>` tag.
56
+
57
+ ### Variant H1
58
+
59
+ <Canvas of={TextStories.VariantHeading1} />
60
+
61
+ ### Variant H2
62
+
63
+ <Canvas of={TextStories.VariantHeading2} />
64
+
65
+ ### Variant H3
66
+
67
+ <Canvas of={TextStories.VariantHeading3} />
68
+
69
+ ### Variant H4
70
+
71
+ <Canvas of={TextStories.VariantHeading4} />
72
+
73
+ ### Variant Body
74
+
75
+ <Canvas of={TextStories.VariantBody} />
76
+
77
+ ### Variant Small
78
+
79
+ <Canvas of={TextStories.VariantSmall} />
80
+
81
+ ### Variant Legal
82
+
83
+ <Canvas of={TextStories.VariantLegal} />
30
84
 
31
85
  ### Themed
32
86
 
@@ -44,12 +98,6 @@ const StyledText = styled(Text)`
44
98
  <StyledText>Sample Text</StyledText>
45
99
  ```
46
100
 
47
- ### Variant
48
-
49
- Override text presentation with a named variant.
50
-
51
- <TextStories.ExampleVariant />
52
-
53
101
  ### Spacing
54
102
 
55
103
  Set the spacing to "loose" or "tight" to override the default line height for text. This applies to any element type or variant.
@@ -8,18 +8,108 @@ type StoryType = StoryObj<typeof Text>;
8
8
  const meta: Meta<typeof Text> = {
9
9
  title: "Components/Text",
10
10
  component: Text,
11
- excludeStories: ["Example", "ExampleSpacing", "ExampleVariant"],
11
+ excludeStories: ["ExampleSpacing"],
12
12
  argTypes: excludeControls("style"),
13
13
  };
14
14
 
15
- export const Normal: StoryType = {
16
- render: (args: TextProps) => <Text {...args}>Sample Text</Text>,
15
+ export const Heading1: StoryType = {
16
+ render: (args: TextProps) => <Text {...args}>Heading 1</Text>,
17
+ args: {
18
+ elementType: "h1",
19
+ },
20
+ };
21
+
22
+ export const Heading2: StoryType = {
23
+ render: (args: TextProps) => <Text {...args}>Heading 2</Text>,
24
+ args: {
25
+ elementType: "h2",
26
+ },
27
+ };
28
+
29
+ export const Heading3: StoryType = {
30
+ render: (args: TextProps) => <Text {...args}>Heading 3</Text>,
31
+ args: {
32
+ elementType: "h3",
33
+ },
34
+ };
35
+
36
+ export const Heading4: StoryType = {
37
+ render: (args: TextProps) => <Text {...args}>Heading 4</Text>,
17
38
  args: {
18
39
  elementType: "h4",
40
+ },
41
+ };
42
+
43
+ export const Paragraph: StoryType = {
44
+ render: (args: TextProps) => <Text {...args}>Paragraph</Text>,
45
+ args: {
46
+ elementType: "p",
47
+ },
48
+ };
49
+
50
+ export const Small: StoryType = {
51
+ render: (args: TextProps) => <Text {...args}>Small paragraph</Text>,
52
+ args: {
53
+ variant: "small",
54
+ },
55
+ };
56
+
57
+ export const Legal: StoryType = {
58
+ render: (args: TextProps) => <Text {...args}>Small print</Text>,
59
+ args: {
60
+ variant: "legal",
61
+ },
62
+ };
63
+
64
+ export const VariantHeading1: StoryType = {
65
+ render: (args: TextProps) => <Text {...args}>Variant H1</Text>,
66
+ args: {
67
+ variant: "h1",
68
+ },
69
+ };
70
+
71
+ export const VariantHeading2: StoryType = {
72
+ render: (args: TextProps) => <Text {...args}>Variant H2</Text>,
73
+ args: {
74
+ variant: "h2",
75
+ },
76
+ };
77
+
78
+ export const VariantHeading3: StoryType = {
79
+ render: (args: TextProps) => <Text {...args}>Variant H3</Text>,
80
+ args: {
81
+ variant: "h3",
82
+ },
83
+ };
84
+
85
+ export const VariantHeading4: StoryType = {
86
+ render: (args: TextProps) => <Text {...args}>Variant H4</Text>,
87
+ args: {
19
88
  variant: "h4",
20
89
  },
21
90
  };
22
91
 
92
+ export const VariantBody: StoryType = {
93
+ render: (args: TextProps) => <Text {...args}>Variant body</Text>,
94
+ args: {
95
+ variant: "body",
96
+ },
97
+ };
98
+
99
+ export const VariantSmall: StoryType = {
100
+ render: (args: TextProps) => <Text {...args}>Variant small</Text>,
101
+ args: {
102
+ variant: "small",
103
+ },
104
+ };
105
+
106
+ export const VariantLegal: StoryType = {
107
+ render: (args: TextProps) => <Text {...args}>Variant legal</Text>,
108
+ args: {
109
+ variant: "legal",
110
+ },
111
+ };
112
+
23
113
  export const Themed: StoryType = {
24
114
  render: (args: TextProps) => <Text {...args}>Sample Text</Text>,
25
115
  args: {
@@ -31,72 +121,9 @@ export const Themed: StoryType = {
31
121
  },
32
122
  };
33
123
 
34
- export const Example = () => (
35
- <>
36
- <Box>
37
- <Text elementType="h1">Heading 1</Text>
38
- <Text elementType="h2">Heading 2</Text>
39
- <Text elementType="h3">Heading 3</Text>
40
- <Text elementType="h4">Heading 4</Text>
41
- <Text>Paragraph</Text>
42
- <Text variant="small">Small paragraph</Text>
43
- <Text variant="legal">Small print</Text>
44
- </Box>
45
- <Box>
46
- <Text elementType="h1">First Heading</Text>
47
- <Text>
48
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel lorem
49
- enim. Nam vitae enim mollis turpis scelerisque vulputate id sit amet
50
- nisl. Etiam et tortor a nunc hendrerit luctus sed at nunc. Lorem ipsum
51
- dolor sit amet, consectetur adipiscing elit. Nullam id turpis nisl. In
52
- hac habitasse platea dictumst. Morbi blandit sodales nibh, auctor
53
- dapibus orci pellentesque sit amet. Etiam posuere massa vel imperdiet
54
- dapibus. Morbi sed tempor neque, sit amet viverra magna. Etiam efficitur
55
- augue accumsan, feugiat libero id, tincidunt turpis. Nam ullamcorper
56
- enim in leo dapibus aliquam eu sit amet erat. Morbi iaculis magna ut
57
- tincidunt rhoncus.
58
- </Text>
59
- <Text>
60
- Mauris pharetra enim et turpis lacinia, quis porta velit commodo. Proin
61
- at vehicula ligula, ut semper sapien. Donec felis elit, pretium vitae
62
- viverra eget, venenatis id elit. Lorem ipsum dolor sit amet, consectetur
63
- adipiscing elit. Quisque blandit et erat nec placerat. Vestibulum vitae
64
- risus pellentesque, semper odio eget, elementum orci. Nam pulvinar metus
65
- sed sapien gravida bibendum. Praesent a malesuada ipsum. Vivamus ac
66
- congue odio.
67
- </Text>
68
- <Text elementType="h2">Second Heading</Text>
69
- <Text>
70
- Ut vel lectus arcu. Etiam ut efficitur turpis, pretium pretium nunc. Ut
71
- dolor nibh, facilisis at tempus at, iaculis sed mi. Etiam sollicitudin,
72
- elit eu dapibus pharetra, purus turpis egestas enim, vel pulvinar leo
73
- libero ac ante. Sed posuere, mi a commodo bibendum, dui lacus
74
- ullamcorper dolor, ut dapibus nunc libero vel felis. Morbi quis
75
- porttitor nisi. Aenean ac elit ipsum. Curabitur nunc nibh, tristique non
76
- purus vel, efficitur vulputate massa. Donec eget risus venenatis turpis
77
- tempor venenatis. Nam aliquet ipsum non faucibus tempus. Vestibulum
78
- efficitur ex erat, eget varius urna venenatis vel. Aenean mollis arcu
79
- purus, id pretium ligula facilisis et.
80
- </Text>
81
- </Box>
82
- </>
83
- );
84
-
85
- export const ExampleVariant = () => (
86
- <div style={{ display: "flex", flexDirection: "column" }}>
87
- <Text variant="h1">variant h1</Text>
88
- <Text variant="h2">variant h2</Text>
89
- <Text variant="h3">variant h3</Text>
90
- <Text variant="h4">variant h4</Text>
91
- <Text variant="body">variant body</Text>
92
- <Text variant="small">variant small</Text>
93
- <Text variant="legal">variant legal</Text>
94
- </div>
95
- );
96
-
97
124
  export const ExampleSpacing = () => (
98
125
  <Box>
99
- <Text variant="h3">Tight Spacing</Text>
126
+ <Text variant="h3">Tight paragraph spacing</Text>
100
127
  <Text spacing="tight">
101
128
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel lorem
102
129
  enim. Nam vitae enim mollis turpis scelerisque vulputate id sit amet nisl.
@@ -111,7 +138,7 @@ export const ExampleSpacing = () => (
111
138
  Ut vel lectus arcu. Etiam ut efficitur turpis, pretium pretium nunc. Ut
112
139
  dolor nibh, facilisis at tempus at, iaculis sed mi.
113
140
  </Text>
114
- <Text variant="h3">Loose Spacing</Text>
141
+ <Text variant="h3">Loose paragraph spacing</Text>
115
142
  <Text>
116
143
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi vel lorem
117
144
  enim. Nam vitae enim mollis turpis scelerisque vulputate id sit amet nisl.