Skip to content

Commit e968ee3

Browse files
committed
Merge branch 'master' of https://github.com/IgniteUI/igniteui-angular into pbozhinov/row-pinning-tree-grid
2 parents df234ef + 494e6e2 commit e968ee3

File tree

9 files changed

+466
-513
lines changed

9 files changed

+466
-513
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ All notable changes for each version of this project will be documented in this
4646
- `IgxCombo`:
4747
- Added `autoFocusSearch` input that allows to manipulate the combo's opening behavior. When the property is `true` (by default), the combo's search input is focused on open. When set to `false`, the focus goes to the combo items container, which can be used to prevent the software keyboard from activating on mobile devices when opening the combo.
4848

49+
- `IgxToast`:
50+
- Added functionality for displaying various content into the toast component. It also allows users to access toast styles through its host element.
51+
4952
### RTL Support
5053
- `igxSlider` have full right-to-left (RTL) support.
5154

projects/igniteui-angular/src/lib/core/styles/components/toast/_toast-theme.scss

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121

122122
%igx-toast--top {
123123
top: 0;
124+
margin-top: 16px;
124125
}
125126

126127
%igx-toast--middle {
@@ -130,6 +131,7 @@
130131

131132
%igx-toast--bottom {
132133
bottom: 0;
134+
margin-bottom: 16px;
133135
}
134136
}
135137

@@ -143,7 +145,7 @@
143145
@mixin igx-toast-typography($type-scale, $categories: (text: 'body-2')) {
144146
$text: map-get($categories, 'text');
145147

146-
%igx-toast-display {
148+
%igx-toast-display > *{
147149
@include igx-type-style($type-scale, $text) {
148150
margin: 0;
149151
}

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.navigation.spec.ts

+356-420
Large diffs are not rendered by default.

projects/igniteui-angular/src/lib/toast/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ You can show hide toast by using `toast.hide()` method.
3636

3737
You can modify the position of the toast by setting `postion="IgxToastPosition.Top"`.
3838

39+
## Toast with different content
40+
41+
```html
42+
<igx-toast #toast [position]="toastPosition">
43+
<igx-icon>notifications</igx-icon>
44+
This message will self-destruct in 4 seconds.
45+
</igx-toast>
46+
```
47+
48+
You can display various content by placing it between the igx-toast tags. If so, the message property will be overwritten.
49+
3950
## Toast with events
4051

4152
```html
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
<div [ngClass]="mapPositionToClassName()" *ngIf="this.isVisible" [@animate]="'show'">
2-
{{ message }}
1+
<div #content>
2+
<ng-content></ng-content>
33
</div>
4+
<span *ngIf="content.childNodes.length == 0">{{ message }}</span>
5+
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import {Component, ViewChild} from '@angular/core';
2-
import {async, TestBed, fakeAsync, tick} from '@angular/core/testing';
1+
import {Component, ViewChild } from '@angular/core';
2+
import {async, TestBed, fakeAsync, tick, ComponentFixture} from '@angular/core/testing';
33
import {By} from '@angular/platform-browser';
44
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
55
import {IgxToastComponent, IgxToastModule, IgxToastPosition} from './toast.component';
6-
76
import { configureTestSuite } from '../test-utils/configure-suite';
8-
import { wait } from '../test-utils/ui-interactions.spec';
97

108
describe('IgxToast', () => {
119
configureTestSuite();
@@ -20,24 +18,32 @@ describe('IgxToast', () => {
2018
]
2119
}).compileComponents();
2220
}));
23-
let fixture, toast, element;
21+
22+
const baseClass = 'igx-toast';
23+
const classes = {
24+
top: `${baseClass}--top`,
25+
middle: `${baseClass}--middle`,
26+
bottom: `${baseClass}--bottom`,
27+
};
28+
29+
let fixture: ComponentFixture<ToastInitializeTestComponent>;
30+
let toast: IgxToastComponent;
31+
2432
beforeEach(() => {
2533
fixture = TestBed.createComponent(ToastInitializeTestComponent);
2634
toast = fixture.componentInstance.toast;
2735
toast.isVisible = true;
2836
fixture.detectChanges();
29-
element = fixture.debugElement.query(By.css('.igx-toast--bottom'));
3037
});
3138

32-
it('should properly initialize properties', () => {
33-
const domToast = fixture.debugElement.query(By.css('igx-toast')).nativeElement;
39+
it('should properly initialize', () => {
40+
const domToast = fixture.debugElement.query(By.css(baseClass)).nativeElement;
3441
expect(toast.id).toContain('igx-toast-');
3542
expect(domToast.id).toContain('igx-toast-');
36-
expect(toast.message).toBeUndefined();
3743
expect(toast.displayTime).toBe(4000);
3844
expect(toast.autoHide).toBeTruthy();
3945
expect(toast.isVisible).toBeTruthy();
40-
expect(element.classes[toast.CSS_CLASSES.IGX_TOAST_BOTTOM]).toBeTruthy();
46+
expect(domToast.classList).toContain(classes.bottom);
4147

4248
toast.id = 'customToast';
4349
fixture.detectChanges();
@@ -49,92 +55,91 @@ describe('IgxToast', () => {
4955
it('should change toast position to middle', () => {
5056
toast.position = IgxToastPosition.Middle;
5157
fixture.detectChanges();
58+
const domToast = fixture.debugElement.query(By.css(baseClass)).nativeElement;
5259

53-
element = fixture.debugElement.query(By.css('.igx-toast--middle'));
54-
expect(element.classes[toast.CSS_CLASSES.IGX_TOAST_MIDDLE]).toBeTruthy();
60+
expect(domToast.classList).toContain(classes.middle);
5561
});
5662

5763
it('should change toast position to top', () => {
5864
toast.position = IgxToastPosition.Top;
5965
fixture.detectChanges();
66+
const domToast = fixture.debugElement.query(By.css(baseClass)).nativeElement;
6067

61-
element = fixture.debugElement.query(By.css('.igx-toast--top'));
62-
expect(element.classes[toast.CSS_CLASSES.IGX_TOAST_TOP]).toBeTruthy();
68+
expect(domToast.classList).toContain(classes.top);
6369
});
6470

65-
it('should change toast position to bottom, the rest should be undefined', () => {
71+
it('should change toast position to bottom', () => {
6672
toast.position = IgxToastPosition.Bottom;
6773
fixture.detectChanges();
74+
const domToast = fixture.debugElement.query(By.css(baseClass)).nativeElement;
6875

69-
expect(element.classes[toast.CSS_CLASSES.IGX_TOAST_TOP]).toBeUndefined();
70-
expect(element.classes[toast.CSS_CLASSES.IGX_TOAST_MIDDLE]).toBeUndefined();
71-
expect(element.classes[toast.CSS_CLASSES.IGX_TOAST_BOTTOM]).toBe(true);
76+
expect(domToast.classList).not.toContain(classes.top);
77+
expect(domToast.classList).not.toContain(classes.middle);
78+
expect(domToast.classList).toContain(classes.bottom);
7279
});
7380

74-
it('should auto hide 1 second after is open', fakeAsync(() => {
81+
it('should auto hide 1 second after it\'s open', fakeAsync(() => {
7582
toast.displayTime = 1000;
7683

7784
toast.show();
7885

7986
expect(toast.isVisible).toBeTruthy();
87+
expect(toast.animationState).toBe('visible');
8088
expect(toast.autoHide).toBeTruthy();
8189

8290
tick(1000);
83-
fixture.detectChanges();
91+
8492
expect(toast.isVisible).toBeFalsy();
93+
expect(toast.animationState).toBe('invisible');
8594
}));
8695

87-
it('should not auto hide seconds after is open', fakeAsync(() => {
96+
it('should not auto hide after it\'s open', fakeAsync(() => {
8897
toast.displayTime = 1000;
8998
toast.autoHide = false;
9099

91100
toast.show();
92101

93102
expect(toast.isVisible).toBeTruthy();
103+
expect(toast.animationState).toBe('visible');
94104
expect(toast.autoHide).toBeFalsy();
95105

96106
tick(1000);
97-
fixture.detectChanges();
107+
98108
expect(toast.isVisible).toBeTruthy();
109+
expect(toast.animationState).toBe('visible');
99110
}));
100111

101-
it('visibility is properly toggled by its toggle() method.', (async() => {
112+
it('visibility is updated by the toggle() method', () => {
102113
spyOn(toast.onShowing, 'emit');
103114
spyOn(toast.onShown, 'emit');
104115
spyOn(toast.onHiding, 'emit');
105116
spyOn(toast.onHidden, 'emit');
106117

118+
toast.show();
107119
expect(toast.isVisible).toBe(true);
108-
toast.toggle();
109-
await wait();
110-
fixture.detectChanges();
120+
expect(toast.animationState).toBe('visible');
111121

112-
expect(toast.isVisible).toBe(false);
113-
expect(toast.onShowing.emit).toHaveBeenCalledTimes(0);
114-
expect(toast.onShown.emit).toHaveBeenCalledTimes(0);
115-
expect(toast.onHiding.emit).toHaveBeenCalledTimes(1);
116-
expect(toast.onHidden.emit).toHaveBeenCalledTimes(1);
122+
expect(toast.onShowing.emit).toHaveBeenCalledTimes(1);
123+
expect(toast.onShown.emit).toHaveBeenCalledTimes(1);
124+
expect(toast.onHiding.emit).toHaveBeenCalledTimes(0);
125+
expect(toast.onHidden.emit).toHaveBeenCalledTimes(0);
117126

118127
toast.toggle();
119-
await wait();
120-
fixture.detectChanges();
128+
expect(toast.isVisible).toBe(false);
129+
expect(toast.animationState).toBe('invisible');
121130

122-
expect(toast.isVisible).toBe(true);
123131
expect(toast.onShowing.emit).toHaveBeenCalledTimes(1);
124132
expect(toast.onShown.emit).toHaveBeenCalledTimes(1);
125133
expect(toast.onHiding.emit).toHaveBeenCalledTimes(1);
126134
expect(toast.onHidden.emit).toHaveBeenCalledTimes(1);
127135

128-
toast.toggle();
129-
await wait();
130-
fixture.detectChanges();
131-
expect(toast.isVisible).toBe(false);
132-
}));
136+
});
133137
});
138+
134139
@Component({
135-
template: `<igx-toast #toast>
136-
</igx-toast>`
140+
template: `<igx-toast #toast></igx-toast>`
137141
})
138142
class ToastInitializeTestComponent {
139-
@ViewChild(IgxToastComponent, { static: true }) public toast: IgxToastComponent;
143+
@ViewChild(IgxToastComponent, { static: true })
144+
public toast: IgxToastComponent;
140145
}

0 commit comments

Comments
 (0)