@wise/art 0.0.0-experimental-b088eec → 0.0.0-experimental-6054253
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wise/art",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-6054253",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React library for art elements in UI",
|
|
6
6
|
"homepage": "https://github.com/transferwise/web-art#readme",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"storybook": "^10.2.10",
|
|
77
77
|
"typescript": "^5.9.3",
|
|
78
78
|
"vite": "^7.3.1",
|
|
79
|
-
"wise-atoms": "git+https://github.com/transferwise/wise-atoms.git#
|
|
79
|
+
"wise-atoms": "git+https://github.com/transferwise/wise-atoms.git#b37005afd0ab740f763dbf022728b9e2a3b56736",
|
|
80
80
|
"@storybook/addon-docs": "^10.2.10",
|
|
81
81
|
"@changesets/cli": "^2.29.8",
|
|
82
82
|
"@changesets/changelog-github": "0.5.2"
|
|
@@ -96,16 +96,18 @@
|
|
|
96
96
|
"setup": "pnpm install && pnpm build",
|
|
97
97
|
"load-3d-i10s": "rm -rf s3-bucket/illustrations3d/ && node ./scripts/load-3d-i10s.mjs && pnpm load-riv",
|
|
98
98
|
"load-riv": "copyfiles -u 1 assets/*.riv s3-bucket/illustrations3d/rive",
|
|
99
|
-
"load-i10s": "copyfiles -u 4 node_modules/wise-atoms/
|
|
99
|
+
"load-i10s": "copyfiles -u 4 node_modules/wise-atoms/illustrations/**/*.png temp",
|
|
100
100
|
"load-flags": "rm -rf s3-bucket/flags/* && pnpm load-country-flags && pnpm load-currency-flags && pnpm transform-flags && pnpm convert-flags-svg-to-png",
|
|
101
101
|
"load-country-flags": "copyfiles -u 4 node_modules/wise-atoms/assets/flags/*.svg s3-bucket/flags && node ./scripts/generate-country-flags.mjs",
|
|
102
102
|
"load-currency-flags": "copyfiles -u 4 node_modules/wise-atoms/assets/flags/_metadata.json s3-bucket/flags && node ./scripts/generate-currency-flags.mjs",
|
|
103
103
|
"transform-flags": "node ./scripts/transform-flags.mjs",
|
|
104
104
|
"convert-flags-svg-to-png": "node ./scripts/convert-flags-svg-to-png.mjs",
|
|
105
|
+
"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",
|
|
105
106
|
"generate-i10s-metadata": "node ./scripts/generate-i10s-metadata.mjs && eslint 'src/illustrations/metadata.ts' --fix",
|
|
106
107
|
"generate-flags-metadata": "node ./scripts/generate-flags-metadata.mjs && eslint 'src/flags/metadata.ts' --fix",
|
|
107
108
|
"bundle": "rm -rf dist && rollup --config --sourcemap && pnpm build-styles",
|
|
108
|
-
"
|
|
109
|
+
"cleanup": "rm -rf temp",
|
|
110
|
+
"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",
|
|
109
111
|
"start": "storybook dev -p 3001",
|
|
110
112
|
"dev": "NODE_ENV=web-art-dev pnpm start",
|
|
111
113
|
"test": "jest",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import flagRawMetaData from "../../node_modules/wise-atoms/assets/flags/_metadata.json";
|
|
3
2
|
|
|
3
|
+
import flagRawMetaData from '../../node_modules/wise-atoms/assets/flags/_metadata.json';
|
|
4
4
|
import { Flag } from './Flag';
|
|
5
5
|
|
|
6
6
|
const meta: Meta<typeof Flag> = {
|
|
@@ -11,25 +11,43 @@ export default meta;
|
|
|
11
11
|
|
|
12
12
|
type Story = StoryObj<typeof Flag>;
|
|
13
13
|
|
|
14
|
+
type GroupedFlag = { country: string[]; currencies: string[][] };
|
|
15
|
+
|
|
16
|
+
const groupFlags = (flags: { country: string[]; currency: string[] }[]): GroupedFlag[] =>
|
|
17
|
+
flags.reduce<GroupedFlag[]>((acc, flag) => {
|
|
18
|
+
const existing = acc.find(
|
|
19
|
+
(currentFlag) => currentFlag.country[0] && currentFlag.country[0] === flag.country[0],
|
|
20
|
+
);
|
|
21
|
+
if (existing) {
|
|
22
|
+
existing.currencies.push(flag.currency);
|
|
23
|
+
} else {
|
|
24
|
+
acc.push({ country: flag.country, currencies: [flag.currency] });
|
|
25
|
+
}
|
|
26
|
+
return acc;
|
|
27
|
+
}, []);
|
|
28
|
+
|
|
29
|
+
const allFlagsSorted = groupFlags(
|
|
30
|
+
Object.values(flagRawMetaData)
|
|
31
|
+
.flat()
|
|
32
|
+
.sort((a, b) => {
|
|
33
|
+
const nameA = (a.country.at(-1) ?? a.currency?.at(-1) ?? '').toLowerCase();
|
|
34
|
+
const nameB = (b.country.at(-1) ?? b.currency?.at(-1) ?? '').toLowerCase();
|
|
35
|
+
return nameA.localeCompare(nameB);
|
|
36
|
+
}),
|
|
37
|
+
);
|
|
38
|
+
|
|
14
39
|
// Helper function to render all flags and sizes for a given region
|
|
15
|
-
const AllFlagsAndSizes = (
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.
|
|
24
|
-
.
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
key,
|
|
28
|
-
name,
|
|
29
|
-
iso2: 'iso2' in entry ? entry.iso2 : undefined,
|
|
30
|
-
currencyCode: 'currencyCode' in entry ? entry.currencyCode : undefined,
|
|
31
|
-
};
|
|
32
|
-
});
|
|
40
|
+
const AllFlagsAndSizes = (
|
|
41
|
+
region: string,
|
|
42
|
+
flagsOverride?: GroupedFlag[],
|
|
43
|
+
) => {
|
|
44
|
+
const regionFlags =
|
|
45
|
+
flagsOverride ??
|
|
46
|
+
groupFlags(
|
|
47
|
+
Object.entries(flagRawMetaData)
|
|
48
|
+
.filter(([currentRegion]) => currentRegion === region)
|
|
49
|
+
.flatMap(([, flags]) => flags),
|
|
50
|
+
);
|
|
33
51
|
|
|
34
52
|
return (
|
|
35
53
|
<>
|
|
@@ -53,11 +71,19 @@ const AllFlagsAndSizes = (region: string) => {
|
|
|
53
71
|
}}
|
|
54
72
|
>
|
|
55
73
|
{regionFlags.map((flag) => {
|
|
56
|
-
const
|
|
74
|
+
const countryCode = flag.country[0]?.toUpperCase();
|
|
75
|
+
const primaryCurrencyCode = flag.currencies[0]?.[0]?.toUpperCase();
|
|
76
|
+
const flagCode = countryCode ?? primaryCurrencyCode;
|
|
77
|
+
const currencyCodes = flag.currencies.map((currency) => currency[0]).filter(Boolean).map((code) => code.toUpperCase());
|
|
78
|
+
|
|
79
|
+
// Covers cases where there's just a currency code and no country (e.g. Euro)
|
|
80
|
+
const flagName = countryCode
|
|
81
|
+
? flag.country.at(-1)
|
|
82
|
+
: flag.currencies[0]?.at(-1);
|
|
57
83
|
|
|
58
84
|
return (
|
|
59
85
|
<div
|
|
60
|
-
key={
|
|
86
|
+
key={flagName}
|
|
61
87
|
style={{
|
|
62
88
|
display: 'flex',
|
|
63
89
|
flexDirection: 'column',
|
|
@@ -85,19 +111,24 @@ const AllFlagsAndSizes = (region: string) => {
|
|
|
85
111
|
alignItems: 'flex-start',
|
|
86
112
|
}}
|
|
87
113
|
>
|
|
88
|
-
<strong>{
|
|
114
|
+
<strong>{flagName}</strong>
|
|
89
115
|
<span>
|
|
90
|
-
{
|
|
91
|
-
<>
|
|
92
|
-
Country: <code>{flag.iso2}</code>
|
|
93
|
-
</>
|
|
94
|
-
)}
|
|
95
|
-
{flag.currencyCode && (
|
|
116
|
+
{countryCode && (
|
|
96
117
|
<>
|
|
97
|
-
|
|
98
|
-
Currency: <code>{flag.currencyCode}</code>
|
|
118
|
+
Country: <code>{countryCode}</code>
|
|
99
119
|
</>
|
|
100
120
|
)}
|
|
121
|
+
{currencyCodes.length > 0 && (
|
|
122
|
+
<>
|
|
123
|
+
<br />
|
|
124
|
+
<span>
|
|
125
|
+
{`${currencyCodes.length === 1 ? 'Currency' : 'Currencies'}: `}
|
|
126
|
+
{currencyCodes.map((currencyCode) => (
|
|
127
|
+
<code key={currencyCode}>{currencyCode}</code>
|
|
128
|
+
))}
|
|
129
|
+
</span>
|
|
130
|
+
</>
|
|
131
|
+
)}
|
|
101
132
|
</span>
|
|
102
133
|
</div>
|
|
103
134
|
</div>
|
|
@@ -108,6 +139,14 @@ const AllFlagsAndSizes = (region: string) => {
|
|
|
108
139
|
);
|
|
109
140
|
};
|
|
110
141
|
|
|
142
|
+
// Stories for each region
|
|
143
|
+
export const World: Story = {
|
|
144
|
+
render: () => AllFlagsAndSizes('World', allFlagsSorted),
|
|
145
|
+
parameters: {
|
|
146
|
+
chromatic: { disableSnapshot: true },
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
111
150
|
export const Africa: Story = {
|
|
112
151
|
render: () => AllFlagsAndSizes('Africa'),
|
|
113
152
|
};
|
|
@@ -143,3 +182,7 @@ export const SouthAmerica: Story = {
|
|
|
143
182
|
export const Misc: Story = {
|
|
144
183
|
render: () => AllFlagsAndSizes('Misc'),
|
|
145
184
|
};
|
|
185
|
+
|
|
186
|
+
export const Fallback: Story = {
|
|
187
|
+
render: () => AllFlagsAndSizes('Fallback'),
|
|
188
|
+
};
|