-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add sidebar component (#2620)
- Loading branch information
1 parent
959ce16
commit 7cefeb1
Showing
41 changed files
with
2,280 additions
and
192 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
'@kadena/kode-ui': minor | ||
--- | ||
|
||
add SideBar Component |
This file contains 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 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,84 @@ | ||
import { | ||
MonoKey, | ||
MonoLightMode, | ||
MonoWifiTethering, | ||
MonoWorkspaces, | ||
} from '@kadena/kode-icons/system'; | ||
|
||
import { NetworkSelector } from '@/Components/NetworkSelector/NetworkSelector'; | ||
import { BreadCrumbs } from '@/pages/BreadCrumbs/BreadCrumbs'; | ||
import { Themes, useTheme } from '@kadena/kode-ui'; | ||
import { | ||
SideBarFooter, | ||
SideBarFooterItem, | ||
SideBarLayout, | ||
useSideBar, | ||
} from '@kadena/kode-ui/patterns'; | ||
import { FC, useEffect } from 'react'; | ||
import { Link, Outlet, useLocation } from 'react-router-dom'; | ||
import { BetaHeader } from './../BetaHeader'; | ||
import { SideBar } from './SideBar'; | ||
|
||
export const Layout: FC = () => { | ||
const { theme, setTheme } = useTheme(); | ||
const { breadCrumbs, setBreadCrumbs, setAppContext } = useSideBar(); | ||
const location = useLocation(); | ||
|
||
useEffect(() => { | ||
if ( | ||
breadCrumbs.length > 0 && | ||
location.pathname !== breadCrumbs[breadCrumbs.length - 1].url | ||
) { | ||
setBreadCrumbs([]); | ||
setAppContext(); | ||
} | ||
}, [location]); | ||
|
||
const toggleTheme = (): void => { | ||
const newTheme = theme === Themes.dark ? Themes.light : Themes.dark; | ||
setTheme(newTheme); | ||
}; | ||
return ( | ||
<> | ||
<SideBarLayout | ||
topBanner={<BetaHeader />} | ||
breadcrumbs={<BreadCrumbs />} | ||
activeUrl={location.pathname} | ||
sidebar={<SideBar />} | ||
footer={ | ||
<SideBarFooter> | ||
<SideBarFooterItem | ||
href="/" | ||
component={Link} | ||
visual={<MonoWifiTethering />} | ||
label="Profile" | ||
/> | ||
|
||
<SideBarFooterItem | ||
href="/key-management/keys" | ||
component={Link} | ||
visual={<MonoKey />} | ||
label="Keys" | ||
/> | ||
|
||
<SideBarFooterItem | ||
visual={<MonoWorkspaces />} | ||
label="Select network" | ||
> | ||
<NetworkSelector variant="transparent" showLabel={false} /> | ||
</SideBarFooterItem> | ||
<SideBarFooterItem | ||
visual={<MonoLightMode />} | ||
label="Change theme" | ||
onPress={toggleTheme} | ||
/> | ||
</SideBarFooter> | ||
} | ||
> | ||
<Outlet /> | ||
</SideBarLayout> | ||
|
||
<div id="modalportal"></div> | ||
</> | ||
); | ||
}; |
This file contains 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,157 @@ | ||
import { | ||
MonoContacts, | ||
MonoContrast, | ||
MonoDashboardCustomize, | ||
MonoDataThresholding, | ||
MonoLogout, | ||
MonoNetworkCheck, | ||
MonoSwapHoriz, | ||
MonoTableRows, | ||
MonoWallet, | ||
} 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 { | ||
SideBarItem, | ||
SideBarItemsInline, | ||
SideBarTree, | ||
SideBarTreeItem, | ||
SideBar as SideBarUI, | ||
useSideBar, | ||
} from '@kadena/kode-ui/patterns'; | ||
import { FC } from 'react'; | ||
import { Link, useNavigate } from 'react-router-dom'; | ||
|
||
export const SideBar: FC = () => { | ||
const { theme, setTheme } = useTheme(); | ||
const { isExpanded } = useSideBar(); | ||
const navigate = useNavigate(); | ||
const { lockProfile } = useWallet(); | ||
|
||
const toggleTheme = (): void => { | ||
const newTheme = theme === Themes.dark ? Themes.light : Themes.dark; | ||
setTheme(newTheme); | ||
}; | ||
|
||
const handleLogout = () => { | ||
lockProfile(); | ||
}; | ||
return ( | ||
<SideBarUI | ||
appContext={ | ||
<SideBarItem visual={<MonoNetworkCheck />} label="Select network"> | ||
<NetworkSelector | ||
showLabel={isExpanded} | ||
variant="outlined" | ||
isCompact={!isExpanded} | ||
/> | ||
</SideBarItem> | ||
} | ||
navigation={ | ||
<> | ||
<SideBarItem | ||
visual={<MonoDataThresholding />} | ||
label="Dashboard" | ||
component={Link} | ||
href="/" | ||
/> | ||
|
||
<SideBarTree visual={<MonoWallet />} label="My Wallets"> | ||
<SideBarTreeItem | ||
label="Keys" | ||
component={Link} | ||
href="/key-management/keys" | ||
/> | ||
</SideBarTree> | ||
<SideBarTree visual={<MonoTableRows />} label="Transactions"> | ||
<SideBarTreeItem | ||
label="History" | ||
component={Link} | ||
href="/transactions" | ||
/> | ||
</SideBarTree> | ||
<SideBarTree visual={<MonoDashboardCustomize />} label="Utilities"> | ||
<SideBarTreeItem | ||
label="Sig Builder" | ||
component={Link} | ||
href="/sig-builder" | ||
/> | ||
<SideBarTreeItem | ||
label="Dev Console" | ||
component={Link} | ||
href="/terminal" | ||
/> | ||
<SideBarTreeItem | ||
label="Backup" | ||
component={Link} | ||
href="/backup-recovery-phrase/write-down" | ||
/> | ||
</SideBarTree> | ||
|
||
<SideBarItem | ||
visual={<MonoSwapHoriz />} | ||
label="Transfer" | ||
component={Link} | ||
href="/transfer" | ||
/> | ||
|
||
<SideBarItem | ||
visual={<MonoContacts />} | ||
label="Contacts" | ||
component={Link} | ||
href="/contacts" | ||
/> | ||
</> | ||
} | ||
context={ | ||
<> | ||
<SideBarItemsInline> | ||
<SideBarItem visual={<MonoContacts />} label="Profile"> | ||
<ContextMenu | ||
trigger={ | ||
<Button | ||
isCompact={!isExpanded} | ||
variant="outlined" | ||
endVisual={<MonoContacts />} | ||
> | ||
{isExpanded ? 'Profile' : undefined} | ||
</Button> | ||
} | ||
> | ||
<ContextMenuItem | ||
onClick={() => navigate('/profile')} | ||
label="Profile" | ||
/> | ||
<ContextMenuItem | ||
endVisual={<MonoLogout />} | ||
label="Logout" | ||
onClick={handleLogout} | ||
/> | ||
</ContextMenu> | ||
</SideBarItem> | ||
<SideBarItem | ||
visual={<MonoContrast />} | ||
onPress={toggleTheme} | ||
label="Change theme" | ||
> | ||
<Button | ||
variant={isExpanded ? 'transparent' : 'outlined'} | ||
onPress={() => toggleTheme()} | ||
startVisual={<MonoContrast />} | ||
isCompact={!isExpanded} | ||
/> | ||
</SideBarItem> | ||
</SideBarItemsInline> | ||
</> | ||
} | ||
></SideBarUI> | ||
); | ||
}; |
This file contains 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 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 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 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.