Skip to content
Open
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
6 changes: 3 additions & 3 deletions apps/code-examples/src/assets/stack-blitz/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ sky-toast {
}

.sky-theme-modern {
.sky-toaster-newest-on-top {
sky-toast:last-child {
.sky-toast {
margin-bottom: var(--sky-comp-omnibar-toaster-space-inset-bottom);
}
}
}

sky-toast {
.sky-toast-btn-close {
transition:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,22 @@ describe('Toaster component', () => {
validateToastMessage(toasts[0], 'Message 1');
validateToastMessage(toasts[1], 'Message 2');
}));

it('should add sky-toaster-newest-on-top class to host when displayDirection is NewestOnTop', fakeAsync(() => {
options.displayDirection = SkyToastDisplayDirection.NewestOnTop;

openMessage();

const toaster = document.querySelector('sky-toaster');
expect(toaster).toHaveCssClass('sky-toaster-newest-on-top');
}));

it('should not add sky-toaster-newest-on-top class to host when displayDirection is OldestOnTop', fakeAsync(() => {
options.displayDirection = SkyToastDisplayDirection.OldestOnTop;

openMessage();

const toaster = document.querySelector('sky-toaster');
expect(toaster).not.toHaveCssClass('sky-toaster-newest-on-top');
}));
});
10 changes: 10 additions & 0 deletions libs/components/toast/src/lib/modules/toast/toaster.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ViewContainerRef,
ViewEncapsulation,
inject,
signal,
} from '@angular/core';
import { SKY_STACKING_CONTEXT, SkyDynamicComponentService } from '@skyux/core';

Expand Down Expand Up @@ -41,6 +42,9 @@ import { SkyToastDisplayDirection } from './types/toast-display-direction';
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
imports: [CommonModule, SkyToastComponent, SkyToastResourcesModule],
host: {
'[class.sky-toaster-newest-on-top]': 'isNewestOnTop()',
},
})
export class SkyToasterComponent implements AfterViewInit, OnDestroy {
public toastsForDisplay: SkyToast[] | undefined;
Expand All @@ -62,6 +66,12 @@ export class SkyToasterComponent implements AfterViewInit, OnDestroy {
readonly #containerOptions = inject(SkyToastContainerOptions, {
optional: true,
});

protected isNewestOnTop = signal(
this.#containerOptions?.displayDirection ===
SkyToastDisplayDirection.NewestOnTop,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to whoever picks up this story next: This needs to be a computed signal so that the spacing changes if consumers change direction

);

readonly #dynamicComponentSvc = inject(SkyDynamicComponentService);
readonly #domAdapter = inject(SkyToastAdapterService);
readonly #environmentInjector = inject(EnvironmentInjector);
Expand Down
Loading