@sit-onyx/icons 1.0.0-beta.2 → 1.0.0-beta.21

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.
Files changed (44) hide show
  1. package/README.md +2 -7
  2. package/dist/index.d.ts +25 -0
  3. package/dist/index.js +52 -0
  4. package/dist/metadata.json +2908 -0
  5. package/{src/types.ts → dist/types.d.ts} +5 -7
  6. package/dist/types.js +1 -0
  7. package/package.json +16 -8
  8. package/src/assets/RSS-web-feed.svg +1 -0
  9. package/src/assets/book-binocular.svg +1 -0
  10. package/src/assets/bookmark-filled.svg +1 -0
  11. package/src/assets/browser-domain.svg +1 -0
  12. package/src/assets/bullet-list.svg +1 -0
  13. package/src/assets/cancellation-undone.svg +1 -1
  14. package/src/assets/check-read.svg +1 -0
  15. package/src/assets/cloud-edge.svg +1 -0
  16. package/src/assets/cloud-files.svg +1 -0
  17. package/src/assets/computer-security-warning.svg +1 -0
  18. package/src/assets/cookie.svg +1 -0
  19. package/src/assets/expand-window-small.svg +1 -0
  20. package/src/assets/eye-closed.svg +1 -0
  21. package/src/assets/folder-file.svg +1 -0
  22. package/src/assets/hacker.svg +1 -0
  23. package/src/assets/heptagon-cloud-foundry.svg +1 -0
  24. package/src/assets/key-clock.svg +1 -0
  25. package/src/assets/key-mail.svg +1 -0
  26. package/src/assets/key-settings.svg +1 -0
  27. package/src/assets/list-arrow-down.svg +1 -0
  28. package/src/assets/list-arrow-up.svg +1 -0
  29. package/src/assets/more-horizontal-small.svg +1 -0
  30. package/src/assets/more-vertical-small.svg +1 -0
  31. package/src/assets/network-card.svg +1 -0
  32. package/src/assets/notebook-code.svg +1 -0
  33. package/src/assets/paragraph.svg +1 -0
  34. package/src/assets/profile-hook.svg +1 -0
  35. package/src/assets/server-edit.svg +1 -0
  36. package/src/assets/server-search.svg +1 -0
  37. package/src/assets/settings-arrows.svg +1 -0
  38. package/src/assets/sidebar-arrow-left.svg +1 -1
  39. package/src/assets/terraform.svg +1 -0
  40. package/src/assets/traffic-light.svg +1 -0
  41. package/src/assets/weight-kg.svg +1 -0
  42. package/src/assets/workflows.svg +1 -0
  43. package/src/index.ts +0 -63
  44. package/src/metadata.json +0 -2729
package/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  <div align="center" style="text-align: center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" type="image/svg+xml" srcset="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-light.svg">
4
- <source media="(prefers-color-scheme: light)" type="image/svg+xml" srcset="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-dark.svg">
5
- <img alt="onyx logo" src="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo-dark.svg" width="160px">
6
- </picture>
2
+ <img alt="onyx logo" src="https://raw.githubusercontent.com/SchwarzIT/onyx/main/.github/onyx-logo.svg" height="96px">
7
3
  </div>
8
4
 
9
5
  <br>
@@ -17,5 +13,4 @@ SVG icons for the onyx design system created by [Schwarz IT](https://it.schwarz)
17
13
  If you want to contribute a new icon, please follow the steps below:
18
14
 
19
15
  1. place the SVG file inside the [`src/assets`](./src/assets/) folder.
20
- 2. run the script `pnpm optimize` to optimize the SVG content
21
- 3. Add an entry inside [`src/metadata.ts`](./src/metadata.ts) to specify the icon category and other metadata
16
+ 2. Add an entry inside [`src/metadata.ts`](./src/metadata.ts) to specify the icon category and other metadata
@@ -0,0 +1,25 @@
1
+ import type { IconCategories, IconMetadata } from "./types.js";
2
+ export {
3
+ /**
4
+ * Metadata for all available onyx icons.
5
+ */
6
+ default as ICON_METADATA, } from "./metadata.json";
7
+ /**
8
+ * Groups all available icon metadata by category.
9
+ * Categories and icons will be sorted alphabetically.
10
+ */
11
+ export declare const groupIconsByCategory: (iconMetadata: Record<string, IconMetadata>) => IconCategories;
12
+ /**
13
+ * Transform an icon name to its corresponding JavaScript import name.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * "bell-disabled" => "bellDisabled"
18
+ * // e.g. used as 'import bellDisabled from "@sit-onyx/icons/bell-disabled.svg?raw"'
19
+ * ```
20
+ */
21
+ export declare const getIconImportName: (iconName: string) => string;
22
+ /**
23
+ * Capitalizes the first character of the given string.
24
+ */
25
+ export declare const capitalize: (value: string) => string;
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ export {
2
+ /**
3
+ * Metadata for all available onyx icons.
4
+ */
5
+ default as ICON_METADATA, } from "./metadata.json";
6
+ /**
7
+ * Groups all available icon metadata by category.
8
+ * Categories and icons will be sorted alphabetically.
9
+ */
10
+ export const groupIconsByCategory = (iconMetadata) => {
11
+ const categories = Object.entries(iconMetadata).reduce((categories, [iconName, metadata]) => {
12
+ const icons = categories[metadata.category] ?? [];
13
+ icons.push({ iconName, metadata });
14
+ categories[metadata.category] = icons;
15
+ return categories;
16
+ }, {});
17
+ const sortedCategories = {};
18
+ Object.keys(categories)
19
+ .sort()
20
+ .forEach((category) => {
21
+ const sortedMetadata = categories[category].slice().sort((a, b) => {
22
+ return a.iconName.localeCompare(b.iconName);
23
+ });
24
+ sortedCategories[category] = sortedMetadata;
25
+ });
26
+ return sortedCategories;
27
+ };
28
+ /**
29
+ * Transform an icon name to its corresponding JavaScript import name.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * "bell-disabled" => "bellDisabled"
34
+ * // e.g. used as 'import bellDisabled from "@sit-onyx/icons/bell-disabled.svg?raw"'
35
+ * ```
36
+ */
37
+ export const getIconImportName = (iconName) => {
38
+ return iconName
39
+ .split("-")
40
+ .map((word, index) => {
41
+ if (index === 0)
42
+ return word;
43
+ return capitalize(word);
44
+ })
45
+ .join("");
46
+ };
47
+ /**
48
+ * Capitalizes the first character of the given string.
49
+ */
50
+ export const capitalize = (value) => {
51
+ return value.charAt(0).toUpperCase() + value.slice(1);
52
+ };