-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): update Layout Panel to latest design (#9499)
- Loading branch information
1 parent
52711cc
commit 3e51e74
Showing
15 changed files
with
201 additions
and
32 deletions.
There are no files selected for viewing
44 changes: 34 additions & 10 deletions
44
libs/core/src/lib/layout-panel/layout-panel-footer/layout-panel-footer.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,52 @@ | ||
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; | ||
import { LayoutPanelFooterComponent, FooterPosition } from './layout-panel-footer.component'; | ||
import { Component, ElementRef, ViewChild } from '@angular/core'; | ||
|
||
import { LayoutPanelFooterComponent } from './layout-panel-footer.component'; | ||
@Component({ | ||
selector: 'fd-test-layout-panel-footer', | ||
template: `<fd-layout-panel-footer [position]="position"> </fd-layout-panel-footer> ` | ||
}) | ||
class TestLayoutPanelFooterComponent { | ||
@ViewChild(LayoutPanelFooterComponent, { static: true, read: ElementRef }) | ||
layoutPanelFooterElementRef: ElementRef; | ||
|
||
position: FooterPosition; | ||
} | ||
|
||
describe('LayoutPanelFooterComponent', () => { | ||
let component: LayoutPanelFooterComponent; | ||
let fixture: ComponentFixture<LayoutPanelFooterComponent>; | ||
let layoutPanelFooterElementRef: ElementRef; | ||
let testComponent: TestLayoutPanelFooterComponent; | ||
let fixture: ComponentFixture<TestLayoutPanelFooterComponent>; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [LayoutPanelFooterComponent] | ||
declarations: [LayoutPanelFooterComponent, TestLayoutPanelFooterComponent] | ||
}).compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(LayoutPanelFooterComponent); | ||
component = fixture.componentInstance; | ||
fixture = TestBed.createComponent(TestLayoutPanelFooterComponent); | ||
layoutPanelFooterElementRef = fixture.componentInstance.layoutPanelFooterElementRef; | ||
testComponent = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
it('Should create', () => { | ||
expect(testComponent).toBeTruthy(); | ||
expect(layoutPanelFooterElementRef).toBeTruthy(); | ||
}); | ||
|
||
it('should have panel footer class', () => { | ||
expect(fixture.nativeElement.className).toBe('fd-layout-panel__footer'); | ||
it('should apply modifier class for footer content position start/left', () => { | ||
testComponent.position = 'start'; | ||
fixture.detectChanges(); | ||
expect( | ||
layoutPanelFooterElementRef.nativeElement.classList.contains('fd-layout-panel__footer--start') | ||
).toBeTrue(); | ||
}); | ||
|
||
it('should apply modifier class for footer content position end/right', () => { | ||
testComponent.position = 'end'; | ||
fixture.detectChanges(); | ||
expect(layoutPanelFooterElementRef.nativeElement.classList.contains('fd-layout-panel__footer--end')).toBeTrue(); | ||
}); | ||
}); |
60 changes: 44 additions & 16 deletions
60
libs/core/src/lib/layout-panel/layout-panel-footer/layout-panel-footer.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,52 @@ | ||
import { ChangeDetectionStrategy, Component, HostBinding, ViewEncapsulation } from '@angular/core'; | ||
|
||
/** | ||
* Layout Panel footer can be utilized for pagination, secondary actions, add more data, etc. | ||
* | ||
* ```html | ||
* <fd-layout-panel> | ||
* <fd-layout-panel-footer> | ||
* Some text can go here! | ||
* </fd-layout-panel-footer> | ||
* </fd-layout-panel> | ||
* ``` | ||
*/ | ||
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit, ViewEncapsulation } from '@angular/core'; | ||
import { applyCssClass } from '@fundamental-ngx/cdk/utils'; | ||
import { CssClassBuilder } from '@fundamental-ngx/cdk/utils'; | ||
import { Nullable } from '@fundamental-ngx/cdk/utils'; | ||
|
||
export type FooterPosition = 'start' | 'end'; | ||
|
||
@Component({ | ||
selector: 'fd-layout-panel-footer', | ||
templateUrl: './layout-panel-footer.component.html', | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class LayoutPanelFooterComponent { | ||
export class LayoutPanelFooterComponent implements OnInit, CssClassBuilder { | ||
/** Apply user custom styles */ | ||
@Input() | ||
class: string; | ||
|
||
/** | ||
* Footer variations, can be start (left aligned), end (right aligned) or null for default. | ||
* The default value will render the content of the footer in the middle. | ||
*/ | ||
@Input() position: Nullable<FooterPosition>; | ||
|
||
/** @hidden */ | ||
constructor(private readonly _elementRef: ElementRef<HTMLElement>) {} | ||
|
||
/** @hidden */ | ||
ngOnInit(): void { | ||
this.buildComponentCssClass(); | ||
} | ||
|
||
/** @hidden */ | ||
ngOnChanges(): void { | ||
this.buildComponentCssClass(); | ||
} | ||
|
||
/** @hidden */ | ||
@applyCssClass | ||
buildComponentCssClass(): string[] { | ||
return [ | ||
'fd-layout-panel__footer', | ||
this.position ? `fd-layout-panel__footer--${this.position}` : '', | ||
this.class | ||
]; | ||
} | ||
|
||
/** @hidden */ | ||
@HostBinding('class.fd-layout-panel__footer') | ||
fdLayoutPanelFooterClass = true; | ||
elementRef(): ElementRef<HTMLElement> { | ||
return this._elementRef; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
libs/docs/core/layout-panel/examples/layout-panel-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
libs/docs/core/layout-panel/examples/layout-panel-footer-variations-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<fd-layout-panel> | ||
<fd-layout-panel-header> | ||
<fd-layout-panel-head> | ||
<h5 fd-layout-panel-title>Layout Panel Title</h5> | ||
<fd-layout-panel-description>Layout Panel Description</fd-layout-panel-description> | ||
</fd-layout-panel-head> | ||
<fd-layout-panel-actions> Layout Panel Actions </fd-layout-panel-actions> | ||
</fd-layout-panel-header> | ||
<fd-layout-panel-filters> Layout Panel Filters </fd-layout-panel-filters> | ||
<fd-layout-panel-body> Layout Panel Body </fd-layout-panel-body> | ||
<fd-layout-panel-footer position="start"> Layout Panel Footer Start </fd-layout-panel-footer> | ||
</fd-layout-panel> | ||
<br /><br /> | ||
<fd-layout-panel> | ||
<fd-layout-panel-header> | ||
<fd-layout-panel-head> | ||
<h5 fd-layout-panel-title>Layout Panel Title</h5> | ||
<fd-layout-panel-description>Layout Panel Description</fd-layout-panel-description> | ||
</fd-layout-panel-head> | ||
<fd-layout-panel-actions> Layout Panel Actions </fd-layout-panel-actions> | ||
</fd-layout-panel-header> | ||
<fd-layout-panel-filters> Layout Panel Filters </fd-layout-panel-filters> | ||
<fd-layout-panel-body> Layout Panel Body </fd-layout-panel-body> | ||
<fd-layout-panel-footer position="end"> Layout Panel Footer End</fd-layout-panel-footer> | ||
</fd-layout-panel> |
7 changes: 7 additions & 0 deletions
7
libs/docs/core/layout-panel/examples/layout-panel-footer-variations-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'fd-layout-panel-footer-variations-example', | ||
templateUrl: './layout-panel-footer-variations-example.component.html' | ||
}) | ||
export class LayoutPanelFooterVariationsExampleComponent {} |
12 changes: 12 additions & 0 deletions
12
libs/docs/core/layout-panel/examples/layout-panel-transparent-example.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<fd-layout-panel [transparent]="true"> | ||
<fd-layout-panel-header> | ||
<fd-layout-panel-head> | ||
<h5 fd-layout-panel-title>Layout Panel Title</h5> | ||
<fd-layout-panel-description>Layout Panel Description</fd-layout-panel-description> | ||
</fd-layout-panel-head> | ||
<fd-layout-panel-actions> Layout Panel Actions </fd-layout-panel-actions> | ||
</fd-layout-panel-header> | ||
<fd-layout-panel-filters> Layout Panel Filters </fd-layout-panel-filters> | ||
<fd-layout-panel-body> Layout Panel Body </fd-layout-panel-body> | ||
<fd-layout-panel-footer> Layout Panel Footer </fd-layout-panel-footer> | ||
</fd-layout-panel> |
7 changes: 7 additions & 0 deletions
7
libs/docs/core/layout-panel/examples/layout-panel-transparent-example.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'fd-layout-panel-transparent-example', | ||
templateUrl: './layout-panel-transparent-example.component.html' | ||
}) | ||
export class LayoutPanelTransparentExampleComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters