Skip to content

Commit a6286b8

Browse files
committed
fix(suite): Fix trade heading
1 parent 8ddf478 commit a6286b8

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

packages/suite/src/components/suite/layouts/SuiteLayout/PageHeader/HeaderActionButton.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button, ButtonProps, IconButton, IconButtonProps } from '@trezor/components';
2+
import { breakpointThresholds } from '@trezor/styles';
23

3-
import { useSelector } from 'src/hooks/suite';
4-
import { selectWindowSize } from 'src/reducers/suite/windowReducer';
4+
import { useResponsiveContext } from '../../../../../support/suite/ResponsiveContext';
55

66
export const HeaderActionButton = ({
77
icon,
@@ -13,12 +13,11 @@ export const HeaderActionButton = ({
1313
children,
1414
}: Pick<ButtonProps, 'onClick' | 'data-testid' | 'variant' | 'size' | 'isDisabled' | 'children'> &
1515
Pick<IconButtonProps, 'icon'>) => {
16-
const layoutSize = useSelector(selectWindowSize);
17-
18-
const isMobileLayout = layoutSize === 'TINY';
16+
const { contentWidth } = useResponsiveContext();
17+
const isContentAreaSmall = contentWidth ? contentWidth < breakpointThresholds.sm : false;
1918
const commonProps = { icon, onClick, 'data-testid': dataTestId, variant, size, isDisabled };
2019

21-
return isMobileLayout ? (
20+
return isContentAreaSmall ? (
2221
<IconButton {...commonProps} />
2322
) : (
2423
<Button {...commonProps}>{children}</Button>

packages/suite/src/components/suite/layouts/SuiteLayout/PageHeader/TradeActions.tsx

+27-30
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import styled, { css } from 'styled-components';
2-
31
import { selectSelectedDevice } from '@suite-common/wallet-core';
42
import { SelectedAccountStatus } from '@suite-common/wallet-types';
5-
import { Row, variables } from '@trezor/components';
3+
import { Row } from '@trezor/components';
64
import { hasBitcoinOnlyFirmware } from '@trezor/device-utils';
5+
import { breakpointThresholds } from '@trezor/styles';
76
import { EventType, analytics } from '@trezor/suite-analytics';
87
import { spacings } from '@trezor/theme';
98

@@ -14,16 +13,8 @@ import { HeaderActionButton } from 'src/components/suite/layouts/SuiteLayout/Pag
1413
import { useDispatch, useSelector } from 'src/hooks/suite';
1514
import { selectIsAccountTabPage, selectRouteName } from 'src/reducers/suite/routerReducer';
1615

17-
// instant without computing the layout
18-
const ShowOnLargeDesktopWrapper = styled.div<{ $isActive?: boolean }>`
19-
${({ $isActive }) =>
20-
$isActive &&
21-
css`
22-
${variables.SCREEN_QUERY.BELOW_DESKTOP} {
23-
display: none;
24-
}
25-
`}
26-
`;
16+
import { useResponsiveContext } from '../../../../../support/suite/ResponsiveContext';
17+
2718
interface TradeActionsProps {
2819
selectedAccount?: SelectedAccountStatus;
2920
hideBuyAndSellBelowDesktop?: boolean;
@@ -59,10 +50,14 @@ export const TradeActions = ({
5950

6051
const isAccountLoading = selectedAccount ? selectedAccount.status === 'loading' : false;
6152

53+
const { contentWidth } = useResponsiveContext();
54+
const isContentAreaLarge = contentWidth ? contentWidth > breakpointThresholds.lg : true;
55+
const isContentAreaMedium = contentWidth ? contentWidth > breakpointThresholds.md : true;
56+
6257
return (
6358
<Row gap={spacings.xxs}>
6459
<AppNavigationTooltip>
65-
<ShowOnLargeDesktopWrapper $isActive={hideBuyAndSellBelowDesktop}>
60+
{isContentAreaLarge && hideBuyAndSellBelowDesktop && (
6661
<HeaderActionButton
6762
icon="currencyCircleDollar"
6863
onClick={() => {
@@ -77,23 +72,25 @@ export const TradeActions = ({
7772
>
7873
<Translation id="TR_TRADING_BUY_AND_SELL" />
7974
</HeaderActionButton>
80-
</ShowOnLargeDesktopWrapper>
81-
{!hasBitcoinOnlyFirmware(device) && (
82-
<HeaderActionButton
83-
icon="arrowsLeftRight"
84-
onClick={() => {
85-
goToWithAnalytics('wallet-trading-exchange', {
86-
preserveParams: true,
87-
});
88-
}}
89-
data-testid="@wallet/menu/wallet-trading-exchange"
90-
variant="tertiary"
91-
size="small"
92-
isDisabled={isAccountLoading}
93-
>
94-
<Translation id="TR_TRADING_SWAP" />
95-
</HeaderActionButton>
9675
)}
76+
{!hasBitcoinOnlyFirmware(device) &&
77+
isContentAreaMedium &&
78+
hideBuyAndSellBelowDesktop && (
79+
<HeaderActionButton
80+
icon="arrowsLeftRight"
81+
onClick={() => {
82+
goToWithAnalytics('wallet-trading-exchange', {
83+
preserveParams: true,
84+
});
85+
}}
86+
data-testid="@wallet/menu/wallet-trading-exchange"
87+
variant="tertiary"
88+
size="small"
89+
isDisabled={isAccountLoading}
90+
>
91+
<Translation id="TR_TRADING_SWAP" />
92+
</HeaderActionButton>
93+
)}
9794
</AppNavigationTooltip>
9895
</Row>
9996
);

0 commit comments

Comments
 (0)