From 52ed74f14ca03e99b1b60e86d9e87a242312ff3f Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 7 Nov 2024 21:00:51 +0100 Subject: [PATCH] fix(devwallet): bug in route changes (#2646) --- .changeset/wicked-masks-love.md | 2 + .../apps/dev-wallet/src/App/Layout/KLogo.tsx | 31 ++++++++++ .../dev-wallet/src/App/Layout/SideBar.tsx | 40 +++---------- .../pages/contacts/Components/ContactForm.tsx | 4 -- .../pages/transfer-v2/Steps/TransferForm.tsx | 24 +++++++- .../src/pages/transfer/transfer.tsx | 3 + .../src/patterns/SideBarLayout/SideBar.tsx | 16 +---- .../SideBarLayout/SideBarLayout.stories.tsx | 10 +--- .../patterns/SideBarLayout/SideBarLayout.tsx | 12 +++- .../SideBarLayout/components/Logo/KLogo.tsx | 36 ++++++----- .../components/Logo/KadenaLogo.tsx | 59 ------------------- .../SideBarLayout/components/SideBarAside.tsx | 6 +- 12 files changed, 102 insertions(+), 141 deletions(-) create mode 100644 .changeset/wicked-masks-love.md create mode 100644 packages/apps/dev-wallet/src/App/Layout/KLogo.tsx delete mode 100644 packages/libs/kode-ui/src/patterns/SideBarLayout/components/Logo/KadenaLogo.tsx diff --git a/.changeset/wicked-masks-love.md b/.changeset/wicked-masks-love.md new file mode 100644 index 0000000000..a845151cc8 --- /dev/null +++ b/.changeset/wicked-masks-love.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/apps/dev-wallet/src/App/Layout/KLogo.tsx b/packages/apps/dev-wallet/src/App/Layout/KLogo.tsx new file mode 100644 index 0000000000..be5aa27cf4 --- /dev/null +++ b/packages/apps/dev-wallet/src/App/Layout/KLogo.tsx @@ -0,0 +1,31 @@ +import type { FC } from 'react'; + +export const KLogo: FC<{ height: number; className?: string }> = (props) => ( + + + + + + + + + + + + +); diff --git a/packages/apps/dev-wallet/src/App/Layout/SideBar.tsx b/packages/apps/dev-wallet/src/App/Layout/SideBar.tsx index 68dae5f4a2..4d0cadaef2 100644 --- a/packages/apps/dev-wallet/src/App/Layout/SideBar.tsx +++ b/packages/apps/dev-wallet/src/App/Layout/SideBar.tsx @@ -6,7 +6,6 @@ import { MonoDarkMode, MonoKey, MonoLightMode, - MonoLogout, MonoNetworkCheck, MonoSignature, MonoSwapHoriz, @@ -14,14 +13,8 @@ import { } from '@kadena/kode-icons/system'; import { NetworkSelector } from '@/Components/NetworkSelector/NetworkSelector'; -import { useWallet } from '@/modules/wallet/wallet.hook'; -import { - Button, - ContextMenu, - ContextMenuItem, - Themes, - useTheme, -} from '@kadena/kode-ui'; + +import { Button, Themes, useTheme } from '@kadena/kode-ui'; import { SideBarItem, SideBarItemsInline, @@ -30,22 +23,24 @@ import { } from '@kadena/kode-ui/patterns'; import { FC } from 'react'; import { Link } from 'react-router-dom'; +import { KLogo } from './KLogo'; export const SideBar: FC = () => { const { theme, setTheme } = useTheme(); const { isExpanded } = useLayout(); - const { lockProfile } = useWallet(); const toggleTheme = (): void => { const newTheme = theme === Themes.dark ? Themes.light : Themes.dark; setTheme(newTheme); }; - const handleLogout = () => { - lockProfile(); - }; return ( + + + } appContext={ } label="Select network"> { context={ <> - } label="Profile"> - } - > - {isExpanded ? 'Profile' : undefined} - - } - > - } - label="Logout" - onClick={handleLogout} - /> - - } onPress={toggleTheme} diff --git a/packages/apps/dev-wallet/src/pages/contacts/Components/ContactForm.tsx b/packages/apps/dev-wallet/src/pages/contacts/Components/ContactForm.tsx index c35d1f907b..79952a18c0 100644 --- a/packages/apps/dev-wallet/src/pages/contacts/Components/ContactForm.tsx +++ b/packages/apps/dev-wallet/src/pages/contacts/Components/ContactForm.tsx @@ -35,8 +35,6 @@ export function ContactForm({ onDone: (contect: IContact) => void; isOpen: boolean; }) { - console.log({ input }); - const prompt = usePrompt(); const { activeNetwork } = useWallet(); const [error, setError] = useState(null); @@ -56,8 +54,6 @@ export function ContactForm({ }); useEffect(() => { - console.log({ input }); - if (!input) { reset( { diff --git a/packages/apps/dev-wallet/src/pages/transfer-v2/Steps/TransferForm.tsx b/packages/apps/dev-wallet/src/pages/transfer-v2/Steps/TransferForm.tsx index 696c12221f..d6a1507893 100644 --- a/packages/apps/dev-wallet/src/pages/transfer-v2/Steps/TransferForm.tsx +++ b/packages/apps/dev-wallet/src/pages/transfer-v2/Steps/TransferForm.tsx @@ -25,7 +25,14 @@ import { TextField, } from '@kadena/kode-ui'; import { PactNumber } from '@kadena/pactjs'; -import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; +import { + Fragment, + useCallback, + useEffect, + useMemo, + useRef, + useState, +} from 'react'; import { Controller, useForm } from 'react-hook-form'; import { DiscoverdAccounts } from '../../transfer/components/DiscoverdAccounts'; import { linkClass } from '../../transfer/style.css'; @@ -316,6 +323,7 @@ export function TransferForm({ render={({ field }) => ( Address:} // label="Account" placeholder="Select and address" @@ -363,6 +372,7 @@ export function TransferForm({ control={control} render={({ field }) => ( Chain:} // label={index === 0 ? 'Chain' : undefined} placeholder="Select a chain" @@ -830,7 +843,7 @@ export function TransferForm({ )} - + ); })} @@ -854,6 +867,7 @@ export function TransferForm({ control={control} render={({ field }) => ( { @@ -440,6 +441,7 @@ export function Transfer() { @@ -453,6 +455,7 @@ export function Transfer() { name="transferAll" render={({ field }) => ( diff --git a/packages/libs/kode-ui/src/patterns/SideBarLayout/SideBar.tsx b/packages/libs/kode-ui/src/patterns/SideBarLayout/SideBar.tsx index e68d30674c..46d47baa06 100644 --- a/packages/libs/kode-ui/src/patterns/SideBarLayout/SideBar.tsx +++ b/packages/libs/kode-ui/src/patterns/SideBarLayout/SideBar.tsx @@ -3,10 +3,9 @@ import classNames from 'classnames'; import type { FC, PropsWithChildren, ReactElement } from 'react'; import React from 'react'; import type { PressEvent } from './../../components'; -import { Button, Media, Stack } from './../../components'; +import { Button, Stack } from './../../components'; import { useLayout } from './components/LayoutProvider'; import { KLogo } from './components/Logo/KLogo'; -import { KadenaLogo } from './components/Logo/KadenaLogo'; import { SideBarAppContext } from './components/SideBarAppContext'; import { SideBarContext } from './components/SideBarContext'; import { SideBarNavigation } from './components/SideBarNavigation'; @@ -24,7 +23,6 @@ export interface ISideBarProps extends PropsWithChildren { navigation?: ReactElement; context?: ReactElement; logo?: ReactElement; - minifiedLogo?: ReactElement; } export const SideBar: FC = ({ @@ -33,7 +31,6 @@ export const SideBar: FC = ({ navigation, context, logo, - minifiedLogo, }) => { const { isExpanded, handleToggleExpand } = useLayout(); @@ -44,11 +41,7 @@ export const SideBar: FC = ({ }; const ShowLogo = () => { - if (!isExpanded) { - return minifiedLogo ? minifiedLogo : ; - } - - return logo ? logo : ; + return logo ? logo : ; }; return ( @@ -65,10 +58,7 @@ export const SideBar: FC = ({ })} > -
- {ShowLogo()} - {ShowLogo()} -
+ {ShowLogo()}