Skip to content

Commit

Permalink
feat(core): Dialog move close button inside dialog (#9712)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdlufy authored Nov 7, 2024
2 parents f8811cf + 4cb002c commit 446e2ea
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 35 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
22 changes: 11 additions & 11 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,33 +152,32 @@

.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;
}

:host-context(tui-root._mobile) & {
position: absolute;
top: 0;
right: 0;
background: transparent !important;
color: var(--tui-text-01);
opacity: 0.5;
Expand Down
30 changes: 13 additions & 17 deletions projects/core/components/dialog/dialog.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,17 @@
<div class="t-filler"></div>

<!-- Close button is insensitive to `context.closeable === Observable<false>` by design -->
<div
<button
*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)"
></button>
</div>
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>
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class ExampleTuiDialogComponent {

size: TuiDialogSize = this.sizeVariants[1];

label = '';
label = 'Form';

appearance = '';

Expand Down
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 446e2ea

Please sign in to comment.