Skip to content

Commit

Permalink
chore: update popout headers
Browse files Browse the repository at this point in the history
  • Loading branch information
pete-watters committed Mar 15, 2024
1 parent 7bbbbed commit 60a724b
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 39 deletions.
2 changes: 1 addition & 1 deletion src/app/components/disclaimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface DisclaimerProps extends BoxProps {
export function Disclaimer({ disclaimerText, learnMoreUrl, ...props }: DisclaimerProps) {
return (
<Box lineHeight="1.4" {...props}>
<styled.span textStyle="caption.02">
<styled.span textStyle="caption.01">
{disclaimerText}
{learnMoreUrl ? (
<Link display="inline" fontSize="14px" onClick={() => openInNewTab(learnMoreUrl)}>
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/no-fees-warning-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ interface NoFeesWarningRowProps {
export function NoFeesWarningRow({ chainId }: NoFeesWarningRowProps) {
return (
<HStack alignItems="center" justifyContent="space-between">
<styled.span textStyle="caption.02">No fees are incurred</styled.span>
<styled.span textStyle="caption.02">
<styled.span textStyle="caption.01">No fees are incurred</styled.span>
<styled.span textStyle="caption.01">
{whenStacksChainId(chainId)({
[ChainID.Testnet]: 'Testnet',
[ChainID.Mainnet]: 'Mainnet',
Expand Down
7 changes: 2 additions & 5 deletions src/app/features/container/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
getDisplayAddresssBalanceOf,
isKnownPopupRoute,
showAccountInfo,
showBalanceInfo,
} from './utils/get-popup-header';
import { getTitleFromUrl } from './utils/get-title-from-url';
import {
Expand Down Expand Up @@ -154,10 +155,6 @@ export function Container() {
align="middle"
img={
<CurrentAccountAvatar
color="white"
fontSize="16px"
fontWeight={500}
size="32px"
toggleSwitchAccount={() =>
setIsShowingSwitchAccount(!isShowingSwitchAccount)
}
Expand All @@ -169,7 +166,7 @@ export function Container() {
)
}
totalBalance={
showAccountInfo(pathname) && (
showBalanceInfo(pathname) && (
<TotalBalance displayAddresssBalanceOf={getDisplayAddresssBalanceOf(pathname)} />
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/container/total-balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface TotalBalanceLayoutProps {
}
function TotalBalanceLayout({ children }: TotalBalanceLayoutProps) {
return (
<Box p="space.04" width="100%" borderBottom="borders.default">
<Box p="space.04" width="100%">
{children}
</Box>
);
Expand Down
39 changes: 31 additions & 8 deletions src/app/features/container/utils/get-popup-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,41 @@
import { RouteUrls } from '@shared/route-urls';

export function showAccountInfo(pathname: RouteUrls) {
return (
pathname === RouteUrls.TransactionRequest ||
pathname === RouteUrls.ProfileUpdateRequest ||
pathname === RouteUrls.PsbtRequest
);
switch (pathname) {
case RouteUrls.TransactionRequest:
case RouteUrls.ProfileUpdateRequest:
case RouteUrls.PsbtRequest:
case RouteUrls.RpcSendTransfer:
case RouteUrls.SignatureRequest:
case RouteUrls.RpcStacksSignature:
return true;
default:
return false;
}
}

export function showBalanceInfo(pathname: RouteUrls) {
switch (pathname) {
case RouteUrls.ProfileUpdateRequest:
case RouteUrls.PsbtRequest:
case RouteUrls.RpcSendTransfer:
case RouteUrls.RpcStacksSignature:
return true;
case RouteUrls.TransactionRequest:
default:
return false;
}
}

export function getDisplayAddresssBalanceOf(pathname: RouteUrls) {
// TODO it's unclear when to show ALL or STX balance here
switch (pathname) {
case RouteUrls.TransactionRequest:
case RouteUrls.ProfileUpdateRequest:
case RouteUrls.PsbtRequest:
case RouteUrls.RpcSendTransfer:
return 'all';
case RouteUrls.SignatureRequest:
case RouteUrls.RpcGetAddresses:
return undefined;
case RouteUrls.RpcStacksSignature:
default:
return 'stx';
}
Expand All @@ -31,6 +51,9 @@ export function isKnownPopupRoute(pathname: RouteUrls) {
case RouteUrls.PsbtRequest:
case RouteUrls.SignatureRequest:
case RouteUrls.RpcGetAddresses:
case RouteUrls.RpcSendTransfer:
case RouteUrls.SignatureRequest:
case RouteUrls.RpcStacksSignature:
return true;
default:
return false;
Expand Down
3 changes: 2 additions & 1 deletion src/app/features/container/utils/get-title-from-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { RouteUrls } from '@shared/route-urls';

export function getTitleFromUrl(pathname: RouteUrls) {
if (pathname.match(RouteUrls.SendCryptoAsset)) {
// don't show send on first step of send flow
// don't show send on first step of send flow or popuop transfer
if (pathname === RouteUrls.SendCryptoAsset) return undefined;
if (pathname === RouteUrls.RpcSendTransfer) return undefined;
return 'Send';
}

Expand Down
6 changes: 2 additions & 4 deletions src/app/features/current-account/current-account-avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import { AccountAvatar } from '@app/ui/components/account/account-avatar/account
interface CurrentAccountAvatar extends CircleProps {
toggleSwitchAccount(): void;
}
export const CurrentAccountAvatar = memo((props: CurrentAccountAvatar) => {
const { toggleSwitchAccount } = props;
export const CurrentAccountAvatar = memo(({ toggleSwitchAccount }: CurrentAccountAvatar) => {
const accountIndex = useCurrentAccountIndex();
const accounts = useStacksAccounts();
const currentAccount = accounts[accountIndex] as StacksAccount | undefined;
Expand All @@ -23,9 +22,8 @@ export const CurrentAccountAvatar = memo((props: CurrentAccountAvatar) => {
<AccountAvatar
index={currentAccount.index}
name={name}
onClick={toggleSwitchAccount}
onClick={() => toggleSwitchAccount()}
publicKey={currentAccount.stxPublicKey}
{...props}
/>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function ContractCallDetailsSuspense() {
py="32px"
gap="space.05"
width="100%"
background="ink.background-primary"
>
<Title>Function and arguments</Title>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function StxTransferDetails(): React.JSX.Element | null {
px="space.04"
py="space.06"
gap="space.05"
backgroundColor="ink.background-secondary"
>
<Title>Transfer details</Title>
<Stack gap="space.04">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export function GetAddressesLayout(props: GetAddressesLayoutProps) {
alignSelf="bottom"
bg="ink.background-secondary"
>
<styled.p textStyle="caption.02">
<styled.p textStyle="caption.01">
By connecting you give permission to {requester} to see all addresses linked to this
account
</styled.p>
Expand Down
8 changes: 7 additions & 1 deletion src/app/pages/transaction-request/transaction-request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,13 @@ function TransactionRequestBase() {
};

return (
<Flex alignItems="center" flexDirection="column" p="space.05" width="100%">
<Flex
alignItems="center"
flexDirection="column"
p="space.05"
width="100%"
background="ink.background-secondary"
>
<Formik
initialValues={initialValues}
onSubmit={onSubmit}
Expand Down
19 changes: 4 additions & 15 deletions src/app/ui/components/containers/headers/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ReactNode } from 'react';
import { SharedComponentsSelectors } from '@tests/selectors/shared-component.selectors';
import { Flex, Grid, GridItem, HStack, styled } from 'leather-styles/jsx';

import { ArrowLeftIcon, CloseIcon } from '@app/ui/icons';
import { ArrowLeftIcon } from '@app/ui/icons';

import { BigTitleHeader } from './components/big-title-header';
import { HeaderActionButton } from './components/header-action-button';
Expand Down Expand Up @@ -37,12 +37,9 @@ export function Header({
}: HeaderProps) {
const logoItem = onGoBack || logo || account;
return (
<styled.header
p={variant === 'bigTitle' ? 'space.05' : 'space.04'}
bg={{ base: 'ink.background-primary', sm: 'transparent' }}
>
<styled.header p={variant === 'bigTitle' ? 'space.05' : 'space.04'} bg="transparent">
<Grid
gridTemplateColumns="1fr 4fr 1fr"
gridTemplateColumns="auto 4fr auto"
gridAutoFlow="column"
width="100%"
maxWidth={{ base: '100vw', md: 'fullPageMaxWidth' }}
Expand Down Expand Up @@ -70,16 +67,8 @@ export function Header({
<GridItem hideBelow={variant === 'bigTitle' ? 'md' : undefined}>
<HStack alignItems="center" justifyContent="flex-end">
{networkBadge}
{totalBalance}
{totalBalance && totalBalance}
{variant !== 'onboarding' && settingsMenu}
{onClose && (
<HeaderActionButton
icon={<CloseIcon />}
dataTestId={SharedComponentsSelectors.HeaderCloseBtn}
isWaitingOnPerformedAction={isWaitingOnPerformedAction}
onAction={onClose}
/>
)}
</HStack>
</GridItem>
</Grid>
Expand Down

0 comments on commit 60a724b

Please sign in to comment.