Skip to content

Commit ecbed4f

Browse files
sergiubologavladjerca
authored andcommitted
feat(snackbar): create ui-snackbar component
add snackbar to commit scope list add forgotten theme tests and some updates unit tests
1 parent 9836b50 commit ecbed4f

20 files changed

+703
-0
lines changed

commitlint.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module.exports = {
1515
'scroll-into-view',
1616
'virtual-scroll-range-loader',
1717
'virtual-scroll-viewport-resize',
18+
'snackbar',
19+
'pipes',
1820
];
1921

2022
return [2, 'always', scopeList];
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
@import "./components/ui-suggest/src/ui-suggest.theme";
22
@import "./components/ui-grid/src/ui-grid.theme";
3+
@import "./components/ui-snackbar/src/ui-snackbar.theme";
34

45
@mixin uipath-angular-theme($theme) {
56
@include ui-suggest-theme($theme);
67
@include ui-grid-theme($theme);
78
}
9+
10+
@mixin uipath-snackbar-theme($theme, $snackbar-theme: null) {
11+
@include ui-snackbar-theme($theme, $snackbar-theme);
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ngPackage": {}
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
$light-gray: rgb(234, 238, 240);
2+
$dark-gray: rgb(51, 51, 51);
3+
$red: rgb(207,41,41);
4+
$dark-orange: rgb(255, 99, 37);
5+
$green: rgb(124, 199, 108);
6+
7+
$default-success: ('text': $light-gray, 'background': mix($green, $dark-gray, 80));
8+
$default-warning: ('text': $light-gray, 'background': mix($dark-orange, $dark-gray, 80));
9+
$default-error: ('text': $light-gray, 'background': mix($red, $dark-gray, 80));
10+
$default-info: ('text': null, 'background': null);
11+
$default-snackbar-theme: ('success': $default-success, 'warning': $default-warning, 'error': $default-error, 'info': $default-info);
12+
13+
@mixin ui-snackbar-theme($theme, $snackbar-theme) {
14+
@if $snackbar-theme == null {
15+
$snackbar-theme: $default-snackbar-theme;
16+
}
17+
18+
$success: map-get($snackbar-theme, 'success');
19+
$warning: map-get($snackbar-theme, 'warning');
20+
$error: map-get($snackbar-theme, 'error');
21+
$info: map-get($snackbar-theme, 'info');
22+
23+
$success-text-color: map-get($success, 'text');
24+
$success-background-color: map-get($success, 'background');
25+
$warning-text-color: map-get($warning, 'text');
26+
$warning-background-color: map-get($warning, 'background');
27+
$error-text-color: map-get($error, 'text');
28+
$error-background-color: map-get($error, 'background');
29+
$info-text-color: map-get($info, 'text');
30+
$info-background-color: map-get($info, 'background');
31+
32+
.ui-snackbar {
33+
&-success,
34+
&-warning,
35+
&-error,
36+
&-info {
37+
mat-icon {
38+
color: inherit;
39+
}
40+
}
41+
42+
&-success {
43+
color: $success-text-color;
44+
background-color: $success-background-color;
45+
}
46+
47+
&-warning {
48+
color: $warning-text-color;
49+
background-color: $warning-background-color;
50+
}
51+
52+
&-error {
53+
color: $error-text-color;
54+
background-color: $error-background-color;
55+
}
56+
57+
&-info {
58+
color: $info-text-color;
59+
background-color: $info-background-color;
60+
}
61+
62+
&-dismiss {
63+
.mat-icon-button:hover {
64+
color: inherit !important;
65+
}
66+
}
67+
}
68+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './ui-snackbar.component';
2+
export { UiSnackBarModule } from './ui-snackbar.module';
3+
export { UiSnackbarIntlService } from './ui-snackbar-intl.service';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { TestBed } from '@angular/core/testing';
2+
3+
import { UiSnackbarIntlService } from './ui-snackbar-intl.service';
4+
5+
describe('Service: UiSnackbarIntlService', () => {
6+
beforeEach(() => TestBed.configureTestingModule({
7+
providers: [UiSnackbarIntlService],
8+
}));
9+
10+
it('should create', () => {
11+
const service: UiSnackbarIntlService = TestBed.get(UiSnackbarIntlService);
12+
expect(service).toBeTruthy();
13+
expect(service.closeAriaLabel).toEqual('Close');
14+
});
15+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {
2+
Injectable,
3+
OnDestroy,
4+
} from '@angular/core';
5+
6+
import { Subject } from 'rxjs';
7+
8+
@Injectable()
9+
export class UiSnackbarIntlService implements OnDestroy {
10+
public closeAriaLabel = 'Close';
11+
protected _destroyed$ = new Subject<void>();
12+
13+
ngOnDestroy() {
14+
this._destroyed$.next();
15+
this._destroyed$.complete();
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="ui-snackbar-container">
2+
<div class="ui-snackbar-message">
3+
<mat-icon *ngIf="data.icon">{{data.icon}}</mat-icon>
4+
<span [innerHTML]="data.message | nl2br"></span>
5+
</div>
6+
<div class="ui-snackbar-dismiss">
7+
<button [attr.aria-label]="data.closeAriaLabel"
8+
(click)="snackBarRef.dismiss()"
9+
mat-icon-button>
10+
<mat-icon>close</mat-icon>
11+
</button>
12+
</div>
13+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.ui-snackbar {
2+
&-container {
3+
display: flex;
4+
justify-content: space-between;
5+
}
6+
7+
&-message,
8+
&-dismiss {
9+
display: flex;
10+
align-items: center;
11+
}
12+
13+
&-message {
14+
mat-icon {
15+
margin-right: 10px;
16+
}
17+
span {
18+
overflow-y: auto;
19+
max-height: calc(100vh - 80px);
20+
font-size: 14.5px;
21+
line-height: 1.35em;
22+
word-break: break-word;
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)