Skip to content

Commit 4480132

Browse files
authored
[AAE-6057] Customize text color in the header (#2326)
* [AAE-6057] Customize text color in the header * [AAE-6057] use css vars * [AAE-6057] added tests * [AAE-6057] clear code * [AAE-6057] quick fix * [AAE-6057] update css so they wark nicly with new --adf-header-text-color
1 parent 8312e7f commit 4480132

File tree

9 files changed

+19
-15
lines changed

9 files changed

+19
-15
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.aca-toolbar-action {
2-
color: var(--theme-foreground-text-color);
32
margin: 0 5px;
3+
4+
adf-userinfo {
5+
color: var(--theme-foreground-text-color);
6+
}
47
}

projects/aca-shared/store/src/selectors/app.selectors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { createSelector } from '@ngrx/store';
2929
export const selectApp = (state: AppStore) => state.app;
3030

3131
export const getHeaderColor = createSelector(selectApp, (state) => state.headerColor);
32+
export const getHeaderTextColor = createSelector(selectApp, (state) => state.headerTextColor);
3233
export const getAppName = createSelector(selectApp, (state) => state.appName);
3334
export const getLogoPath = createSelector(selectApp, (state) => state.logoPath);
3435
export const getHeaderImagePath = createSelector(selectApp, (state) => state.headerImagePath);

projects/aca-shared/store/src/states/app.state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { RepositoryInfo, VersionEntry } from '@alfresco/js-api';
2929
export interface AppState {
3030
appName: string;
3131
headerColor: string;
32+
headerTextColor: string;
3233
logoPath: string;
3334
headerImagePath: string;
3435
sharedUrl: string;

src/app.config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"viewer.maxRetries": 1,
3030
"sharedLinkDateTimePickerType": "date",
3131
"headerColor": "#ffffff",
32+
"headerTextColor": "#000000",
3233
"pagination": {
3334
"size": 25,
3435
"supportedPageSizes": [25, 50, 100]

src/app/app.component.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export class AppComponent implements OnInit, OnDestroy {
161161
...INITIAL_APP_STATE,
162162
appName: this.config.get<string>('application.name'),
163163
headerColor: this.config.get<string>('headerColor'),
164+
headerTextColor: this.config.get<string>('headerTextColor', '#000000'),
164165
logoPath: this.config.get<string>('application.logo'),
165166
headerImagePath: this.config.get<string>('application.headerImagePath'),
166167
sharedUrl: baseShareUrl

src/app/components/header/header.component.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,12 @@
66
background-image: var(--header-background-image) !important;
77
background-repeat: no-repeat !important;
88

9-
.adf-app-title {
10-
color: var(--theme-foreground-text-color);
11-
}
12-
13-
.adf-menu-icon {
14-
color: var(--theme-foreground-text-color) !important;
15-
}
16-
179
.aca-current-user {
1810
color: var(--theme-foreground-text-color) !important;
1911
}
2012

2113
.adf-toolbar-divider div {
2214
background-color: var(--theme-foreground-text-color) !important;
2315
}
24-
25-
.app-toolbar-menu {
26-
color: var(--theme-foreground-text-color) !important;
27-
}
2816
}
2917
}

src/app/components/header/header.component.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ describe('AppHeaderComponent', () => {
5454

5555
const app = {
5656
headerColor: 'some-color',
57+
headerTextColor: 'text-color',
5758
appName: 'name',
5859
logoPath: 'some/path'
5960
} as AppState;
@@ -82,10 +83,11 @@ describe('AppHeaderComponent', () => {
8283
component = fixture.componentInstance;
8384
});
8485

85-
it('should set header color, name and logo', fakeAsync(() => {
86+
it('should set header color, header text color, name and logo', fakeAsync(() => {
8687
component.appName$.subscribe((val) => expect(val).toBe(app.appName));
8788
component.logo$.subscribe((val) => expect(val).toBe(app.logoPath));
8889
component.headerColor$.subscribe((val) => expect(val).toBe(app.headerColor));
90+
component.headerTextColor$.subscribe((val) => expect(val).toBe(app.headerTextColor));
8991
}));
9092

9193
it('should get header actions', fakeAsync(() => {

src/app/components/header/header.component.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import { Component, ViewEncapsulation, Output, EventEmitter, OnInit, Input, OnDe
2727
import { Store } from '@ngrx/store';
2828
import { Observable, Subject } from 'rxjs';
2929
import { ContentActionRef } from '@alfresco/adf-extensions';
30-
import { AppStore, getHeaderColor, getAppName, getLogoPath, getHeaderImagePath } from '@alfresco/aca-shared/store';
30+
import { AppStore, getHeaderColor, getAppName, getLogoPath, getHeaderImagePath, getHeaderTextColor } from '@alfresco/aca-shared/store';
3131
import { AppExtensionService } from '@alfresco/aca-shared';
3232
import { takeUntil } from 'rxjs/operators';
3333

@@ -47,12 +47,14 @@ export class AppHeaderComponent implements OnInit, OnDestroy {
4747

4848
appName$: Observable<string>;
4949
headerColor$: Observable<any>;
50+
headerTextColor$: Observable<string>;
5051
logo$: Observable<string>;
5152

5253
actions: Array<ContentActionRef> = [];
5354

5455
constructor(store: Store<AppStore>, private appExtensions: AppExtensionService) {
5556
this.headerColor$ = store.select(getHeaderColor);
57+
this.headerTextColor$ = store.select(getHeaderTextColor);
5658
this.appName$ = store.select(getAppName);
5759
this.logo$ = store.select(getLogoPath);
5860

@@ -68,6 +70,10 @@ export class AppHeaderComponent implements OnInit, OnDestroy {
6870
.subscribe((actions) => {
6971
this.actions = actions;
7072
});
73+
74+
this.headerTextColor$.subscribe((color) => {
75+
document.documentElement.style.setProperty('--adf-header-text-color', color);
76+
});
7177
}
7278

7379
ngOnDestroy() {

src/app/store/initial-state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { AppState, AppStore } from '@alfresco/aca-shared/store';
2828
export const INITIAL_APP_STATE: AppState = {
2929
appName: 'Alfresco Content Application',
3030
headerColor: '#ffffff',
31+
headerTextColor: '#000000',
3132
logoPath: 'assets/images/alfresco-logo-white.svg',
3233
headerImagePath: 'assets/images/mastHead-bg-shapesPattern.svg',
3334
sharedUrl: '',

0 commit comments

Comments
 (0)