-
-
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.
feat(design): change daffSkeletonMixin to a directive
- Loading branch information
Showing
11 changed files
with
116 additions
and
156 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { DaffSkeletonable } from './skeletonable'; | ||
export { daffSkeletonableMixin } from './skeletonable-mixin'; | ||
export { DaffSkeletonableDirective } from './skeletonable.directive'; |
This file was deleted.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
libs/design/src/core/skeletonable/skeletonable.directive.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,72 @@ | ||
import { | ||
Component, | ||
DebugElement, | ||
} from '@angular/core'; | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { DaffSkeletonableDirective } from './skeletonable.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<div daffSkeletonable | ||
[skeleton]="skeleton"> | ||
</div>`, | ||
}) | ||
|
||
class WrapperComponent { | ||
skeleton: boolean; | ||
} | ||
|
||
describe('@daffodil/design | DaffSkeletonableDirective', () => { | ||
let wrapper: WrapperComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let directive: DaffSkeletonableDirective; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
WrapperComponent, | ||
], | ||
imports: [ | ||
DaffSkeletonableDirective, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
de = fixture.debugElement.query(By.css('[daffSkeletonable]')); | ||
directive = de.injector.get(DaffSkeletonableDirective); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(wrapper).toBeTruthy(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
|
||
it('should take skeleton as an input', () => { | ||
expect(directive.skeleton).toEqual(wrapper.skeleton); | ||
}); | ||
|
||
it('should add a class of "daff-skeleton" to the host element when skeleton is true', () => { | ||
wrapper.skeleton = true; | ||
fixture.detectChanges(); | ||
|
||
expect(de.classes).toEqual(jasmine.objectContaining({ | ||
'daff-skeleton': true, | ||
})); | ||
}); | ||
|
||
it('should not add a class of "daff-skeleton" to the host element when skeleton is false', () => { | ||
expect(de.classes['daff-skeleton']).toBeUndefined(); | ||
}); | ||
}); |
14 changes: 14 additions & 0 deletions
14
libs/design/src/core/skeletonable/skeletonable.directive.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,14 @@ | ||
import { | ||
Directive, | ||
HostBinding, | ||
Input, | ||
} from '@angular/core'; | ||
|
||
@Directive({ | ||
selector: '[daffSkeletonable]', | ||
standalone: true, | ||
}) | ||
|
||
export class DaffSkeletonableDirective { | ||
@Input() @HostBinding('class.daff-skeleton') skeleton = false; | ||
} |
This file was deleted.
Oops, something went wrong.
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