Skip to content

Commit 1944b18

Browse files
committed
Start removing Menu.children
1 parent 40d5da5 commit 1944b18

File tree

2 files changed

+90
-5
lines changed

2 files changed

+90
-5
lines changed

src/App.tsx

+88-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import react, {useEffect, useMemo} from 'react';
1+
import react, {useEffect, useMemo, useState} from 'react';
22
import {BrowserRouter as Router, Link, Route, Routes, useLocation, useNavigate} from 'react-router-dom';
33
import './App.css';
44
import 'antd/dist/reset.css';
@@ -19,7 +19,7 @@ import {
1919
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
2020
import {faBroadcastTower, faHandHolding, faIdCard, faWallet,} from '@fortawesome/free-solid-svg-icons';
2121

22-
import {Badge, Breadcrumb, Layout, Menu, Switch as ToggleSwitch} from 'antd';
22+
import {Badge, Breadcrumb, Layout, Menu, MenuProps, Switch as ToggleSwitch} from 'antd';
2323
import {AccountState} from "./Components/AccountSelector";
2424
import {Workbox} from "workbox-window";
2525
import AppVersion, {useUpdateAvailable} from "./Pages/AppVersion";
@@ -38,9 +38,11 @@ const App = () => {
3838
const navigate = useNavigate();
3939
const location = useLocation();
4040
const updateAvailable = useUpdateAvailable();
41+
const [navigateTo, setNavigateTo] = useState('/account/');
4142
function goHome() {
4243
navigate("/account/");
4344
}
45+
4446
const refreshApp = () => {
4547
const workbox = new Workbox(process.env.PUBLIC_URL + "/service-worker.js");
4648
workbox.addEventListener('controlling', () => {
@@ -62,6 +64,9 @@ const App = () => {
6264
if ([AccountState.valid].includes(accountInformation.state!)) navigate(`/${page}/${accountInformation.account!.id}`, { replace: true });
6365
}
6466
}, [accountInformation, navigate, location.pathname]);
67+
useEffect(() => {
68+
navigate(navigateTo);
69+
}, [navigateTo, navigate]);
6570

6671
const worker = useMemo(() =>
6772
new Worker(new URL('./updateAccountWorker.tsx', import.meta.url), {type: "module"}),
@@ -96,6 +101,86 @@ const App = () => {
96101
// eslint-disable-next-line
97102
}, [accountInformation.account, usePublicNetwork]);
98103

104+
105+
type AntMenuItem = Required<MenuProps>['items'][number];
106+
const menuItems: AntMenuItem[] = [
107+
{
108+
key: 'account',
109+
label: 'Stellar Account',
110+
icon: <FontAwesomeIcon icon={faWallet}/>,
111+
onClick: () => setNavigateTo('/account/'),
112+
children: [
113+
{
114+
key: 'account:overview',
115+
label: 'Account overview',
116+
icon: <FontAwesomeIcon icon={faIdCard}/>,
117+
onClick: () => setNavigateTo('/account/'),
118+
},
119+
{
120+
key: 'account:claim',
121+
label: 'Claim balances',
122+
icon: <FontAwesomeIcon icon={faIdCard}/>,
123+
onClick: () => setNavigateTo('/claim/'),
124+
},
125+
]
126+
},
127+
{
128+
key: 'settings',
129+
label: 'Settings',
130+
icon: <SettingOutlined />,
131+
children: [
132+
{
133+
type: 'group',
134+
label: 'Network',
135+
children: [
136+
{
137+
label: 'Network',
138+
key: 'settings:toggleNetwork',
139+
icon: <FontAwesomeIcon icon={faBroadcastTower}/>,
140+
children: [
141+
{
142+
icon: <ToggleSwitch checkedChildren="Public" unCheckedChildren="Testnet" onChange={setUsePublicNetwork} checked={usePublicNetwork}/>
143+
}
144+
]
145+
} as AntMenuItem
146+
],
147+
},
148+
{
149+
type: 'group',
150+
label: 'Account overview',
151+
children: [
152+
{
153+
label: 'Load market for balances',
154+
key: 'settings:loadMarket',
155+
},
156+
{
157+
label: 'Paginate balances list',
158+
key: 'settings:paginateBalances',
159+
}
160+
],
161+
}
162+
],
163+
},
164+
{
165+
key: 'about',
166+
label: 'About this site',
167+
icon: <InfoCircleOutlined />,
168+
onClick: () => setNavigateTo('/about'),
169+
},
170+
{
171+
key: 'privacy',
172+
label: 'Privacy information',
173+
icon: <SafetyOutlined />,
174+
onClick: () => setNavigateTo('/privacy'),
175+
},
176+
{
177+
key: 'app:version',
178+
label: "App Version"+(updateAvailable?" - update available":""),
179+
icon: <Badge count={menuCollapsed && updateAvailable?1:0} dot offset={[0, 8]}><ApiOutlined style={{color: "lightgray"}}/></Badge>,
180+
children: [<AppVersion style={{color: "lightgray"}} />]
181+
} as AntMenuItem
182+
];
183+
99184
return (
100185
<Layout className="App">
101186
<Sider
@@ -110,7 +195,7 @@ const App = () => {
110195
left: 0,
111196
}}>
112197
{/*<div><img src={logo} className="App-logo" alt="logo"/></div>*/}
113-
<Menu forceSubMenuRender={true} theme="dark" mode="vertical" selectable={false}>
198+
<Menu forceSubMenuRender={true} theme="dark" mode="vertical" selectable={false} items={menuItems}>
114199
<SubMenu title="Stellar Account" key="account" icon={<FontAwesomeIcon icon={faWallet}/>} onTitleClick={goHome}>
115200
<MenuItem title="Account overview" icon={<FontAwesomeIcon icon={faIdCard}/>} key="account:overview">
116201
<Link to="/account/">Account overview</Link>

src/Pages/AccountOverview.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {BackTop, Col, Row, Table, TablePaginationConfig} from 'antd';
1+
import {Col, FloatButton, Row, Table, TablePaginationConfig} from 'antd';
22
import React, {ReactNode, useEffect, useState} from 'react';
33
import AccountSelector from '../Components/AccountSelector';
44
import useApplicationState from '../useApplicationState';
@@ -116,7 +116,7 @@ export default function AccountOverview() {
116116
return (<>
117117
<AccountSelector />
118118
<>Account {shortAddress(accountInformation.account?.id??'', 9)} created on {accountCreated.date} by <StellarAddressLink id={accountCreated.by} length={9} /></>
119-
<BackTop visibilityHeight={50} />
119+
<FloatButton.BackTop visibilityHeight={50} />
120120
<Table
121121
showHeader={true}
122122
sticky

0 commit comments

Comments
 (0)