diff --git a/projects/design-angular-kit/src/lib/components/utils/icon/icon.component.ts b/projects/design-angular-kit/src/lib/components/utils/icon/icon.component.ts index a4cb61a8..84479d2d 100644 --- a/projects/design-angular-kit/src/lib/components/utils/icon/icon.component.ts +++ b/projects/design-angular-kit/src/lib/components/utils/icon/icon.component.ts @@ -1,6 +1,7 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { ChangeDetectionStrategy, Component, Inject, Input } from '@angular/core'; import { IconColor, IconName, IconSize } from '../../../interfaces/icon'; import { BooleanInput, isTrueBooleanInput } from '../../../utils/boolean-input'; +import { DESIGN_ANGULAR_KIT_CONFIG, DesignAngularKitConfig } from '../../../design-angular-kit-config'; @Component({ selector: 'it-icon[name]', @@ -38,7 +39,7 @@ export class IconComponent { * Return the icon href */ get iconHref(): string { - return `./bootstrap-italia/dist/svg/sprites.svg#it-${this.name}`; + return `${this.config.iconHref}#it-${this.name}`; } /** @@ -61,4 +62,8 @@ export class IconComponent { return iconClass; } + constructor( + @Inject(DESIGN_ANGULAR_KIT_CONFIG) private readonly config: DesignAngularKitConfig + ) { + } } diff --git a/src/app/icon/icon-index/icon-index.component.html b/src/app/icon/icon-index/icon-index.component.html index c53c2fd1..c9206115 100644 --- a/src/app/icon/icon-index/icon-index.component.html +++ b/src/app/icon/icon-index/icon-index.component.html @@ -7,6 +7,11 @@

Icone

IconComponent

+ +

E' possibile configurare il path href del componente attraverso la configurazione iniziale della libreria.

+ + +
diff --git a/src/app/icon/icon-index/icon-index.component.ts b/src/app/icon/icon-index/icon-index.component.ts index 31e8e4e1..b798e343 100644 --- a/src/app/icon/icon-index/icon-index.component.ts +++ b/src/app/icon/icon-index/icon-index.component.ts @@ -9,6 +9,23 @@ export class IconIndexComponent { component: any; + readonly hrefLibraryConfig = "import {DesignAngularKitModule, DesignAngularKitInit} from 'design-angular-kit';\n" + + " \n" + + " const initConfig: DesignAngularKitInit = {\n" + + " /**\n" + + " * The initial path in the `href` attribute in the `IconComponent` component\n" + + " * @default './bootstrap-italia/dist/svg/sprites.svg'\n" + + " */\n" + + " iconHref: 'my-path/svg/sprites.svg',\n" + + " };\n" + + " \n" + + " @NgModule({\n" + + " imports: [\n" + + " ...\n" + + " DesignAngularKitModule.forRoot(initConfig)\n" + + " ]\n" + + " })"; + constructor() { this.component = (Documentation).components.find(component => component.name === 'IconComponent'); }