-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add dashboard menu * Readd components
- Loading branch information
Showing
12 changed files
with
164 additions
and
13 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
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,42 @@ | ||
import { Box, IconDashboard, Stack } from '@centrifuge/fabric' | ||
import { useIsAboveBreakpoint } from '../../utils/useIsAboveBreakpoint' | ||
import { MenuLink } from './MenuLink' | ||
import { PageLink } from './PageLink' | ||
|
||
const pages = [ | ||
{ label: 'Account', href: 'account', match: 'dashboard/account' }, | ||
{ label: 'Assets', href: 'assets', match: 'dashboard/assets' }, | ||
{ label: 'Investors', href: 'investors', match: 'dashboard/investors' }, | ||
] | ||
|
||
export function DashboardMenu() { | ||
const isLarge = useIsAboveBreakpoint('L') | ||
return ( | ||
<> | ||
{isLarge ? ( | ||
<PageLink to="/dashboard" stacked={!isLarge} exact> | ||
<IconDashboard size={['iconMedium', 'iconMedium', 'iconSmall']} /> | ||
Dashboard | ||
</PageLink> | ||
) : ( | ||
pages.map(({ href, label }) => ( | ||
<Box width="100%"> | ||
<PageLink to={`/dashboard/${href}`} stacked={!isLarge}> | ||
<IconDashboard size={['iconMedium', 'iconMedium', 'iconSmall']} /> | ||
{label} | ||
</PageLink> | ||
</Box> | ||
)) | ||
)} | ||
{isLarge && ( | ||
<Box pl={4}> | ||
<Stack as="ul" gap={1}> | ||
{pages.map(({ href, label, match }) => ( | ||
<MenuLink path={href} name={label} matchingPath={match} /> | ||
))} | ||
</Stack> | ||
</Box> | ||
)} | ||
</> | ||
) | ||
} |
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,41 @@ | ||
import { Text } from '@centrifuge/fabric' | ||
import { useLocation } from 'react-router' | ||
import { Link } from 'react-router-dom' | ||
import styled from 'styled-components' | ||
import { prefetchRoute } from '../Root' | ||
import { baseButton } from './styles' | ||
|
||
const Root = styled(Text)` | ||
${baseButton} | ||
display: block; | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
border-radius: ${({ theme }) => theme.radii.input}px; | ||
color: ${({ isActive, theme }) => (isActive ? theme.colors.textGold : theme.colors.textInverted)}; | ||
&:hover { | ||
color: ${({ isActive, theme }) => (isActive ? theme.colors.textGold : theme.colors.textGold)}; | ||
} | ||
` | ||
|
||
type MenuLinkProps = { | ||
path?: string | ||
name?: string | ||
matchingPath: string | ||
} | ||
|
||
export function MenuLink({ path = 'dashboard', name, matchingPath }: MenuLinkProps) { | ||
const location = useLocation() | ||
const match = location.pathname.includes(matchingPath) | ||
return ( | ||
<Root | ||
forwardedAs={Link} | ||
to={`/dashboard/${path}`} | ||
variant="body2" | ||
isActive={match} | ||
onMouseOver={() => prefetchRoute('/dashboard')} | ||
> | ||
{name} | ||
</Root> | ||
) | ||
} |
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 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,3 @@ | ||
export default function AccountsPage() { | ||
return <></> | ||
} |
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,3 @@ | ||
export default function AssetsPage() { | ||
return <></> | ||
} |
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,3 @@ | ||
export default function Dashboard() { | ||
return <></> | ||
} |
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,3 @@ | ||
export default function InvestorsPage() { | ||
return <></> | ||
} |
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,16 @@ | ||
import { Route, Routes } from 'react-router' | ||
import AccountsPage from './AccountsPage' | ||
import AssetsPage from './AssetsPage' | ||
import Dashboard from './Dashboard' | ||
import InvestorsPage from './InvestorsPage' | ||
|
||
export default function DashboardPage() { | ||
return ( | ||
<Routes> | ||
<Route path="/" element={<Dashboard />} /> | ||
<Route path="/accounts" element={<AccountsPage />} /> | ||
<Route path="/assets" element={<AssetsPage />} /> | ||
<Route path="/investors" element={<InvestorsPage />} /> | ||
</Routes> | ||
) | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.