-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from criar-art/custom-footer
Implement Custom Footer for `up-window-angular` Component
- Loading branch information
Showing
7 changed files
with
177 additions
and
20 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
69 changes: 69 additions & 0 deletions
69
projects/up-window-angular/src/lib/up-window-angular.custom-footer.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,69 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { UpWindowAngularComponent } from './up-window-angular.component'; | ||
import { By } from '@angular/platform-browser'; | ||
import { Component, signal, WritableSignal } from '@angular/core'; | ||
|
||
@Component({ | ||
template: ` | ||
<up-window-angular | ||
[isOpen]="isWindowOpenFooter" | ||
title="Test Window" | ||
subtitle="Test Subtitle" | ||
> | ||
<div footer> | ||
<p class="custom-footer">Custom Footer Content</p> | ||
<button | ||
class="custom-btn close" | ||
(click)="isWindowOpenFooter.set(false)" | ||
> | ||
Close | ||
</button> | ||
</div> | ||
</up-window-angular> | ||
`, | ||
}) | ||
class HostComponentWithCustomFooter { | ||
isWindowOpenFooter: WritableSignal<boolean> = signal(true); | ||
} | ||
|
||
describe('UpWindowAngularComponent HostComponentWithCustomFooter', () => { | ||
let fixture: ComponentFixture<HostComponentWithCustomFooter>; | ||
let component: HostComponentWithCustomFooter; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [UpWindowAngularComponent, HostComponentWithCustomFooter], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(HostComponentWithCustomFooter); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should not render default footer buttons when custom footer is provided', () => { | ||
const confirmButton = fixture.debugElement.query(By.css('.btn-confirm')); | ||
const cancelButton = fixture.debugElement.query(By.css('.btn-cancel')); | ||
|
||
expect(confirmButton).toBeNull(); | ||
expect(cancelButton).toBeNull(); | ||
}); | ||
|
||
it('should render custom footer content when ng-content is used', () => { | ||
fixture.detectChanges(); | ||
|
||
const footerTemplate = fixture.debugElement.query( | ||
By.css('.up-window-footer') | ||
); | ||
expect(footerTemplate).toBeTruthy(); | ||
|
||
const projectedFooter = footerTemplate.query(By.css('.custom-footer')); | ||
console.log('projectedFooter', projectedFooter); | ||
|
||
expect(projectedFooter).toBeTruthy(); | ||
expect(projectedFooter.nativeElement.textContent).toContain( | ||
'Custom Footer 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
</div> | ||
<examples-animation /> | ||
<examples-mode /> | ||
<examples-actions /> | ||
</main> | ||
<app-footer></app-footer> | ||
</div> |
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,34 @@ | ||
<p>actions works!</p> | ||
<div class="content"> | ||
<h2 class="content-title">Actions</h2> | ||
<div class="examples"> | ||
<button | ||
class="button-modal-example" | ||
type="button" | ||
(click)="openWindowExample('footer')" | ||
> | ||
<span class="material-symbols-outlined">  </span> Custom Footer | ||
</button> | ||
|
||
<up-window-angular | ||
[isOpen]="isWindowOpenFooter" | ||
title="Custom Footer Example" | ||
subtitle="Choose an action below" | ||
buttonAlignment="start" | ||
> | ||
<p> | ||
This window features a custom footer that provides tailored actions for | ||
your convenience. You can use the buttons below to either close the | ||
window or perform the designated action as per your requirement. | ||
</p> | ||
<div footer> | ||
<button class="custom-btn close" (click)="isWindowOpenFooter.set(false)"> | ||
Close | ||
</button> | ||
<button class="custom-btn confirm" (click)="isWindowOpenFooter.set(false)"> | ||
Perform Action | ||
</button> | ||
<span>Custom footer example text.</span> | ||
</div> | ||
</up-window-angular> | ||
</div> | ||
</div> |
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,34 @@ | ||
$close-color: #dc3545; | ||
$close-hover-color: #c82333; | ||
$confirm-color: #007bff; | ||
$confirm-hover-color: #0056b3; | ||
|
||
.custom-btn { | ||
padding: 8px 12px; | ||
margin: 5px; | ||
cursor: pointer; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
transition: background-color 0.3s; | ||
|
||
&.close { | ||
background-color: $close-color; | ||
|
||
&:hover { | ||
background-color: $close-hover-color; | ||
} | ||
} | ||
|
||
&.confirm { | ||
background-color: $confirm-color; | ||
|
||
&:hover { | ||
background-color: $confirm-hover-color; | ||
} | ||
} | ||
|
||
&:hover { | ||
opacity: 0.9; | ||
} | ||
} |
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,12 +1,22 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, signal, WritableSignal } from '@angular/core'; | ||
import { UpWindowAngularModule } from '../../../../projects/up-window-angular/src/public-api'; | ||
|
||
@Component({ | ||
selector: 'examples-actions', | ||
standalone: true, | ||
imports: [], | ||
imports: [UpWindowAngularModule], | ||
templateUrl: './actions.component.html', | ||
styleUrl: './actions.component.scss' | ||
}) | ||
export class ActionsComponent { | ||
isWindowOpenFooter: WritableSignal<boolean> = signal(false); | ||
|
||
openWindowExample(type: string) { | ||
this.isWindowOpenFooter.set(false); | ||
switch (type) { | ||
case 'footer': | ||
this.isWindowOpenFooter.set(true); | ||
break; | ||
} | ||
} | ||
} |