-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(minifront, ui): #1732: v2 header #1734
Merged
Merged
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
7022071
feat(minifront): #1732: add support for react-svgr vite plugin
VanishMax 7fa48a3
refactor(minifront): #1732: externalize `getV2Link` function
VanishMax 7cbdc75
feat(minifront): #1732: implement basic header with prax wallet info
VanishMax 3bb2366
feat(ui): #1732: fix button and dialog styles
VanishMax f4f1a2e
feat(minifront): #1732: implement basic mobile nav dialog
VanishMax 2eba608
feat(ui): #1732: update Tabs component to support compact version
VanishMax 0fe79bd
feat(ui): #1732: apply v2 colors to tailwind theme
VanishMax 79f30bc
feat(UI): #1732: Implement MenuItem component
VanishMax 3fe08c1
feat(minifront): #1732: use MenuItem to create mobile nav
VanishMax e750454
feat(ui): #1732: add Progress UI component
VanishMax 1d03070
feat(minifront): #1732: display sync bar on the top
VanishMax d5247dc
feat(ui): #1732: update Pill component to support context prop
VanishMax 9f9081e
feat(minifront): #1732: apply updated Pill to the status popover
VanishMax 2f10be8
fix: prettier
VanishMax c0c851f
chore: changeset
VanishMax 472b7fa
Merge remote-tracking branch 'origin/main' into feat/#1732-v2-header
VanishMax 1098add
fix: update paths after rebase
VanishMax 48a46a6
fix: syncpack
VanishMax 5c51d9f
fix: ts
VanishMax ab7a56b
fix(minifront): #1732: fix after the review
VanishMax 0874073
fix(ui): externalize `getAllEntries` function
VanishMax 078fc7f
Merge remote-tracking branch 'origin/main' into feat/#1732-v2-header
VanishMax 15acfb0
fix(minifront): #1732: refactor the manifest usage
VanishMax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,22 @@ | ||
--- | ||
'@repo/tailwind-config': minor | ||
'minifront': minor | ||
'@penumbra-zone/ui': minor | ||
--- | ||
|
||
UI: | ||
|
||
- Add new `Progress` component | ||
- Add `MenuItem` component that shares the styles with `DropdownMenu.Item` | ||
- Update the `Pill` component to support `context` prop | ||
- Update the `Tabs` component to support the `compact` density | ||
- Allow passing custom icons to the `Button` | ||
- Fix `density` tag in Storybook | ||
|
||
Tailwind Config: | ||
|
||
- Add support for v2 colors with v2 prefix like `bg-v2-secondary-dark` | ||
|
||
Minifront: | ||
|
||
- Add top navigation to the v2 minifront with sync bar and prax connection infos |
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
2 changes: 1 addition & 1 deletion
2
apps/minifront/src/components/syncing-dialog/sync-animation.tsx
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,4 @@ | ||
import type { PagePath } from '../metadata/paths.ts'; | ||
|
||
/** @todo: Remove this function and its uses after we switch to v2 layout */ | ||
export const getV2Link = (path: PagePath) => `/v2${path}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thought: maybe instead of manipulating strings to create paths, we should rely on utilities provided by the router https://reactrouter.com/en/main/hooks/use-resolved-path not a task for this PR |
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,24 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import { Tabs } from '@penumbra-zone/ui/Tabs'; | ||
import { Density } from '@penumbra-zone/ui/Density'; | ||
import { getV2Link } from '../get-v2-link.ts'; | ||
import { usePagePath } from '../../../fetchers/page-path.ts'; | ||
import { HEADER_LINKS } from './links.ts'; | ||
|
||
export const DesktopNav = () => { | ||
const pagePath = usePagePath(); | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<nav className='hidden rounded-full bg-v2-other-tonalFill5 px-4 py-1 backdrop-blur-xl lg:flex'> | ||
<Density compact> | ||
<Tabs | ||
value={getV2Link(pagePath)} | ||
onChange={value => navigate(value)} | ||
options={HEADER_LINKS} | ||
actionType='accent' | ||
/> | ||
</Density> | ||
</nav> | ||
); | ||
}; |
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,26 @@ | ||
import { Density } from '@penumbra-zone/ui/Density'; | ||
import { HeaderLogo } from './logo.tsx'; | ||
import { ProviderPopover } from './provider-popover.tsx'; | ||
import { StatusPopover } from './status-popover.tsx'; | ||
import { MobileNav } from './mobile-nav.tsx'; | ||
import { DesktopNav } from './desktop-nav.tsx'; | ||
|
||
export const Header = () => { | ||
return ( | ||
<header className='flex items-center justify-between py-5'> | ||
<HeaderLogo /> | ||
|
||
<DesktopNav /> | ||
|
||
<Density compact> | ||
<div className='hidden gap-2 lg:flex'> | ||
<StatusPopover /> | ||
<ProviderPopover /> | ||
</div> | ||
<div className='block lg:hidden'> | ||
<MobileNav /> | ||
</div> | ||
</Density> | ||
</header> | ||
); | ||
}; |
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,11 @@ | ||
import { Shield, MoonStar, ArrowLeftRight, ArrowUpFromDot, Coins } from 'lucide-react'; | ||
import { getV2Link } from '../get-v2-link.ts'; | ||
import { PagePath } from '../../metadata/paths.ts'; | ||
|
||
export const HEADER_LINKS = [ | ||
{ label: 'Dashboard', value: getV2Link(PagePath.DASHBOARD), icon: Coins }, | ||
{ label: 'Shield', value: getV2Link(PagePath.IBC), icon: Shield }, | ||
{ label: 'Transfer', value: getV2Link(PagePath.SEND), icon: ArrowUpFromDot }, | ||
{ label: 'Swap', value: getV2Link(PagePath.SWAP), icon: ArrowLeftRight }, | ||
{ label: 'Stake', value: getV2Link(PagePath.STAKING), icon: MoonStar }, | ||
]; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 @@ | ||
import { Link } from 'react-router-dom'; | ||
import { PagePath } from '../../metadata/paths.ts'; | ||
import { getV2Link } from '../get-v2-link.ts'; | ||
import PenumbraLogo from './logo.svg'; | ||
|
||
export const HeaderLogo = () => { | ||
return ( | ||
<Link className='flex h-8 items-center' to={getV2Link(PagePath.INDEX)}> | ||
<PenumbraLogo /> | ||
</Link> | ||
); | ||
}; |
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,57 @@ | ||
import { Menu, X } from 'lucide-react'; | ||
import { Button } from '@penumbra-zone/ui/Button'; | ||
import { Dialog } from '@penumbra-zone/ui/Dialog'; | ||
import { Display } from '@penumbra-zone/ui/Display'; | ||
import { MenuItem } from '@penumbra-zone/ui/MenuItem'; | ||
import { StatusPopover } from './status-popover.tsx'; | ||
import { ProviderPopover } from './provider-popover.tsx'; | ||
import { HeaderLogo } from './logo.tsx'; | ||
import { useState } from 'react'; | ||
import { HEADER_LINKS } from './links.ts'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export const MobileNav = () => { | ||
const navigate = useNavigate(); | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const onNavigate = (link: string) => { | ||
navigate(link); | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<Dialog isOpen={isOpen} onClose={() => setIsOpen(false)}> | ||
<Button iconOnly icon={Menu} onClick={() => setIsOpen(true)}> | ||
Menu | ||
</Button> | ||
<Dialog.EmptyContent> | ||
<div className='pointer-events-auto h-full overflow-hidden bg-black'> | ||
<Display> | ||
<nav className='flex items-center justify-between py-5'> | ||
<HeaderLogo /> | ||
|
||
<div className='flex gap-2'> | ||
<StatusPopover /> | ||
<ProviderPopover /> | ||
<Button iconOnly icon={X} onClick={() => setIsOpen(false)}> | ||
Close | ||
</Button> | ||
</div> | ||
</nav> | ||
|
||
<div className='flex flex-col gap-4'> | ||
{HEADER_LINKS.map(link => ( | ||
<MenuItem | ||
key={link.value} | ||
label={link.label} | ||
icon={link.icon} | ||
onClick={() => onNavigate(link.value)} | ||
/> | ||
))} | ||
</div> | ||
</Display> | ||
</div> | ||
</Dialog.EmptyContent> | ||
</Dialog> | ||
); | ||
}; |
51 changes: 51 additions & 0 deletions
51
apps/minifront/src/components/v2/header/provider-popover.tsx
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,51 @@ | ||
import { useMemo } from 'react'; | ||
import { Link2Off } from 'lucide-react'; | ||
import { Popover } from '@penumbra-zone/ui/Popover'; | ||
import { Button } from '@penumbra-zone/ui/Button'; | ||
import { Text } from '@penumbra-zone/ui/Text'; | ||
import { penumbra, usePraxManifest } from '../../../prax.ts'; | ||
|
||
export const ProviderPopover = () => { | ||
const manifest = usePraxManifest(); | ||
|
||
const icon = useMemo(() => { | ||
const icons = manifest?.icons; | ||
const blob = icons?.['32'] ?? icons?.['128']; | ||
const name = manifest?.['name'] as string; | ||
const element = !blob ? null : ( | ||
<img src={URL.createObjectURL(blob)} alt={name} className='size-4' /> | ||
); | ||
return () => element; | ||
}, [manifest]); | ||
|
||
const disconnect = () => { | ||
void penumbra.disconnect().then(() => window.location.reload()); | ||
}; | ||
|
||
return ( | ||
<Popover> | ||
<Popover.Trigger> | ||
<Button icon={icon} iconOnly> | ||
{manifest?.['name'] ?? ''} | ||
</Button> | ||
</Popover.Trigger> | ||
<Popover.Content align='end' side='bottom'> | ||
{manifest ? ( | ||
<div className='flex flex-col gap-2'> | ||
<Text body> | ||
{manifest['name']} v{manifest['version']} | ||
</Text> | ||
<Text small>{manifest['description']}</Text> | ||
</div> | ||
) : ( | ||
<Text body>Loading provider manifest...</Text> | ||
)} | ||
<div className='mt-4'> | ||
<Button icon={Link2Off} onClick={disconnect}> | ||
Disconnect | ||
</Button> | ||
</div> | ||
</Popover.Content> | ||
</Popover> | ||
); | ||
}; |
61 changes: 61 additions & 0 deletions
61
apps/minifront/src/components/v2/header/status-popover.tsx
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,61 @@ | ||
import { Blocks } from 'lucide-react'; | ||
import { Popover } from '@penumbra-zone/ui/Popover'; | ||
import { Button } from '@penumbra-zone/ui/Button'; | ||
import { Density } from '@penumbra-zone/ui/Density'; | ||
import { Pill } from '@penumbra-zone/ui/Pill'; | ||
import { Text } from '@penumbra-zone/ui/Text'; | ||
import { statusSelector, useStatus } from '../../../state/status.ts'; | ||
import { useMemo } from 'react'; | ||
|
||
export const StatusPopover = () => { | ||
const status = useStatus({ | ||
select: statusSelector, | ||
}); | ||
|
||
const pill = useMemo(() => { | ||
turbocrime marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (status?.isCatchingUp === undefined) { | ||
return null; | ||
} | ||
|
||
if (status.error) { | ||
return <Pill context='technical-destructive'>Block Sync Error</Pill>; | ||
} | ||
|
||
if (status.percentSyncedNumber === 1) { | ||
return <Pill context='technical-success'>Blocks Synced</Pill>; | ||
} | ||
|
||
return <Pill context='technical-caution'>Block Syncing</Pill>; | ||
}, [status]); | ||
|
||
return ( | ||
<Popover> | ||
<Popover.Trigger> | ||
<Button icon={Blocks} iconOnly> | ||
Status | ||
</Button> | ||
</Popover.Trigger> | ||
{status?.isCatchingUp !== undefined && ( | ||
<Popover.Content align='end' side='bottom'> | ||
<Density compact> | ||
<div className='flex flex-col gap-4'> | ||
<div className='flex flex-col gap-2'> | ||
<Text technical>Status</Text> | ||
{pill} | ||
{!!status.error && String(status.error)} | ||
</div> | ||
<div className='flex flex-col gap-2'> | ||
<Text technical>Block Height</Text> | ||
<Pill context='technical-default'> | ||
{status.latestKnownBlockHeight !== status.fullSyncHeight | ||
? `${status.fullSyncHeight} of ${status.latestKnownBlockHeight}` | ||
: `${status.latestKnownBlockHeight}`} | ||
</Pill> | ||
</div> | ||
</div> | ||
</Density> | ||
</Popover.Content> | ||
)} | ||
</Popover> | ||
); | ||
}; |
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,22 @@ | ||
import { statusSelector, useStatus } from '../../../state/status.ts'; | ||
import { Progress } from '@penumbra-zone/ui/Progress'; | ||
|
||
export const SyncBar = () => { | ||
const status = useStatus({ | ||
select: statusSelector, | ||
}); | ||
|
||
return ( | ||
<div className='fixed left-0 top-0 h-1 w-full'> | ||
{status?.isCatchingUp === undefined ? ( | ||
<Progress value={0} loading /> | ||
) : ( | ||
<Progress | ||
value={status.percentSyncedNumber} | ||
loading={status.isUpdating} | ||
error={Boolean(status.error)} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: The old sync bar subtly provided useful information about whether the blocks were synced and the latest block height. We should consider whether this is something we want to retain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this info is now in its own popover and in the syncing dialog. Sam continues working on different states of this popover (e.g. if there's an error, colorize the popover trigger in red), so we will see more information about the syncing process later.
i'd appreciate if you could send your notes about what info about the sync should or should not be displayed to Sam
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as for the text transitions, i am personally ok about it, or maybe i got used to it. We make a poll from this question and ask the team for opinions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My 2 cents:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is sufficient for now, but we should revisit the segmented pickers for text in a future iteration of the V2 header.