diff --git a/projects/go-lib/src/lib/components/go-header/go-header.component.html b/projects/go-lib/src/lib/components/go-header/go-header.component.html index 2226f1cb7..0e6a681a1 100644 --- a/projects/go-lib/src/lib/components/go-header/go-header.component.html +++ b/projects/go-lib/src/lib/components/go-header/go-header.component.html @@ -1,22 +1,22 @@
- - + [ngClass]="{ 'go-header__left--dark': brandColorIsDark }"> +
+ + +
+ [ngClass]="{ 'go-header__logo-container--collapsed': isNavCollapsed() }" + [ngStyle]="{ 'background': getLogoBackground() }">
diff --git a/projects/go-lib/src/lib/components/go-header/go-header.component.scss b/projects/go-lib/src/lib/components/go-header/go-header.component.scss index 1962eb7c0..4c5e95263 100644 --- a/projects/go-lib/src/lib/components/go-header/go-header.component.scss +++ b/projects/go-lib/src/lib/components/go-header/go-header.component.scss @@ -5,7 +5,7 @@ $breakpoint-header-mobile-small: 500px; .go-header { background: $theme-light-bg; - box-shadow: $global-box-shadow--small; + box-shadow: $global-box-shadow--large; display: flex; height: $header-height; justify-content: space-between; @@ -18,13 +18,26 @@ $breakpoint-header-mobile-small: 500px; } } +.go-header__menu-container { + align-items: center; + cursor: pointer; + display: flex; + justify-content: center; + width: $side-nav-width--collapsed; + + &:hover { + .go-header__menu { + opacity: .5; + } + } +} + .go-header__menu { - @include transition(background); + @include transition(all); align-items: center; align-self: center; border-radius: 50%; - cursor: pointer; display: flex; flex-shrink: 0; font-size: 1.5rem; @@ -39,7 +52,7 @@ $breakpoint-header-mobile-small: 500px; display: flex; flex: 1; justify-content: flex-start; - padding: 0.5rem 1rem; + padding: 1rem; @media (max-width: $breakpoint-header-mobile-small) { padding: 0.5rem; @@ -61,7 +74,6 @@ $breakpoint-header-mobile-small: 500px; @include transition(width); display: flex; - padding: 0.5rem; width: 15.5rem; @media (max-width: $breakpoint-mobile) { @@ -69,10 +81,6 @@ $breakpoint-header-mobile-small: 500px; } } -.go-header__left--collapsed { - width: auto; -} - .go-header__left--dark { color: $theme-dark-color } @@ -94,10 +102,6 @@ $breakpoint-header-mobile-small: 500px; } } -.go-header__middle--collapsed { - padding: 0 1rem; -} - .go-header__middle--hide { display: none; } diff --git a/projects/go-lib/src/lib/components/go-header/go-header.component.spec.ts b/projects/go-lib/src/lib/components/go-header/go-header.component.spec.ts index 5120ebc8d..82003500b 100644 --- a/projects/go-lib/src/lib/components/go-header/go-header.component.spec.ts +++ b/projects/go-lib/src/lib/components/go-header/go-header.component.spec.ts @@ -1,7 +1,10 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { GoHeaderComponent } from './go-header.component'; -import { GoIconButtonModule } from '../go-icon-button/go-icon-button.module'; +import { GoIconModule } from '../go-icon/go-icon.module'; +import { CommonModule } from '@angular/common'; +import { RouterModule } from '@angular/router'; +import { RouterTestingModule } from '@angular/router/testing'; import { GoConfigService } from '../../go-config.service'; describe('GoHeaderComponent', () => { @@ -12,7 +15,10 @@ describe('GoHeaderComponent', () => { TestBed.configureTestingModule({ declarations: [ GoHeaderComponent ], imports: [ - GoIconButtonModule + CommonModule, + GoIconModule, + RouterModule, + RouterTestingModule ], providers: [ GoConfigService diff --git a/projects/go-lib/src/lib/components/go-header/go-header.component.ts b/projects/go-lib/src/lib/components/go-header/go-header.component.ts index 7413257cb..7c2dc4682 100644 --- a/projects/go-lib/src/lib/components/go-header/go-header.component.ts +++ b/projects/go-lib/src/lib/components/go-header/go-header.component.ts @@ -1,6 +1,6 @@ import { Component, ElementRef, Input, OnChanges, ViewChild } from '@angular/core'; import { fromEvent, Observable, Subscription } from 'rxjs'; -import { debounceTime, distinctUntilKeyChanged, distinctUntilChanged } from 'rxjs/operators'; +import { debounceTime, distinctUntilChanged } from 'rxjs/operators'; import { GoConfigInterface } from '../../go-config.model'; import { GoConfigService } from '../../go-config.service'; import { GoSideNavService } from '../go-side-nav/go-side-nav/go-side-nav.service'; @@ -37,7 +37,12 @@ export class GoHeaderComponent implements OnChanges { .pipe(distinctUntilChanged()) .subscribe((value: GoConfigInterface) => { if (value.headerBrandingEnabled) { - this.handleBrandColorChange(value); + if (value.brandFontColor) { + this.brandColor = value.brandColor; + this.brandColorIsDark = value.brandFontColor === 'light'; + } else { + this.handleBrandColorChange(value); + } } else { this.brandColor = ''; this.brandColorIsDark = false; @@ -49,6 +54,14 @@ export class GoHeaderComponent implements OnChanges { return window.innerWidth <= this.minWidthBreakpoint ? true : !this.sideNavService.navOpen; } + getLogoBackground(): string | null { + if (this.brandColor && !this.isNavCollapsed()) { + return this.brandColor; + } else { + return null; + } + } + toggleSideMenu(): void { this.sideNavService.toggleNav(); } diff --git a/projects/go-lib/src/lib/components/go-header/go-header.module.ts b/projects/go-lib/src/lib/components/go-header/go-header.module.ts index 0fb57a052..f18580700 100644 --- a/projects/go-lib/src/lib/components/go-header/go-header.module.ts +++ b/projects/go-lib/src/lib/components/go-header/go-header.module.ts @@ -1,7 +1,7 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { GoIconButtonModule} from '../go-icon-button/go-icon-button.module'; +import { GoIconModule} from '../go-icon/go-icon.module'; import { GoSideNavModule } from '../go-side-nav/go-side-nav.module'; import { GoSideNavService } from '../go-side-nav/go-side-nav/go-side-nav.service'; @@ -14,7 +14,7 @@ import { GoHeaderComponent } from './go-header.component'; ], imports: [ CommonModule, - GoIconButtonModule, + GoIconModule, GoSideNavModule ], exports: [ diff --git a/projects/go-lib/src/lib/components/go-search/go-search.component.scss b/projects/go-lib/src/lib/components/go-search/go-search.component.scss index 761b356b0..c705a1605 100644 --- a/projects/go-lib/src/lib/components/go-search/go-search.component.scss +++ b/projects/go-lib/src/lib/components/go-search/go-search.component.scss @@ -41,11 +41,7 @@ } .go-search__container--active { - border: 0; box-shadow: $global-box-shadow--search; - padding: 0.5rem; - top: calc(50% - (2.875rem / 2)); - // height of input with padding, halfed &:hover { background: $theme-light-bg; diff --git a/projects/go-lib/src/lib/components/go-side-nav/_variables.scss b/projects/go-lib/src/lib/components/go-side-nav/_variables.scss index 68df03c55..1cc332dfd 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/_variables.scss +++ b/projects/go-lib/src/lib/components/go-side-nav/_variables.scss @@ -1,6 +1,7 @@ @import "../../../styles/variables"; -$inner-side-nav-font-size: 0.875rem; +$inner-side-nav-font-size: .875rem; $inner-side-nav-padding: $column-gutter--half $column-gutter--three-quarters $column-gutter--half 3.2rem; $outer-side-nav-padding: 1rem 1rem 1rem 0; -$side-nav-letter-spacing: .02rem; +$side-nav-base-color: rgba($theme-dark-color, .7); +$side-nav-root-item-height: 3.2rem; diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.html b/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.html index dd24126c7..b3b83a666 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.html +++ b/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.html @@ -3,10 +3,14 @@ *ngIf="group.subRoutes && group.subRoutes.length > 0; else noSubRoutes">
+ [attr.title]="group.description" + [ngClass]="{ 'go-nav-group__dropdown--expanded': group.expanded }">
- + diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.scss b/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.scss index e2076c564..cbe509d19 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.scss +++ b/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.scss @@ -2,43 +2,68 @@ @import '../variables'; .go-nav-group__dropdown { + @include transition(background, color); + align-items: center; + color: $side-nav-base-color; + cursor: pointer; display: flex; + font-weight: $weight-light; padding-right: .5rem; user-select: none; - @include transition(all); &:hover { background: $theme-dark-bg-hover; + color: $theme-dark-color; + + .go-nav-group__expand-icon { + color: $theme-dark-color; + } + } +} + +.go-nav-group__dropdown--expanded { + background: $theme-dark-bg-active; + color: $theme-dark-color; + font-weight: $weight-regular; + + .go-nav-group__expand-icon { + color: $theme-dark-color; } } .go-nav-group__link { display: flex; flex-grow: 1; + position: relative; } .go-nav-group__title { align-items: center; display: flex; - font-weight: $weight-light; - letter-spacing: $side-nav-letter-spacing; padding: $outer-side-nav-padding; } .go-nav-group__icon { + align-self: flex-start; font-size: 1.2rem; + height: $side-nav-root-item-height; padding: 1rem; } +.go-nav-group__icon--external { + padding-left: .5rem; + padding-right: .75rem; +} + .go-nav-group__expand-icon { border-radius: 50%; - color: $theme-dark-color; + color: $side-nav-base-color; cursor: pointer; font-size: 1.5rem; - height: 2.5rem; - padding: 0.5rem; - width: 2.5rem; + height: 2rem; + padding: .25rem; + width: 2rem; &:hover { background: $theme-dark-bg; @@ -58,4 +83,17 @@ .go-nav-group--expanded { background: $theme-dark-bg-active; + color: $theme-dark-color; } + +.go-nav-item--selected { + @include transition(all); + + border-radius: 0 $global-radius $global-radius 0; + content: ' '; + height: 1.5rem; + position: absolute; + top: 50%; + transform: translateY(-50%); + width: 4px; +} \ No newline at end of file diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.ts b/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.ts index 4ff759941..222e2b608 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.ts +++ b/projects/go-lib/src/lib/components/go-side-nav/go-nav-group/go-nav-group.component.ts @@ -1,26 +1,47 @@ -import { Component, EventEmitter, Input, OnInit, Output, ViewEncapsulation } from '@angular/core'; +import { + Component, + EventEmitter, + Input, + OnInit, + Output, + ViewEncapsulation +} from '@angular/core'; import { NavGroup } from '../nav-group.model'; import { NavItem } from '../nav-item.model'; import { GoSideNavService } from '../go-side-nav/go-side-nav.service'; +import { GoConfigService } from '../../../go-config.service'; +import { distinctUntilKeyChanged } from 'rxjs/operators'; +import { GoConfigInterface } from '../../../go-config.model'; @Component({ selector: 'go-nav-group', templateUrl: './go-nav-group.component.html', styleUrls: ['./go-nav-group.component.scss'], + // tslint:disable-next-line: use-component-view-encapsulation encapsulation: ViewEncapsulation.None }) -export class GoNavGroupComponent implements OnInit { +export class GoNavGroupComponent implements OnInit { @Input() navItem: NavGroup | NavItem; @Input() class: string; - @Output() closeNavs = new EventEmitter(); + @Input() level: number; + @Output() closeNavs: EventEmitter = new EventEmitter(); + brandColor: string; group: NavGroup; - constructor (public navService: GoSideNavService) { } + constructor ( + public navService: GoSideNavService, + private configService: GoConfigService + ) { } ngOnInit(): void { // Using this to do type checking between NavGroup and NavItem in the html this.group = this.navItem as NavGroup; + this.configService.config + .pipe(distinctUntilKeyChanged('brandColor')) + .subscribe((value: GoConfigInterface) => { + this.brandColor = value.brandColor; + }); } expand(navGroup: NavGroup): void { diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.html b/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.html index c630f75d0..db3f6fe51 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.html +++ b/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.html @@ -1,9 +1,13 @@
+ [attr.title]="navItem.description" + [ngClass]="{ 'go-nav-item--collapsed': !navService.navOpen }"> + @@ -13,23 +17,19 @@ [target]="navItem.externalLinkTarget ? navItem.externalLinkTarget : '_blank'" rel="noreferrer"> - + class="go-nav-group__icon go-nav-group__icon--external">
- - {{navItem.routeTitle}} diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.scss b/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.scss index fb05f64ab..f1daefdb9 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.scss +++ b/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.scss @@ -3,30 +3,45 @@ @import '../variables'; .go-nav-item { + @include transition(all); + align-items: center; display: flex; - @include transition(all); + min-height: 2rem; position: relative; &:hover { - background: $theme-dark-bg-hover; + .go-nav-item__link { + background: $theme-dark-bg-hover; + color: $theme-dark-color; + } } } +.go-nav-item--collapsed { + min-height: 0; +} + .go-nav-item__link--active { .go-nav-item__title { font-weight: $weight-regular; + color: $theme-dark-color; + } + + .go-nav-group__icon { + color: $theme-dark-color; } .go-nav-item--selected { + @include transition(all); + border-radius: 0 $global-radius $global-radius 0; - content: " "; + content: ' '; height: 1.5rem; position: absolute; top: 50%; transform: translateY(-50%); width: 4px; - @include transition(all); } } @@ -34,27 +49,37 @@ .go-nav-item__link:visited, .go-nav-item__link:focus, .go-nav-item__link:active { - color: $theme-dark-color; + color: $side-nav-base-color; } .go-nav-item__link { + @include transition(all); + align-items: center; - border: none; + border: 0; display: flex; flex-grow: 1; + max-width: 100%; position: relative; text-decoration: none; } .go-nav-item__title { + flex-grow: 1; font-size: $inner-side-nav-font-size; font-weight: $weight-light; - letter-spacing: $side-nav-letter-spacing; + max-height: $side-nav-root-item-height; padding: $inner-side-nav-padding; - flex-grow: 1; +} + +.go-nav-item__title--level-2 { + padding-left: calc(#{$side-nav-root-item-height} + .5rem); } .go-nav-item__title--with-icon { + align-items: center; + display: inline-flex; font-size: 1rem; - padding: $outer-side-nav-padding; + height: $side-nav-root-item-height; + padding: 0 1rem 0 0; } diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.ts b/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.ts index 4d4cbe13a..d5bcc7d56 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.ts +++ b/projects/go-lib/src/lib/components/go-side-nav/go-nav-item/go-nav-item.component.ts @@ -14,6 +14,7 @@ export class GoNavItemComponent implements OnInit { brandColor: string; @Input() navItem: NavItem; + @Input() level: number; constructor ( public navService: GoSideNavService, diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.component.html b/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.component.html index 3ab0ca377..39248234f 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.component.html +++ b/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.component.html @@ -2,6 +2,7 @@ [ngClass]="{ 'go-side-nav--show-mobile' : navService.navOpen, 'go-side-nav--collapsed' : !navService.navOpen }"> + (closeNavs)="closeNavs($event)" + [level]="0"> diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.component.ts b/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.component.ts index 856909e68..9a5887461 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.component.ts +++ b/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.component.ts @@ -1,5 +1,5 @@ -import { Component, OnInit, Input } from '@angular/core'; -import { Router, NavigationEnd } from '@angular/router'; +import { Component, Input, OnInit } from '@angular/core'; +import { NavigationEnd, Router } from '@angular/router'; import { filter } from 'rxjs/operators'; import { NavGroup } from '../nav-group.model'; import { NavItem } from '../nav-item.model'; @@ -13,22 +13,26 @@ import { GoSideNavService } from './go-side-nav.service'; export class GoSideNavComponent implements OnInit { @Input() menuItems: Array; - constructor (private router: Router, public navService: GoSideNavService) { } + constructor ( + private router: Router, + public navService: GoSideNavService + ) { } ngOnInit(): void { + this.navService.setMenuItems(this.menuItems); this.router.events .pipe( - filter(event => event instanceof NavigationEnd) + filter((event: any) => event instanceof NavigationEnd) ).subscribe((event: NavigationEnd) => { - this.menuItems.forEach(item => { + this.menuItems.forEach((item: (NavGroup | NavItem)) => { (item as NavGroup).expanded = this.setExpanded(item, event.url); }); }); } closeNavs(navGroup: NavGroup): void { - this.menuItems.forEach(group => { - const g = group as NavGroup; + this.menuItems.forEach((group: (NavGroup | NavItem)) => { + const g: NavGroup = group as NavGroup; g.expanded = this.openAccordion(g, navGroup); }); } @@ -44,7 +48,7 @@ export class GoSideNavComponent implements OnInit { } private navGroupExpansion(group: NavGroup, url: string): boolean { - group.expanded = group.subRoutes.some(subRoute => { + group.expanded = group.subRoutes.some((subRoute: (NavGroup | NavItem)) => { return this.setExpanded(subRoute, url); }); return group.expanded; @@ -58,11 +62,10 @@ export class GoSideNavComponent implements OnInit { * @param group this is the group we are trying to decide if it should be open. * @param item this is the group that we are searching for that was clicked on and needs opened. */ - private openAccordion(group: NavGroup, item: NavGroup): boolean { if (group.subRoutes) { if (group.routeTitle !== item.routeTitle) { - group.expanded = group.subRoutes.some(subRoute => { + group.expanded = group.subRoutes.some((subRoute: (NavGroup | NavItem)) => { return this.openAccordion((subRoute as NavGroup), item); }); } else { diff --git a/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.service.ts b/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.service.ts index d2f2dda34..87a9da7f5 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.service.ts +++ b/projects/go-lib/src/lib/components/go-side-nav/go-side-nav/go-side-nav.service.ts @@ -1,16 +1,66 @@ import { Injectable } from '@angular/core'; -import { Observable, of as observableOf, BehaviorSubject } from 'rxjs'; +import { NavGroup } from '../nav-group.model'; +import { NavItem } from '../nav-item.model'; +import { NavigationEnd, Router } from '@angular/router'; @Injectable({ providedIn: 'root' }) export class GoSideNavService { - public navOpen = true; + public navOpen: boolean = true; + public menuItems: (NavGroup | NavItem)[]; + private _menuItems: Map = new Map(); + private currentItem: NavItem | NavGroup; - constructor() { } + constructor(private router: Router) { + this.router.events.subscribe((event: any) => { + if (event instanceof NavigationEnd) { + const obj: NavGroup | NavItem = this._menuItems.get(event.urlAfterRedirects); + if (obj) { + if (this.currentItem) { + this.currentItem.routeActive = false; + } - toggleNav() { + obj.routeActive = true; + this.currentItem = obj; + } + } + }); + } + + setMenuItems(val: (NavGroup | NavItem)[]): void { + this.menuItems = val; + this.createNavMap(); + } + + toggleNav(): void { this.navOpen = !this.navOpen; } + + private isNavGroup(item: NavGroup | NavItem): item is NavGroup { + return (item as NavGroup).subRoutes !== undefined; + } + + private extractNested(group: NavGroup, base: NavGroup): void { + for (const route of group.subRoutes) { + if (this.isNavGroup(route)) { + this.extractNested(route, base); + } else { + this._menuItems.set('/' + route.route, base); + } + } + } + + private createNavMap(): void { + let baseItem: NavGroup | NavItem; + for (let i: number = 0; i < this.menuItems.length; i++) { + baseItem = this.menuItems[i]; + if (!this.isNavGroup(baseItem)) { + this._menuItems.set('/' + baseItem.route, baseItem); + } else { + this.extractNested(baseItem, baseItem); + } + } + } } diff --git a/projects/go-lib/src/lib/components/go-side-nav/nav-group.model.ts b/projects/go-lib/src/lib/components/go-side-nav/nav-group.model.ts index dd13bde46..4014d2c2b 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/nav-group.model.ts +++ b/projects/go-lib/src/lib/components/go-side-nav/nav-group.model.ts @@ -3,6 +3,7 @@ import { NavItem } from './nav-item.model'; export interface NavGroup { description?: string; expanded?: boolean; + routeActive?: boolean; routeIcon?: string; routeTitle: string; subRoutes: Array; diff --git a/projects/go-lib/src/lib/components/go-side-nav/nav-item.model.ts b/projects/go-lib/src/lib/components/go-side-nav/nav-item.model.ts index eeaa0b8cf..a3fdb7a46 100644 --- a/projects/go-lib/src/lib/components/go-side-nav/nav-item.model.ts +++ b/projects/go-lib/src/lib/components/go-side-nav/nav-item.model.ts @@ -3,6 +3,7 @@ export interface NavItem { route: string; routeIcon?: string; routeTitle: string; + routeActive?: boolean; /** * When `isExternalLink` is true, the value passed to `route` will be used for redirection. By default, all external links will open in a diff --git a/projects/go-lib/src/lib/go-config.model.ts b/projects/go-lib/src/lib/go-config.model.ts index 863e08fa5..345be4265 100644 --- a/projects/go-lib/src/lib/go-config.model.ts +++ b/projects/go-lib/src/lib/go-config.model.ts @@ -1,4 +1,5 @@ export interface GoConfigInterface { brandColor: string; + brandFontColor?: undefined | 'light' | 'dark'; headerBrandingEnabled: boolean; } diff --git a/projects/go-lib/src/lib/go-config.service.ts b/projects/go-lib/src/lib/go-config.service.ts index c2ff6182f..6b7af66dc 100644 --- a/projects/go-lib/src/lib/go-config.service.ts +++ b/projects/go-lib/src/lib/go-config.service.ts @@ -15,6 +15,10 @@ export class GoConfigService { headerBrandingEnabled: false }); + /** + * Use this method to specific a brand color to be used in all places where branding is applied + * @param color The color for the brand + */ public setBrandColor(color: string): void { // we have to copy the config here or it won't regester a change in components const config: GoConfigInterface = Object.assign({}, this.config.getValue()); @@ -22,6 +26,9 @@ export class GoConfigService { this.config.next(config); } + /** + * Use this method to turn the branding in the header on/off + */ public toggleHeaderBrandingEnabled(): void { // we have to copy the config here or it won't regester a change in components const config: GoConfigInterface = Object.assign({}, this.config.getValue()); @@ -29,6 +36,21 @@ export class GoConfigService { this.config.next(config); } + /** + * Use this method to override the accessibility check and set a consistent background + * @param useColor specifies the font color to use, regardless of accessibilty + */ + public overrideMenuColor(useColor: 'light'| 'dark'): void { + const config: GoConfigInterface = Object.assign({}, this.config.getValue()); + config.brandFontColor = useColor; + this.config.next(config); + } + + /** + * Use this method to check the contrast ratio between a foreground and background color combination + * @param backgroundHex the hexidecimal code for the background color + * @param foregroundHex the hexidecimal code for the foreground color + */ public contrastIsAccessible(backgroundHex: string, foregroundHex: string): boolean { const backgroundRgb: RGB = this.hexToRgb(backgroundHex); const foregroundRgb: RGB = this.hexToRgb(foregroundHex); diff --git a/projects/go-lib/src/styles/_variables.scss b/projects/go-lib/src/styles/_variables.scss index a9734396f..5aa468299 100644 --- a/projects/go-lib/src/styles/_variables.scss +++ b/projects/go-lib/src/styles/_variables.scss @@ -28,7 +28,7 @@ $column-sizes: ( 75: 3 / 4, 100: 1 ); - + $side-nav-width: 15.5rem; $side-nav-width--collapsed: 3.2rem; diff --git a/projects/go-style-guide/src/app/features/ui-kit/components/configuration-docs/configuration-docs.component.html b/projects/go-style-guide/src/app/features/ui-kit/components/configuration-docs/configuration-docs.component.html index 806b8617c..04884a254 100644 --- a/projects/go-style-guide/src/app/features/ui-kit/components/configuration-docs/configuration-docs.component.html +++ b/projects/go-style-guide/src/app/features/ui-kit/components/configuration-docs/configuration-docs.component.html @@ -1,84 +1,114 @@
-

{{ pageTitle }}

-
- -
- - -

Branding

-
- -

- The GoConfigurationService can be used to brand a few select - pieces of our design system. Currently the only things that can be branded are the active indicators - on the sidenav and accordions as well as the left portion of the header. -

+

{{ pageTitle }}

+
-

Update Branding Color

-
-
-
-

- The public setBrandColor(color: string): void method can be used - to update the branding color by passing in a hex code. -

-
-
+
+ + +

Branding

+
+ +

+ The GoConfigurationService can be used to brand a few select + pieces of our design system. Currently the only things that can be branded are the active indicators + on the sidenav and accordions as well as the left portion of the header. +

-
-
- +

Update Branding Color

+

+ The public setBrandColor(color: string): void method can be used + to update the branding color by passing in a hex code. +

+ +
+
+
+
+
- -
- +
+ Update Branding Color
+
-
- - - - - -
+
+ + + + +
+
+ + -

Enable Header Branding

-
-
-
-

- The public toggleHeaderBrandingEnabled(): void method can - be used to enable/disable header branding. -

-
-
+ + +

Enable Header Branding

+
+ +

+ The public toggleHeaderBrandingEnabled(): void method can + be used to enable/disable header branding. +

+
+
+ + +
-
-
- - -
-
+
+ + + + + +
+
+
+
-
- - - - - -
+ + +

Override Accessibility Color

+
+ +

+ The overrideMenuColor() method can + be used to override the accessibility check that is performed on the header. + You can specify light, dark + or leave it undefined to allow the accessibility check. + This feature is only activated if headerBrandingEnabled is enabled. +

+
+
+

+ + +

+

+ Note: to see this example take affect, toggle the "Enable Header Branding" above to true. +

+
+ +
+ + + + +
- - -
+
+ + + diff --git a/projects/go-style-guide/src/app/features/ui-kit/components/configuration-docs/configuration-docs.component.ts b/projects/go-style-guide/src/app/features/ui-kit/components/configuration-docs/configuration-docs.component.ts index 892e2050e..e7854a39e 100644 --- a/projects/go-style-guide/src/app/features/ui-kit/components/configuration-docs/configuration-docs.component.ts +++ b/projects/go-style-guide/src/app/features/ui-kit/components/configuration-docs/configuration-docs.component.ts @@ -8,8 +8,14 @@ import { FormControl } from '@angular/forms'; }) export class ConfigurationDocsComponent implements OnInit { pageTitle: string = 'Configuration'; - inputControl: FormControl; + inputControl: FormControl = new FormControl(false); toggleControl: FormControl = new FormControl(false); + colorControl: FormControl = new FormControl(''); + colorOptions: any = [ + { label: 'Default', value: undefined }, + { label: 'Light', value: 'light' }, + { label: 'Dark', value: 'dark' } + ]; updateColorExample: string = ` updateColor(): void { @@ -45,6 +51,30 @@ export class ConfigurationDocsComponent implements OnInit { } `; + colorEx: string = ` + colorControl: FormControl = new FormControl(''); + colorOptions: any = [ + { label: 'Default', value: undefined }, + { label: 'Light', value: 'light' }, + { label: 'Dark', value: 'dark' } + ]; + + constructor(private goConfigService: GoConfigService) { } + + this.colorControl.valueChanges.subscribe(value => { + this.goConfigService.overrideMenuColor(value); + }); + `; + + colorEx_html: string = ` + + + `; + constructor(private goConfigService: GoConfigService) { } ngOnInit(): void { @@ -52,6 +82,10 @@ export class ConfigurationDocsComponent implements OnInit { this.toggleControl.valueChanges.subscribe(() => { this.goConfigService.toggleHeaderBrandingEnabled(); }); + + this.colorControl.valueChanges.subscribe((value: ('light' | 'dark')) => { + this.goConfigService.overrideMenuColor(value); + }); } updateColor(): void { diff --git a/projects/go-tester/src/app/app.component.ts b/projects/go-tester/src/app/app.component.ts index 0106e741d..25059b030 100644 --- a/projects/go-tester/src/app/app.component.ts +++ b/projects/go-tester/src/app/app.component.ts @@ -27,12 +27,14 @@ export class AppComponent implements OnInit { { routeIcon: 'dashboard', routeTitle: 'Tests', description: 'Test Routes', subRoutes: [ { route: 'test-page-1', routeTitle: 'Test 1', description: 'Test Route 1' }, { route: 'test-page-2', routeTitle: 'Test 2' }, - { route: 'test-page-3', routeTitle: 'Test 3', description: 'Forms' } + { routeTitle: 'Test 3', description: 'Forms', subRoutes: [ + { route: 'test-page-3', routeTitle: 'test 4' } + ]} ]}, { routeIcon: 'explore', routeTitle: 'Second Test', route: 'test-page-4', description: 'Test Route 4' }, { routeIcon: 'search', - routeTitle: 'External Link (New Tab)', + routeTitle: 'External Link (In a New Tab)', description: 'Test external link opening in new tab', route: 'https://www.google.com/', isExternalLink: true @@ -71,6 +73,7 @@ export class AppComponent implements OnInit { ngOnInit(): void { this.goConfigService.setBrandColor('#8A4EDE'); + this.goConfigService.overrideMenuColor('light'); this.toggleControl.valueChanges.subscribe(() => { this.goConfigService.toggleHeaderBrandingEnabled();