-
-
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 daffManageContainerLayoutMixin to a directive
BREAKING CHANGE: daffManageContainerLayoutMixin has been removed in favor of DaffManageContainerLayoutDirective. Update usage by using the hostDirective feature.
- Loading branch information
1 parent
b00d1e1
commit 8da0adf
Showing
8 changed files
with
110 additions
and
74 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
26 changes: 0 additions & 26 deletions
26
libs/design/src/core/manage-container-layout/manage-container-layout-mixin.ts
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
libs/design/src/core/manage-container-layout/manage-container-layout.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,57 @@ | ||
import { | ||
Component, | ||
DebugElement, | ||
} from '@angular/core'; | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { DaffManageContainerLayoutDirective } from './manage-container-layout.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<div daffManageContainerLayout></div>`, | ||
}) | ||
|
||
class WrapperComponent {} | ||
|
||
describe('@daffodil/design | DaffManageContainerLayoutDirective', () => { | ||
let wrapper: WrapperComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let directive: DaffManageContainerLayoutDirective; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
WrapperComponent, | ||
], | ||
imports: [ | ||
DaffManageContainerLayoutDirective, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
de = fixture.debugElement.query(By.css('[daffManageContainerLayout]')); | ||
directive = de.injector.get(DaffManageContainerLayoutDirective); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(wrapper).toBeTruthy(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
|
||
it('should add a class of "daff-manage-container-layout" to the host element', () => { | ||
expect(de.classes).toEqual(jasmine.objectContaining({ | ||
'daff-manage-container-layout': true, | ||
})); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
libs/design/src/core/manage-container-layout/manage-container-layout.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,35 @@ | ||
import { | ||
Directive, | ||
HostBinding, | ||
} from '@angular/core'; | ||
|
||
/** | ||
* A directive that gives a component the ability to manage a DaffContainerComponent's layout. | ||
* By including this directive, predetermined layout styles are passed down to the container. | ||
* | ||
* To understand the motivation for this directive, consider: | ||
* | ||
* ```html | ||
* <daff-container> | ||
* <daff-hero></daff-hero> | ||
* </daff-container> | ||
* ``` | ||
* vs. | ||
* | ||
* ```html | ||
* <daff-hero> | ||
* <daff-container></daff-container> | ||
* </daff-hero> | ||
* ``` | ||
* | ||
* The former may inappropriately constrain the width of its child elements, | ||
* while the latter (without `DaffManageContainerLayoutDirective`) may unexpectedly | ||
* interfere in the layout features of its parent element (i.e. display: grid, display: flex). | ||
*/ | ||
@Directive({ | ||
selector: '[daffManageContainerLayout]', | ||
standalone: true, | ||
}) | ||
export class DaffManageContainerLayoutDirective { | ||
@HostBinding('class.daff-manage-container-layout') class = true; | ||
} |
35 changes: 0 additions & 35 deletions
35
libs/design/src/core/manage-container-layout/manage-container-layout.spec.ts
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export { daffManageContainerLayoutMixin } from './manage-container-layout-mixin'; | ||
export { DaffManageContainerLayoutDirective } from './manage-container-layout.directive'; |