(icons: { [name: string]: string })
| 17 | }; |
| 18 | |
| 19 | export 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 | |
| 40 | const addToIconMap = (name: string, data: any) => { |
| 41 | const map = getIconMap(); |
no test coverage detected
searching dependent graphs…