@sit-onyx/icons 0.1.0-alpha.0 → 0.1.0-alpha.1
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 +3 -3
- package/src/metadata.ts +27 -1
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sit-onyx/icons",
|
3
3
|
"description": "SVG icons for the onyx design system",
|
4
|
-
"version": "0.1.0-alpha.
|
4
|
+
"version": "0.1.0-alpha.1",
|
5
5
|
"type": "module",
|
6
6
|
"license": "Apache-2.0",
|
7
7
|
"repository": {
|
@@ -21,8 +21,8 @@
|
|
21
21
|
"./*": "./src/assets/*"
|
22
22
|
},
|
23
23
|
"devDependencies": {
|
24
|
-
"svgo": "^3.2
|
25
|
-
"tsx": "^4.
|
24
|
+
"svgo": "^3.3.2",
|
25
|
+
"tsx": "^4.10.5"
|
26
26
|
},
|
27
27
|
"scripts": {
|
28
28
|
"optimize:check": "tsx ./src/check.ts",
|
package/src/metadata.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { groupIconsByCategory, type IconMetadata } from "./utils.js";
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Metadata for all available onyx icons.
|
@@ -1787,3 +1787,29 @@ export const ICON_METADATA = {
|
|
1787
1787
|
* Categories and icons will be sorted alphabetically.
|
1788
1788
|
*/
|
1789
1789
|
export const ICON_CATEGORIES = groupIconsByCategory(ICON_METADATA);
|
1790
|
+
|
1791
|
+
/**
|
1792
|
+
* Transform an icon name to its corresponding JavaScript import name.
|
1793
|
+
*
|
1794
|
+
* @example
|
1795
|
+
* ```ts
|
1796
|
+
* "bell-disabled" => "bellDisabled"
|
1797
|
+
* // e.g. used as 'import bellDisabled from "@sit-onyx/icons/bell-disabled.svg?raw"'
|
1798
|
+
* ```
|
1799
|
+
*/
|
1800
|
+
export const getIconImportName = (iconName: string) => {
|
1801
|
+
return iconName
|
1802
|
+
.split("-")
|
1803
|
+
.map((word, index) => {
|
1804
|
+
if (index === 0) return word;
|
1805
|
+
return capitalize(word);
|
1806
|
+
})
|
1807
|
+
.join("");
|
1808
|
+
};
|
1809
|
+
|
1810
|
+
/**
|
1811
|
+
* Capitalizes the first character of the given string.
|
1812
|
+
*/
|
1813
|
+
const capitalize = (value: string) => {
|
1814
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
1815
|
+
};
|