diff --git a/demo-shell/resources/i18n/en.json b/demo-shell/resources/i18n/en.json index d0f5dc74c1..081bf970dd 100644 --- a/demo-shell/resources/i18n/en.json +++ b/demo-shell/resources/i18n/en.json @@ -55,6 +55,7 @@ }, "APP_LAYOUT": { "APP": "App", + "HEADER_TEXT_COLOR": "Header text color", "APP_NAME": "ADF Demo Application", "FILTERED_SEARCH": "Filter Header", "HOME": "Home", diff --git a/demo-shell/src/app/components/app-layout/app-layout.component.html b/demo-shell/src/app/components/app-layout/app-layout.component.html index e09045e04f..2fa808e4be 100644 --- a/demo-shell/src/app/components/app-layout/app-layout.component.html +++ b/demo-shell/src/app/components/app-layout/app-layout.component.html @@ -4,9 +4,17 @@ - +
diff --git a/demo-shell/src/app/components/app-layout/app-layout.component.ts b/demo-shell/src/app/components/app-layout/app-layout.component.ts index 394ea1dfd5..7a074450d9 100644 --- a/demo-shell/src/app/components/app-layout/app-layout.component.ts +++ b/demo-shell/src/app/components/app-layout/app-layout.component.ts @@ -121,12 +121,25 @@ export class AppLayoutComponent implements OnInit, OnDestroy { this.headerService.color .pipe(takeUntil(this.onDestroy$)) - .subscribe(color => this.color = color); + .subscribe(color => { + if (['primary', 'accent', 'warn'].includes(color)) { + this.color = color; + } else { + this.color = undefined; + document.documentElement.style.setProperty('--adf-header-background-color', color); + } + }); this.headerService.title .pipe(takeUntil(this.onDestroy$)) .subscribe(title => this.title = title); + this.headerService.headerTextColor + .pipe(takeUntil(this.onDestroy$)) + .subscribe(headerTextColor => { + document.documentElement.style.setProperty('--adf-header-text-color', headerTextColor); + }); + this.headerService.logo .pipe(takeUntil(this.onDestroy$)) .subscribe(path => this.logo = path); diff --git a/demo-shell/src/app/components/header-data/header-data.component.html b/demo-shell/src/app/components/header-data/header-data.component.html index bc101916f3..1d4d7330b7 100644 --- a/demo-shell/src/app/components/header-data/header-data.component.html +++ b/demo-shell/src/app/components/header-data/header-data.component.html @@ -26,6 +26,14 @@

*press enter for submitting new title

+
+ + +

*press enter for submitting new color text

+

*hex color

+
+
diff --git a/demo-shell/src/app/components/header-data/header-data.component.ts b/demo-shell/src/app/components/header-data/header-data.component.ts index 0f48c0fd09..7201c72805 100644 --- a/demo-shell/src/app/components/header-data/header-data.component.ts +++ b/demo-shell/src/app/components/header-data/header-data.component.ts @@ -27,6 +27,11 @@ export class HeaderDataComponent { checkbox = true; position: 'start' | 'end' = 'start'; hideSidenavToggle = false; + colorsHashesTests = [ + /#[a-z0-9]{3}/i, + /#[a-z0-9]{4}/i, + /#[a-z0-9]{6}/i + ]; constructor(private headerService: HeaderDataService) { } @@ -45,6 +50,14 @@ export class HeaderDataComponent { } } + submitHeaderTextColor(color: string): void { + const isColorHashValid = this.colorsHashesTests.some(colorTest => colorTest.test(color)); + + if (isColorHashValid || !color) { + this.headerService.changeHeaderTextColor(color); + } + } + submitLogo(logoPath: string) { if (logoPath) { this.headerService.changeLogo(logoPath); diff --git a/demo-shell/src/app/components/header-data/header-data.service.ts b/demo-shell/src/app/components/header-data/header-data.service.ts index ee01e62c3d..6e58c98fc1 100644 --- a/demo-shell/src/app/components/header-data/header-data.service.ts +++ b/demo-shell/src/app/components/header-data/header-data.service.ts @@ -28,6 +28,7 @@ export class HeaderDataService { @Output() hideMenu = new EventEmitter(); @Output() color = new EventEmitter(); + @Output() headerTextColor = new EventEmitter(); @Output() title = new EventEmitter(); @Output() logo = new EventEmitter(); @Output() redirectUrl = new EventEmitter(); @@ -46,13 +47,16 @@ export class HeaderDataService { changeTitle(title: string) { this.title.emit(title); - } changeLogo(logoPath: string) { this.logo.emit(logoPath); } + changeHeaderTextColor(color: string): void { + this.headerTextColor.emit(color); + } + changeRedirectUrl(redirectUrl: string | any[]) { this.redirectUrl.emit(redirectUrl); } diff --git a/lib/core/layout/components/header/header.component.scss b/lib/core/layout/components/header/header.component.scss index 0d0cb5b964..741ef75a46 100644 --- a/lib/core/layout/components/header/header.component.scss +++ b/lib/core/layout/components/header/header.component.scss @@ -1,6 +1,7 @@ -adf-layout-header .mat-toolbar-single-row { - color: var(--theme-primary-color-default-contrast) !important; +adf-layout-header .mat-toolbar-single-row { + color: var(--adf-header-text-color) !important; + background-color: var(--adf-header-background-color); position: relative; padding: 0 24px; diff --git a/lib/core/styles/_index.scss b/lib/core/styles/_index.scss index 31e0f69f97..420e71d4f4 100644 --- a/lib/core/styles/_index.scss +++ b/lib/core/styles/_index.scss @@ -48,6 +48,8 @@ --adf-card-view-label-color: mat-color($foreground, text, 0.4), --adf-card-view-datetime-border-color: mat-color($foreground, text, 0.42), --adf-upload-border-color: mat-color($foreground, text, 0.14), + --adf-header-background-color: mat-color($primary), + --adf-header-text-color: mat-color($primary, default-contrast), --theme-hover-bg-color: mat-color($background, hover), --theme-text-color: mat-color($foreground, text, 0.54),