@wise/art 0.0.0-experimental-1d6d788
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/README.md +155 -0
- package/dist/CheckMark-C7SPkQjr.esm.js +38 -0
- package/dist/CheckMark-C7SPkQjr.esm.js.map +1 -0
- package/dist/CheckMark-DbWrBNtH.js +40 -0
- package/dist/CheckMark-DbWrBNtH.js.map +1 -0
- package/dist/Confetti-BbPKLCpN.js +37 -0
- package/dist/Confetti-BbPKLCpN.js.map +1 -0
- package/dist/Confetti-DPMBG56o.esm.js +35 -0
- package/dist/Confetti-DPMBG56o.esm.js.map +1 -0
- package/dist/Flower-Dhjb1Y6Z.esm.js +28 -0
- package/dist/Flower-Dhjb1Y6Z.esm.js.map +1 -0
- package/dist/Flower-I053ey4H.js +30 -0
- package/dist/Flower-I053ey4H.js.map +1 -0
- package/dist/Globe-CJDK9wR6.esm.js +44 -0
- package/dist/Globe-CJDK9wR6.esm.js.map +1 -0
- package/dist/Globe-DD_Ybugr.js +46 -0
- package/dist/Globe-DD_Ybugr.js.map +1 -0
- package/dist/Graph-D1M4JGez.esm.js +32 -0
- package/dist/Graph-D1M4JGez.esm.js.map +1 -0
- package/dist/Graph-DrtwCTeB.js +34 -0
- package/dist/Graph-DrtwCTeB.js.map +1 -0
- package/dist/Illustration.css +1 -0
- package/dist/Interest-5AzhwfRZ.js +53 -0
- package/dist/Interest-5AzhwfRZ.js.map +1 -0
- package/dist/Interest-d9YRzYsQ.esm.js +51 -0
- package/dist/Interest-d9YRzYsQ.esm.js.map +1 -0
- package/dist/Jars-Bj5zryIy.esm.js +51 -0
- package/dist/Jars-Bj5zryIy.esm.js.map +1 -0
- package/dist/Jars-DTpuM002.js +53 -0
- package/dist/Jars-DTpuM002.js.map +1 -0
- package/dist/Lock-Ca-LEge7.js +44 -0
- package/dist/Lock-Ca-LEge7.js.map +1 -0
- package/dist/Lock-xy_KoW2g.esm.js +42 -0
- package/dist/Lock-xy_KoW2g.esm.js.map +1 -0
- package/dist/MagnifyingGlass-CR0nvKTo.esm.js +31 -0
- package/dist/MagnifyingGlass-CR0nvKTo.esm.js.map +1 -0
- package/dist/MagnifyingGlass-DFASWsdn.js +33 -0
- package/dist/MagnifyingGlass-DFASWsdn.js.map +1 -0
- package/dist/Marble-BZIHD9uw.js +45 -0
- package/dist/Marble-BZIHD9uw.js.map +1 -0
- package/dist/Marble-Dn1NhVNa.esm.js +43 -0
- package/dist/Marble-Dn1NhVNa.esm.js.map +1 -0
- package/dist/MarbleCard-CLq_nDBM.esm.js +46 -0
- package/dist/MarbleCard-CLq_nDBM.esm.js.map +1 -0
- package/dist/MarbleCard-CtjGjEPp.js +48 -0
- package/dist/MarbleCard-CtjGjEPp.js.map +1 -0
- package/dist/MultiCurrency-B5HtZfTG.esm.js +62 -0
- package/dist/MultiCurrency-B5HtZfTG.esm.js.map +1 -0
- package/dist/MultiCurrency-Bh-7t3nH.js +64 -0
- package/dist/MultiCurrency-Bh-7t3nH.js.map +1 -0
- package/dist/Plane-D-NW6i-O.js +40 -0
- package/dist/Plane-D-NW6i-O.js.map +1 -0
- package/dist/Plane-aYcLKAhf.esm.js +38 -0
- package/dist/Plane-aYcLKAhf.esm.js.map +1 -0
- package/dist/Scene-ClmxQ_BP.esm.js +54 -0
- package/dist/Scene-ClmxQ_BP.esm.js.map +1 -0
- package/dist/Scene-DNB5gL2m.js +56 -0
- package/dist/Scene-DNB5gL2m.js.map +1 -0
- package/dist/common-DBpCdW70.esm.js +14 -0
- package/dist/common-DBpCdW70.esm.js.map +1 -0
- package/dist/common-H4L6Hbbh.js +16 -0
- package/dist/common-H4L6Hbbh.js.map +1 -0
- package/dist/common.d.ts +15 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/flags/Flag.d.ts +14 -0
- package/dist/flags/Flag.d.ts.map +1 -0
- package/dist/flags/Flag.spec.d.ts +2 -0
- package/dist/flags/Flag.spec.d.ts.map +1 -0
- package/dist/flags/index.d.ts +3 -0
- package/dist/flags/index.d.ts.map +1 -0
- package/dist/flags/metadata.d.ts +2 -0
- package/dist/flags/metadata.d.ts.map +1 -0
- package/dist/illustrations/Illustration.d.ts +20 -0
- package/dist/illustrations/Illustration.d.ts.map +1 -0
- package/dist/illustrations/Illustration.spec.d.ts +2 -0
- package/dist/illustrations/Illustration.spec.d.ts.map +1 -0
- package/dist/illustrations/index.d.ts +5 -0
- package/dist/illustrations/index.d.ts.map +1 -0
- package/dist/illustrations/metadata.d.ts +113 -0
- package/dist/illustrations/metadata.d.ts.map +1 -0
- package/dist/illustrations3d/Illustration3D.d.ts +10 -0
- package/dist/illustrations3d/Illustration3D.d.ts.map +1 -0
- package/dist/illustrations3d/Scene.d.ts +10 -0
- package/dist/illustrations3d/Scene.d.ts.map +1 -0
- package/dist/illustrations3d/index.d.ts +5 -0
- package/dist/illustrations3d/index.d.ts.map +1 -0
- package/dist/illustrations3d/models/CheckMark.d.ts +3 -0
- package/dist/illustrations3d/models/CheckMark.d.ts.map +1 -0
- package/dist/illustrations3d/models/Confetti.d.ts +3 -0
- package/dist/illustrations3d/models/Confetti.d.ts.map +1 -0
- package/dist/illustrations3d/models/Flower.d.ts +3 -0
- package/dist/illustrations3d/models/Flower.d.ts.map +1 -0
- package/dist/illustrations3d/models/Globe.d.ts +3 -0
- package/dist/illustrations3d/models/Globe.d.ts.map +1 -0
- package/dist/illustrations3d/models/Graph.d.ts +3 -0
- package/dist/illustrations3d/models/Graph.d.ts.map +1 -0
- package/dist/illustrations3d/models/Interest.d.ts +3 -0
- package/dist/illustrations3d/models/Interest.d.ts.map +1 -0
- package/dist/illustrations3d/models/Jars.d.ts +3 -0
- package/dist/illustrations3d/models/Jars.d.ts.map +1 -0
- package/dist/illustrations3d/models/Lock.d.ts +3 -0
- package/dist/illustrations3d/models/Lock.d.ts.map +1 -0
- package/dist/illustrations3d/models/MagnifyingGlass.d.ts +3 -0
- package/dist/illustrations3d/models/MagnifyingGlass.d.ts.map +1 -0
- package/dist/illustrations3d/models/Marble.d.ts +3 -0
- package/dist/illustrations3d/models/Marble.d.ts.map +1 -0
- package/dist/illustrations3d/models/MarbleCard.d.ts +3 -0
- package/dist/illustrations3d/models/MarbleCard.d.ts.map +1 -0
- package/dist/illustrations3d/models/MultiCurrency.d.ts +3 -0
- package/dist/illustrations3d/models/MultiCurrency.d.ts.map +1 -0
- package/dist/illustrations3d/models/Plane.d.ts +3 -0
- package/dist/illustrations3d/models/Plane.d.ts.map +1 -0
- package/dist/illustrations3d/utils.d.ts +9 -0
- package/dist/illustrations3d/utils.d.ts.map +1 -0
- package/dist/illustrations3d/utils.spec.d.ts +2 -0
- package/dist/illustrations3d/utils.spec.d.ts.map +1 -0
- package/dist/index-ApMK-TMV.esm.js +377 -0
- package/dist/index-ApMK-TMV.esm.js.map +1 -0
- package/dist/index-CeTVmx_6.js +383 -0
- package/dist/index-CeTVmx_6.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +6 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/rive/RiveIllustration.d.ts +13 -0
- package/dist/rive/RiveIllustration.d.ts.map +1 -0
- package/dist/rive/index.d.ts +3 -0
- package/dist/rive/index.d.ts.map +1 -0
- package/dist/rive/index.esm.js +47 -0
- package/dist/rive/index.esm.js.map +1 -0
- package/dist/rive/index.js +53 -0
- package/dist/rive/index.js.map +1 -0
- package/package.json +125 -0
- package/src/common.ts +17 -0
- package/src/flags/AllFlagsAndSizes.stories.tsx +131 -0
- package/src/flags/Flag.css +4 -0
- package/src/flags/Flag.spec.tsx +31 -0
- package/src/flags/Flag.stories.tsx +20 -0
- package/src/flags/Flag.tsx +65 -0
- package/src/flags/index.ts +2 -0
- package/src/flags/metadata.ts +9 -0
- package/src/illustrations/Illustration.css +27 -0
- package/src/illustrations/Illustration.spec.tsx +20 -0
- package/src/illustrations/Illustration.stories.tsx +58 -0
- package/src/illustrations/Illustration.tsx +95 -0
- package/src/illustrations/index.ts +5 -0
- package/src/illustrations/metadata.ts +13 -0
- package/src/illustrations3d/Illustration3D.stories.tsx +101 -0
- package/src/illustrations3d/Illustration3D.tsx +139 -0
- package/src/illustrations3d/Scene.tsx +62 -0
- package/src/illustrations3d/index.ts +6 -0
- package/src/illustrations3d/models/CheckMark.tsx +30 -0
- package/src/illustrations3d/models/Confetti.tsx +29 -0
- package/src/illustrations3d/models/Flower.tsx +24 -0
- package/src/illustrations3d/models/Globe.tsx +41 -0
- package/src/illustrations3d/models/Graph.tsx +26 -0
- package/src/illustrations3d/models/Interest.tsx +42 -0
- package/src/illustrations3d/models/Jars.tsx +47 -0
- package/src/illustrations3d/models/Lock.tsx +38 -0
- package/src/illustrations3d/models/MagnifyingGlass.tsx +30 -0
- package/src/illustrations3d/models/Marble.tsx +47 -0
- package/src/illustrations3d/models/MarbleCard.tsx +50 -0
- package/src/illustrations3d/models/MultiCurrency.tsx +58 -0
- package/src/illustrations3d/models/Plane.tsx +33 -0
- package/src/illustrations3d/utils.spec.tsx +36 -0
- package/src/illustrations3d/utils.ts +73 -0
- package/src/index.css +3 -0
- package/src/index.ts +12 -0
- package/src/rive/RiveIllustration.css +18 -0
- package/src/rive/RiveIllustration.stories.tsx +20 -0
- package/src/rive/RiveIllustration.tsx +54 -0
- package/src/rive/index.ts +2 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reactWebgl2 = require('@rive-app/react-webgl2');
|
|
4
|
+
var clsx = require('clsx');
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var common = require('../common-H4L6Hbbh.js');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
var clsx__default = /*#__PURE__*/_interopDefault(clsx);
|
|
12
|
+
|
|
13
|
+
const Rive = ({
|
|
14
|
+
src,
|
|
15
|
+
animationNames
|
|
16
|
+
}) => {
|
|
17
|
+
const {
|
|
18
|
+
RiveComponent
|
|
19
|
+
} = reactWebgl2.useRive({
|
|
20
|
+
src,
|
|
21
|
+
animations: animationNames,
|
|
22
|
+
autoplay: true
|
|
23
|
+
});
|
|
24
|
+
return /*#__PURE__*/jsxRuntime.jsx(RiveComponent, {});
|
|
25
|
+
};
|
|
26
|
+
const RiveIllustrationExperimental = ({
|
|
27
|
+
name,
|
|
28
|
+
size: sizeProp = common.Sizes.MEDIUM,
|
|
29
|
+
className
|
|
30
|
+
}) => {
|
|
31
|
+
const [size, setSize] = react.useState(sizeProp);
|
|
32
|
+
react.useEffect(() => {
|
|
33
|
+
const isMobile = (typeof window !== "undefined" && window?.matchMedia('(max-width: 575px)')?.matches) ?? false;
|
|
34
|
+
if (isMobile) {
|
|
35
|
+
setSize(common.Sizes.SMALL);
|
|
36
|
+
}
|
|
37
|
+
}, []);
|
|
38
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
39
|
+
className: clsx__default.default(`wds-illustration-rive wds-illustration-rive-${name} wds-illustration-rive-${size}`, className),
|
|
40
|
+
children: (() => {
|
|
41
|
+
if (name === 'document-scan') {
|
|
42
|
+
return /*#__PURE__*/jsxRuntime.jsx(Rive, {
|
|
43
|
+
src: "https://wise.com/web-art/assets/illustrations3d/rive/doc-scan.riv",
|
|
44
|
+
animationNames: ["Scan Line Appearing", "Scan Line Moving"]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return null;
|
|
48
|
+
})()
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
exports.RiveIllustrationExperimental = RiveIllustrationExperimental;
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/rive/RiveIllustration.tsx"],"sourcesContent":["import { useRive } from \"@rive-app/react-webgl2\";\nimport clsx from \"clsx\";\nimport { useEffect, useState } from \"react\";\n\nimport { Sizes } from \"../common\";\nimport type { Illustration3DProps } from \"../illustrations3d\";\n\nexport interface RiveProps {\n src: string;\n animationNames?: string | string[];\n}\n\nconst Rive = ({ src, animationNames }: RiveProps) => {\n const { RiveComponent } = useRive({\n src,\n animations: animationNames,\n autoplay: true,\n });\n\n return (<RiveComponent />);\n};\n\nexport type Props = {\n name: 'document-scan';\n size?: Illustration3DProps[\"size\"];\n className?: Illustration3DProps[\"className\"];\n};\n\nconst RiveIllustrationExperimental = ({ name, size: sizeProp = Sizes.MEDIUM, className }: Props) => {\n const [size, setSize] = useState<Props['size']>(sizeProp);\n useEffect(() => {\n const isMobile: boolean =\n (typeof window !== \"undefined\" && window?.matchMedia('(max-width: 575px)')?.matches) ?? false;\n if (isMobile) {\n setSize(Sizes.SMALL);\n }\n }, []);\n return (\n <div className={clsx('wds-illustration-rive', `wds-illustration-rive-${name}`, `wds-illustration-rive-${size}`, className)}>\n {(() => {\n if (name === 'document-scan') {\n return (\n <Rive\n src=\"https://wise.com/web-art/assets/illustrations3d/rive/doc-scan.riv\"\n animationNames={[\"Scan Line Appearing\", \"Scan Line Moving\"]}\n />);\n }\n return null;\n })()}\n </div>\n );\n};\n\nexport default RiveIllustrationExperimental;\n"],"names":["Rive","src","animationNames","RiveComponent","useRive","animations","autoplay","_jsx","RiveIllustrationExperimental","name","size","sizeProp","Sizes","MEDIUM","className","setSize","useState","useEffect","isMobile","window","matchMedia","matches","SMALL","clsx","children"],"mappings":";;;;;;;;;;;;AAYA,MAAMA,IAAI,GAAGA,CAAC;EAAEC,GAAG;AAAEC,EAAAA;AAAc,CAAa,KAAI;EAClD,MAAM;AAAEC,IAAAA;GAAe,GAAGC,mBAAO,CAAC;IAChCH,GAAG;AACHI,IAAAA,UAAU,EAAEH,cAAc;AAC1BI,IAAAA,QAAQ,EAAE;AACX,GAAA,CAAC;AAEF,EAAA,oBAAQC,cAAA,CAACJ,aAAa,EAAA,EAAA,CAAG;AAC3B,CAAC;AAQD,MAAMK,4BAA4B,GAAGA,CAAC;EAAEC,IAAI;AAAEC,EAAAA,IAAI,EAAEC,QAAQ,GAAGC,YAAK,CAACC,MAAM;AAAEC,EAAAA;AAAS,CAAS,KAAI;EACjG,MAAM,CAACJ,IAAI,EAAEK,OAAO,CAAC,GAAGC,cAAQ,CAAgBL,QAAQ,CAAC;AACzDM,EAAAA,eAAS,CAAC,MAAK;AACb,IAAA,MAAMC,QAAQ,GACZ,CAAC,OAAOC,MAAM,KAAK,WAAW,IAAIA,MAAM,EAAEC,UAAU,CAAC,oBAAoB,CAAC,EAAEC,OAAO,KAAK,KAAK;AAC/F,IAAA,IAAIH,QAAQ,EAAE;AACZH,MAAAA,OAAO,CAACH,YAAK,CAACU,KAAK,CAAC;AACtB,IAAA;EACF,CAAC,EAAE,EAAE,CAAC;AACN,EAAA,oBACEf,cAAA,CAAA,KAAA,EAAA;IAAKO,SAAS,EAAES,qBAAI,CAAA,CAAA,4CAAA,EAAmDd,IAAI,0BAA6BC,IAAI,CAAA,CAAA,EAAII,SAAS,CAAE;IAAAU,QAAA,EACxH,CAAC,MAAK;MACL,IAAIf,IAAI,KAAK,eAAe,EAAE;QAC5B,oBACEF,cAAA,CAACP,IAAI,EAAA;AACHC,UAAAA,GAAG,EAAC,mEAAmE;AACvEC,UAAAA,cAAc,EAAE,CAAC,qBAAqB,EAAE,kBAAkB;AAAE,SAAA,CAC5D;AACN,MAAA;AACA,MAAA,OAAO,IAAI;AACb,IAAA,CAAC;AAAG,GACD,CAAC;AAEV;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wise/art",
|
|
3
|
+
"version": "0.0.0-experimental-1d6d788",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "React library for art elements in UI",
|
|
6
|
+
"homepage": "https://github.com/transferwise/web-art#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/transferwise/web-art.git"
|
|
10
|
+
},
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"registry": "https://registry.npmjs.org/",
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"author": "Wise Payments Ltd.",
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"*.css"
|
|
18
|
+
],
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"module": "./dist/index.esm.js",
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"files": [
|
|
23
|
+
"dist/",
|
|
24
|
+
"src/",
|
|
25
|
+
"!**/*.tsbuildinfo"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@babel/runtime": "^7.28.4",
|
|
29
|
+
"@react-three/drei": "9.122.0",
|
|
30
|
+
"@react-three/fiber": "8.18.0",
|
|
31
|
+
"@rive-app/react-webgl2": "^4.25.1",
|
|
32
|
+
"@types/three": "0.164.0",
|
|
33
|
+
"clsx": "^2.1.1",
|
|
34
|
+
"three": "0.164.0"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@babel/core": "^7.28.5",
|
|
38
|
+
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
39
|
+
"@babel/preset-env": "^7.28.5",
|
|
40
|
+
"@babel/preset-react": "^7.28.5",
|
|
41
|
+
"@babel/preset-typescript": "^7.28.5",
|
|
42
|
+
"@csstools/postcss-minify": "^2.0.5",
|
|
43
|
+
"@rollup/plugin-babel": "^6.1.0",
|
|
44
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
45
|
+
"@storybook/react-vite": "^10.1.11",
|
|
46
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
47
|
+
"@testing-library/react": "^16.3.1",
|
|
48
|
+
"@transferwise/neptune-css": "^14.26.0",
|
|
49
|
+
"@tsconfig/recommended": "^1.0.13",
|
|
50
|
+
"@types/babel__core": "^7.20.5",
|
|
51
|
+
"@types/imagemin": "^9.0.1",
|
|
52
|
+
"@types/imagemin-webp": "^7.0.3",
|
|
53
|
+
"@types/jest": "^30.0.0",
|
|
54
|
+
"@types/jsdom": "^27.0.0",
|
|
55
|
+
"@types/react": "^18.3.23",
|
|
56
|
+
"@types/react-dom": "^18.3.7",
|
|
57
|
+
"@vitejs/plugin-react": "^5.1.2",
|
|
58
|
+
"@wise/eslint-config": "^13.3.0",
|
|
59
|
+
"babel-plugin-optimize-clsx": "^2.6.2",
|
|
60
|
+
"copyfiles": "^2.4.1",
|
|
61
|
+
"eslint": "^9.39.2",
|
|
62
|
+
"glob": "^13.0.0",
|
|
63
|
+
"gltf-pipeline": "^4.3.0",
|
|
64
|
+
"imagemin": "^9.0.1",
|
|
65
|
+
"imagemin-webp": "^8.0.0",
|
|
66
|
+
"jest": "^30.2.0",
|
|
67
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
68
|
+
"jsdom": "^27.4.0",
|
|
69
|
+
"postcss": "^8.5.6",
|
|
70
|
+
"postcss-cli": "^11.0.1",
|
|
71
|
+
"postcss-import": "^16.1.1",
|
|
72
|
+
"prettier": "^3.7.4",
|
|
73
|
+
"react": "^18.3.1",
|
|
74
|
+
"react-dom": "^18.3.1",
|
|
75
|
+
"rollup": "^4.54.0",
|
|
76
|
+
"sharp": "^0.34.5",
|
|
77
|
+
"storybook": "^10.1.11",
|
|
78
|
+
"typescript": "^5.9.3",
|
|
79
|
+
"vite": "^7.3.0",
|
|
80
|
+
"wise-atoms": "git+https://github.com/transferwise/wise-atoms.git#8afba508f461e91d458d4312600cb279b3f47086",
|
|
81
|
+
"@storybook/addon-docs": "^10.1.11",
|
|
82
|
+
"@changesets/cli": "^2.29.8",
|
|
83
|
+
"@changesets/changelog-github": "0.5.2"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"@transferwise/neptune-css": "^14.25.2",
|
|
87
|
+
"react": ">=18",
|
|
88
|
+
"react-dom": ">=18"
|
|
89
|
+
},
|
|
90
|
+
"resolutions": {
|
|
91
|
+
"http-cache-semantics": "^4.1.1",
|
|
92
|
+
"semver-regex": "^4.0.5"
|
|
93
|
+
},
|
|
94
|
+
"engines": {
|
|
95
|
+
"node": "^24"
|
|
96
|
+
},
|
|
97
|
+
"scripts": {
|
|
98
|
+
"setup": "pnpm install && pnpm build",
|
|
99
|
+
"load-3d-i10s": "rm -rf s3-bucket/illustrations3d/ && node ./scripts/load-3d-i10s.mjs && pnpm load-riv",
|
|
100
|
+
"load-riv": "copyfiles -u 1 assets/*.riv s3-bucket/illustrations3d/rive",
|
|
101
|
+
"load-i10s": "copyfiles -u 3 node_modules/wise-atoms/illustrations/**/*.png temp",
|
|
102
|
+
"load-flags": "rm -rf s3-bucket/flags/* && pnpm load-country-flags && pnpm load-currency-flags && pnpm transform-flags && pnpm convert-flags-svg-to-png",
|
|
103
|
+
"load-country-flags": "copyfiles -u 3 node_modules/wise-atoms/flags/*.svg s3-bucket/flags && node ./scripts/generate-country-flags.mjs",
|
|
104
|
+
"load-currency-flags": "copyfiles -u 3 node_modules/wise-atoms/flags/.metadata.json s3-bucket/flags && node ./scripts/generate-currency-flags.mjs",
|
|
105
|
+
"transform-flags": "node ./scripts/transform-flags.mjs",
|
|
106
|
+
"convert-flags-svg-to-png": "node ./scripts/convert-flags-svg-to-png.mjs",
|
|
107
|
+
"convert-i10s-png-to-webp": "rm -rf s3-bucket/illustrations/ && copyfiles --f node_modules/wise-atoms/illustrations/**/*.png s3-bucket/illustrations && node ./scripts/convert-png-to-webp.mjs",
|
|
108
|
+
"generate-i10s-metadata": "node ./scripts/generate-i10s-metadata.mjs && eslint 'src/illustrations/metadata.ts' --fix",
|
|
109
|
+
"generate-flags-metadata": "node ./scripts/generate-flags-metadata.mjs && eslint 'src/flags/metadata.ts' --fix",
|
|
110
|
+
"bundle": "rm -rf dist && rollup --config --sourcemap && pnpm build-styles",
|
|
111
|
+
"cleanup": "rm -rf temp",
|
|
112
|
+
"build": "NODE_ENV=web-art-prod pnpm load-i10s && pnpm load-3d-i10s && pnpm convert-i10s-png-to-webp && pnpm generate-i10s-metadata && pnpm load-flags && pnpm generate-flags-metadata && pnpm bundle && pnpm cleanup",
|
|
113
|
+
"build:experimental": "NODE_ENV=web-art-prod pnpm generate-i10s-metadata && pnpm generate-flags-metadata && pnpm bundle && pnpm cleanup",
|
|
114
|
+
"start": "storybook dev -p 3001",
|
|
115
|
+
"dev": "NODE_ENV=web-art-dev pnpm start",
|
|
116
|
+
"test": "jest",
|
|
117
|
+
"test:watch": "jest --watch",
|
|
118
|
+
"lint": "eslint 'src/**/*.{js,ts,tsx}' 'scripts/*.{mjs,js,ts,tsx}'",
|
|
119
|
+
"lint-fix": "eslint 'src/**/*.{js,ts,tsx}' 'scripts/*.{mjs,js,ts,tsx}' --fix",
|
|
120
|
+
"build-docs": "storybook build --stats-json -o docs && touch ./docs/.nojekyll",
|
|
121
|
+
"build-styles": "postcss src/index.css -o dist/Illustration.css",
|
|
122
|
+
"changeset": "changeset",
|
|
123
|
+
"release": "changeset publish"
|
|
124
|
+
}
|
|
125
|
+
}
|
package/src/common.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export enum Sizes {
|
|
2
|
+
SMALL = 'small',
|
|
3
|
+
MEDIUM = 'medium',
|
|
4
|
+
LARGE = 'large',
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const ImageSizes = {
|
|
8
|
+
[Sizes.SMALL]: 200,
|
|
9
|
+
[Sizes.MEDIUM]: 300,
|
|
10
|
+
[Sizes.LARGE]: 500,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type LargeSize = 'large';
|
|
14
|
+
export type MediumSize = 'medium';
|
|
15
|
+
export type SmallSize = 'small';
|
|
16
|
+
|
|
17
|
+
export type Descriptors = '1x' | '1.5x' | '2x' | '3x' | '4x';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import flagRawMetaData from '../../node_modules/wise-atoms/flags/.metadata.json';
|
|
4
|
+
import { Flag } from './Flag';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof Flag> = {
|
|
7
|
+
component: Flag,
|
|
8
|
+
title: 'Flag/All Flags and Sizes',
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
|
|
12
|
+
type Story = StoryObj<typeof Flag>;
|
|
13
|
+
|
|
14
|
+
// Helper function to render all flags and sizes for a given region
|
|
15
|
+
const AllFlagsAndSizes = (region: string) => {
|
|
16
|
+
const regionFlags = Object.entries(flagRawMetaData)
|
|
17
|
+
.filter(([r]) => r === region)
|
|
18
|
+
.flatMap(([, flags]) => flags);
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<div
|
|
23
|
+
style={{
|
|
24
|
+
display: 'flex',
|
|
25
|
+
flexDirection: 'column',
|
|
26
|
+
marginBottom: 'var(--padding-medium)',
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
<span className="np-text-title-section">{region}</span>
|
|
30
|
+
<span className="np-text-body-large-bold">
|
|
31
|
+
Total number of flags in category: {regionFlags.length}
|
|
32
|
+
</span>
|
|
33
|
+
</div>
|
|
34
|
+
<div
|
|
35
|
+
style={{
|
|
36
|
+
display: 'grid',
|
|
37
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(350px, 1fr))',
|
|
38
|
+
gap: 'var(--padding-small)',
|
|
39
|
+
}}
|
|
40
|
+
>
|
|
41
|
+
{regionFlags.map((flag) => {
|
|
42
|
+
const countryCode = flag.country[0]?.toUpperCase();
|
|
43
|
+
const currencyCode = flag.currency[0]?.toUpperCase();
|
|
44
|
+
const flagCode = countryCode ?? currencyCode;
|
|
45
|
+
|
|
46
|
+
// Covers cases where there's just a currency code and no country (e.g. Euro)
|
|
47
|
+
const flagName = countryCode
|
|
48
|
+
? flag.country.at(-1)
|
|
49
|
+
: flag.currency?.at(-1);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
key={flagName}
|
|
54
|
+
style={{
|
|
55
|
+
display: 'grid',
|
|
56
|
+
gridTemplateColumns: 'minmax(auto, 1fr) auto 1fr',
|
|
57
|
+
gap: 'var(--padding-small)',
|
|
58
|
+
alignItems: 'center',
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<div
|
|
62
|
+
style={{
|
|
63
|
+
display: 'flex',
|
|
64
|
+
flexWrap: 'wrap',
|
|
65
|
+
flexDirection: 'column',
|
|
66
|
+
alignItems: 'flex-start',
|
|
67
|
+
gap: 'var(--padding-small)',
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
{flagName}
|
|
71
|
+
<span>
|
|
72
|
+
{countryCode && (
|
|
73
|
+
<>
|
|
74
|
+
Country: <code>{countryCode}</code>
|
|
75
|
+
</>
|
|
76
|
+
)}
|
|
77
|
+
{currencyCode && countryCode && <br />}
|
|
78
|
+
{currencyCode && (
|
|
79
|
+
<>
|
|
80
|
+
Currency: <code>{currencyCode}</code>
|
|
81
|
+
</>
|
|
82
|
+
)}
|
|
83
|
+
</span>
|
|
84
|
+
{currencyCode && <span />}
|
|
85
|
+
</div>
|
|
86
|
+
<Flag code={flagCode} />
|
|
87
|
+
<Flag code={flagCode} intrinsicSize={150} />
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
})}
|
|
91
|
+
</div>
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// Stories for each region
|
|
97
|
+
export const Africa: Story = {
|
|
98
|
+
render: () => AllFlagsAndSizes('Africa'),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const Antarctic: Story = {
|
|
102
|
+
render: () => AllFlagsAndSizes('Antarctic'),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const Asia: Story = {
|
|
106
|
+
render: () => AllFlagsAndSizes('Asia'),
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const CentralAmerica: Story = {
|
|
110
|
+
render: () => AllFlagsAndSizes('Central America'),
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const Europe: Story = {
|
|
114
|
+
render: () => AllFlagsAndSizes('Europe'),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const NorthAmerica: Story = {
|
|
118
|
+
render: () => AllFlagsAndSizes('North America'),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const Oceania: Story = {
|
|
122
|
+
render: () => AllFlagsAndSizes('Oceania'),
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const SouthAmerica: Story = {
|
|
126
|
+
render: () => AllFlagsAndSizes('South America'),
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export const Fallback: Story = {
|
|
130
|
+
render: () => AllFlagsAndSizes('Fallback'),
|
|
131
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
|
|
5
|
+
import { Flag } from './Flag';
|
|
6
|
+
|
|
7
|
+
describe('Flag', () => {
|
|
8
|
+
it('use default image when < 150px', () => {
|
|
9
|
+
const { container } = render(<Flag code="es" />);
|
|
10
|
+
|
|
11
|
+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
|
|
12
|
+
const flag = container.querySelector('img');
|
|
13
|
+
expect(flag?.src.includes('detailed')).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('use detailed image when available and >= 150px', () => {
|
|
17
|
+
const { container } = render(<Flag code="es" intrinsicSize={150} />);
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
|
|
20
|
+
const flag = container.querySelector('img');
|
|
21
|
+
expect(flag?.src.includes('detailed')).toBe(true);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("don't try to use detailed image if not available", () => {
|
|
25
|
+
const { container } = render(<Flag code="fr" />);
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line testing-library/no-container, testing-library/no-node-access
|
|
28
|
+
const flag = container.querySelector('img');
|
|
29
|
+
expect(flag?.src.includes('detailed')).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Flag } from './Flag';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Flag> = {
|
|
6
|
+
component: Flag,
|
|
7
|
+
title: 'Flag',
|
|
8
|
+
};
|
|
9
|
+
export default meta;
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof Flag>;
|
|
12
|
+
|
|
13
|
+
export const Basic: Story = {
|
|
14
|
+
render: (args) => <Flag {...args} />,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
args: {
|
|
17
|
+
code: 'GBP',
|
|
18
|
+
intrinsicSize: 64,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { DETAILED_FLAG_CODES } from './metadata';
|
|
5
|
+
|
|
6
|
+
export interface FlagProps {
|
|
7
|
+
/**
|
|
8
|
+
* Two-letter country code (ISO 3166-1 alpha-2) or three-letter currency code (ISO 4217).
|
|
9
|
+
*/
|
|
10
|
+
code: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Width and height to reserve for the underlying image, in pixels. A detailed variant is shown from 150px and above.
|
|
14
|
+
*/
|
|
15
|
+
intrinsicSize?: number;
|
|
16
|
+
className?: string;
|
|
17
|
+
loading?: 'lazy' | 'eager';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const unknownFlagName = 'wise';
|
|
21
|
+
|
|
22
|
+
export const Flag = ({
|
|
23
|
+
code,
|
|
24
|
+
intrinsicSize = 64,
|
|
25
|
+
className = undefined,
|
|
26
|
+
loading = 'lazy',
|
|
27
|
+
}: FlagProps) => {
|
|
28
|
+
const [fallback, setFallback] = useState<'simple' | 'unknown' | null>(null);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
setFallback(null);
|
|
31
|
+
}, [code]);
|
|
32
|
+
|
|
33
|
+
const detailed = intrinsicSize >= 150;
|
|
34
|
+
// Only get detailed svg if we know it exists, to avoid the performance hit of failing requests
|
|
35
|
+
const name =
|
|
36
|
+
fallback !== 'unknown'
|
|
37
|
+
? `${code.toLowerCase()}${
|
|
38
|
+
fallback == null &&
|
|
39
|
+
detailed &&
|
|
40
|
+
DETAILED_FLAG_CODES.includes(code.toLowerCase())
|
|
41
|
+
? '-detailed'
|
|
42
|
+
: ''
|
|
43
|
+
}`
|
|
44
|
+
: unknownFlagName;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<img
|
|
48
|
+
className={clsx('wds-flag', `wds-flag-${name}`, className)}
|
|
49
|
+
src={
|
|
50
|
+
process.env.NODE_ENV === 'web-art-dev'
|
|
51
|
+
? `${name}.svg`
|
|
52
|
+
: `https://wise.com/web-art/assets/flags/${name}.svg`
|
|
53
|
+
}
|
|
54
|
+
loading={loading}
|
|
55
|
+
alt=""
|
|
56
|
+
width={intrinsicSize}
|
|
57
|
+
height={intrinsicSize}
|
|
58
|
+
onError={() => {
|
|
59
|
+
setFallback((prev) =>
|
|
60
|
+
prev == null && detailed ? 'simple' : 'unknown',
|
|
61
|
+
);
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*
|
|
2
|
+
*
|
|
3
|
+
* DON'T MODIFY THIS FILE IT'S AUTO GENERATED
|
|
4
|
+
* See: `scripts/generate-flags-metadata.mjs`
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const DETAILED_FLAG_CODES = ['zm', 'va', 'uy', 'us', 'ug', 'tw', 'tv', 'tm', 'sv', 'sm', 'si', 'sg', 'py', 'pt', 'ph', 'pe', 'pa', 'om', 'nz', 'np', 'ni', 'mz', 'my', 'mx', 'mt', 'mh', 'md', 'ls', 'lk', 'li', 'ki', 'ke', 'je', 'in', 'im', 'hr', 'hn', 'hm', 'hk', 'gt', 'gi', 'gg', 'fj', 'eur', 'es', 'eg', 'do', 'cn', 'by', 'br', 'bn', 'bf', 'ba', 'az', 'au', 'ar', 'an', 'am', 'al', 'ad'];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Prevent image overflow viewport or container element */
|
|
2
|
+
img.wds-illustration {
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.wds-illustration-padding {
|
|
7
|
+
padding: 24px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.wds-illustration-3d {
|
|
11
|
+
display: inline-flex;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wds-illustration-3d-small {
|
|
15
|
+
width: 200px;
|
|
16
|
+
height: 200px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.wds-illustration-3d-medium {
|
|
20
|
+
width: 300px;
|
|
21
|
+
height: 300px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.wds-illustration-3d-large {
|
|
25
|
+
width: 500px;
|
|
26
|
+
height: 500px;
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
|
|
4
|
+
import Illustration from './Illustration';
|
|
5
|
+
import { Assets } from './metadata';
|
|
6
|
+
|
|
7
|
+
describe('Illustration', () => {
|
|
8
|
+
it('should create empty alt att', () => {
|
|
9
|
+
render(<Illustration name={Assets.CHECK_MARK} />);
|
|
10
|
+
|
|
11
|
+
expect(screen.getByRole('presentation')).toHaveAttribute('alt', '');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should create alt with custom text', () => {
|
|
15
|
+
const customAltText = 'Image of slick check mark';
|
|
16
|
+
render(<Illustration alt={customAltText} name={Assets.CHECK_MARK} />);
|
|
17
|
+
|
|
18
|
+
expect(screen.getByRole('img')).toHaveAttribute('alt', customAltText);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react-vite";
|
|
2
|
+
|
|
3
|
+
import Illustration, { type Props as IllustrationProps } from "./Illustration";
|
|
4
|
+
import { Assets, type IllustrationNames } from "./metadata";
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
component: Illustration,
|
|
8
|
+
title: "Illustration",
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type Story = StoryObj<typeof Illustration>;
|
|
12
|
+
|
|
13
|
+
export const Basic: Story = {
|
|
14
|
+
tags: ["autodocs"],
|
|
15
|
+
render: function Render({
|
|
16
|
+
name = Assets.CHECK_MARK,
|
|
17
|
+
...props
|
|
18
|
+
}: IllustrationProps) {
|
|
19
|
+
return <Illustration name={name} {...props} />;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const All = () => {
|
|
24
|
+
const assetNames = Object.values(Assets);
|
|
25
|
+
return (
|
|
26
|
+
<>
|
|
27
|
+
<span className="np-text-body-large-bold">
|
|
28
|
+
Total number of illustrations: {assetNames.length}
|
|
29
|
+
</span>
|
|
30
|
+
<div
|
|
31
|
+
style={{
|
|
32
|
+
display: "grid",
|
|
33
|
+
gridTemplateColumns: "repeat(auto-fill, minmax(250px, 1fr))",
|
|
34
|
+
gap: "var(--padding-small)",
|
|
35
|
+
}}
|
|
36
|
+
>
|
|
37
|
+
{Object.values(Assets).map((assetName) => (
|
|
38
|
+
<div
|
|
39
|
+
key={assetName}
|
|
40
|
+
style={{
|
|
41
|
+
display: "grid",
|
|
42
|
+
alignItems: "center",
|
|
43
|
+
justifyItems: "center",
|
|
44
|
+
}}
|
|
45
|
+
>
|
|
46
|
+
<Illustration
|
|
47
|
+
alt={assetName}
|
|
48
|
+
name={assetName as IllustrationNames}
|
|
49
|
+
/>
|
|
50
|
+
<span>
|
|
51
|
+
<code>{assetName}</code>
|
|
52
|
+
</span>
|
|
53
|
+
</div>
|
|
54
|
+
))}
|
|
55
|
+
</div>
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
type LargeSize,
|
|
6
|
+
type MediumSize,
|
|
7
|
+
type SmallSize,
|
|
8
|
+
type Descriptors,
|
|
9
|
+
Sizes,
|
|
10
|
+
} from './../common';
|
|
11
|
+
import type { IllustrationNames } from './metadata';
|
|
12
|
+
|
|
13
|
+
// Picking only a few props from Image element to avoid breaking change
|
|
14
|
+
// as in future underlying element might change
|
|
15
|
+
type ImgProps = Pick<React.ImgHTMLAttributes<HTMLImageElement>, 'id' | 'className'>;
|
|
16
|
+
|
|
17
|
+
export type IllustrationSizes = LargeSize | MediumSize | SmallSize;
|
|
18
|
+
|
|
19
|
+
export type Props = {
|
|
20
|
+
name: IllustrationNames;
|
|
21
|
+
alt?: string;
|
|
22
|
+
size?: IllustrationSizes;
|
|
23
|
+
loading?: 'eager' | 'lazy';
|
|
24
|
+
disablePadding?: boolean;
|
|
25
|
+
} & ImgProps;
|
|
26
|
+
|
|
27
|
+
const imageSizes = {
|
|
28
|
+
[Sizes.SMALL]: 200,
|
|
29
|
+
[Sizes.MEDIUM]: 300,
|
|
30
|
+
[Sizes.LARGE]: 500,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const Illustration = forwardRef<HTMLImageElement, Props>(
|
|
34
|
+
(
|
|
35
|
+
{
|
|
36
|
+
id,
|
|
37
|
+
name,
|
|
38
|
+
alt = '',
|
|
39
|
+
loading = 'eager',
|
|
40
|
+
className,
|
|
41
|
+
size = Sizes.MEDIUM,
|
|
42
|
+
disablePadding = false,
|
|
43
|
+
}: Props,
|
|
44
|
+
ref,
|
|
45
|
+
) => {
|
|
46
|
+
const { SMALL, MEDIUM } = Sizes;
|
|
47
|
+
|
|
48
|
+
return name ? (
|
|
49
|
+
<picture>
|
|
50
|
+
{size === Sizes.LARGE || size === Sizes.MEDIUM ? (
|
|
51
|
+
<>
|
|
52
|
+
<source
|
|
53
|
+
width={imageSizes[SMALL]}
|
|
54
|
+
height={imageSizes[SMALL]}
|
|
55
|
+
media="(max-width: 575px)"
|
|
56
|
+
srcSet={`${defineSrc(name, SMALL, '1x')}, ${defineSrc(name, SMALL, '2x')} 2x`}
|
|
57
|
+
/>
|
|
58
|
+
{size !== Sizes.MEDIUM ? (
|
|
59
|
+
<source
|
|
60
|
+
width={imageSizes[MEDIUM]}
|
|
61
|
+
height={imageSizes[MEDIUM]}
|
|
62
|
+
media="(max-width: 992px)"
|
|
63
|
+
srcSet={`${defineSrc(name, MEDIUM, '1x')}, ${defineSrc(name, MEDIUM, '2x')} 2x`}
|
|
64
|
+
/>
|
|
65
|
+
) : null}
|
|
66
|
+
</>
|
|
67
|
+
) : null}
|
|
68
|
+
|
|
69
|
+
<img
|
|
70
|
+
id={id}
|
|
71
|
+
ref={ref}
|
|
72
|
+
alt={alt}
|
|
73
|
+
data-testid={`wds-${name}-illustration`}
|
|
74
|
+
className={clsx(
|
|
75
|
+
'wds-illustration',
|
|
76
|
+
`wds-illustration-${name}`,
|
|
77
|
+
{ 'wds-illustration-padding': !disablePadding },
|
|
78
|
+
className,
|
|
79
|
+
)}
|
|
80
|
+
loading={loading}
|
|
81
|
+
src={defineSrc(name, size, '1x')}
|
|
82
|
+
srcSet={`${defineSrc(name, size, '2x')} 2x`}
|
|
83
|
+
width={imageSizes[size]}
|
|
84
|
+
height={imageSizes[size]}
|
|
85
|
+
/>
|
|
86
|
+
</picture>
|
|
87
|
+
) : null;
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
function defineSrc(illustration: string, size: IllustrationSizes, descriptor: Descriptors) {
|
|
92
|
+
return `https://wise.com/web-art/assets/illustrations/${illustration}-${size}@${descriptor}.webp`;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default Illustration;
|