MCPcopy
hub / github.com/ionic-team/ionicons / addIcons

Function addIcons

src/components/icon/utils.ts:19–38  ·  view source on GitHub ↗
(icons: { [name: string]: string })

Source from the content-addressed store, hash-verified

17};
18
19export const addIcons = (icons: { [name: string]: string }) => {
20 Object.keys(icons).forEach((name) => {
21 addToIconMap(name, icons[name]);
22
23 /**
24 * Developers can also pass in the SVG object directly
25 * and Ionicons can map the object to a kebab case name.
26 * Example: addIcons({ addCircleOutline });
27 * This will create an "addCircleOutline" entry and
28 * an "add-circle-outline" entry.
29 * Usage: <ion-icon name="add-circle-outline"></ion-icon>
30 * Using name="addCircleOutline" is valid too, but the
31 * kebab case naming is preferred.
32 */
33 const toKebabCase = name.replace(/([a-z0-9]|(?=[A-Z]))([A-Z0-9])/g, '$1-$2').toLowerCase();
34 if (name !== toKebabCase) {
35 addToIconMap(toKebabCase, icons[name]);
36 }
37 });
38};
39
40const addToIconMap = (name: string, data: any) => {
41 const map = getIconMap();

Callers 1

utils.spec.tsFile · 0.90

Calls 1

addToIconMapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…