@wise/art 0.0.0-experimental-2d83161 → 0.0.0-experimental-05967c7

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-2d83161",
3
+ "version": "0.0.0-experimental-05967c7",
4
4
  "license": "MIT",
5
5
  "description": "React library for art elements in UI",
6
6
  "homepage": "https://github.com/transferwise/web-art#readme",
@@ -14,8 +14,19 @@ type Story = StoryObj<typeof Flag>;
14
14
  // Helper function to render all flags and sizes for a given region
15
15
  const AllFlagsAndSizes = (region: string) => {
16
16
  const regionFlags = Object.entries(flagRawMetaData)
17
- .filter(([r]) => r === region)
18
- .flatMap(([, flags]) => flags);
17
+ .filter(([currentRegion]) => currentRegion === region)
18
+ .flatMap(([, flags]) => flags)
19
+ .reduce<{ country: string[]; currencies: string[][] }[]>((acc, flag) => {
20
+ const existing = acc.find(
21
+ (currentFlag) => currentFlag.country[0] && currentFlag.country[0] === flag.country[0],
22
+ );
23
+ if (existing) {
24
+ existing.currencies.push(flag.currency);
25
+ } else {
26
+ acc.push({ country: flag.country, currencies: [flag.currency] });
27
+ }
28
+ return acc;
29
+ }, []);
19
30
 
20
31
  return (
21
32
  <>
@@ -35,56 +46,60 @@ const AllFlagsAndSizes = (region: string) => {
35
46
  style={{
36
47
  display: 'grid',
37
48
  gridTemplateColumns: 'repeat(auto-fill, minmax(350px, 1fr))',
38
- gap: 'var(--padding-small)',
49
+ gap: 'var(--size-24)',
39
50
  }}
40
51
  >
41
52
  {regionFlags.map((flag) => {
42
53
  const countryCode = flag.country[0]?.toUpperCase();
43
- const currencyCode = flag.currency[0]?.toUpperCase();
44
- const flagCode = countryCode ?? currencyCode;
54
+ const primaryCurrencyCode = flag.currencies[0]?.[0]?.toUpperCase();
55
+ const flagCode = countryCode ?? primaryCurrencyCode;
56
+ const currencyCodes = flag.currencies.map((currency) => currency[0]).filter(Boolean).map((code) => code.toUpperCase());
45
57
 
46
58
  // Covers cases where there's just a currency code and no country (e.g. Euro)
47
59
  const flagName = countryCode
48
60
  ? flag.country.at(-1)
49
- : flag.currency?.at(-1);
61
+ : flag.currencies[0]?.at(-1);
50
62
 
51
63
  return (
52
64
  <div
53
65
  key={flagName}
54
66
  style={{
55
67
  display: 'grid',
56
- gridTemplateColumns: 'minmax(auto, 1fr) auto 1fr',
57
- gap: 'var(--padding-small)',
68
+ gridTemplateColumns: 'auto auto minmax(auto, 1fr)',
69
+ gap: 'var(--size-12)',
58
70
  alignItems: 'center',
59
71
  }}
60
72
  >
73
+ <Flag code={flagCode} intrinsicSize={150} />
74
+ <Flag code={flagCode} />
61
75
  <div
62
76
  style={{
63
77
  display: 'flex',
64
78
  flexWrap: 'wrap',
65
79
  flexDirection: 'column',
66
80
  alignItems: 'flex-start',
67
- gap: 'var(--padding-small)',
68
81
  }}
69
82
  >
70
- {flagName}
83
+ <strong>{flagName}</strong>
71
84
  <span>
72
85
  {countryCode && (
73
86
  <>
74
87
  Country: <code>{countryCode}</code>
75
88
  </>
76
89
  )}
77
- {currencyCode && countryCode && <br />}
78
- {currencyCode && (
79
- <>
80
- Currency: <code>{currencyCode}</code>
81
- </>
82
- )}
90
+ {currencyCodes.length > 0 && (
91
+ <>
92
+ <br />
93
+ <span>
94
+ {`${currencyCodes.length === 1 ? 'Currency' : 'Currencies'}: `}
95
+ {currencyCodes.map((currencyCode) => (
96
+ <code key={currencyCode}>{currencyCode}</code>
97
+ ))}
98
+ </span>
99
+ </>
100
+ )}
83
101
  </span>
84
- {currencyCode && <span />}
85
102
  </div>
86
- <Flag code={flagCode} />
87
- <Flag code={flagCode} intrinsicSize={150} />
88
103
  </div>
89
104
  );
90
105
  })}