-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
) BREAKING CHANGE: `DaffBackdropModule` code has been moved into `DaffSidebarModule`. It can no longer be used as a standalone component in `@daffodil/design`
- Loading branch information
Showing
18 changed files
with
178 additions
and
222 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
2 changes: 2 additions & 0 deletions
2
libs/design/sidebar/src/sidebar-viewport-backdrop/animation/backdrop-animation-state.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,2 @@ | ||
export type DaffSidebarViewportBackdropAnimationState = 'interactable' | 'non-interactable'; | ||
export const getAnimationState = (interactable: boolean): DaffSidebarViewportBackdropAnimationState=> interactable ? 'interactable' : 'non-interactable'; |
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
144 changes: 144 additions & 0 deletions
144
.../design/sidebar/src/sidebar-viewport-backdrop/sidebar-viewport-backdrop.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,144 @@ | ||
import { | ||
Component, | ||
DebugElement, | ||
} from '@angular/core'; | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
import { NoopAnimationsModule } from '@angular/platform-browser/animations'; | ||
|
||
import { DaffSidebarViewportBackdropComponent } from './sidebar-viewport-backdrop.component'; | ||
|
||
@Component({ template: ` | ||
<daff-sidebar-viewport-backdrop | ||
[fullscreen]="fullscreen" | ||
[transparent]="transparent" | ||
(backdropClicked)="backdropFunction()"></daff-sidebar-viewport-backdrop> | ||
` }) | ||
class WrapperComponent { | ||
fullscreen = false; | ||
showValue = true; | ||
transparent = true; | ||
backdropFunction = () => {}; | ||
} | ||
|
||
describe('@daffodil/design/sidebar | DaffSidebarViewportBackdropComponent | Usage', () => { | ||
let wrapper: WrapperComponent; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let component: DaffSidebarViewportBackdropComponent; | ||
let de: DebugElement; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NoopAnimationsModule, | ||
], | ||
declarations: [ | ||
WrapperComponent, | ||
DaffSidebarViewportBackdropComponent, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
|
||
de = fixture.debugElement.query(By.css('daff-sidebar-viewport-backdrop')); | ||
component = de.componentInstance; | ||
}); | ||
|
||
it('should create', () => { | ||
expect(wrapper).toBeTruthy(); | ||
}); | ||
|
||
describe('the transparent property', () => { | ||
describe('when trasparent="false"', () => { | ||
it('should not add the class `transparent` to the host element', () => { | ||
wrapper.transparent = false; | ||
fixture.detectChanges(); | ||
|
||
expect(de.nativeElement.classList).not.toContain('transparent'); | ||
}); | ||
}); | ||
|
||
describe('when transparent="true"', () => { | ||
it('should add the class `transparent` to the host element', () => { | ||
wrapper.transparent = true; | ||
fixture.detectChanges(); | ||
|
||
expect(de.nativeElement.classList).toContain('transparent'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('the fullscreen property', () => { | ||
describe('when fullscreen="false"', () => { | ||
it('should not add the class `fullscreen` to the host element', () => { | ||
wrapper.fullscreen = false; | ||
fixture.detectChanges(); | ||
|
||
expect(de.nativeElement.classList).not.toContain('fullscreen'); | ||
}); | ||
}); | ||
|
||
describe('when fullscreen="true"', () => { | ||
it('should add the class `fullscreen` to the host element', () => { | ||
wrapper.fullscreen = true; | ||
fixture.detectChanges(); | ||
expect(de.nativeElement.classList).toContain('fullscreen'); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('when the backdrop host element is clicked', () => { | ||
it('should emit backdropClicked', () => { | ||
spyOn(component.backdropClicked, 'emit'); | ||
|
||
de.nativeElement.click(); | ||
|
||
expect(component.backdropClicked.emit).toHaveBeenCalledWith(); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
describe('@daffodil/design/sidebar | DaffSidebarViewportBackdropComponent | Defaults', () => { | ||
let fixture: ComponentFixture<DaffSidebarViewportBackdropComponent>; | ||
let component: DaffSidebarViewportBackdropComponent; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [ | ||
NoopAnimationsModule, | ||
], | ||
declarations: [ | ||
DaffSidebarViewportBackdropComponent, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(DaffSidebarViewportBackdropComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
|
||
it('should set transparent to `false` by default', () => { | ||
expect(component.transparent).toBe(false); | ||
}); | ||
|
||
it('should set fullscreen to `false` by default', () => { | ||
expect(component.fullscreen).toBe(false); | ||
}); | ||
}); |
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
5 changes: 2 additions & 3 deletions
5
libs/design/sidebar/src/sidebar-viewport/sidebar-viewport.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
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
Oops, something went wrong.