-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the segmented picker animated (#1167)
* Make the segmented picker animated * Add comment * Extract a helpfully named component * Hide the duplicate text * Fix tests * Add changeset * Set short duration for motion transitions * Animate top tabs
- Loading branch information
1 parent
b8c8749
commit 5b80e7c
Showing
9 changed files
with
142 additions
and
60 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 @@ | ||
--- | ||
'@penumbra-zone/ui': minor | ||
--- | ||
|
||
Add animations to SegmentedPicker |
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
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 |
---|---|---|
@@ -1,37 +1,45 @@ | ||
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@penumbra-zone/ui/components/ui/tabs'; | ||
import { JsonViewer } from '@penumbra-zone/ui/components/ui/json-viewer'; | ||
import { TransactionViewComponent } from '@penumbra-zone/ui/components/ui/tx/view/transaction'; | ||
import { TxDetailsLoaderResult } from '.'; | ||
import { TransactionInfo } from '@buf/penumbra-zone_penumbra.bufbuild_es/penumbra/view/v1/view_pb'; | ||
import type { Jsonified } from '@penumbra-zone/types/jsonified'; | ||
import { viewFromEmptyPerspective } from '@penumbra-zone/perspective/transaction/perspective'; | ||
import { useState } from 'react'; | ||
import { SegmentedPicker } from '@penumbra-zone/ui/components/ui/segmented-picker'; | ||
|
||
export enum TxDetailsTab { | ||
PUBLIC = 'public', | ||
PRIVATE = 'private', | ||
} | ||
|
||
const OPTIONS = [ | ||
{ label: 'Your View', value: TxDetailsTab.PRIVATE }, | ||
{ label: 'Public View', value: TxDetailsTab.PUBLIC }, | ||
]; | ||
|
||
export const TxViewer = ({ txInfo, hash }: TxDetailsLoaderResult) => { | ||
const [option, setOption] = useState(TxDetailsTab.PRIVATE); | ||
|
||
return ( | ||
<div> | ||
<div className='text-xl font-bold'>Transaction View</div> | ||
<div className='mb-8 break-all font-mono italic text-muted-foreground'>{hash}</div> | ||
<Tabs defaultValue={TxDetailsTab.PRIVATE}> | ||
<TabsList className='mx-auto grid w-3/4 grid-cols-2 gap-4 xl:w-[372px]'> | ||
<TabsTrigger value={TxDetailsTab.PRIVATE}>Your View</TabsTrigger> | ||
<TabsTrigger value={TxDetailsTab.PUBLIC}>Public View</TabsTrigger> | ||
</TabsList> | ||
<TabsContent value={TxDetailsTab.PRIVATE}> | ||
|
||
<div className='mx-auto mb-4 max-w-[70%]'> | ||
<SegmentedPicker options={OPTIONS} value={option} onChange={setOption} grow size='lg' /> | ||
</div> | ||
{option === TxDetailsTab.PRIVATE && ( | ||
<> | ||
<TransactionViewComponent txv={txInfo.view!} /> | ||
<div className='mt-8'> | ||
<div className='text-xl font-bold'>Raw JSON</div> | ||
<JsonViewer jsonObj={txInfo.toJson() as Jsonified<TransactionInfo>} /> | ||
</div> | ||
</TabsContent> | ||
<TabsContent value={TxDetailsTab.PUBLIC} className='mt-10'> | ||
<TransactionViewComponent txv={viewFromEmptyPerspective(txInfo.transaction!)} /> | ||
</TabsContent> | ||
</Tabs> | ||
</> | ||
)} | ||
{option === TxDetailsTab.PUBLIC && ( | ||
<TransactionViewComponent txv={viewFromEmptyPerspective(txInfo.transaction!)} /> | ||
)} | ||
</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
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