mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-15251] Making header component more customizable (#8670)
This commit is contained in:
@@ -46,6 +46,8 @@ body of the element:
|
|||||||
| showSidenavToggle | `boolean` | true | Toggles whether the sidenav button will be displayed in the header or not. |
|
| showSidenavToggle | `boolean` | true | Toggles whether the sidenav button will be displayed in the header or not. |
|
||||||
| title | `string` | | Title of the application. |
|
| title | `string` | | Title of the application. |
|
||||||
| tooltip | `string` | | The tooltip text for the application logo. |
|
| tooltip | `string` | | The tooltip text for the application logo. |
|
||||||
|
| toggleIcon | `string` | "menu" | The toggle icon that will be used inside header. |
|
||||||
|
| showLogo | `boolean` | true | Toggles whether the logo will be displayed inside the header or not. |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
|
@@ -13,10 +13,10 @@
|
|||||||
<mat-icon
|
<mat-icon
|
||||||
class="mat-icon material-icon"
|
class="mat-icon material-icon"
|
||||||
role="img"
|
role="img"
|
||||||
aria-hidden="true">menu</mat-icon>
|
aria-hidden="true">{{ toggleIcon }}</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<a [routerLink]="redirectUrl" title="{{ tooltip }}">
|
<a *ngIf="showLogo" [routerLink]="redirectUrl" title="{{ tooltip }}">
|
||||||
<img
|
<img
|
||||||
src="{{ logo }}"
|
src="{{ logo }}"
|
||||||
class="adf-app-logo"
|
class="adf-app-logo"
|
||||||
@@ -48,6 +48,6 @@
|
|||||||
<mat-icon
|
<mat-icon
|
||||||
class="mat-icon material-icon"
|
class="mat-icon material-icon"
|
||||||
role="img"
|
role="img"
|
||||||
aria-hidden="true">menu</mat-icon>
|
aria-hidden="true">{{ toggleIcon }}</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
</mat-toolbar>
|
</mat-toolbar>
|
||||||
|
@@ -175,6 +175,43 @@ describe('HeaderLayoutComponent', () => {
|
|||||||
expect(buttonStart === null).toBeFalsy();
|
expect(buttonStart === null).toBeFalsy();
|
||||||
expect(buttonEnd === null).toBeTruthy();
|
expect(buttonEnd === null).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should display the logo image when the input is set to true [showLogo=true]', () => {
|
||||||
|
component.showLogo = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const logo = fixture.debugElement.query(By.css('.adf-app-logo'));
|
||||||
|
|
||||||
|
expect(logo.nativeElement).not.toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should NOT display the logo image when the input is set to false [showLogo=false]', () => {
|
||||||
|
component.showLogo = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const logo = fixture.debugElement.query(By.css('.adf-app-logo'));
|
||||||
|
|
||||||
|
expect(logo).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display the default toggle icon', () => {
|
||||||
|
component.showSidenavToggle = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const toggleIcon = fixture.debugElement.query(By.css('.adf-menu-icon'));
|
||||||
|
|
||||||
|
expect(toggleIcon.nativeElement.textContent).toBe('menu');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should display the correct toggle icon', () => {
|
||||||
|
component.showSidenavToggle = true;
|
||||||
|
component.toggleIcon = 'apps';
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
const toggleIcon = fixture.debugElement.query(By.css('.adf-menu-icon'));
|
||||||
|
|
||||||
|
expect(toggleIcon.nativeElement.textContent).toBe('apps');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Template transclusion', () => {
|
describe('Template transclusion', () => {
|
||||||
|
@@ -33,6 +33,9 @@ export class HeaderLayoutComponent implements OnInit {
|
|||||||
/** Path to an image file for the application logo. */
|
/** Path to an image file for the application logo. */
|
||||||
@Input() logo: string;
|
@Input() logo: string;
|
||||||
|
|
||||||
|
/** Toggles whether the logo will be displayed inside the header or not. */
|
||||||
|
@Input() showLogo: boolean = true;
|
||||||
|
|
||||||
/** The router link for the application logo, when clicked. */
|
/** The router link for the application logo, when clicked. */
|
||||||
@Input() redirectUrl: string | any[] = '/';
|
@Input() redirectUrl: string | any[] = '/';
|
||||||
|
|
||||||
@@ -51,6 +54,9 @@ export class HeaderLayoutComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
@Input() showSidenavToggle: boolean = true;
|
@Input() showSidenavToggle: boolean = true;
|
||||||
|
|
||||||
|
/** The toggle icon that will be used inside header. */
|
||||||
|
@Input() toggleIcon = 'menu';
|
||||||
|
|
||||||
/** Emitted when the sidenav button is clicked. */
|
/** Emitted when the sidenav button is clicked. */
|
||||||
@Output() clicked = new EventEmitter<boolean>();
|
@Output() clicked = new EventEmitter<boolean>();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user