-
Notifications
You must be signed in to change notification settings - Fork 21
[BOOKINGSG-9244][RYN] migrate navbar component #1171
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
Open
ryan-nguyen-t
wants to merge
16
commits into
pre-release/v4
Choose a base branch
from
BOOKINGSG-9244/navbar
base: pre-release/v4
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ecb6149
[BOOKINGSG-9244][RYN] rename style file extension
8f68e5b
[BOOKINGSG-9244][RYN] migrate V3 design tokens to V4 design tokens
718de1c
[BOOKINGSG-9244][RYN] fix CSP issue with test assets
7d10c9d
[BOOKINGSG-9244][RYN] add e2e tests for desktop
017286b
[BOOKINGSG-9244][RYN] fix secondary asset links
57ec931
[BOOKINGSG-9244][RYN] refactor e2e tests naming
06520e3
[BOOKINGSG-9244][RYN] add e2e tests for navbar mobile
f44a029
[BOOKINGSG-9244][RYN] convert Styled Components styled tags to Linari…
32375e6
[BOOKINGSG-9244][RYN] whitelist BookingSG logo
d054efa
[BOOKINGSG-9244][RYN] add nav responsive classes
fec29a6
[BOOKINGSG-9244][RYN] fix navbar dark mode 1 pixel offset
4847434
[BOOKINGSG-9244][RYN] whitelist BSG domain and simplify mock links
c35241b
[BOOKINGSG-9244][RYN] rename custom action button and clean up locators
c331ff6
[BOOKINGSG-9244][RYN] reorder responsive class names
1dec81a
[BOOKINGSG-9244][RYN] use variables for nav heights
6c21a58
[BOOKINGSG-9244][RYN] use maxWidth for media query
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
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,61 @@ | ||
| import type { | ||
| NavbarButtonProps, | ||
| NavItemProps, | ||
| } from "@lifesg/react-design-system/navbar"; | ||
|
|
||
| export const navItems: NavItemProps<undefined>[] = [ | ||
| { | ||
| id: "home", | ||
| children: "Home", | ||
| href: "https://www.life.gov.sg", | ||
| }, | ||
| { | ||
| id: "guides", | ||
| children: "Guides", | ||
| href: "https://www.life.gov.sg", | ||
| }, | ||
| { | ||
| id: "lifesg-app", | ||
| children: "LifeSG app", | ||
| href: "https://www.life.gov.sg", | ||
| }, | ||
| ]; | ||
|
|
||
| export const downloadActionButtons: NavbarButtonProps[] = [ | ||
| { type: "download" }, | ||
| ]; | ||
|
|
||
| export const navItemsWithSubmenu: NavItemProps<undefined>[] = [ | ||
| { | ||
| id: "home", | ||
| children: "Home", | ||
| href: "https://www.life.gov.sg", | ||
| }, | ||
| { | ||
| id: "services", | ||
| children: "Services", | ||
| href: "https://www.life.gov.sg/?section=services-and-tools", | ||
| subMenu: [ | ||
| { | ||
| id: "services-getting-started", | ||
| children: "Birth registration", | ||
| href: "https://www.life.gov.sg", | ||
| }, | ||
| { | ||
| id: "services-baby-bonus", | ||
| children: "Baby bonus", | ||
| href: "https://www.life.gov.sg", | ||
| }, | ||
| { | ||
| id: "services-preschool-search", | ||
| children: "Preschool search", | ||
| href: "https://www.life.gov.sg", | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| id: "lifesg-app", | ||
| children: "LifeSG app", | ||
| href: "https://www.life.gov.sg", | ||
| }, | ||
| ]; |
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,16 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems, downloadActionButtons } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-compressed" | ||
| compress | ||
| selectedId="guides" | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ desktop: downloadActionButtons }} | ||
| /> | ||
| ); | ||
| } |
24 changes: 24 additions & 0 deletions
24
e2e/nextjs-app/src/app/components/navbar/custom-action-button.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,24 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems } from "./common"; | ||
| import { Avatar } from "@lifesg/react-design-system/avatar"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-with-avatar" | ||
| selectedId="guides" | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ | ||
| desktop: [ | ||
| { | ||
| type: "component", | ||
| args: { render: <Avatar>GovTech</Avatar> }, | ||
| uncollapsible: true, | ||
| }, | ||
| ], | ||
| }} | ||
| /> | ||
| ); | ||
| } |
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 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems, downloadActionButtons } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-default" | ||
| selectedId="guides" | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ desktop: downloadActionButtons }} | ||
| /> | ||
| ); | ||
| } |
16 changes: 16 additions & 0 deletions
16
e2e/nextjs-app/src/app/components/navbar/hide-branding.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,16 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems, downloadActionButtons } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-hide-branding" | ||
| hideNavBranding | ||
| selectedId="guides" | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ desktop: downloadActionButtons }} | ||
| /> | ||
| ); | ||
| } |
16 changes: 16 additions & 0 deletions
16
e2e/nextjs-app/src/app/components/navbar/hide-link-indicator.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,16 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems, downloadActionButtons } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-hide-link-indicator" | ||
| hideLinkIndicator | ||
| selectedId="guides" | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ desktop: downloadActionButtons }} | ||
| /> | ||
| ); | ||
| } |
27 changes: 27 additions & 0 deletions
27
e2e/nextjs-app/src/app/components/navbar/multiple-action-buttons.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 { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-multiple-action-buttons" | ||
| selectedId="guides" | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ | ||
| desktop: [ | ||
| { type: "download" }, | ||
| { | ||
| type: "button", | ||
| args: { children: "Sign up", styleType: "secondary" }, | ||
| }, | ||
| { | ||
| type: "button", | ||
| args: { children: "Log in" }, | ||
| }, | ||
| ], | ||
| }} | ||
| /> | ||
| ); | ||
| } |
16 changes: 16 additions & 0 deletions
16
e2e/nextjs-app/src/app/components/navbar/no-masthead.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,16 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems, downloadActionButtons } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-no-masthead" | ||
| masthead={false} | ||
| selectedId="guides" | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ desktop: downloadActionButtons }} | ||
| /> | ||
| ); | ||
| } |
21 changes: 21 additions & 0 deletions
21
e2e/nextjs-app/src/app/components/navbar/secondary-brand.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,21 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems, downloadActionButtons } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-secondary-brand" | ||
| selectedId="guides" | ||
| resources={{ | ||
| secondary: { | ||
| brandName: "BookingSG", | ||
| logoSrc: "https://www.booking.gov.sg/logo.svg", | ||
| }, | ||
| }} | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ desktop: downloadActionButtons }} | ||
| /> | ||
| ); | ||
| } |
26 changes: 26 additions & 0 deletions
26
e2e/nextjs-app/src/app/components/navbar/single-action-button.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,26 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| actionButtons={{ | ||
| desktop: [ | ||
| { | ||
| args: { | ||
| children: "Logout", | ||
| styleType: "secondary", | ||
| }, | ||
| type: "button", | ||
| }, | ||
| ], | ||
| }} | ||
| items={{ | ||
| desktop: [], | ||
| mobile: [], | ||
| }} | ||
| selectedId="home" | ||
| /> | ||
| ); | ||
| } |
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,16 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { navItems, downloadActionButtons } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-stretch" | ||
| layout="stretch" | ||
| selectedId="guides" | ||
| items={{ desktop: navItems }} | ||
| actionButtons={{ desktop: downloadActionButtons }} | ||
| /> | ||
| ); | ||
| } |
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,16 @@ | ||
| "use client"; | ||
|
|
||
| import { Navbar } from "@lifesg/react-design-system/navbar"; | ||
| import { downloadActionButtons, navItemsWithSubmenu } from "./common"; | ||
|
|
||
| export default function Story() { | ||
| return ( | ||
| <Navbar | ||
| data-testid="navbar-submenu" | ||
| items={{ desktop: navItemsWithSubmenu }} | ||
| actionButtons={{ desktop: downloadActionButtons }} | ||
| onItemClick={() => {}} | ||
| selectedId="services" | ||
| /> | ||
| ); | ||
| } |
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
Binary file added
BIN
+14.1 KB
e2e/tests/components/navbar/__screenshots__/chromium/Navbar-Compress--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
+15.2 KB
e2e/tests/components/navbar/__screenshots__/chromium/Navbar-Default--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
+14.9 KB
...components/navbar/__screenshots__/chromium/Navbar-Default-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
+11.9 KB
...ests/components/navbar/__screenshots__/chromium/Navbar-Hide-branding--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
+15.2 KB
...omponents/navbar/__screenshots__/chromium/Navbar-Hide-link-indicator--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
+8.6 KB
...s/components/navbar/__screenshots__/chromium/Navbar-Mobile-Collapsed--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
+8.34 KB
...s/navbar/__screenshots__/chromium/Navbar-Mobile-Collapsed-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
+21.4 KB
...tests/components/navbar/__screenshots__/chromium/Navbar-Mobile-Drawer--open.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.4 KB
...nents/navbar/__screenshots__/chromium/Navbar-Mobile-Drawer-dark-mode---open.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
...onents/navbar/__screenshots__/chromium/Navbar-Mobile-Secondary-brand--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
+26.2 KB
...ests/components/navbar/__screenshots__/chromium/Navbar-Mobile-Submenu--open.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.46 KB
...components/navbar/__screenshots__/chromium/Navbar-Mobile-With-avatar--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
+17.3 KB
...nents/navbar/__screenshots__/chromium/Navbar-Multiple-action-buttons--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.87 KB
e2e/tests/components/navbar/__screenshots__/chromium/Navbar-No-masthead--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
+20.4 KB
...ts/components/navbar/__screenshots__/chromium/Navbar-Secondary-brand--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.4 KB
...mponents/navbar/__screenshots__/chromium/Navbar-Single-action-button--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
+15.5 KB
e2e/tests/components/navbar/__screenshots__/chromium/Navbar-Stretch--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
+25.5 KB
e2e/tests/components/navbar/__screenshots__/chromium/Navbar-Submenu--open.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
+13.9 KB
e2e/tests/components/navbar/__screenshots__/chromium/Navbar-With-avatar--mount.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to
custom-action-button. the key here is to test the custom component support, avatar is only an example on how the navbar can be used