@sit-onyx/flags 1.0.0-beta.0 → 1.0.0-beta.2

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.js CHANGED
@@ -3,3 +3,25 @@ export {
3
3
  * Metadata for all available onyx flags.
4
4
  */
5
5
  default as FLAG_METADATA, } from "./metadata.json";
6
+ /**
7
+ * Groups all available flag metadata by continent.
8
+ * Continents and flags will be sorted alphabetically.
9
+ */
10
+ export const groupFlagsByContinent = (flagMetadata) => {
11
+ const continents = Object.entries(flagMetadata).reduce((continents, [code, metadata]) => {
12
+ const flags = continents[metadata.continent] ?? [];
13
+ flags.push({ code, metadata });
14
+ continents[metadata.continent] = flags;
15
+ return continents;
16
+ }, {});
17
+ const sortedContinents = {};
18
+ Object.keys(continents)
19
+ .sort()
20
+ .forEach((continent) => {
21
+ const sortedMetadata = continents[continent].slice().sort((a, b) => {
22
+ return a.code.localeCompare(b.code);
23
+ });
24
+ sortedContinents[continent] = sortedMetadata;
25
+ });
26
+ return sortedContinents;
27
+ };
@@ -143,6 +143,10 @@
143
143
  "continent": "North America",
144
144
  "internationalName": ""
145
145
  },
146
+ "CC": {
147
+ "continent": "Asia",
148
+ "internationalName": "Cocos (Keeling) Islands"
149
+ },
146
150
  "CD": {
147
151
  "continent": "Africa",
148
152
  "internationalName": "Congo - Kinshasa"
@@ -164,7 +168,7 @@
164
168
  "internationalName": "Côte d’Ivoire"
165
169
  },
166
170
  "CK": {
167
- "continent": "Asia",
171
+ "continent": "Oceania",
168
172
  "internationalName": "Cook Islands"
169
173
  },
170
174
  "CL": {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sit-onyx/flags",
3
3
  "description": "SVG country flags for the onyx design system",
4
- "version": "1.0.0-beta.0",
4
+ "version": "1.0.0-beta.2",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
7
7
  "repository": {
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><g clip-path="url(#a)"><path fill="#6DA544" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12"/><path fill="#FFDA44" d="m18.421 17.217.33.689.743-.172-.333.687.598.474-.744.168.002.763-.596-.477-.595.477.002-.763-.745-.168.598-.474-.333-.687.744.172zm-3.063-7.304.329.689.744-.172-.333.687.598.474-.745.168.002.763-.595-.478-.596.478.002-.764-.744-.167.598-.474-.333-.687.743.172zm3.063-4.173.33.688.743-.172-.333.687.598.474-.745.168.002.763-.595-.478-.595.478.002-.763-.745-.168.598-.474-.333-.687.744.172zm2.676 3.13.33.688.743-.172-.333.687.598.474-.745.168.002.763-.595-.477-.596.477.002-.763-.744-.168.598-.474-.333-.687.744.172zm-1.913 3.652.259.797h.838l-.678.493.259.797-.678-.493-.678.493.259-.797-.679-.493h.839z"/><path fill="#FFDA44" d="M13.305 15.391a3.39 3.39 0 1 1 1.613-6.375 4.174 4.174 0 1 0 0 5.967c-.48.26-1.03.408-1.613.408M7.546 4.696a2.086 2.086 0 0 0-3.614 0zm.007.012L5.74 6.522 3.925 4.708a2.087 2.087 0 1 0 3.628 0"/><path fill="#A2001D" d="M5.217 6v1.76a2.1 2.1 0 0 0 1.044 0V6z"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h24v24H0z"/></clipPath></defs></svg>
package/src/assets/CK.svg CHANGED
@@ -1 +1 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#6DA544" d="M12 24c6.627 0 12-5.373 12-12S18.627 0 12 0 0 5.373 0 12s5.373 12 12 12"/><path fill="#FFDA44" d="m18.421 17.217.33.689.743-.172-.333.687.598.474-.744.168.002.763-.596-.477-.595.477.002-.763-.745-.168.598-.474-.333-.687.744.172zm-3.063-7.304.329.689.744-.172-.333.687.598.474-.745.168.002.763-.595-.478-.596.478.002-.764-.744-.167.598-.474-.333-.687.743.172zm3.063-4.173.33.688.743-.172-.333.687.598.474-.745.168.002.763-.595-.478-.595.478.002-.763-.745-.168.598-.474-.333-.687.744.172zm2.676 3.13.329.688.744-.172-.333.687.598.474-.745.168.002.763-.595-.477-.596.477.002-.763-.744-.168.598-.474-.333-.687.743.172zm-1.914 3.652.26.797h.838l-.679.493.26.797-.679-.493-.678.493.26-.797-.679-.493h.838z"/><path fill="#FFDA44" d="M13.304 15.391a3.391 3.391 0 1 1 1.613-6.375 4.174 4.174 0 1 0 0 5.967c-.48.26-1.029.408-1.613.408M7.546 4.696a2.086 2.086 0 0 0-3.614 0zm.007.012L5.739 6.522 3.925 4.708a2.087 2.087 0 1 0 3.628 0"/><path fill="#A2001D" d="M5.217 6v1.76a2.1 2.1 0 0 0 1.044 0V6z"/></svg>-.683.221.422-.581-.422-.581.683.222.423-.581v.718zm-1.223-2.951-.326.64.508.508-.71-.113-.326.64-.112-.71-.71-.112.64-.326-.112-.71.508.509z"/></svg>
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#0052B4" d="M24 12c0 6.627-5.373 12-12 12S0 18.627 0 12C0 12.003 12 .001 12 0c6.627 0 12 5.373 12 12"/><path fill="#F0F0F0" d="M11.968 12H12v-.032z"/><path fill="#F0F0F0" d="M12 6.26V0h-.002C5.371.001 0 5.373 0 12h6.26V8.474L9.787 12h2.182l.032-.032V9.786L8.474 6.261z"/><path fill="#D80027" d="M6.071 1.565a12.06 12.06 0 0 0-4.506 4.506V12h3.13V4.696H12v-3.13z"/><path fill="#D80027" d="M12 10.524 7.737 6.261H6.26L12.001 12z"/><path fill="#F0F0F0" d="m16.174 12 .222.683h.718l-.58.422.221.684-.581-.422-.581.422.222-.684-.582-.422h.719zm-2.952 1.223.64.326.508-.508-.112.71.64.325-.71.113-.112.71-.326-.64-.71.112.509-.508zM12 16.174l.683-.222v-.718l.422.58.684-.221-.422.58.422.582-.684-.222-.422.581v-.718zm1.222 2.951.327-.64-.508-.508.71.113.325-.64.113.709.71.112-.64.327.111.71-.507-.509zm2.952 1.223-.222-.683h-.719l.582-.423-.222-.683.58.422.582-.422-.222.683.581.422h-.718zm2.951-1.223-.64-.326-.508.508.112-.71-.64-.326.71-.112.112-.71.326.64.71-.112-.508.508zm1.223-2.951-.683.222v.718l-.423-.58-.683.221.422-.581-.422-.581.683.222.423-.581v.718zm-1.223-2.951-.326.64.508.508-.71-.113-.326.64-.112-.71-.71-.112.64-.326-.112-.71.508.509z"/></svg>
package/src/index.ts CHANGED
@@ -1,6 +1,37 @@
1
+ import type { FlagContinents, FlagMetadata } from "./types.js";
2
+
1
3
  export {
2
4
  /**
3
5
  * Metadata for all available onyx flags.
4
6
  */
5
7
  default as FLAG_METADATA,
6
8
  } from "./metadata.json";
9
+
10
+ /**
11
+ * Groups all available flag metadata by continent.
12
+ * Continents and flags will be sorted alphabetically.
13
+ */
14
+ export const groupFlagsByContinent = (flagMetadata: Record<string, FlagMetadata>) => {
15
+ const continents = Object.entries(flagMetadata).reduce<FlagContinents>(
16
+ (continents, [code, metadata]) => {
17
+ const flags = continents[metadata.continent] ?? [];
18
+ flags.push({ code, metadata });
19
+ continents[metadata.continent] = flags;
20
+ return continents;
21
+ },
22
+ {},
23
+ );
24
+
25
+ const sortedContinents: typeof continents = {};
26
+
27
+ Object.keys(continents)
28
+ .sort()
29
+ .forEach((continent) => {
30
+ const sortedMetadata = continents[continent].slice().sort((a, b) => {
31
+ return a.code.localeCompare(b.code);
32
+ });
33
+ sortedContinents[continent] = sortedMetadata;
34
+ });
35
+
36
+ return sortedContinents;
37
+ };
package/src/metadata.json CHANGED
@@ -143,6 +143,10 @@
143
143
  "continent": "North America",
144
144
  "internationalName": ""
145
145
  },
146
+ "CC": {
147
+ "continent": "Asia",
148
+ "internationalName": "Cocos (Keeling) Islands"
149
+ },
146
150
  "CD": {
147
151
  "continent": "Africa",
148
152
  "internationalName": "Congo - Kinshasa"
@@ -164,7 +168,7 @@
164
168
  "internationalName": "Côte d’Ivoire"
165
169
  },
166
170
  "CK": {
167
- "continent": "Asia",
171
+ "continent": "Oceania",
168
172
  "internationalName": "Cook Islands"
169
173
  },
170
174
  "CL": {
package/src/types.ts ADDED
@@ -0,0 +1,17 @@
1
+ export type FlagMetadata = {
2
+ continent: string;
3
+ internationalName: string;
4
+ };
5
+
6
+ export type GroupedFlagContinent = {
7
+ /**
8
+ * Country code of the flag.
9
+ */
10
+ code: string;
11
+ /**
12
+ * Additional flag metadata.
13
+ */
14
+ metadata: FlagMetadata;
15
+ };
16
+
17
+ export type FlagContinents = Record<string, GroupedFlagContinent[]>;