-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(template): footer support custom (#222)
- Loading branch information
1 parent
a700170
commit 652a8b1
Showing
15 changed files
with
94 additions
and
17 deletions.
There are no files selected for viewing
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
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
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 +1 @@ | ||
Copyright © 2020-present Powered by PingCode<br /> | ||
<ng-content></ng-content> |
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
45 changes: 45 additions & 0 deletions
45
packages/template/src/shared/footer/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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { createComponentFactory, Spectator } from '@ngneat/spectator'; | ||
import { GlobalContext } from '../../services/global-context'; | ||
import { FooterComponent } from './footer.component'; | ||
|
||
describe('#footer', () => { | ||
let spectator: Spectator<FooterComponent>; | ||
const createComponent = createComponentFactory({ | ||
component: FooterComponent, | ||
providers: [ | ||
{ | ||
provide: GlobalContext, | ||
useValue: { | ||
config: { | ||
footer: 'My Footer Content' | ||
} | ||
} | ||
} | ||
] | ||
}); | ||
|
||
it('should get correct footer', () => { | ||
spectator = createComponent(); | ||
expect(spectator.element.classList.contains('dg-footer')).toBeTruthy(); | ||
expect(spectator.element.classList.contains('dg-hidden')).toBeFalsy(); | ||
expect(spectator.element.textContent).toContain('My Footer Content'); | ||
}); | ||
|
||
it('should hidden footer when footer is empty', () => { | ||
spectator = createComponent({ | ||
providers: [ | ||
{ | ||
provide: GlobalContext, | ||
useValue: { | ||
config: { | ||
footer: undefined | ||
} | ||
} | ||
} | ||
] | ||
}); | ||
expect(spectator.element.classList.contains('dg-footer')).toBeTruthy(); | ||
expect(spectator.element.classList.contains('dg-hidden')).toBeTruthy(); | ||
expect(spectator.element.textContent).toBeFalsy(); | ||
}); | ||
}); |
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,13 +1,24 @@ | ||
import { Component, OnInit, HostBinding } from '@angular/core'; | ||
import { Component, OnInit, HostBinding, ElementRef } from '@angular/core'; | ||
import { GlobalContext } from '../../services/global-context'; | ||
|
||
@Component({ | ||
selector: 'dg-footer', | ||
templateUrl: './footer.component.html' | ||
templateUrl: './footer.component.html', | ||
host: { | ||
class: 'dg-footer' | ||
} | ||
}) | ||
export class FooterComponent implements OnInit { | ||
@HostBinding(`class.dg-footer`) isFooter = true; | ||
@HostBinding(`class.dg-hidden`) isHide = true; | ||
|
||
constructor() {} | ||
constructor(private global: GlobalContext, private elementRef: ElementRef) {} | ||
|
||
ngOnInit(): void {} | ||
ngOnInit(): void { | ||
if (this.global.config.footer) { | ||
this.elementRef.nativeElement.innerHTML = this.global.config.footer; | ||
this.isHide = false; | ||
} else { | ||
this.isHide = true; | ||
} | ||
} | ||
} |
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