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

Redesign send amount #963

Merged
merged 11 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 47 additions & 19 deletions packages/app/components/FormFields/CoinField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@ import {
Button,
FieldError,
Fieldset,
getFontSize,
isWeb,
isTouchable,
Paragraph,
Select,
type SelectProps,
Shake,
Sheet,
Spinner,
Theme,
useThemeName,
XStack,
YStack,
getFontSize,
isWeb,
useThemeName,
type SelectProps,
} from '@my/ui'
import { baseMainnet, usdcAddress } from '@my/wagmi'
import { ChevronDown, ChevronUp, CheckCircle as IconCheckCircle } from '@tamagui/lucide-icons'
import { CheckCircle as IconCheckCircle, ChevronDown, ChevronUp } from '@tamagui/lucide-icons'
import { useTsController } from '@ts-react/form'
import { IconX } from 'app/components/icons'
import formatAmount from 'app/utils/formatAmount'
import { useId, useState } from 'react'
import { IconCoin } from '../icons/IconCoin'
import type { CoinWithBalance } from 'app/data/coins'
import { useCoins } from 'app/provider/coins'

export const CoinField = ({
native = false,
...props
Expand All @@ -42,6 +44,8 @@ export const CoinField = ({
const id = useId()
const disabled = isSubmitting

const pickedCoinSymbol = coins.find((coin) => coin.token === field.value)?.symbol

return (
<Theme name={error ? 'red' : themeName} forceClassName>
<Fieldset>
Expand All @@ -58,22 +62,36 @@ export const CoinField = ({
>
<Select.Trigger
testID={'SelectCoinTrigger'}
w={106}
h={48}
br="$3"
br={0}
borderWidth={0}
scaleSpace={0}
w={'fit-content'}
scaleSpace={0.5}
scaleIcon={1.5}
hoverStyle={{ bc: '$primary' }}
bc={isOpen ? '$color2' : '$primary'}
iconAfter={isOpen ? <ChevronUp color={'$color11'} /> : <ChevronDown color="$black" />}
padding={0}
bc={'transparent'}
focusStyle={{
bc: 'transparent',
}}
iconAfter={
isOpen ? (
<ChevronUp color={'$primary'} $theme-light={{ color: '$color12' }} />
) : (
<ChevronDown color="$primary" $theme-light={{ color: '$color12' }} />
)
}
>
<Select.Value
testID={'SelectCoinValue'}
fontWeight={'bold'}
color={'$black'}
placeholder={'Token'}
/>
<XStack gap={'$2'} ai={'center'}>
{pickedCoinSymbol && <IconCoin symbol={pickedCoinSymbol} size={'$2'} />}
<Select.Value
testID={'SelectCoinValue'}
size={'$5'}
color={'$color12'}
placeholder={'Token'}
$gtSm={{
size: '$8',
}}
/>
</XStack>
</Select.Trigger>

<Adapt when="sm" platform="touch">
Expand Down Expand Up @@ -122,8 +140,18 @@ export const CoinField = ({
btrr={0}
boc="transparent"
focusStyle={{ bc: '$color0' }}
x={'-50%'}
$gtLg={{
x: 0,
}}
>
<XStack als="flex-start" w={320} $sm={{ w: '100%' }} boc={'transparent'} f={1}>
<XStack
als="flex-start"
w={320}
$sm={{ w: isTouchable ? '100%' : 320 }}
boc={'transparent'}
f={1}
>
<Select.Group disabled={disabled} space="$0">
{/* <Select.Label>{label}</Select.Label> */}
{coins.map((coin, i) => {
Expand Down
25 changes: 18 additions & 7 deletions packages/app/components/icons/IconCoin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@ import { IconEthereum } from './IconEthereum'
import { IconSend } from './IconSend'
import { IconUSDC } from './IconUSDC'
import { IconSPX6900 } from './IconSPX6900'
import type { IconProps } from '@tamagui/helpers-icon'
import type { NamedExoticComponent } from 'react'

const coinSymbolToIcons: Record<coin['symbol'], JSX.Element> = {
USDC: <IconUSDC size={'$2.5'} />,
ETH: <IconEthereum size={'$2.5'} />,
SEND: <IconSend size={'$2.5'} />,
SPX: <IconSPX6900 size={'$2.5'} />,
const coinSymbolToIcons: Record<coin['symbol'], NamedExoticComponent<IconProps>> = {
USDC: IconUSDC,
ETH: IconEthereum,
SEND: IconSend,
SPX: IconSPX6900,
}

export const IconCoin = ({ symbol }: { symbol: allCoins[number]['symbol'] }) => {
return coinSymbolToIcons[symbol]
export const IconCoin = ({
symbol,
...props
}: { symbol: allCoins[number]['symbol'] } & IconProps) => {
const Icon = coinSymbolToIcons[symbol]

if (!Icon) {
return null
}

return <Icon size={'$2.5'} {...props} />
}
13 changes: 12 additions & 1 deletion packages/app/components/sidebar/HomeSideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ import {
type YStackProps,
} from '@my/ui'
import { baseMainnet } from '@my/wagmi/chains'
import { IconAccount, IconDeviceReset, IconHome, IconSendLogo } from 'app/components/icons'
import {
IconAccount,
IconActivity,
IconDeviceReset,
IconHome,
IconSendLogo,
} from 'app/components/icons'
import { SideBarNavLink } from 'app/components/sidebar/SideBarNavLink'

import type { ReactElement } from 'react'
Expand All @@ -28,6 +34,11 @@ const links = [
text: 'Home',
href: '/',
},
{
icon: <IconActivity size={'$1'} color={'inherit'} />,
text: 'Send',
href: '/send',
},
{
icon: <IconDeviceReset size={'$1'} color={'inherit'} />,
text: 'Activity',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ exports[`TokenDetails 1`] = `
>
<RNSVGSvgView
align="xMidYMid"
bbHeight={32}
bbWidth={32}
bbHeight={16.8}
bbWidth={16.8}
color="#FFFFFF"
focusable={false}
height={32}
height={16.8}
meetOrSlice={0}
minX={0}
minY={0}
Expand All @@ -107,18 +107,20 @@ exports[`TokenDetails 1`] = `
"backgroundColor": "transparent",
"borderWidth": 0,
},
{},
{
"color": "#FFFFFF",
},
{
"flex": 0,
"height": 32,
"width": 32,
"height": 16,
"width": 16,
},
]
}
tintColor="#FFFFFF"
vbHeight={32}
vbWidth={32}
width={32}
width={16.8}
>
<RNSVGGroup
fill={
Expand Down
12 changes: 5 additions & 7 deletions packages/app/features/profile/AvatarProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Avatar, SizableText, type AvatarProps } from '@my/ui'
import { Avatar, type AvatarProps } from '@my/ui'
import { IconAccount } from 'app/components/icons'

export type AvatarProfileProps = { name: string | null; avatar_url: string | null } | null

Expand All @@ -13,13 +14,10 @@ export function AvatarProfile({
accessibilityLabel={profile?.name ?? '??'}
accessibilityRole="image"
accessible
src={
profile?.avatar_url ??
`https://ui-avatars.com/api.jpg?name=${profile?.name ?? '??'}&size=256`
}
src={profile?.avatar_url ?? ''}
/>
<Avatar.Fallback bc="$backgroundFocus" f={1} justifyContent="center" alignItems="center">
<SizableText size="$12">??</SizableText>
<Avatar.Fallback jc="center" ai="center">
<IconAccount size="$6" color="$olive" />
</Avatar.Fallback>
</Avatar>
)
Expand Down
Loading
Loading