From ac920a02c864bc97c294c45708540b814aa145ae Mon Sep 17 00:00:00 2001 From: Tal Derei Date: Fri, 22 Nov 2024 00:58:14 -0800 Subject: [PATCH 1/8] use valueViewComponent from ui library --- apps/extension/package.json | 1 + packages/ui/components/ui/tx/action-view.tsx | 2 ++ .../ui/tx/actions-views/delegator-vote.tsx | 15 +++++++-- .../components/ui/tx/actions-views/output.tsx | 15 +++++++-- .../components/ui/tx/actions-views/spend.tsx | 15 +++++++-- .../ui/tx/actions-views/swap/index.tsx | 27 ++++++++++++++-- .../ui/tx/actions-views/swap/one-way-swap.tsx | 31 ++++++++++++++++--- .../ui/tx/actions-views/swap/swap-claim.tsx | 27 ++++++++++++++-- .../progress-bar/index.tsx | 28 ++++++++++++++--- packages/ui/components/ui/tx/index.tsx | 15 +++++++-- packages/ui/package.json | 1 + 11 files changed, 154 insertions(+), 23 deletions(-) diff --git a/apps/extension/package.json b/apps/extension/package.json index 1cf201ee..cbb6906b 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -32,6 +32,7 @@ "@penumbra-zone/transport-chrome": "8.0.1", "@penumbra-zone/transport-dom": "7.5.0", "@penumbra-zone/types": "26.1.0", + "@penumbra-zone/ui": "13.3.1", "@penumbra-zone/wasm": "32.0.0", "@radix-ui/react-icons": "^1.3.0", "@repo/context": "workspace:*", diff --git a/packages/ui/components/ui/tx/action-view.tsx b/packages/ui/components/ui/tx/action-view.tsx index 79c0b0a9..94838ef7 100644 --- a/packages/ui/components/ui/tx/action-view.tsx +++ b/packages/ui/components/ui/tx/action-view.tsx @@ -61,6 +61,8 @@ const getLabelForActionCase = (actionCase: ActionView['actionView']['case']): st return String(actionCase); }; +// note: ensure to update the ValueViewComponent to handle unimplemented views +// once support for them is added. export const ActionViewComponent = ({ av: { actionView }, feeValueView, diff --git a/packages/ui/components/ui/tx/actions-views/delegator-vote.tsx b/packages/ui/components/ui/tx/actions-views/delegator-vote.tsx index de2b6ade..da465712 100644 --- a/packages/ui/components/ui/tx/actions-views/delegator-vote.tsx +++ b/packages/ui/components/ui/tx/actions-views/delegator-vote.tsx @@ -1,5 +1,6 @@ import { ViewBox } from '../viewbox'; -import { ValueViewComponent } from '../../value'; +import { ValueViewComponent } from '@penumbra-zone/ui/ValueView'; +import { Density } from '@penumbra-zone/ui/Density'; import { getAddress } from '@penumbra-zone/getters/note-view'; import { ActionDetails } from './action-details'; import { @@ -116,7 +117,17 @@ const VoteBodyDetails = ({ body }: { body?: DelegatorVoteBody }) => { )} {!!body?.unbondedAmount && ( - + +
+ +
+
)} diff --git a/packages/ui/components/ui/tx/actions-views/output.tsx b/packages/ui/components/ui/tx/actions-views/output.tsx index 8c525842..dac09870 100644 --- a/packages/ui/components/ui/tx/actions-views/output.tsx +++ b/packages/ui/components/ui/tx/actions-views/output.tsx @@ -1,6 +1,7 @@ import { OutputView } from '@penumbra-zone/protobuf/penumbra/core/component/shielded_pool/v1/shielded_pool_pb'; import { ViewBox } from '../viewbox'; -import { ValueViewComponent } from '../../value'; +import { ValueViewComponent } from '@penumbra-zone/ui/ValueView'; +import { Density } from '@penumbra-zone/ui/Density'; import { ValueWithAddress } from './value-with-address'; import { getNote } from '@penumbra-zone/getters/output-view'; import { getAddress } from '@penumbra-zone/getters/note-view'; @@ -15,7 +16,17 @@ export const OutputViewComponent = ({ value }: { value: OutputView }) => { label='Output' visibleContent={ - + +
+ +
+
} /> diff --git a/packages/ui/components/ui/tx/actions-views/spend.tsx b/packages/ui/components/ui/tx/actions-views/spend.tsx index 47254b1c..ea0ea878 100644 --- a/packages/ui/components/ui/tx/actions-views/spend.tsx +++ b/packages/ui/components/ui/tx/actions-views/spend.tsx @@ -1,6 +1,7 @@ import { SpendView } from '@penumbra-zone/protobuf/penumbra/core/component/shielded_pool/v1/shielded_pool_pb'; import { ViewBox } from '../viewbox'; -import { ValueViewComponent } from '../../value'; +import { ValueViewComponent } from '@penumbra-zone/ui/ValueView'; +import { Density } from '@penumbra-zone/ui/Density'; import { ValueWithAddress } from './value-with-address'; import { getNote } from '@penumbra-zone/getters/spend-view'; import { getAddress } from '@penumbra-zone/getters/note-view'; @@ -15,7 +16,17 @@ export const SpendViewComponent = ({ value }: { value: SpendView }) => { label='Spend' visibleContent={ - + +
+ +
+
} /> diff --git a/packages/ui/components/ui/tx/actions-views/swap/index.tsx b/packages/ui/components/ui/tx/actions-views/swap/index.tsx index aab630b1..b183e8c0 100644 --- a/packages/ui/components/ui/tx/actions-views/swap/index.tsx +++ b/packages/ui/components/ui/tx/actions-views/swap/index.tsx @@ -9,7 +9,8 @@ import { getClaimFeeFromSwapView, getClaimTx, } from '@penumbra-zone/getters/swap-view'; -import { ValueViewComponent } from '../../../value'; +import { ValueViewComponent } from '@penumbra-zone/ui/ValueView'; +import { Density } from '@penumbra-zone/ui/Density'; import { ActionDetails } from '../action-details'; import { ValueView } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb'; @@ -48,13 +49,33 @@ export const SwapViewComponent = ({ {oneWaySwap?.unfilled && ( - + +
+ +
+
)}
- + +
+ +
+
diff --git a/packages/ui/components/ui/tx/actions-views/swap/one-way-swap.tsx b/packages/ui/components/ui/tx/actions-views/swap/one-way-swap.tsx index 6fa0c7f7..649176ab 100644 --- a/packages/ui/components/ui/tx/actions-views/swap/one-way-swap.tsx +++ b/packages/ui/components/ui/tx/actions-views/swap/one-way-swap.tsx @@ -1,7 +1,8 @@ -import { ValueViewComponent } from '../../../value'; +import { ValueViewComponent } from '@penumbra-zone/ui/ValueView'; +import { Density } from '@penumbra-zone/ui/Density'; import { ArrowRight } from 'lucide-react'; import { ValueView } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb'; -import { getAmount } from '@penumbra-zone/getters/value-view'; +// import { getAmount } from '@penumbra-zone/getters/value-view'; /** * Renders a one-way swap (which should be the only kind of swap that ever @@ -10,15 +11,35 @@ import { getAmount } from '@penumbra-zone/getters/value-view'; * 1.23INPUT -> 4.56OUTPUT */ export const OneWaySwap = ({ input, output }: { input: ValueView; output: ValueView }) => { - const outputAmount = getAmount.optional(output); + // const outputAmount = getAmount.optional(output); return (
- + +
+ +
+
- + +
+ +
+
); }; diff --git a/packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx b/packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx index 749d109c..d0513d59 100644 --- a/packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx +++ b/packages/ui/components/ui/tx/actions-views/swap/swap-claim.tsx @@ -10,7 +10,8 @@ import { import { getAmount } from '@penumbra-zone/getters/value-view'; import { getAmount as getAmountFee } from '@penumbra-zone/getters/fee'; import { isZero, joinLoHiAmount } from '@penumbra-zone/types/amount'; -import { ValueViewComponent } from '../../../value'; +import { ValueViewComponent } from '@penumbra-zone/ui/ValueView'; +import { Density } from '@penumbra-zone/ui/Density'; import { Amount } from '@penumbra-zone/protobuf/penumbra/core/num/v1/num_pb'; const getClaimLabel = ( @@ -44,10 +45,30 @@ export const SwapClaimViewComponent = ({ value }: { value: SwapClaimView }) => {
{output1Amount && !isZero(output1Amount) && ( - + +
+ +
+
)} {output2Amount && !isZero(output2Amount) && ( - + +
+ +
+
)}
diff --git a/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/index.tsx b/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/index.tsx index 117d840d..d102cb05 100644 --- a/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/index.tsx +++ b/packages/ui/components/ui/tx/dutch-auction-component/progress-bar/index.tsx @@ -1,5 +1,6 @@ import { Metadata } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb'; -import { ValueViewComponent } from '../../../value'; +import { ValueViewComponent } from '@penumbra-zone/ui/ValueView'; +import { Density } from '@penumbra-zone/ui/Density'; import { DutchAuction } from '@penumbra-zone/protobuf/penumbra/core/component/auction/v1/auction_pb'; import { Separator } from '../../../separator'; import { Indicator } from './indicator'; @@ -41,8 +42,17 @@ export const ProgressBar = ({ return (
- - + +
+ +
+
{!auctionIsUpcoming && ( @@ -84,7 +94,17 @@ export const ProgressBar = ({
{outputMetadata && ( - + +
+ +
+
)}
); diff --git a/packages/ui/components/ui/tx/index.tsx b/packages/ui/components/ui/tx/index.tsx index aaf0d8b2..b07b270c 100644 --- a/packages/ui/components/ui/tx/index.tsx +++ b/packages/ui/components/ui/tx/index.tsx @@ -7,7 +7,8 @@ import { Metadata, ValueView, } from '@penumbra-zone/protobuf/penumbra/core/asset/v1/asset_pb'; -import { ValueViewComponent } from '../value'; +import { ValueViewComponent } from '@penumbra-zone/ui/ValueView'; +import { Density } from '@penumbra-zone/ui/Density'; import { useEffect, useState } from 'react'; // Likely something that calls the registry or view service for metadata @@ -76,7 +77,17 @@ export const TransactionViewComponent = ({ label='Transaction Fee' visibleContent={
- + +
+ +
+
{isLoading && Loading...} {error ? ( Error: {String(error)} diff --git a/packages/ui/package.json b/packages/ui/package.json index 9f2e4c8e..8189c0b9 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -36,6 +36,7 @@ "@penumbra-zone/protobuf": "6.3.0", "@penumbra-zone/types": "26.1.0", "@penumbra-zone/wasm": "32.0.0", + "@penumbra-zone/ui": "13.3.1", "@radix-ui/react-avatar": "^1.1.0", "@radix-ui/react-checkbox": "^1.1.1", "@radix-ui/react-dialog": "1.1.1", From 0a8034a20e055127ba995ff069c542b18b49e60c Mon Sep 17 00:00:00 2001 From: Tal Derei Date: Fri, 22 Nov 2024 08:09:03 -0800 Subject: [PATCH 2/8] manual css --- apps/extension/package.json | 1 - .../routes/popup/approval/approve-deny.tsx | 19 +++++-- .../popup/approval/transaction/index.tsx | 23 ++++++--- .../popup/approval/transaction/view-tabs.tsx | 2 +- .../extension/src/routes/popup/home/index.tsx | 6 +-- packages/ui/components/ui/tabs/index.tsx | 1 + packages/ui/components/ui/tx/action-view.tsx | 2 - .../ui/tx/actions-views/delegator-vote.tsx | 15 +----- .../components/ui/tx/actions-views/output.tsx | 22 +++----- .../components/ui/tx/actions-views/spend.tsx | 22 +++----- .../ui/tx/actions-views/swap/index.tsx | 27 ++-------- .../ui/tx/actions-views/swap/one-way-swap.tsx | 50 +++++++------------ .../ui/tx/actions-views/swap/swap-claim.tsx | 27 ++-------- .../progress-bar/index.tsx | 28 ++--------- packages/ui/components/ui/tx/index.tsx | 21 ++------ packages/ui/components/ui/tx/memo-view.tsx | 4 +- packages/ui/components/ui/tx/viewbox.tsx | 31 ++++++------ packages/ui/package.json | 1 - 18 files changed, 102 insertions(+), 200 deletions(-) diff --git a/apps/extension/package.json b/apps/extension/package.json index cbb6906b..1cf201ee 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -32,7 +32,6 @@ "@penumbra-zone/transport-chrome": "8.0.1", "@penumbra-zone/transport-dom": "7.5.0", "@penumbra-zone/types": "26.1.0", - "@penumbra-zone/ui": "13.3.1", "@penumbra-zone/wasm": "32.0.0", "@radix-ui/react-icons": "^1.3.0", "@repo/context": "workspace:*", diff --git a/apps/extension/src/routes/popup/approval/approve-deny.tsx b/apps/extension/src/routes/popup/approval/approve-deny.tsx index 88aa94bf..0a98c625 100644 --- a/apps/extension/src/routes/popup/approval/approve-deny.tsx +++ b/apps/extension/src/routes/popup/approval/approve-deny.tsx @@ -15,12 +15,21 @@ export const ApproveDeny = ({ const count = useWindowCountdown(wait); return ( -
- {ignore && (