From 9d346d7846404e4acc372792b02d51aafc4172ab Mon Sep 17 00:00:00 2001 From: Art Date: Fri, 10 Mar 2023 16:46:51 +0100 Subject: [PATCH] feat(ui-toolkit): navigation (#3069) --- .../explorer-e2e/src/integration/blocks.cy.js | 20 +- .../src/integration/network.cy.js | 62 +-- apps/explorer/src/app/app.tsx | 56 +-- .../src/app/components/footer/footer.tsx | 2 +- .../src/app/components/header/header.spec.tsx | 6 +- .../src/app/components/header/header.tsx | 131 ++++-- .../explorer/src/app/components/nav/index.tsx | 1 - apps/explorer/src/app/components/nav/nav.tsx | 181 -------- .../src/app/components/search/search.tsx | 134 ++++-- .../explorer/src/app/routes/router-config.tsx | 29 +- apps/explorer/src/app/setup-tests.ts | 10 + .../src/integration/flow/staking-flow.cy.js | 7 +- .../src/integration/view/home.cy.js | 52 +-- .../src/integration/view/pages.cy.js | 284 +++++++++++++ .../src/integration/view/proposal.cy.js | 68 --- .../src/integration/view/pubkey-view.cy.js | 2 +- .../src/integration/view/rewards.cy.js | 35 -- .../src/integration/view/token.cy.js | 3 +- .../src/integration/view/tranches.cy.js | 8 +- .../src/integration/view/validators.cy.js | 27 +- .../src/integration/view/vesting.cy.js | 29 +- .../src/integration/view/wallet-eth.cy.js | 19 +- .../src/integration/view/wallet-vega.cy.js | 203 +++------ .../src/integration/view/withdraw.cy.js | 27 -- .../src/support/common.functions.js | 23 +- .../src/support/staking.functions.js | 6 +- .../src/support/wallet-eth.functions.js | 5 +- .../src/support/wallet-teardown.functions.js | 4 +- .../src/components/nav/nav-draw.tsx | 126 ------ .../src/components/nav/nav-dropdown.tsx | 50 --- .../src/components/nav/nav-link.tsx | 57 --- apps/governance/src/components/nav/nav.css | 25 -- .../src/components/nav/nav.spec.tsx | 56 --- apps/governance/src/components/nav/nav.tsx | 150 +++---- .../page-templates/template-sidebar.tsx | 2 +- .../contexts/app-state/app-state-context.ts | 3 - .../contexts/app-state/app-state-provider.tsx | 5 - .../components/list-asset/list-asset.spec.tsx | 1 - .../hooks/use-vote-information.spec.ts | 1 - apps/governance/src/routes/routes.ts | 1 + apps/trading-e2e/src/integration/navbar.cy.ts | 8 +- apps/trading/components/navbar/navbar.tsx | 267 ++++-------- .../vega-wallet-connect-button.tsx | 2 +- apps/trading/pages/_app.page.tsx | 6 +- .../lib/commands/add-connect-public-key.ts | 2 +- .../src/lib/commands/vega-wallet-connect.ts | 2 +- .../network-switcher/network-switcher.tsx | 23 +- libs/tailwindcss-config/src/theme.js | 1 + .../src/components/drawer/drawer.stories.tsx | 2 +- .../src/components/drawer/drawer.tsx | 3 +- .../dropdown-menu/dropdown-menu.tsx | 2 +- libs/ui-toolkit/src/components/index.ts | 15 +- .../components/input-error/input-error.tsx | 3 +- .../src/components/navigation/index.ts | 3 + .../navigation/navigation-drawer.tsx | 136 ++++++ .../components/navigation/navigation-utils.ts | 97 +++++ .../navigation/navigation.stories.tsx | 251 +++++++++++ .../src/components/navigation/navigation.tsx | 388 ++++++++++++++++++ .../src/components/theme-switcher/icons.tsx | 12 +- .../src/components/vega-logo/vega-logo.tsx | 9 +- package.json | 1 + yarn.lock | 21 + 62 files changed, 1778 insertions(+), 1387 deletions(-) delete mode 100644 apps/explorer/src/app/components/nav/index.tsx delete mode 100644 apps/explorer/src/app/components/nav/nav.tsx create mode 100644 apps/governance-e2e/src/integration/view/pages.cy.js delete mode 100644 apps/governance-e2e/src/integration/view/proposal.cy.js delete mode 100644 apps/governance-e2e/src/integration/view/rewards.cy.js delete mode 100644 apps/governance-e2e/src/integration/view/withdraw.cy.js delete mode 100644 apps/governance/src/components/nav/nav-draw.tsx delete mode 100644 apps/governance/src/components/nav/nav-dropdown.tsx delete mode 100644 apps/governance/src/components/nav/nav-link.tsx delete mode 100644 apps/governance/src/components/nav/nav.css delete mode 100644 apps/governance/src/components/nav/nav.spec.tsx create mode 100644 libs/ui-toolkit/src/components/navigation/index.ts create mode 100644 libs/ui-toolkit/src/components/navigation/navigation-drawer.tsx create mode 100644 libs/ui-toolkit/src/components/navigation/navigation-utils.ts create mode 100644 libs/ui-toolkit/src/components/navigation/navigation.stories.tsx create mode 100644 libs/ui-toolkit/src/components/navigation/navigation.tsx diff --git a/apps/explorer-e2e/src/integration/blocks.cy.js b/apps/explorer-e2e/src/integration/blocks.cy.js index aeb680b73..db664b1da 100644 --- a/apps/explorer-e2e/src/integration/blocks.cy.js +++ b/apps/explorer-e2e/src/integration/blocks.cy.js @@ -1,33 +1,27 @@ context('Blocks page', { tags: '@regression' }, function () { - before('visit token home page', function () { - cy.visit('/'); - }); - describe('Verify elements on page', function () { - const blockNavigation = 'a[href="/blocks"]'; + beforeEach(() => { + cy.visit('/blocks'); + }); const blockHeight = '[data-testid="block-height"]'; const blockTime = '[data-testid="block-time"]'; const blockHeader = '[data-testid="block-header"]'; const previousBlockBtn = '[data-testid="previous-block"]'; const infiniteScrollWrapper = '[data-testid="infinite-scroll-wrapper"]'; - beforeEach('navigate to blocks page', function () { - cy.get(blockNavigation).click(); - }); - it('Blocks page is displayed', function () { validateBlocksDisplayed(); }); it('Blocks page is displayed on mobile', function () { - cy.common_switch_to_mobile_and_click_toggle(); - cy.get(blockNavigation).click(); + cy.switchToMobile(); validateBlocksDisplayed(); }); it('Block validator page is displayed', function () { waitForBlocksResponse(); - cy.get(blockHeight).eq(0).click(); + cy.get(blockHeight).eq(0).find('a').click({ force: true }); + cy.get('[data-testid="block-validator"]').should('not.be.empty'); cy.get(blockTime).should('not.be.empty'); //TODO: Add assertion for transactions when txs are added @@ -35,7 +29,7 @@ context('Blocks page', { tags: '@regression' }, function () { it('Navigate to previous block', function () { waitForBlocksResponse(); - cy.get(blockHeight).eq(0).click(); + cy.get(blockHeight).eq(0).find('a').click({ force: true }); cy.get(blockHeader) .invoke('text') .then(($blockHeaderTxt) => { diff --git a/apps/explorer-e2e/src/integration/network.cy.js b/apps/explorer-e2e/src/integration/network.cy.js index cea6b65f9..2de12f213 100644 --- a/apps/explorer-e2e/src/integration/network.cy.js +++ b/apps/explorer-e2e/src/integration/network.cy.js @@ -2,17 +2,14 @@ context('Network parameters page', { tags: '@smoke' }, function () { before('navigate to network parameter page', function () { cy.fixture('net_parameter_format_lookup').as('networkParameterFormat'); }); - describe('Verify elements on page', function () { - const networkParametersNavigation = 'a[href="/network-parameters"]'; + beforeEach(() => { + cy.visit('/network-parameters'); + }); + const networkParametersHeader = '[data-testid="network-param-header"]'; const tableRows = '[data-testid="key-value-table-row"]'; - before('navigate to network parameter page', function () { - cy.visit('/'); - cy.get(networkParametersNavigation).click(); - }); - it('should show network parameter heading at top of page', function () { cy.get(networkParametersHeader) .should('have.text', 'Network Parameters') @@ -201,55 +198,8 @@ context('Network parameters page', { tags: '@smoke' }, function () { }); }); - it('should be able to switch network parameter page - between light and dark mode', function () { - const whiteThemeSelectedMenuOptionColor = 'rgb(255, 7, 127)'; - const whiteThemeJsonFieldBackColor = 'rgb(255, 255, 255)'; - const whiteThemeSideMenuBackgroundColor = 'rgb(255, 255, 255)'; - const darkThemeSelectedMenuOptionColor = 'rgb(215, 251, 80)'; - const darkThemeJsonFieldBackColor = 'rgb(38, 38, 38)'; - const darkThemeSideMenuBackgroundColor = 'rgb(0, 0, 0)'; - const themeSwitcher = '[data-testid="theme-switcher"]'; - const jsonFields = '.hljs'; - const sideMenuBackground = '.absolute'; - - // Engage dark mode if not already set - cy.get(sideMenuBackground) - .should('have.css', 'background-color') - .then((background_color) => { - if (background_color.includes(whiteThemeSideMenuBackgroundColor)) - cy.get(themeSwitcher).click(); - }); - - // Engage white mode - cy.get(themeSwitcher).click(); - - // White Mode - cy.get(networkParametersNavigation) - .should('have.css', 'background-color') - .and('include', whiteThemeSelectedMenuOptionColor); - cy.get(jsonFields) - .should('have.css', 'background-color') - .and('include', whiteThemeJsonFieldBackColor); - cy.get(sideMenuBackground) - .should('have.css', 'background-color') - .and('include', whiteThemeSideMenuBackgroundColor); - - // Dark Mode - cy.get(themeSwitcher).click(); - cy.get(networkParametersNavigation) - .should('have.css', 'background-color') - .and('include', darkThemeSelectedMenuOptionColor); - cy.get(jsonFields) - .should('have.css', 'background-color') - .and('include', darkThemeJsonFieldBackColor); - cy.get(sideMenuBackground) - .should('have.css', 'background-color') - .and('include', darkThemeSideMenuBackgroundColor); - }); - - it.skip('should be able to see network parameters - on mobile', function () { - cy.common_switch_to_mobile_and_click_toggle(); - cy.get(networkParametersNavigation).click(); + it('should be able to see network parameters - on mobile', function () { + cy.switchToMobile(); cy.get_network_parameters().then((network_parameters) => { network_parameters = Object.entries(network_parameters); network_parameters.forEach((network_parameter) => { diff --git a/apps/explorer/src/app/app.tsx b/apps/explorer/src/app/app.tsx index 1f292caed..8aac5da50 100644 --- a/apps/explorer/src/app/app.tsx +++ b/apps/explorer/src/app/app.tsx @@ -1,6 +1,4 @@ -import classnames from 'classnames'; import { NetworkLoader, useInitializeEnv } from '@vegaprotocol/environment'; -import { Nav } from './components/nav'; import { Header } from './components/header'; import { Main } from './components/main'; import { TendermintWebsocketProvider } from './contexts/websocket/tendermint-websocket-provider'; @@ -11,6 +9,7 @@ import { useAssetDetailsDialogStore, } from '@vegaprotocol/assets'; import { DEFAULT_CACHE_CONFIG } from '@vegaprotocol/apollo-client'; +import classNames from 'classnames'; const DialogsContainer = () => { const { isOpen, id, trigger, asJson, setOpen } = useAssetDetailsDialogStore(); @@ -25,35 +24,42 @@ const DialogsContainer = () => { ); }; -function App() { - const layoutClasses = classnames( - 'grid grid-rows-[auto_1fr_auto] grid-cols-[1fr] md:grid-rows-[auto_minmax(700px,_1fr)_auto] md:grid-cols-[300px_1fr]', - 'min-h-[100vh] mx-auto my-0', - 'border-neutral-700 dark:border-neutral-300 lg:border-l lg:border-r', - 'bg-white dark:bg-black', - 'antialiased text-black dark:text-white', - 'overflow-hidden relative' - ); +const MainnetSimAd = () => ( + +
+ Mainnet sim 2 is live! + + Come help stress test the network + +
+
+); +function App() { return ( - -
- Mainnet sim 2 is live! - - Come help stress test the network - +
+
+
+ +
+
+
+
+
+
- - -
-
-
- diff --git a/apps/explorer/src/app/components/footer/footer.tsx b/apps/explorer/src/app/components/footer/footer.tsx index ce817c809..ab1b5e755 100644 --- a/apps/explorer/src/app/components/footer/footer.tsx +++ b/apps/explorer/src/app/components/footer/footer.tsx @@ -16,7 +16,7 @@ export const Footer = () => { return ( <> -