From 131b7317fa7f181abbf415c9e844abe05e080ce6 Mon Sep 17 00:00:00 2001 From: Michael Liendo Date: Tue, 9 May 2023 13:04:31 -0400 Subject: [PATCH 1/2] feat: custom clases for the notification list component --- src/index.test.ts | 9 +++++++++ src/lib/components/NotificationList.svelte | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/index.test.ts b/src/index.test.ts index 1084bf1..4c2aead 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -51,3 +51,12 @@ describe('getPositionClasses', () => { expect(getPositionClasses(Position.BottomLeft)).toBe('bottom-6 left-6'); }); }); + +describe('Custom Classes', () => { + it('renders correctly with custom class', () => { + const { container } = render(NotificationList, { + class: 'custom-class' + }); + expect(container.querySelector('.custom-class')).not.toBeNull(); + }); +}); diff --git a/src/lib/components/NotificationList.svelte b/src/lib/components/NotificationList.svelte index cf79602..34fc9af 100644 --- a/src/lib/components/NotificationList.svelte +++ b/src/lib/components/NotificationList.svelte @@ -31,6 +31,10 @@ let notificationsList: INotification[] = []; + // custom class props for the notification list + let className = ''; + export { className as class }; + export let position: Position = Position.TopRight; // Use auto-subscriptions to avoid leaking memory on re-renders @@ -43,7 +47,7 @@