Skip to content

Commit

Permalink
feat(core): Dialog move close button inside dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy committed Nov 7, 2024
1 parent f8811cf commit 739ff25
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 28 deletions.
4 changes: 4 additions & 0 deletions projects/core/components/dialog/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export class TuiDialogComponent<O, I> {
: this.animation;
}

get mobile(): boolean {
return this.isMobile;
}

get fullscreen(): boolean {
return !this.isMobile && (this.size === 'fullscreen' || this.size === 'page');
}
Expand Down
18 changes: 10 additions & 8 deletions projects/core/components/dialog/dialog.style.less
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@

.t-heading {
margin: 0;
padding-inline-end: 2rem;
word-wrap: break-word;
font: var(--tui-font-heading-3);

Expand Down Expand Up @@ -151,26 +152,27 @@

.t-close {
.transition(background);
position: fixed;
top: 1.5rem;
right: 1.5rem;
position: absolute;
top: 1rem;
right: 1rem;

display: none;
color: var(--tui-base-01);
color: var(--tui-neutral-fill);

:host-context(.t-dialog:last-of-type) & {
display: block;
}

:host:not([data-size='fullscreen']):not([data-size='page']) & {
:host:not([data-size='page']) & {
animation: tuiFadeIn var(--tui-duration);
background: rgba(104, 104, 104, 0.96);
background: var(--tui-neutral-bg);

&:hover {
background: rgba(159, 159, 159, 0.86);
background: var(--tui-neutral-bg-hover);
}
}

:host:not([data-size='fullscreen']).ng-animating & {
:host.ng-animating & {
display: none;
}

Expand Down
57 changes: 43 additions & 14 deletions projects/core/components/dialog/dialog.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,50 @@
<div class="t-filler"></div>

<!-- Close button is insensitive to `context.closeable === Observable<false>` by design -->
<div
<button
*ngIf="context.closeable"
automation-id="tui-dialog__close"
shape="rounded"
size="s"
tuiIconButton
type="button"
class="t-close"
[appearance]="mobile ? 'icon' : ''"
[icon]="icons.close"
[title]="closeWord$ | async"
(click)="close$.next()"
(mousedown.prevent.silent)="(0)"
></button>

<!-- <button
automation-id="tui-dialog__close"
shape="rounded"
size="s"
tuiIconButton
type="button"
class="t-close"
[appearance]="fullscreen ? 'secondary' : ''"
[icon]="icons.close"
[title]="closeWord$ | async"
(click)="close$.next()"
(mousedown.prevent.silent)="(0)"
></button> -->

<!-- <div
*ngIf="context.closeable"
class="t-wrapper"
>
>
<button
automation-id="tui-dialog__close"
shape="rounded"
size="s"
tuiIconButton
type="button"
class="t-close"
[appearance]="fullscreen ? 'secondary' : ''"
[icon]="icons.close"
[title]="closeWord$ | async"
(click)="close$.next()"
(mousedown.prevent.silent)="(0)"
automation-id="tui-dialog__close"
shape="rounded"
size="s"
tuiIconButton
type="button"
class="t-close"
[appearance]="fullscreen ? 'secondary' : ''"
[icon]="icons.close"
[title]="closeWord$ | async"
(click)="close$.next()"
(mousedown.prevent.silent)="(0)"
></button>
</div>
</div> -->
14 changes: 8 additions & 6 deletions projects/demo/src/modules/components/dialog/examples/8/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ export class TuiDialogExampleComponent8 {
},
});

this.dialogs.open(content, {closeable, dismissible: closeable}).subscribe({
complete: () => {
this.value = '';
this.dialogForm.markAsPristine();
},
});
this.dialogs
.open(content, {label: 'Form', closeable, dismissible: closeable})
.subscribe({
complete: () => {
this.value = '';
this.dialogForm.markAsPristine();
},
});
}
}

0 comments on commit 739ff25

Please sign in to comment.