1
- import styled , { css } from 'styled-components' ;
2
-
3
1
import { selectSelectedDevice } from '@suite-common/wallet-core' ;
4
2
import { SelectedAccountStatus } from '@suite-common/wallet-types' ;
5
- import { Row , variables } from '@trezor/components' ;
3
+ import { Row } from '@trezor/components' ;
6
4
import { hasBitcoinOnlyFirmware } from '@trezor/device-utils' ;
5
+ import { breakpointThresholds } from '@trezor/styles' ;
7
6
import { EventType , analytics } from '@trezor/suite-analytics' ;
8
7
import { spacings } from '@trezor/theme' ;
9
8
@@ -14,16 +13,8 @@ import { HeaderActionButton } from 'src/components/suite/layouts/SuiteLayout/Pag
14
13
import { useDispatch , useSelector } from 'src/hooks/suite' ;
15
14
import { selectIsAccountTabPage , selectRouteName } from 'src/reducers/suite/routerReducer' ;
16
15
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
+
27
18
interface TradeActionsProps {
28
19
selectedAccount ?: SelectedAccountStatus ;
29
20
hideBuyAndSellBelowDesktop ?: boolean ;
@@ -59,10 +50,14 @@ export const TradeActions = ({
59
50
60
51
const isAccountLoading = selectedAccount ? selectedAccount . status === 'loading' : false ;
61
52
53
+ const { contentWidth } = useResponsiveContext ( ) ;
54
+ const isContentAreaLarge = contentWidth ? contentWidth > breakpointThresholds . lg : true ;
55
+ const isContentAreaMedium = contentWidth ? contentWidth > breakpointThresholds . md : true ;
56
+
62
57
return (
63
58
< Row gap = { spacings . xxs } >
64
59
< AppNavigationTooltip >
65
- < ShowOnLargeDesktopWrapper $isActive = { hideBuyAndSellBelowDesktop } >
60
+ { isContentAreaLarge && hideBuyAndSellBelowDesktop && (
66
61
< HeaderActionButton
67
62
icon = "currencyCircleDollar"
68
63
onClick = { ( ) => {
@@ -77,23 +72,25 @@ export const TradeActions = ({
77
72
>
78
73
< Translation id = "TR_TRADING_BUY_AND_SELL" />
79
74
</ 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 >
96
75
) }
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
+ ) }
97
94
</ AppNavigationTooltip >
98
95
</ Row >
99
96
) ;
0 commit comments