Skip to content
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

Create initial pass of v2 send/receive pages #1665

Merged
merged 7 commits into from
Aug 19, 2024
Merged

Conversation

jessepinho
Copy link
Contributor

@jessepinho jessepinho commented Aug 9, 2024

First of all, sorry for the huge PR 😭 I was working on a lot of moving parts at once, and they're all a bit intertwined, and I wasn't able to separate them out in time.

Also, a lot of the diffs in this PR involve whitespace changes due to nesting, etc. So I'd recommend reviewing it with whitespace changes hidden.

In this PR

  • Introduce a new useAnimationDeferredValue() hook that prevents glitches in an animation if data loads while the animation is still in progress.
  • Use that hook in several places.
  • Convert components that previously accepted framer-motion layout and layoutId props to instead accept a motion prop that can accept an object of framer-motion props (docs).
  • Tweak <SegmentedControl /> to allow arbitrary value types, not just string values. This makes the component much more flexible/powerful.
  • Allow color to be set directly on both the <Text /> and <Icon /> components via a callback — e.g., <Text color={color => color.text.primary}>...</Text>
  • Add the new detailTechnical text variant.
  • Create v2 send/receive pages. Note that they're not finished yet — the asset selector isn't yet in place, for example.
  • Create the new <AssetSelector /> component. Not 100% finished yet, but can still be merged and iterated on.
  • Add Storybook links to the Penumbra UI README.
  • Create the <Tooltip /> component.
  • Add motion prop to <Table /> and <Card />.
  • Make it possible to animate a <Dialog /> out of its trigger (could use some de-janking):
Screen.Recording.2024-08-16.at.8.21.34.PM.mov

Copy link

changeset-bot bot commented Aug 9, 2024

🦋 Changeset detected

Latest commit: 46dc416

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@penumbra-zone/getters Major
minifront Patch
@penumbra-zone/perspective Major
@penumbra-zone/query Major
@penumbra-zone/services Major
@penumbra-zone/storage Major
@penumbra-zone/types Major
@repo/ui Patch
node-status Patch
@penumbra-zone/crypto-web Major
@penumbra-zone/wasm Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Aug 9, 2024

Visit the preview URL for this PR (updated for commit 46dc416):

https://penumbra-ui-preview--pr1665-jessepinho-transfer-qsdpwkgt.web.app

(expires Mon, 26 Aug 2024 11:55:55 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 709d729610ef7a6369b23f1cb2b820a60cc685b1

@jessepinho jessepinho changed the base branch from main to jessepinho/input August 9, 2024 17:36
Base automatically changed from jessepinho/input to main August 9, 2024 17:42
@jessepinho jessepinho force-pushed the jessepinho/transfer branch 6 times, most recently from 37c22f8 to c5f034e Compare August 10, 2024 04:21
@jessepinho jessepinho changed the base branch from main to jessepinho/more-v2-components August 10, 2024 04:22
@jessepinho jessepinho force-pushed the jessepinho/more-v2-components branch from 97f1285 to 75ddb24 Compare August 12, 2024 23:23
Base automatically changed from jessepinho/more-v2-components to main August 12, 2024 23:31
@jessepinho jessepinho force-pushed the jessepinho/transfer branch 3 times, most recently from 848012e to 5aa3c78 Compare August 13, 2024 16:00
@jessepinho jessepinho force-pushed the jessepinho/transfer branch 2 times, most recently from 7c48de7 to 5ada544 Compare August 17, 2024 02:26
import { GasFee } from '../../shared/gas-fee';
import { useBalancesResponses, useStakingTokenMetadata } from '../../../state/shared';
import { NonNativeFeeWarning } from '../../shared/non-native-fee-warning';
import { transferableBalancesResponsesSelector } from '../../../state/send/helpers';
import { useRefreshFee } from '../../v2/transfer-layout/send-page/use-refresh-fee';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I deleted the use-refresh-fee.ts file from the v1 directory, and moved it to the v2 directory. Now, we're "reaching into" the v2 directory from v1 to import its logic.

I think this is a good approach for logic-heavy files (like hooks, etc.), since eventually, we'll want to just delete all the v1 code and move the v2 code up into src. At that point, if we've already moved all the v1 hooks/etc. into the v2 directory, the migration will be a cinch.

And in the meantime, we don't need to maintain two copies of each hook file (i.e., we don't have to have a copy of use-refresh-fee.ts in both the v1 src directory, and the v2 directory).

@@ -6,7 +6,7 @@ import { ReactNode, useCallback, useEffect, useState } from 'react';
import {
getAddressIndex,
getAmount,
getAssetIdFromBalancesResponseOptional,
getAssetIdFromBalancesResponse,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got rid of the optional one, since we can now just call .optional() on it.

</Dialog>
</div>
);
export const AssetsCardTitle = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to review this file with whitespace changes hidden. I just added a useId() call, and then passed it to the dialog trigger and content to make the dialog "grow out of" the info icon.

</Dialog>
</div>
);
export const TransactionsCardTitle = () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to review this file with whitespace changes hidden. I just added a useId() call, and then passed it to the dialog trigger and content to make the dialog "grow out of" the info icon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in this file relate to transitions between the assets and transactions pages, and use the useAnimationDeferredValue hook (docs).

.optional()
.pipe(getMetadata)
.pipe(getAssetId);
export const getAssetIdFromBalancesResponse = getBalanceView.pipe(getMetadata).pipe(getAssetId);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can now just call .optional() on this, so no need to hard-code an optional version.

import { PenumbraUIProvider } from '../src/PenumbraUIProvider';
import { Density } from '../src/Density';
import { Tabs } from '../src/Tabs';
import styled from 'styled-components';

const WhiteTextWrapper = styled.div`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All <Text /> components now render with text.primary color by default, so this is no longer needed.

@@ -21,6 +21,7 @@
"./lib/utils": "./lib/utils.ts",
"./postcss.config.js": "./postcss.config.js",
"./styles/*": "./styles/*",
"./hooks/*": "./src/hooks/*/index.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that consumers can import our hooks

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a tooltip to the IBC Deposit toggle

Comment on lines +9 to +14
const BorderWrapper = styled.div`
border-radius: ${props => props.theme.borderRadius.full};
border: 1px solid ${props => props.theme.color.other.tonalStroke};
overflow: hidden;
`;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should now be a border on <AssetIcon />, per latest Figma designs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the entire <AssetIcon /> component up to the root src directory, since it's now used by multiple other components in Penumbra UI (and can be used by consumers).


const iconOnlyAdornment = css<StyledButtonProps>`
border-radius: ${props => props.theme.borderRadius.full};
padding: ${props => props.theme.spacing(1)};
width: max-content;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes a weird issue where the button was sometimes full-width when it shouldn't have been

@@ -28,6 +31,7 @@ const compact = css<StyledButtonProps>`
padding-right: ${props => props.theme.spacing(props.$iconOnly ? 2 : 4)};
height: 32px;
min-width: 32px;
width: max-content;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes a weird issue where the button was sometimes full-width when it shouldn't have been

@@ -57,7 +61,7 @@ interface StyledButtonProps {
$getBorderRadius: (theme: DefaultTheme) => string;
}

const StyledButton = styled.button<StyledButtonProps>`
const StyledButton = styled(motion.button)<StyledButtonProps>`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling framer motion on the button

Comment on lines +5 to +7
const WhiteTextWrapper = styled.div`
color: ${props => props.theme.color.text.primary};
`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WhiteTextWrapper is required for this story, since <CharacterTransition /> is unstyled text, and I didn't want to wrap this story in a <Text /> or else consumers might think that it was styled out of the box.

@@ -11,10 +11,10 @@ const Root = styled.label`
`;

const HelperText = styled.div<{ $disabled: boolean }>`
${small}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this to before color, since small now has its own color styles

@@ -20,6 +20,7 @@ const Root = styled.span<{ $density: Density; $priority: Priority }>`
display: inline-block;
max-width: 100%;
width: max-content;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prevents a weird issue where the pill is sometimes full-width

/** Content that will appear above the table. */
title?: ReactNode;
children: ReactNode;
/** Which CSS `table-layout` property to use. */
layout?: 'fixed' | 'auto';
tableLayout?: 'fixed' | 'auto';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed this prop to avoid confusion with framer-motion's layout prop

@jessepinho jessepinho changed the title WIP: Create v2 send/receive pages Create v2 send/receive pages Aug 17, 2024
@jessepinho jessepinho marked this pull request as ready for review August 17, 2024 03:26
@jessepinho jessepinho requested a review from a team August 17, 2024 03:26
@jessepinho jessepinho changed the title Create v2 send/receive pages Create initial pass of v2 send/receive pages Aug 17, 2024
@VanishMax VanishMax self-assigned this Aug 19, 2024
Copy link
Contributor

@VanishMax VanishMax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grod220 I am going to merge this PR and continue the work over this code. Any objections?

This is how the PR looks in action:

kap.mp4

The future work includes adding the AssetSelector and moving some more logic here

@grod220
Copy link
Collaborator

grod220 commented Aug 19, 2024

Go for it! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants