-
-
Notifications
You must be signed in to change notification settings - Fork 256
refactor: refactoring navbars #1195
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
jderochervlk
wants to merge
30
commits into
master
Choose a base branch
from
vlk/refactor-navigation
base: master
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
30 commits
Select commit
Hold shift + click to select a range
51dc3f8
refactor: refactoring navbars
jderochervlk be70e99
making progress on the nav
jderochervlk 0808cbc
scrolling works again
jderochervlk 949389f
refactoring
jderochervlk bd7b348
mobile overlay works
jderochervlk 482b405
tests are passing
jderochervlk 80b836d
done with mobile overlay
jderochervlk 3eb6f20
screenshots
jderochervlk 53682b0
removing top padding
jderochervlk 876486a
fix playground
jderochervlk 57dae95
remove unused open
jderochervlk b7de7a6
fix issue with homepage reloading nonstop
jderochervlk 86f806b
restor mdx route
jderochervlk 09e42d4
remove dummy page
jderochervlk f642c1c
fixing docs
jderochervlk 6e0bc9d
fix syntax lookup
jderochervlk c671d16
remove build errors and warnings
jderochervlk e0bf40d
commit screenshot changes
jderochervlk 21a333c
chore: update vitest screenshots [skip ci]
jderochervlk f4ec369
remove unused values
jderochervlk f66a9f1
remove unused file
jderochervlk 5e5c0e1
tidying up
jderochervlk 76414e8
fix version dropdown
jderochervlk 95b07eb
Update src/components/Search.res
jderochervlk a15986e
Update src/components/BreadCrumbs.res
jderochervlk 588fc92
Fix mobile overlay not closing on navigation link clicks (#1198)
Copilot 0f26f30
PR feedback.
jderochervlk 17f7d42
PR feedback
jderochervlk 2605d2a
cleanup
jderochervlk 04ba370
Fix sidebar scrolling when it shouldn't
jderochervlk 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
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
This file was deleted.
Oops, something went wrong.
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,101 @@ | ||
| open ReactRouter | ||
| open Vitest | ||
|
|
||
| test("desktop has everything visible", async () => { | ||
| await viewport(1440, 500) | ||
|
|
||
| let screen = await render( | ||
| <BrowserRouter> | ||
| <NavbarPrimary /> | ||
| </BrowserRouter>, | ||
| ) | ||
|
|
||
| let leftContent = await screen->getByTestId("navbar-primary-left-content") | ||
|
|
||
| await element(await leftContent->getByText("Docs"))->toBeVisible | ||
| await element(await leftContent->getByText("Playground"))->toBeVisible | ||
| await element(await leftContent->getByText("Blog"))->toBeVisible | ||
| await element(await leftContent->getByText("Community"))->toBeVisible | ||
|
|
||
| let rightContent = await screen->getByTestId("navbar-primary-right-content") | ||
|
|
||
| await element(await rightContent->getByLabelText("GitHub"))->toBeVisible | ||
| await element(await rightContent->getByLabelText("X (formerly Twitter)"))->toBeVisible | ||
| await element(await rightContent->getByLabelText("Bluesky"))->toBeVisible | ||
| await element(await rightContent->getByLabelText("Forum"))->toBeVisible | ||
|
|
||
| let navbar = await screen->getByTestId("navbar-primary") | ||
|
|
||
| await element(navbar)->toMatchScreenshot("desktop-navbar-primary") | ||
| }) | ||
|
|
||
| test("tablet has everything visible", async () => { | ||
| await viewport(900, 500) | ||
|
|
||
| let screen = await render( | ||
| <BrowserRouter> | ||
| <NavbarPrimary /> | ||
| </BrowserRouter>, | ||
| ) | ||
|
|
||
| let leftContent = await screen->getByTestId("navbar-primary-left-content") | ||
|
|
||
| await element(await leftContent->getByText("Docs"))->toBeVisible | ||
| await element(await leftContent->getByText("Playground"))->toBeVisible | ||
| await element(await leftContent->getByText("Blog"))->toBeVisible | ||
| await element(await leftContent->getByText("Community"))->toBeVisible | ||
|
|
||
| let rightContent = await screen->getByTestId("navbar-primary-right-content") | ||
|
|
||
| await element(await rightContent->getByLabelText("GitHub"))->toBeVisible | ||
| await element(await rightContent->getByLabelText("X (formerly Twitter)"))->toBeVisible | ||
| await element(await rightContent->getByLabelText("Bluesky"))->toBeVisible | ||
| await element(await rightContent->getByLabelText("Forum"))->toBeVisible | ||
|
|
||
| let navbar = await screen->getByTestId("navbar-primary") | ||
|
|
||
| await element(navbar)->toMatchScreenshot("tablet-navbar-primary") | ||
| }) | ||
|
|
||
| test("phone has some things hidden and a mobile nav that can be toggled", async () => { | ||
| await viewport(600, 1200) | ||
|
|
||
| let screen = await render( | ||
| <BrowserRouter> | ||
| <NavbarPrimary /> | ||
| </BrowserRouter>, | ||
| ) | ||
|
|
||
| let leftContent = await screen->getByTestId("navbar-primary-left-content") | ||
|
|
||
| await element(await leftContent->getByText("Docs"))->toBeVisible | ||
| await element(await leftContent->getByText("Playground"))->notToBeVisible | ||
| await element(await leftContent->getByText("Blog"))->notToBeVisible | ||
| await element(await leftContent->getByText("Community"))->notToBeVisible | ||
|
|
||
| let rightContent = await screen->getByTestId("navbar-primary-right-content") | ||
|
|
||
| await element(await rightContent->getByLabelText("GitHub"))->notToBeVisible | ||
| await element(await rightContent->getByLabelText("X (formerly Twitter)"))->notToBeVisible | ||
| await element(await rightContent->getByLabelText("Bluesky"))->notToBeVisible | ||
| await element(await rightContent->getByLabelText("Forum"))->notToBeVisible | ||
|
|
||
| let mobileNav = await screen->getByTestId("mobile-nav") | ||
| await element(mobileNav)->notToBeVisible | ||
|
|
||
| let button = await screen->getByTestId("toggle-mobile-overlay") | ||
|
|
||
| await element(button)->toBeVisible | ||
|
|
||
| await button->click | ||
|
|
||
| let mobileNavAfterOpen = await screen->getByTestId("mobile-nav") | ||
|
|
||
| await element(mobileNavAfterOpen)->toBeVisible | ||
|
|
||
| let navbar = await screen->getByTestId("navbar-primary") | ||
|
|
||
| await element(navbar)->toMatchScreenshot("mobile-navbar-primary") | ||
|
|
||
| await element(mobileNavAfterOpen)->toMatchScreenshot("mobile-overlay-navbar-primary") | ||
| }) |
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,93 @@ | ||
| open ReactRouter | ||
| open Vitest | ||
|
|
||
| let sidebarContent = | ||
| <aside> | ||
| <div dataTestId="sidebar-version-select"> {React.string("v12 (latest)")} </div> | ||
| <div dataTestId="sidebar-categories"> | ||
| <div> {React.string("OVERVIEW")} </div> | ||
| <div> {React.string("Introduction")} </div> | ||
| </div> | ||
| </aside> | ||
|
|
||
| let breadcrumbs = | ||
| <span dataTestId="breadcrumbs"> {React.string("Docs / Language Manual / Installation")} </span> | ||
|
|
||
| let editLink = <a dataTestId="edit-link" href="#"> {React.string("Edit")} </a> | ||
|
|
||
| test("desktop shows breadcrumbs and edit link", async () => { | ||
| await viewport(1440, 500) | ||
|
|
||
| let screen = await render( | ||
| <BrowserRouter> | ||
| <NavbarTertiary sidebar=sidebarContent> | ||
| breadcrumbs | ||
| editLink | ||
| </NavbarTertiary> | ||
| </BrowserRouter>, | ||
| ) | ||
|
|
||
| let navbar = await screen->getByTestId("navbar-tertiary") | ||
|
|
||
| await element(navbar)->toBeVisible | ||
|
|
||
| let crumbs = await screen->getByTestId("breadcrumbs") | ||
| await element(crumbs)->toBeVisible | ||
|
|
||
| let edit = await screen->getByTestId("edit-link") | ||
| await element(edit)->toBeVisible | ||
|
|
||
| await element(navbar)->toMatchScreenshot("desktop-navbar-tertiary") | ||
| }) | ||
|
|
||
| test("mobile shows breadcrumbs and drawer button", async () => { | ||
| await viewport(600, 1200) | ||
|
|
||
| let screen = await render( | ||
| <BrowserRouter> | ||
| <NavbarTertiary sidebar=sidebarContent> | ||
| breadcrumbs | ||
| editLink | ||
| </NavbarTertiary> | ||
| </BrowserRouter>, | ||
| ) | ||
|
|
||
| let navbar = await screen->getByTestId("navbar-tertiary") | ||
| await element(navbar)->toBeVisible | ||
|
|
||
| let crumbs = await screen->getByTestId("breadcrumbs") | ||
| await element(crumbs)->toBeVisible | ||
|
|
||
| let edit = await screen->getByTestId("edit-link") | ||
| await element(edit)->toBeVisible | ||
|
|
||
| await element(navbar)->toMatchScreenshot("mobile-navbar-tertiary") | ||
| }) | ||
|
|
||
| test("mobile drawer can be toggled open", async () => { | ||
| await viewport(600, 1200) | ||
|
|
||
| let screen = await render( | ||
| <BrowserRouter> | ||
| <NavbarTertiary sidebar=sidebarContent> | ||
| breadcrumbs | ||
| editLink | ||
| </NavbarTertiary> | ||
| </BrowserRouter>, | ||
| ) | ||
|
|
||
| // Sidebar dialog should not be visible initially | ||
| let sidebar = await screen->getByTestId("sidebar-categories") | ||
| await element(sidebar)->notToBeVisible | ||
|
|
||
| // Click the drawer toggle button | ||
| let drawerButton = await screen->getByRole(#button) | ||
| await drawerButton->click | ||
|
|
||
| // Sidebar content should now be visible | ||
| let sidebarAfter = await screen->getByTestId("sidebar-categories") | ||
| await element(sidebarAfter)->toBeVisible | ||
|
|
||
| let versionSelect = await screen->getByTestId("sidebar-version-select") | ||
| await element(versionSelect)->toBeVisible | ||
| }) |
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,80 @@ | ||
| open Vitest | ||
|
|
||
| test("renders current version label", async () => { | ||
| let screen = await render(<VersionSelect />) | ||
|
|
||
| let el = await screen->getByTestId("version-select") | ||
| await element(el)->toBeVisible | ||
|
|
||
| let label = await screen->getByText("v12 (latest)") | ||
| await element(label)->toBeVisible | ||
| }) | ||
|
|
||
| test("clicking button shows older versions", async () => { | ||
| let screen = await render(<VersionSelect />) | ||
|
|
||
| // Menu should be hidden initially | ||
| let v11 = await screen->getByText("v11") | ||
| await element(v11)->notToBeVisible | ||
|
|
||
| // Click the trigger button | ||
| let button = await screen->getByRole(#button) | ||
| await button->click | ||
|
|
||
| // Older versions should now be visible | ||
| let v11After = await screen->getByText("v11") | ||
| await element(v11After)->toBeVisible | ||
|
|
||
| let v9 = await screen->getByText("v9.1 - v10.1") | ||
| await element(v9)->toBeVisible | ||
|
|
||
| let v8 = await screen->getByText("v8.2 - v9.0") | ||
| await element(v8)->toBeVisible | ||
|
|
||
| let v6 = await screen->getByText("v6.0 - v8.1") | ||
| await element(v6)->toBeVisible | ||
| }) | ||
|
|
||
| test("clicking button again closes older versions", async () => { | ||
| let screen = await render(<VersionSelect />) | ||
|
|
||
| let button = await screen->getByRole(#button) | ||
|
|
||
| // Open | ||
| await button->click | ||
| let v11 = await screen->getByText("v11") | ||
| await element(v11)->toBeVisible | ||
|
|
||
| // Close | ||
| await button->click | ||
| let v11After = await screen->getByText("v11") | ||
| await element(v11After)->notToBeVisible | ||
| }) | ||
|
|
||
| test("multiple instances have unique popover IDs", async () => { | ||
| let screen = await render( | ||
| <div> | ||
| <div dataTestId="first"> | ||
| <VersionSelect /> | ||
| </div> | ||
| <div dataTestId="second"> | ||
| <VersionSelect /> | ||
| </div> | ||
| </div>, | ||
| ) | ||
|
|
||
| let first = await screen->getByTestId("first") | ||
| let second = await screen->getByTestId("second") | ||
|
|
||
| // Click the button in the first instance | ||
| let firstButton = await first->getByRole(#button) | ||
| await firstButton->click | ||
|
|
||
| // First instance menu should be visible | ||
| let firstV11 = await first->getByText("v11") | ||
| await element(firstV11)->toBeVisible | ||
|
|
||
| // Second instance menu should remain hidden | ||
| let secondV11 = await second->getByText("v11") | ||
| await element(secondV11)->notToBeVisible | ||
| }) |
Binary file added
BIN
+9.92 KB
...screenshots__/NavbarPrimary_.test.jsx/desktop-navbar-primary-chromium-linux.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
+1.69 KB
..._screenshots__/NavbarPrimary_.test.jsx/mobile-navbar-primary-chromium-linux.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
+5.45 KB
...hots__/NavbarPrimary_.test.jsx/mobile-overlay-navbar-primary-chromium-linux.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 KB
..._screenshots__/NavbarPrimary_.test.jsx/tablet-navbar-primary-chromium-linux.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
+4.43 KB
...reenshots__/NavbarTertiary_.test.jsx/desktop-navbar-tertiary-chromium-linux.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
+2.31 KB
...creenshots__/NavbarTertiary_.test.jsx/mobile-navbar-tertiary-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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.