From 9162566675fee0b57d69583132420fe923e41264 Mon Sep 17 00:00:00 2001 From: splincode Date: Wed, 7 Feb 2024 10:25:29 +0300 Subject: [PATCH] feat(core): add right icon into notification --- .../notification/notification.component.ts | 13 +++- .../notification/notification.style.less | 27 ++++++- .../notification/notification.template.html | 7 +- .../notification/examples/1/index.html | 75 ++++++++++++------- .../notification/examples/1/index.less | 5 ++ .../notification/examples/1/index.ts | 6 +- .../notification/notification.module.ts | 5 +- 7 files changed, 106 insertions(+), 32 deletions(-) create mode 100644 projects/demo/src/modules/components/notification/examples/1/index.less diff --git a/projects/core/components/notification/notification.component.ts b/projects/core/components/notification/notification.component.ts index 5eac40ebbbfd5..f2b13d4710fcd 100644 --- a/projects/core/components/notification/notification.component.ts +++ b/projects/core/components/notification/notification.component.ts @@ -16,10 +16,12 @@ import { TuiNotificationDefaultOptions, } from '@taiga-ui/core/tokens'; import {TuiNotificationT} from '@taiga-ui/core/types'; +import {PolymorpheusContent} from '@tinkoff/ng-polymorpheus'; import {Observable} from 'rxjs'; @Component({ - selector: 'tui-notification', + selector: + 'tui-notification,[tuiNotification],[tuiNotification][tuiNotificationChevron]', templateUrl: './notification.template.html', styleUrls: ['./notification.style.less'], changeDetection: ChangeDetectionStrategy.OnPush, @@ -31,6 +33,9 @@ export class TuiNotificationComponent { @Input() hasIcon = this.options.hasIcon; + /** + * @deprecated use {@link TuiNotificationComponent.leftIcon} + */ @Input() icon = this.options.icon; @@ -45,6 +50,12 @@ export class TuiNotificationComponent { @Input() hideClose = false; + @Input() + leftIcon = this.icon; + + @Input() + rightIcon: PolymorpheusContent = ''; + @Output() // eslint-disable-next-line @angular-eslint/no-output-native readonly close = new EventEmitter(); diff --git a/projects/core/components/notification/notification.style.less b/projects/core/components/notification/notification.style.less index e79b6855795b3..a3610b2573c28 100644 --- a/projects/core/components/notification/notification.style.less +++ b/projects/core/components/notification/notification.style.less @@ -11,6 +11,11 @@ box-sizing: border-box; overflow: hidden; + &button { + border: none; + cursor: pointer; + } + &[data-size='s'] { padding: 0.375rem 0.625rem; @@ -26,7 +31,8 @@ } &[data-size='m'] { - padding: 0.75rem; + padding: 0.75rem 1rem; + border-radius: 0.75rem; .t-icon { width: 1.25rem; @@ -42,7 +48,7 @@ &[data-size='l'] { padding: 1rem; font: var(--tui-font-text-m); - border-radius: var(--tui-radius-l); + border-radius: 1rem; .t-icon { width: 1.5rem; @@ -75,10 +81,27 @@ color: var(--tui-neutral-fill); background: linear-gradient(var(--tui-neutral-bg), var(--tui-neutral-bg)), var(--tui-base-01); } + + &[tuiNotificationChevron] { + &::ng-deep .t-content + tui-icon { + margin-right: -0.375rem; + } + } } .t-content { flex: 1; word-break: break-word; color: var(--tui-text-01); + text-align: left; + + &::ng-deep + tui-icon { + display: flex; + align-self: center; + width: 1rem; + height: 1rem; + margin-left: 0.75rem; + color: var(--tui-text-01); + opacity: 0.5; + } } diff --git a/projects/core/components/notification/notification.template.html b/projects/core/components/notification/notification.template.html index de5b9015fdde0..2cdc50c43cd25 100644 --- a/projects/core/components/notification/notification.template.html +++ b/projects/core/components/notification/notification.template.html @@ -11,7 +11,7 @@ + + + {{ text }} + + diff --git a/projects/demo/src/modules/components/notification/examples/1/index.html b/projects/demo/src/modules/components/notification/examples/1/index.html index be82e0bc68b8a..2e17ee4d0ba98 100644 --- a/projects/demo/src/modules/components/notification/examples/1/index.html +++ b/projects/demo/src/modules/components/notification/examples/1/index.html @@ -1,26 +1,49 @@ - - A short simple - informative - message - - - A short simple - informative - message - - - A short simple - informative - message - - - A short simple - informative - message - + + + {{ status | titlecase }} label ({{ size | uppercase }}) + + +
+ + + +
+ + + {{ status | titlecase }} label ({{ size | uppercase }}) + + + + + +
+
diff --git a/projects/demo/src/modules/components/notification/examples/1/index.less b/projects/demo/src/modules/components/notification/examples/1/index.less new file mode 100644 index 0000000000000..23d25a3bb0a19 --- /dev/null +++ b/projects/demo/src/modules/components/notification/examples/1/index.less @@ -0,0 +1,5 @@ +:host { + display: flex; + flex-direction: column; + gap: 1rem; +} diff --git a/projects/demo/src/modules/components/notification/examples/1/index.ts b/projects/demo/src/modules/components/notification/examples/1/index.ts index 43168567369c0..d2ab9728e088d 100644 --- a/projects/demo/src/modules/components/notification/examples/1/index.ts +++ b/projects/demo/src/modules/components/notification/examples/1/index.ts @@ -5,7 +5,11 @@ import {encapsulation} from '@demo/emulate/encapsulation'; @Component({ selector: 'tui-notification-example-1', templateUrl: './index.html', + styleUrls: ['./index.less'], encapsulation, changeDetection, }) -export class TuiNotificationExample1 {} +export class TuiNotificationExample1 { + readonly statuses = ['neutral', 'info', 'success', 'warning', 'error'] as const; + readonly sizes = ['s', 'm', 'l'] as const; +} diff --git a/projects/demo/src/modules/components/notification/notification.module.ts b/projects/demo/src/modules/components/notification/notification.module.ts index 9a72f53d8e97b..b62c63111d943 100644 --- a/projects/demo/src/modules/components/notification/notification.module.ts +++ b/projects/demo/src/modules/components/notification/notification.module.ts @@ -4,11 +4,12 @@ import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {RouterModule} from '@angular/router'; import {TuiAddonDocModule, tuiGenerateRoutes} from '@taiga-ui/addon-doc'; import { - TuiButtonModule, + TuiHintModule, TuiLinkModule, TuiModeModule, TuiNotificationModule, } from '@taiga-ui/core'; +import {TuiButtonModule, TuiIconModule} from '@taiga-ui/experimental'; import {TuiNotificationExample1} from './examples/1'; import {TuiNotificationExample2} from './examples/2'; @@ -26,6 +27,8 @@ import {ExampleTuiNotificationComponent} from './notification.component'; ReactiveFormsModule, TuiAddonDocModule, RouterModule.forChild(tuiGenerateRoutes(ExampleTuiNotificationComponent)), + TuiIconModule, + TuiHintModule, ], declarations: [ ExampleTuiNotificationComponent,