Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add interactive mode for notification #6703

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {TuiNotificationT} from '@taiga-ui/core/types';
import {Observable} from 'rxjs';

@Component({
selector: 'tui-notification',
selector: 'tui-notification,a[tuiNotification],button[tuiNotification]',
templateUrl: './notification.template.html',
styleUrls: ['./notification.style.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
30 changes: 30 additions & 0 deletions projects/core/components/notification/notification.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,22 @@
box-sizing: border-box;
overflow: hidden;

.t-more {
display: none;
}

&button,
&a {
border: none;
cursor: pointer;

.t-more {
display: inline-flex;
color: var(--tui-text-01);
opacity: 0.5;
}
}

&[data-size='s'] {
padding: 0.375rem 0.625rem;

Expand All @@ -23,6 +39,10 @@
.t-close {
margin: -0.125rem -0.375rem -0.125rem 0.75rem;
}

.t-more {
margin: -0.125rem -0.375rem -0.125rem 0;
}
}

&[data-size='m'] {
Expand All @@ -37,6 +57,10 @@
.t-close {
margin: -0.125rem -0.125rem -0.125rem 1rem;
}

.t-more {
margin: -0.125rem -0.375rem -0.125rem 0;
}
}

&[data-size='l'] {
Expand All @@ -49,6 +73,10 @@
height: 1.5rem;
margin-right: 0.5rem;
}

.t-more {
margin-right: -0.5rem;
}
}

&[data-status='info'] {
Expand Down Expand Up @@ -81,4 +109,6 @@
flex: 1;
word-break: break-word;
color: var(--tui-text-01);
text-align: left;
align-self: center;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[src]="iconName"
></tui-svg>
</ng-container>

<div class="t-content">
<ng-content></ng-content>
</div>
Expand All @@ -22,3 +21,8 @@
[title]="closeWord$ | async"
(click)="close.emit()"
></button>
<tui-svg
automation-id="tui-notification__more"
class="t-more"
[src]="icons.more"
></tui-svg>
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
<tui-notification>
A short simple
<code>informative</code>
message
</tui-notification>
<tui-notification
status="success"
class="tui-space_vertical-4"
>
A short simple
<code>informative</code>
message
</tui-notification>
<tui-notification
status="error"
class="tui-space_vertical-4"
>
A short simple
<code>informative</code>
message
</tui-notification>
<tui-notification status="warning">
A short simple
<code>informative</code>
message
</tui-notification>
<ng-container *ngFor="let status of statuses; let last = last">
<tui-notification
*ngFor="let size of sizes"
[size]="size"
[status]="status"
>
{{ status | titlecase }} label ({{ size | uppercase }})
</tui-notification>

<hr />

<tui-notification
*ngFor="let size of sizes"
tuiNotification
[size]="size"
[status]="status"
>
{{ status | titlecase }} label ({{ size | uppercase }})
<tui-svg
src="tuiIconHelpCircle"
tuiHintAppearance="onDark"
tuiHintDirection="right"
[tuiHint]="tooltip"
></tui-svg>
<ng-template #tooltip>Hello world</ng-template>
</tui-notification>

<hr />

<button
*ngFor="let size of sizes"
tuiNotification
[size]="size"
[status]="status"
>
{{ status | titlecase }} label ({{ size | uppercase }})
</button>

<hr *ngIf="!last" />
</ng-container>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
:host {
display: flex;
flex-direction: column;
gap: 1rem;
}

tui-svg:last-child {
display: flex;
align-self: center;
width: 1rem;
height: 1rem;
margin: 0 0 0 0.75rem;
color: var(--tui-text-01);
opacity: 0.5;
float: right;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ 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,
TuiSvgModule,
} from '@taiga-ui/core';
import {TuiButtonModule} from '@taiga-ui/experimental';

import {TuiNotificationExample1} from './examples/1';
import {TuiNotificationExample2} from './examples/2';
Expand All @@ -26,6 +28,8 @@ import {ExampleTuiNotificationComponent} from './notification.component';
ReactiveFormsModule,
TuiAddonDocModule,
RouterModule.forChild(tuiGenerateRoutes(ExampleTuiNotificationComponent)),
TuiHintModule,
TuiSvgModule,
],
declarations: [
ExampleTuiNotificationComponent,
Expand Down
Loading