From e56bff955fe3e7756d7883f8617912539b271d76 Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 7 Nov 2024 08:56:18 +0100 Subject: [PATCH] chore(devwallet): stylefixes (#2639) --- .changeset/purple-rabbits-drum.md | 2 + .../dev-wallet/src/App/Layout/BreadCrumbs.tsx | 34 -- .../apps/dev-wallet/src/App/Layout/Layout.tsx | 2 - .../dev-wallet/src/App/Layout/SideBar.tsx | 8 - .../SideBarBreadcrumbs/SideBarBreadcrumbs.tsx | 20 + .../dev-wallet/src/pages/account/account.tsx | 29 +- .../backup-recovery-phrase.tsx | 25 +- .../write-down/write-down-recovery-phrase.tsx | 23 +- .../src/pages/contacts/contacts.tsx | 27 +- .../dev-wallet/src/pages/home/home-page.tsx | 71 ++-- .../dev-wallet/src/pages/keys/keys-page.tsx | 83 ++--- .../src/pages/networks/networks.tsx | 26 +- .../signature-builder/signature-builder.tsx | 80 ++-- .../src/pages/transaction/Transaction.tsx | 45 ++- .../src/pages/transactions/transactions.tsx | 111 +++--- .../src/pages/transfer-v2/transfer-v2.tsx | 178 +++++---- packages/libs/kode-ui/package.json | 1 + .../components/Breadcrumbs/Breadcrumbs.css.ts | 21 +- .../src/patterns/SideBarLayout/SideBar.tsx | 1 + .../SideBarLayout/SideBarLayout.stories.tsx | 344 +++++++++++------- .../patterns/SideBarLayout/SideBarLayout.tsx | 39 +- .../src/patterns/SideBarLayout/aside.css.ts | 12 +- .../Breadcrumbs/SideBarBreadcrumbs.tsx | 20 + .../Breadcrumbs/SideBarBreadcrumbsItem.tsx | 12 + .../components/Breadcrumbs/index.ts | 2 + .../components/LayoutProvider.tsx | 52 +-- .../SideBarLayout/components/SideBarAside.tsx | 4 +- .../components/SideBarHeader.tsx | 15 +- .../SideBarLayout/components/SideBarTree.tsx | 4 +- .../components/SideBarTreeWrapper.tsx | 21 ++ .../components/sidebartree.css.ts | 24 +- .../src/patterns/SideBarLayout/sidebar.css.ts | 2 +- .../src/patterns/SideBarLayout/styles.css.ts | 16 +- packages/libs/kode-ui/src/patterns/index.ts | 5 + .../kode-ui/src/styles/tokens/contract.css.ts | 72 ++-- .../kode-ui/src/styles/tokens/dark.css.ts | 26 +- .../kode-ui/src/styles/tokens/light.css.ts | 26 +- pnpm-lock.yaml | 241 +++++++----- 38 files changed, 919 insertions(+), 805 deletions(-) create mode 100644 .changeset/purple-rabbits-drum.md delete mode 100644 packages/apps/dev-wallet/src/App/Layout/BreadCrumbs.tsx create mode 100644 packages/apps/dev-wallet/src/Components/SideBarBreadcrumbs/SideBarBreadcrumbs.tsx create mode 100644 packages/libs/kode-ui/src/patterns/SideBarLayout/components/Breadcrumbs/SideBarBreadcrumbs.tsx create mode 100644 packages/libs/kode-ui/src/patterns/SideBarLayout/components/Breadcrumbs/SideBarBreadcrumbsItem.tsx create mode 100644 packages/libs/kode-ui/src/patterns/SideBarLayout/components/Breadcrumbs/index.ts create mode 100644 packages/libs/kode-ui/src/patterns/SideBarLayout/components/SideBarTreeWrapper.tsx diff --git a/.changeset/purple-rabbits-drum.md b/.changeset/purple-rabbits-drum.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/purple-rabbits-drum.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/apps/dev-wallet/src/App/Layout/BreadCrumbs.tsx b/packages/apps/dev-wallet/src/App/Layout/BreadCrumbs.tsx deleted file mode 100644 index 5c0671da07..0000000000 --- a/packages/apps/dev-wallet/src/App/Layout/BreadCrumbs.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { MonoWindow } from '@kadena/kode-icons/system'; -import { - BreadcrumbsItem, - Breadcrumbs as BreadcrumbsUI, - Text, -} from '@kadena/kode-ui'; -import { useLayout } from '@kadena/kode-ui/patterns'; -import { FC } from 'react'; -import { Link } from 'react-router-dom'; - -export const BreadCrumbs: FC = () => { - const { breadCrumbs } = useLayout(); - - return ( - - {breadCrumbs.length ? breadCrumbs[0].visual : } - - } - > - <> - - Dashboard - - {breadCrumbs.map((crumb) => ( - - {crumb.label} - - ))} - - - ); -}; diff --git a/packages/apps/dev-wallet/src/App/Layout/Layout.tsx b/packages/apps/dev-wallet/src/App/Layout/Layout.tsx index c70c167390..3809e3ee0a 100644 --- a/packages/apps/dev-wallet/src/App/Layout/Layout.tsx +++ b/packages/apps/dev-wallet/src/App/Layout/Layout.tsx @@ -15,7 +15,6 @@ import { import { FC, useMemo } from 'react'; import { Link, Outlet, useLocation, useNavigate } from 'react-router-dom'; import { BetaHeader } from './../BetaHeader'; -import { BreadCrumbs } from './BreadCrumbs'; import { SideBar } from './SideBar'; export const Layout: FC = () => { @@ -41,7 +40,6 @@ export const Layout: FC = () => { <> } - breadcrumbs={} location={innerLocation} sidebar={} footer={ diff --git a/packages/apps/dev-wallet/src/App/Layout/SideBar.tsx b/packages/apps/dev-wallet/src/App/Layout/SideBar.tsx index e4add3720e..c70ad3c6b6 100644 --- a/packages/apps/dev-wallet/src/App/Layout/SideBar.tsx +++ b/packages/apps/dev-wallet/src/App/Layout/SideBar.tsx @@ -4,7 +4,6 @@ import { MonoDashboardCustomize, MonoLogout, MonoNetworkCheck, - MonoSwapHoriz, MonoTableRows, MonoWallet, MonoWindow, @@ -91,13 +90,6 @@ export const SideBar: FC = () => { /> - } - label="Transfer" - component={Link} - href="/transfer" - /> - } label="Contacts" diff --git a/packages/apps/dev-wallet/src/Components/SideBarBreadcrumbs/SideBarBreadcrumbs.tsx b/packages/apps/dev-wallet/src/Components/SideBarBreadcrumbs/SideBarBreadcrumbs.tsx new file mode 100644 index 0000000000..7f96614874 --- /dev/null +++ b/packages/apps/dev-wallet/src/Components/SideBarBreadcrumbs/SideBarBreadcrumbs.tsx @@ -0,0 +1,20 @@ +import { IBreadcrumbsProps } from '@kadena/kode-ui'; +import { SideBarBreadcrumbs as SideBarBreadcrumbsUI } from '@kadena/kode-ui/patterns'; +import React, { FC } from 'react'; +import { Link } from 'react-router-dom'; + +export const SideBarBreadcrumbs: FC = ({ + children, + ...props +}) => { + return ( + + {React.Children.map(children, (child) => { + if (!React.isValidElement(child)) { + return null; + } + return React.cloneElement(child, { ...child.props, component: Link }); + })} + + ); +}; diff --git a/packages/apps/dev-wallet/src/pages/account/account.tsx b/packages/apps/dev-wallet/src/pages/account/account.tsx index 15d8f50381..068dcaf87d 100644 --- a/packages/apps/dev-wallet/src/pages/account/account.tsx +++ b/packages/apps/dev-wallet/src/pages/account/account.tsx @@ -15,14 +15,8 @@ import { getTransferActivities } from '@/modules/activity/activity.service'; import * as transactionService from '@/modules/transaction/transaction.service'; import { useAsync } from '@/utils/useAsync'; import { ChainId } from '@kadena/client'; -import { - MonoKey, - MonoRemoveRedEye, - MonoTransform, - MonoWallet, -} from '@kadena/kode-icons/system'; +import { MonoKey, MonoRemoveRedEye } from '@kadena/kode-icons/system'; import { Button, Heading, Stack, TabItem, Tabs, Text } from '@kadena/kode-ui'; -import { useLayout } from '@kadena/kode-ui/patterns'; import { useMemo, useState } from 'react'; import { Link, useNavigate, useParams } from 'react-router-dom'; import { noStyleLinkClass, panelClass } from '../home/style.css'; @@ -41,27 +35,6 @@ export function AccountPage() { watchAccounts.find((account) => account.uuid === accountId); const navigate = useNavigate(); - useLayout({ - breadCrumbs: [ - { - label: - activeNetwork?.name || activeNetwork?.networkId || 'Unknown Network', - url: '/', - visual: , - }, - { - url: `/account/${accountId || ''}`, - label: `Account (${account?.alias || account?.address || 'Unknown Account'})`, - }, - ], - appContext: { - visual: , - label: 'Add Asset', - onPress: () => { - navigate('/add-asset'); - }, - }, - }); const keyset = account?.keyset; const asset = fungibles.find((f) => f.contract === account?.contract); diff --git a/packages/apps/dev-wallet/src/pages/backup-recovery-phrase/backup-recovery-phrase.tsx b/packages/apps/dev-wallet/src/pages/backup-recovery-phrase/backup-recovery-phrase.tsx index 71d8fde7d8..9b0af35bda 100644 --- a/packages/apps/dev-wallet/src/pages/backup-recovery-phrase/backup-recovery-phrase.tsx +++ b/packages/apps/dev-wallet/src/pages/backup-recovery-phrase/backup-recovery-phrase.tsx @@ -1,23 +1,22 @@ import { AuthCard } from '@/Components/AuthCard/AuthCard'; +import { SideBarBreadcrumbs } from '@/Components/SideBarBreadcrumbs/SideBarBreadcrumbs'; import { MonoDashboardCustomize } from '@kadena/kode-icons/system'; import { Box, Button, Heading, Stack, Text } from '@kadena/kode-ui'; -import { useLayout } from '@kadena/kode-ui/patterns'; +import { SideBarBreadcrumbsItem } from '@kadena/kode-ui/patterns'; import { Link } from 'react-router-dom'; - +}> + Dashboard + Dev Console +; export function BackupRecoveryPhrase() { - useLayout({ - appContext: undefined, - breadCrumbs: [ - { - label: 'Backup', - visual: , - url: '/backup-recovery-phrase', - }, - ], - }); - return ( <> + }> + Dashboard + + Backup + + Backup the recovery phrase diff --git a/packages/apps/dev-wallet/src/pages/backup-recovery-phrase/write-down/write-down-recovery-phrase.tsx b/packages/apps/dev-wallet/src/pages/backup-recovery-phrase/write-down/write-down-recovery-phrase.tsx index e6af31c94f..bf0869b0b1 100644 --- a/packages/apps/dev-wallet/src/pages/backup-recovery-phrase/write-down/write-down-recovery-phrase.tsx +++ b/packages/apps/dev-wallet/src/pages/backup-recovery-phrase/write-down/write-down-recovery-phrase.tsx @@ -1,27 +1,14 @@ import { AuthCard } from '@/Components/AuthCard/AuthCard'; import { BackupMnemonic } from '@/Components/BackupMnemonic/BackupMnemonic'; +import { SideBarBreadcrumbs } from '@/Components/SideBarBreadcrumbs/SideBarBreadcrumbs'; import { useWallet } from '@/modules/wallet/wallet.hook'; import { MonoDashboardCustomize } from '@kadena/kode-icons/system'; import { Notification } from '@kadena/kode-ui'; -import { useLayout } from '@kadena/kode-ui/patterns'; +import { SideBarBreadcrumbsItem } from '@kadena/kode-ui/patterns'; import { useState } from 'react'; import { useNavigate } from 'react-router-dom'; export function WriteDownRecoveryPhrase() { - useLayout({ - appContext: undefined, - breadCrumbs: [ - { - label: 'Backup', - visual: , - url: '/backup-recovery-phrase', - }, - { - label: 'Recovery phrase', - url: '/backup-recovery-phrase/write-down', - }, - ], - }); const { decryptSecret, askForPassword, profile } = useWallet(); const [mnemonic, setMnemonic] = useState(''); const [error, setError] = useState(''); @@ -55,6 +42,12 @@ export function WriteDownRecoveryPhrase() { } return ( <> + }> + Dashboard + + Recovery phrase + + { , - label: 'Add Contact', - onPress: () => { - setIsRightAsideExpanded(true); - }, - }, - breadCrumbs: [ - { - label: 'Contacts', - visual: , - url: '/contacts', - }, - ], - }); + const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); const [editContact, setEditContact] = useState(); const { contacts } = useWallet(); const prompt = usePrompt(); @@ -53,6 +39,13 @@ export function Contacts() { return ( <> + }> + Dashboard + + Contacts + + + , - }, - ], - appContext: { - visual: , - label: 'Add Asset', - onPress: () => { - setIsRightAsideExpanded(true); - }, - }, - }); const [transactions] = useAsync( async (profile, activeNetwork) => { @@ -56,28 +38,33 @@ export function HomePage() { ); return ( - - Welcome back - {profile?.name} - - - - Wallet Activities - - - - - - - All transactions - - - - WIP: Not implemented yet - + <> + }> + Dashboard + + + Welcome back + {profile?.name} + + + + Wallet Activities + + + + + + + All transactions + + + + WIP: Not implemented yet + + - - + + ); } diff --git a/packages/apps/dev-wallet/src/pages/keys/keys-page.tsx b/packages/apps/dev-wallet/src/pages/keys/keys-page.tsx index 75fd5f5cc1..e0f7b99787 100644 --- a/packages/apps/dev-wallet/src/pages/keys/keys-page.tsx +++ b/packages/apps/dev-wallet/src/pages/keys/keys-page.tsx @@ -1,56 +1,49 @@ -import { createAsideUrl } from '@/utils/createAsideUrl'; +import { SideBarBreadcrumbs } from '@/Components/SideBarBreadcrumbs/SideBarBreadcrumbs'; import { Mono123, MonoKey } from '@kadena/kode-icons/system'; import { Heading, Stack, TabItem, Tabs, Text } from '@kadena/kode-ui'; -import { useLayout } from '@kadena/kode-ui/patterns'; -import { Link, useParams } from 'react-router-dom'; +import { SideBarBreadcrumbsItem } from '@kadena/kode-ui/patterns'; +import { useParams } from 'react-router-dom'; import { Keys } from './Components/Keys'; import { KeySets } from './Components/KeySets'; export function KeysPage() { const { tab = 'keys' } = useParams(); - useLayout({ - appContext: { - visual: , - label: 'Add key Source', - href: createAsideUrl('KeySource'), - component: Link, - }, - breadCrumbs: [ - { - label: 'Manage Your Keys', - visual: , - url: '/key-management/keys', - }, - ], - }); return ( - - Manage Your Keys - - - - Your Keys - - } - > - - - - - Your Key Sets - - } - > - - - - + <> + }> + Dashboard + + Manage Your Keys + + + + Manage Your Keys + + + + Your Keys + + } + > + + + + + Your Key Sets + + } + > + + + + + ); } diff --git a/packages/apps/dev-wallet/src/pages/networks/networks.tsx b/packages/apps/dev-wallet/src/pages/networks/networks.tsx index a784050e35..8fe87b0fdc 100644 --- a/packages/apps/dev-wallet/src/pages/networks/networks.tsx +++ b/packages/apps/dev-wallet/src/pages/networks/networks.tsx @@ -1,10 +1,10 @@ import { ListItem } from '@/Components/ListItem/ListItem'; +import { SideBarBreadcrumbs } from '@/Components/SideBarBreadcrumbs/SideBarBreadcrumbs'; import { networkRepository } from '@/modules/network/network.repository'; import { useWallet } from '@/modules/wallet/wallet.hook'; -import { createAsideUrl } from '@/utils/createAsideUrl'; -import { MonoWifiTethering, MonoWorkspaces } from '@kadena/kode-icons/system'; -import { Button, Heading, Link, Stack, Text } from '@kadena/kode-ui'; -import { useLayout } from '@kadena/kode-ui/patterns'; +import { MonoWifiTethering } from '@kadena/kode-icons/system'; +import { Button, Heading, Stack, Text } from '@kadena/kode-ui'; +import { SideBarBreadcrumbsItem, useLayout } from '@kadena/kode-ui/patterns'; import { useState } from 'react'; import { panelClass } from '../home/style.css'; import { @@ -18,20 +18,16 @@ export function Networks() { const { setIsRightAsideExpanded, isRightAsideExpanded } = useLayout(); const [selectedNetwork, setSelectedNetwork] = useState(() => getNewNetwork()); - useLayout({ - appContext: { - visual: , - label: 'Add Network', - href: createAsideUrl('KeySource'), - component: Link, - }, - breadCrumbs: [ - { label: 'Networks', visual: , url: '/networks' }, - ], - }); return ( <> + }> + Dashboard + + Networks + + + ([]); const { profile, activeNetwork, networks, setActiveNetwork } = useWallet(); const navigate = useNavigate(); - useLayout({ - appContext: undefined, - breadCrumbs: [ - { - label: 'Sig Builder', - visual: , - url: '/sig-builder', - }, - ], - }); const exec = pactCommand && pactCommand.payload && 'exec' in pactCommand.payload @@ -200,35 +191,46 @@ export function SignatureBuilder() { }; return ( - - Paste SigData, CommandSigData, or Payload -