diff --git a/README.md b/README.md
index d43dbbb2..a1f9a56d 100644
--- a/README.md
+++ b/README.md
@@ -63,13 +63,39 @@ npm install design-angular-kit@unstable --save
Procedi a registrare `DesignAngularKitModule` nel tuo **app.module.ts**.
```typescript
+import {DesignAngularKitModule} from 'design-angular-kit';
+
@NgModule({
imports: [
...
- DesignAngularKitModule
+ DesignAngularKitModule.forRoot() // .forRoot obligatorio
]
})
```
+
+ Configurazione della libreria
+
+ ```typescript
+ import {DesignAngularKitModule, DesignAngularKitInit} from 'design-angular-kit';
+
+ // Puoi aggiungere alla libreria una configurazione iniziale
+ const initConfig: DesignAngularKitInit | undefined = {
+ /**
+ * The initial path in the `href` attribute in the `IconComponent` component
+ * @default './bootstrap-italia/dist/svg/sprites.svg'
+ */
+ iconHref: string | undefined,
+ };
+
+ @NgModule({
+ imports: [
+ ...
+ DesignAngularKitModule.forRoot(initConfig) // .forRoot obligatorio
+ ]
+ })
+ ```
+
+
### Importazione stili bootstrap-italia
Configura gli stili richiesti nel file `styles.scss`. Importa la libreria SCSS come mostrato nell'esempio qui sotto.
@@ -171,7 +197,7 @@ Modifica nel tuo `app.module.ts`:
},
defaultLanguage: 'it'
}),
- DesignAngularKitModule
+ DesignAngularKitModule.forRoot()
]
})
```
@@ -188,7 +214,7 @@ Se non utilizzi i file di localizzazione nella tua app, devi aggiungere il provi
@NgModule({
imports: [
...
- DesignAngularKitModule,
+ DesignAngularKitModule.forRoot(),
],
providers: [
TranslateStore
diff --git a/projects/design-angular-kit/src/lib/design-angular-kit-config.ts b/projects/design-angular-kit/src/lib/design-angular-kit-config.ts
new file mode 100644
index 00000000..932d9eca
--- /dev/null
+++ b/projects/design-angular-kit/src/lib/design-angular-kit-config.ts
@@ -0,0 +1,26 @@
+import { InjectionToken } from '@angular/core';
+import { DesignAngularKitInit } from './interfaces/design-angular-kit-init';
+
+export const DESIGN_ANGULAR_KIT_CONFIG = new InjectionToken('DesignAngularKitConfig');
+
+export class DesignAngularKitConfig {
+
+ /**
+ * The init config
+ * @private
+ */
+ private readonly initConfig?: DesignAngularKitInit;
+
+ constructor(nextInit?: DesignAngularKitInit) {
+ this.initConfig = nextInit;
+ }
+
+ /**
+ * The initial path in the `href` attribute in the `IconComponent` component
+ * @default './bootstrap-italia/dist/svg/sprites.svg'
+ */
+ get iconHref(): string {
+ return this.initConfig?.iconHref || './bootstrap-italia/dist/svg/sprites.svg';
+ }
+
+}
diff --git a/projects/design-angular-kit/src/lib/design-angular-kit.module.ts b/projects/design-angular-kit/src/lib/design-angular-kit.module.ts
index 77801b98..a30f68b9 100644
--- a/projects/design-angular-kit/src/lib/design-angular-kit.module.ts
+++ b/projects/design-angular-kit/src/lib/design-angular-kit.module.ts
@@ -1,8 +1,10 @@
-import { NgModule } from '@angular/core';
+import { ModuleWithProviders, NgModule } from '@angular/core';
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { ComponentsModule } from './components/components.module';
+import { DESIGN_ANGULAR_KIT_CONFIG, DesignAngularKitConfig } from './design-angular-kit-config';
+import { DesignAngularKitInit } from './interfaces/design-angular-kit-init';
@NgModule({
declarations: [],
@@ -27,6 +29,18 @@ import { ComponentsModule } from './components/components.module';
})
export class DesignAngularKitModule {
+ static forRoot(initConfig?: DesignAngularKitInit): ModuleWithProviders {
+ return {
+ ngModule: DesignAngularKitModule,
+ providers: [
+ {
+ provide: DESIGN_ANGULAR_KIT_CONFIG,
+ useValue: new DesignAngularKitConfig(initConfig)
+ }
+ ]
+ };
+ }
+
constructor(
private readonly translateService: TranslateService
) {
diff --git a/projects/design-angular-kit/src/lib/interfaces/design-angular-kit-init.ts b/projects/design-angular-kit/src/lib/interfaces/design-angular-kit-init.ts
new file mode 100644
index 00000000..ca433e64
--- /dev/null
+++ b/projects/design-angular-kit/src/lib/interfaces/design-angular-kit-init.ts
@@ -0,0 +1,9 @@
+export interface DesignAngularKitInit {
+
+ /**
+ * The initial path in the `href` attribute in the `IconComponent` component
+ * @default './bootstrap-italia/dist/svg/sprites.svg'
+ */
+ iconHref?: string;
+
+}
diff --git a/projects/design-angular-kit/src/public_api.ts b/projects/design-angular-kit/src/public_api.ts
index d44a32e7..f53105d5 100644
--- a/projects/design-angular-kit/src/public_api.ts
+++ b/projects/design-angular-kit/src/public_api.ts
@@ -5,6 +5,8 @@
export * from './lib/design-angular-kit.module';
export * from './lib/components/components.module';
+// Config
+export * from './lib/design-angular-kit-config';
// Core
export * from './lib/components/core/accordion/accordion.component';
@@ -71,6 +73,8 @@ export * from './lib/services/notifications/notifications.service';
export * from './lib/pipes/mark-matching-text.pipe';
// Interfaces
+export * from './lib/interfaces/design-angular-kit-init';
+
export * from './lib/interfaces/core';
export * from './lib/interfaces/form';
export * from './lib/interfaces/icon';
diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 8b78265b..3a876e10 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -24,7 +24,7 @@ import { DesignAngularKitModule } from '../../projects/design-angular-kit/src/li
BrowserModule,
BrowserAnimationsModule,
AppRoutingModule,
- DesignAngularKitModule
+ DesignAngularKitModule.forRoot()
],
providers: [
TranslateStore,