diff --git a/projects/design-angular-kit/src/lib/components/core/alert/alert.component.spec.ts b/projects/design-angular-kit/src/lib/components/core/alert/alert.component.spec.ts index c96fa2201..d3c3a9684 100644 --- a/projects/design-angular-kit/src/lib/components/core/alert/alert.component.spec.ts +++ b/projects/design-angular-kit/src/lib/components/core/alert/alert.component.spec.ts @@ -60,4 +60,18 @@ describe('ItAlertComponent', () => { const spanElement = fixture.debugElement.query(By.css('div.alert.alert-success')); expect(spanElement).toBeTruthy(); }); + + it('should accept a custom-generated color (e.g. primary-a1 from Bootstrap Italia HSB)', () => { + component.selectedColor = 'primary-a1'; + fixture.detectChanges(); + const el = fixture.debugElement.query(By.css('div.alert.alert-primary-a1')); + expect(el).toBeTruthy(); + }); + + it('should accept an analogue custom color (e.g. analogue-1-a2)', () => { + component.selectedColor = 'analogue-1-a2'; + fixture.detectChanges(); + const el = fixture.debugElement.query(By.css('div.alert.alert-analogue-1-a2')); + expect(el).toBeTruthy(); + }); }); diff --git a/projects/design-angular-kit/src/lib/interfaces/core.ts b/projects/design-angular-kit/src/lib/interfaces/core.ts index dbd7640fe..685100ff0 100644 --- a/projects/design-angular-kit/src/lib/interfaces/core.ts +++ b/projects/design-angular-kit/src/lib/interfaces/core.ts @@ -1,6 +1,6 @@ import { IconName } from './icon'; -export type AlertColor = 'primary' | 'info' | 'success' | 'warning' | 'danger'; +export type AlertColor = 'primary' | 'info' | 'success' | 'warning' | 'danger' | (string & {}); export type ButtonColor = | 'primary' @@ -19,23 +19,24 @@ export type ButtonColor = | 'outline-light' | 'dark' | 'outline-dark' - | 'link'; + | 'link' + | (string & {}); export type ButtonSize = 'lg' | 'sm' | 'xs'; export type ButtonType = 'submit' | 'button'; -export type CalloutColor = 'success' | 'warning' | 'danger' | 'important' | 'note'; +export type CalloutColor = 'success' | 'warning' | 'danger' | 'important' | 'note' | (string & {}); export type CalloutAppearance = 'default' | 'highlight' | 'more'; -export type ChipColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning'; +export type ChipColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | (string & {}); export type ElementPlacement = 'top' | 'bottom' | 'left' | 'right'; -export type ProgressBarColor = 'primary' | 'success' | 'warning' | 'danger' | 'info'; +export type ProgressBarColor = 'primary' | 'success' | 'warning' | 'danger' | 'info' | (string & {}); -export type BadgeColor = 'primary' | 'secondary' | 'success' | 'warning' | 'danger'; +export type BadgeColor = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | (string & {}); -export type TableColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark'; +export type TableColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | (string & {}); export type TableHeadColor = 'light' | 'dark'; diff --git a/projects/design-angular-kit/src/lib/interfaces/icon.ts b/projects/design-angular-kit/src/lib/interfaces/icon.ts index 8ea97937d..51679ca12 100644 --- a/projects/design-angular-kit/src/lib/interfaces/icon.ts +++ b/projects/design-angular-kit/src/lib/interfaces/icon.ts @@ -1,6 +1,6 @@ export type IconSize = 'xs' | 'sm' | 'lg' | 'xl'; -export type IconColor = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'light' | 'white'; +export type IconColor = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'light' | 'white' | (string & {}); export type IconName = (typeof IconNameArray)[number]; diff --git a/src/app/alert/alert-custom-color-example/alert-custom-color-example.component.html b/src/app/alert/alert-custom-color-example/alert-custom-color-example.component.html new file mode 100644 index 000000000..94219e66a --- /dev/null +++ b/src/app/alert/alert-custom-color-example/alert-custom-color-example.component.html @@ -0,0 +1,15 @@ +

Colori personalizzati

+

+ Tutti i componenti con input di colore (AlertColor, ButtonColor, BadgeColor, ecc.) accettano anche + stringhe custom oltre ai colori predefiniti. Questo permette di utilizzare le classi CSS generate dal tema Bootstrap Italia + personalizzato. +

+ + Primary — Colore predefinito del tema. + + + Teal — Colore custom: la classe alert-teal viene applicata. Richiede che il tema CSS definisca + .alert-teal. + + + Indigo — Altro colore custom: genera la classe alert-indigo. diff --git a/src/app/alert/alert-custom-color-example/alert-custom-color-example.component.ts b/src/app/alert/alert-custom-color-example/alert-custom-color-example.component.ts new file mode 100644 index 000000000..d99b5d0f5 --- /dev/null +++ b/src/app/alert/alert-custom-color-example/alert-custom-color-example.component.ts @@ -0,0 +1,7 @@ +import { Component } from '@angular/core'; + +@Component({ + selector: 'it-alert-custom-color-example', + templateUrl: './alert-custom-color-example.component.html', +}) +export class AlertCustomColorExampleComponent {} diff --git a/src/app/alert/alert-examples/alert-examples.component.tpl b/src/app/alert/alert-examples/alert-examples.component.tpl index 4d1cb9391..4aa3a44f7 100644 --- a/src/app/alert/alert-examples/alert-examples.component.tpl +++ b/src/app/alert/alert-examples/alert-examples.component.tpl @@ -40,3 +40,16 @@ + +{% set htmlCustomColor %} + {% include "../alert-custom-color-example/alert-custom-color-example.component.html" %} +{% endset %} + +{% set typescriptCustomColor %} + {% include "../alert-custom-color-example/alert-custom-color-example.component.ts" %} +{% endset %} + + + + + diff --git a/src/app/alert/alert.module.ts b/src/app/alert/alert.module.ts index 9bf0eb02e..5deb97895 100644 --- a/src/app/alert/alert.module.ts +++ b/src/app/alert/alert.module.ts @@ -7,6 +7,7 @@ import { SharedModule } from '../shared/shared.module'; import { AlertColorExampleComponent } from './alert-color-example/alert-color-example.component'; import { AlertAdditionalContentExampleComponent } from './alert-additional-content-example/alert-additional-content-example.component'; import { AlertClosingExampleComponent } from './alert-closing-example/alert-closing-example.component'; +import { AlertCustomColorExampleComponent } from './alert-custom-color-example/alert-custom-color-example.component'; @NgModule({ declarations: [ @@ -15,6 +16,7 @@ import { AlertClosingExampleComponent } from './alert-closing-example/alert-clos AlertColorExampleComponent, AlertAdditionalContentExampleComponent, AlertClosingExampleComponent, + AlertCustomColorExampleComponent, ], imports: [CommonModule, SharedModule, AlertRoutingModule], })