-
-
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.
Browse files
Browse the repository at this point in the history
BREAKING CHANGE: daffCompactableMixin has been removed in favor of DaffCompactableDirective. Update usage by using the hostDirective feature.
- Loading branch information
Showing
9 changed files
with
128 additions
and
119 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 was deleted.
Oops, something went wrong.
74 changes: 74 additions & 0 deletions
74
libs/design/src/core/compactable/compactable.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,74 @@ | ||
import { | ||
Component, | ||
DebugElement, | ||
} from '@angular/core'; | ||
import { | ||
waitForAsync, | ||
ComponentFixture, | ||
TestBed, | ||
} from '@angular/core/testing'; | ||
import { By } from '@angular/platform-browser'; | ||
|
||
import { DaffCompactableDirective } from './compactable.directive'; | ||
|
||
@Component({ | ||
template: ` | ||
<div daffCompactable [compact]="compact"></div>`, | ||
}) | ||
|
||
class WrapperComponent { | ||
compact: boolean; | ||
} | ||
|
||
describe('@daffodil/design | DaffCompactableDirective', () => { | ||
let wrapper: WrapperComponent; | ||
let de: DebugElement; | ||
let fixture: ComponentFixture<WrapperComponent>; | ||
let directive: DaffCompactableDirective; | ||
|
||
beforeEach(waitForAsync(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ | ||
WrapperComponent, | ||
], | ||
imports: [ | ||
DaffCompactableDirective, | ||
], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(WrapperComponent); | ||
wrapper = fixture.componentInstance; | ||
de = fixture.debugElement.query(By.css('[daffCompactable]')); | ||
|
||
directive = de.injector.get(DaffCompactableDirective); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(wrapper).toBeTruthy(); | ||
expect(directive).toBeTruthy(); | ||
}); | ||
|
||
it('should take compact as an input', () => { | ||
expect(directive.compact).toEqual(wrapper.compact); | ||
}); | ||
|
||
it('should add a class of .daff-compact to the host element if compact is set to true', () => { | ||
wrapper.compact = true; | ||
fixture.detectChanges(); | ||
|
||
expect(de.classes).toEqual(jasmine.objectContaining({ | ||
'daff-compact': true, | ||
})); | ||
}); | ||
|
||
it('should not add a class of .daff-compact to the host element if compact is set to false', () => { | ||
wrapper.compact = false; | ||
fixture.detectChanges(); | ||
|
||
expect(de.classes['daff-skeleton']).toBeUndefined(); | ||
}); | ||
}); |
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,32 @@ | ||
import { | ||
Directive, | ||
HostBinding, | ||
Input, | ||
} from '@angular/core'; | ||
|
||
/** | ||
* The `DaffCompactableDirective` allows a component to conditionally apply a compact | ||
* style by toggling a CSS class. This is useful for creating components that can | ||
* switch between regular and compact styles based on the `compact` property. | ||
* | ||
* ## Example | ||
* | ||
* ```html | ||
* <div daffCompactable [compact]="isCompact">Content goes here</div> | ||
* ``` | ||
* | ||
* In this example, the `daff-compact` class is applied to the `div` element when | ||
* `isCompact` is `true`, making the `div` display its compact state. | ||
* | ||
* ## Styles | ||
* | ||
* The `daff-compact` class should be defined in your styles to display the compact | ||
* state as desired. | ||
*/ | ||
@Directive({ | ||
selector: '[daffCompactable]', | ||
standalone: true, | ||
}) | ||
export class DaffCompactableDirective { | ||
@Input() @HostBinding('class.daff-compact') compact = 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { DaffCompactable } from './compactable'; | ||
export { daffCompactableMixin } from './compactable-mixin'; | ||
export { DaffCompactableDirective } from './compactable.directive'; |