-
Notifications
You must be signed in to change notification settings - Fork 21
[BOOKINGSG-9340][IT] Migrate notification banner component #1221
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2ffdfdd
[BOOKINGSG-9340][IT] Rename style file extensions
iant-gds 977a03c
[BOOKINGSG-9340][IT] Migrate v3 design tokens to v4 tokens
iant-gds ac5cc33
[BOOKINGSG-9340][IT] Convert styled interpolations to class names
iant-gds 21bcdb6
[BOOKINGSG-9340][IT] Convert styled components to linaria
iant-gds d65ec69
[BOOKINGSG-9340][IT] Add unit tests
iant-gds 6c38949
[BOOKINGSG-9340][IT] Fix styling issue
iant-gds 6fdd110
[BOOKINGSG-9340][IT] Add e2e test spec and screenshots
iant-gds 65b0636
[BOOKINGSG-9340][IT] Update to use placeholder icon
iant-gds 064a3f0
[BOOKINGSG-9340][IT] Update test files and add new screenshots
iant-gds ba84226
[BOOKINGSG-9340][IT] Update component and component style file
iant-gds 6926836
[BOOKINGSG-9340][RL] Extract link style
b2d2764
[BOOKINGSG-9340][RL] Update sticky behaviour test to follow toast
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
e2e/nextjs-app/src/app/components/notification-banner/all-variants.e2e.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| "use client"; | ||
| import { PlaceholderIcon } from "@lifesg/react-icons/placeholder"; | ||
| import { NotificationBanner } from "@lifesg/react-design-system/notification-banner"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-column-container"> | ||
| <NotificationBanner data-testid="banner-default"> | ||
| This is a default notification banner | ||
| </NotificationBanner> | ||
|
|
||
| <NotificationBanner | ||
| data-testid="banner-with-icon" | ||
| icon={<PlaceholderIcon />} | ||
| > | ||
| This is a notification banner with an icon | ||
| </NotificationBanner> | ||
|
|
||
| <NotificationBanner | ||
| data-testid="banner-non-dismissible" | ||
| dismissible={false} | ||
| > | ||
| This is a non-dismissible notification banner | ||
| </NotificationBanner> | ||
| </div> | ||
| ); | ||
| } |
20 changes: 20 additions & 0 deletions
20
e2e/nextjs-app/src/app/components/notification-banner/custom-content.e2e.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| "use client"; | ||
| import { GearFillIcon } from "@lifesg/react-icons/gear-fill"; | ||
| import { NotificationBanner } from "@lifesg/react-design-system/notification-banner"; | ||
| import styles from "./notification-banner.module.css"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-column-container"> | ||
| <NotificationBanner data-testid="banner-custom-content"> | ||
| <div | ||
| data-testid="custom-content-wrapper" | ||
| className={styles.custom} | ||
| > | ||
| <GearFillIcon /> | ||
| Custom content | ||
| </div> | ||
| </NotificationBanner> | ||
| </div> | ||
| ); | ||
| } |
43 changes: 43 additions & 0 deletions
43
e2e/nextjs-app/src/app/components/notification-banner/long-content.e2e.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| "use client"; | ||
| import { NotificationBanner } from "@lifesg/react-design-system/notification-banner"; | ||
| import { ArrowRightIcon } from "@lifesg/react-icons/arrow-right"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-column-container"> | ||
| <NotificationBanner | ||
| data-testid="banner-long-content" | ||
| maxCollapsedHeight={100} | ||
| > | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | ||
| eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut | ||
| enim ad minim veniam, quis nostrud exercitation ullamco laboris | ||
| nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor | ||
| in reprehenderit in voluptate velit esse cillum dolore eu fugiat | ||
| nulla pariatur. Excepteur sint occaecat cupidatat non proident, | ||
| sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
| </NotificationBanner> | ||
|
|
||
| <NotificationBanner | ||
| data-testid="banner-long-content-action-button" | ||
| maxCollapsedHeight={100} | ||
| actionButton={{ | ||
| children: ( | ||
| <> | ||
| View more | ||
| <ArrowRightIcon /> | ||
| </> | ||
| ), | ||
| }} | ||
| > | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | ||
| eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut | ||
| enim ad minim veniam, quis nostrud exercitation ullamco laboris | ||
| nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor | ||
| in reprehenderit in voluptate velit esse cillum dolore eu fugiat | ||
| nulla pariatur. Excepteur sint occaecat cupidatat non proident, | ||
| sunt in culpa qui officia deserunt mollit anim id est laborum. | ||
| </NotificationBanner> | ||
| </div> | ||
| ); | ||
| } |
25 changes: 25 additions & 0 deletions
25
e2e/nextjs-app/src/app/components/notification-banner/non-sticky.e2e.tsx
|
qroll marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| "use client"; | ||
| import { NotificationBanner } from "@lifesg/react-design-system/notification-banner"; | ||
| import styles from "./notification-banner.module.css"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div> | ||
| <NotificationBanner data-testid="banner-non-sticky" sticky={false}> | ||
| This is a non-sticky notification banner. | ||
| </NotificationBanner> | ||
| <div className={styles.sticky}> | ||
| <p> | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed | ||
| do eiusmod tempor incididunt ut labore et dolore magna | ||
| aliqua. Ut enim ad minim veniam, quis nostrud exercitation | ||
| ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
| Duis aute irure dolor in reprehenderit in voluptate velit | ||
| esse cillum dolore eu fugiat nulla pariatur. Excepteur sint | ||
| occaecat cupidatat non proident, sunt in culpa qui officia | ||
| deserunt mollit anim id est laborum. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
15 changes: 15 additions & 0 deletions
15
e2e/nextjs-app/src/app/components/notification-banner/notification-banner.module.css
|
qroll marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| .custom { | ||
| display: flex; | ||
| gap: 1rem; | ||
| align-items: center; | ||
| width: 100%; | ||
| padding: 1rem; | ||
| color: black; | ||
| background: yellow; | ||
| } | ||
|
|
||
| .sticky { | ||
| height: 200vh; | ||
| background-color: teal; | ||
| border: solid 10px crimson; | ||
| } |
25 changes: 25 additions & 0 deletions
25
e2e/nextjs-app/src/app/components/notification-banner/sticky.e2e.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| "use client"; | ||
| import { NotificationBanner } from "@lifesg/react-design-system/notification-banner"; | ||
| import styles from "./notification-banner.module.css"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div> | ||
| <NotificationBanner data-testid="banner-sticky"> | ||
| This is a sticky notification banner. | ||
| </NotificationBanner> | ||
| <div className={styles.sticky}> | ||
| <p> | ||
| Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed | ||
| do eiusmod tempor incididunt ut labore et dolore magna | ||
| aliqua. Ut enim ad minim veniam, quis nostrud exercitation | ||
| ullamco laboris nisi ut aliquip ex ea commodo consequat. | ||
| Duis aute irure dolor in reprehenderit in voluptate velit | ||
| esse cillum dolore eu fugiat nulla pariatur. Excepteur sint | ||
| occaecat cupidatat non proident, sunt in culpa qui officia | ||
| deserunt mollit anim id est laborum. | ||
| </p> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
19 changes: 19 additions & 0 deletions
19
e2e/nextjs-app/src/app/components/notification-banner/text-styling.e2e.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| "use client"; | ||
| import { NotificationBanner } from "@lifesg/react-design-system/notification-banner"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <div className="story-column-container"> | ||
| <NotificationBanner data-testid="banner-text-styling"> | ||
| This banner has <strong>bold text</strong>, <em>italic text</em> | ||
| , anchor tag for normal{" "} | ||
| <a href="https://sample-url.com">link</a>, and Link component | ||
| for{" "} | ||
| <NotificationBanner.Link href="https://sample-url.com" external> | ||
| external link | ||
| </NotificationBanner.Link> | ||
| . | ||
| </NotificationBanner> | ||
| </div> | ||
| ); | ||
| } |
Binary file added
BIN
+11.5 KB
...tion-banner/__screenshots__/chromium/NotificationBanner-All-variants--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+11.7 KB
.../__screenshots__/chromium/NotificationBanner-All-variants-dark-mode---mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.24 KB
...on-banner/__screenshots__/chromium/NotificationBanner-Custom-content--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.7 KB
...tion-banner/__screenshots__/chromium/NotificationBanner-Long-content--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.9 KB
...tification-banner/__screenshots__/chromium/NotificationBanner-Mobile--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.76 KB
...enshots__/chromium/NotificationBanner-Sticky-banner-behaviour--after-scroll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.2 KB
.../__screenshots__/chromium/NotificationBanner-Sticky-banner-behaviour--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.33 KB
...tion-banner/__screenshots__/chromium/NotificationBanner-Text-styling--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
136 changes: 136 additions & 0 deletions
136
e2e/tests/components/notification-banner/notification-banner.e2e.spec.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| import { test as base, expect, Locator, Page } from "@playwright/test"; | ||
| import { AbstractStoryPage, compareScreenshot } from "../../utils"; | ||
|
|
||
| class StoryPage extends AbstractStoryPage { | ||
| protected readonly component = "notification-banner"; | ||
|
|
||
| public readonly locators: { | ||
| bannerNonSticky: Locator; | ||
| bannerSticky: Locator; | ||
| }; | ||
|
|
||
| constructor(page: Page) { | ||
| super(page); | ||
|
|
||
| this.locators = { | ||
| bannerNonSticky: page.getByTestId("banner-non-sticky"), | ||
| bannerSticky: page.getByTestId("banner-sticky"), | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| const test = base.extend<{ story: StoryPage }>({ | ||
| story: async ({ page }, use) => { | ||
| const story = new StoryPage(page); | ||
| await use(story); | ||
| }, | ||
| }); | ||
|
|
||
| test.describe("NotificationBanner", () => { | ||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("all-variants"); | ||
| }); | ||
|
|
||
| test("All variants", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("all-variants", { mode: "dark" }); | ||
| }); | ||
|
|
||
| test("All variants (dark mode)", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("all-variants", { size: "mobile" }); | ||
| }); | ||
|
|
||
| test("Mobile", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("long-content"); | ||
| }); | ||
|
|
||
| test("Long content", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("custom-content"); | ||
| }); | ||
|
|
||
| test("Custom content", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("text-styling"); | ||
| }); | ||
|
|
||
| test("Text styling", async ({ story }) => { | ||
| await compareScreenshot(story, "mount"); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("non-sticky"); | ||
| }); | ||
|
|
||
| test("Non-sticky banner scrolls out of view", async ({ story }) => { | ||
| await test.step("Verify non-sticky banner is visible initially", async () => { | ||
| await expect(story.locators.bannerNonSticky).toBeInViewport(); | ||
| }); | ||
|
|
||
| await test.step("Scroll down the page", async () => { | ||
| await story.page.mouse.wheel(0, 100); | ||
| await story.page.waitForTimeout(300); | ||
| }); | ||
|
|
||
| await test.step("Verify non-sticky banner scrolled out of view", async () => { | ||
| await expect( | ||
| story.locators.bannerNonSticky | ||
| ).not.toBeInViewport(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe(() => { | ||
| test.beforeEach(async ({ story }) => { | ||
| await story.init("sticky"); | ||
| }); | ||
|
|
||
| test("Sticky banner behaviour", async ({ story }) => { | ||
| await test.step("Verify sticky banner is visible initially", async () => { | ||
| await expect(story.locators.bannerSticky).toBeInViewport(); | ||
| await compareScreenshot(story, "mount", { fullscreen: true }); | ||
| }); | ||
|
|
||
| await test.step("Scroll down the page", async () => { | ||
| await story.scrollToEnd({ scrollTarget: story.layout }); | ||
| }); | ||
|
|
||
| await test.step("Verify sticky banner remains in view", async () => { | ||
| await expect(story.locators.bannerSticky).toBeInViewport(); | ||
| await compareScreenshot(story, "after-scroll", { | ||
| fullscreen: true, | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.