Skip to content

Commit ffee6e5

Browse files
committed
Use shared FilterButton in bridge
1 parent 51730d2 commit ffee6e5

2 files changed

Lines changed: 10 additions & 49 deletions

File tree

app/components/UI/Bridge/components/BridgeTrendingTokensSection/BridgeTrendingTokensSection.tsx

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import {
99
TextVariant,
1010
TextColor,
1111
FontWeight,
12-
Icon,
13-
IconName,
14-
IconColor,
15-
IconSize,
1612
} from '@metamask/design-system-react-native';
1713
import { selectNetworkConfigurationsByCaipChainId } from '../../../../../selectors/networkController';
1814
import {
@@ -36,6 +32,7 @@ import { getNetworkImageSource } from '../../../../../util/networks';
3632
import { NETWORK_TO_SHORT_NETWORK_NAME_MAP } from '../../../../../constants/bridge';
3733
import type { ProcessedNetwork } from '../../../../hooks/useNetworksByNamespace/useNetworksByNamespace';
3834
import type { CaipChainId } from '@metamask/utils';
35+
import { FilterButton } from '../../../Trending/components/FilterBar/FilterBar';
3936

4037
const TOKEN_CHUNK_SIZE = 12;
4138

@@ -45,46 +42,6 @@ interface BridgeTrendingTokensSectionProps {
4542
isNearBottom?: boolean;
4643
}
4744

48-
const FilterButton = ({
49-
testID,
50-
onPress,
51-
text,
52-
twClassName: btnClass,
53-
}: {
54-
testID: string;
55-
onPress: () => void;
56-
text: string;
57-
twClassName?: string;
58-
}) => {
59-
const tw = useTailwind();
60-
return (
61-
<Pressable
62-
testID={testID}
63-
onPress={onPress}
64-
style={({ pressed }) =>
65-
tw.style(
66-
'flex-row items-center justify-center gap-1 py-2 px-3 rounded-lg bg-background-muted',
67-
btnClass,
68-
pressed && 'opacity-20',
69-
)
70-
}
71-
>
72-
<Text
73-
variant={TextVariant.BodySm}
74-
fontWeight={FontWeight.Medium}
75-
color={TextColor.TextDefault}
76-
>
77-
{text}
78-
</Text>
79-
<Icon
80-
name={IconName.ArrowDown}
81-
color={IconColor.IconAlternative}
82-
size={IconSize.Xs}
83-
/>
84-
</Pressable>
85-
);
86-
};
87-
8845
const BridgeTrendingTokensSection = ({
8946
isNearBottom,
9047
}: BridgeTrendingTokensSectionProps) => {
@@ -201,19 +158,19 @@ const BridgeTrendingTokensSection = ({
201158
<FilterButton
202159
testID={BridgeViewSelectorsIDs.TRENDING_PRICE_FILTER}
203160
onPress={() => setActiveBottomSheet('price_change')}
204-
text={priceChangeButtonText}
161+
label={priceChangeButtonText}
205162
twClassName="flex-1"
206163
/>
207164
<FilterButton
208165
testID={BridgeViewSelectorsIDs.TRENDING_NETWORK_FILTER}
209166
onPress={() => setActiveBottomSheet('network')}
210-
text={selectedNetworkName}
167+
label={selectedNetworkName}
211168
twClassName="flex-1"
212169
/>
213170
<FilterButton
214171
testID={BridgeViewSelectorsIDs.TRENDING_TIME_FILTER}
215172
onPress={() => setActiveBottomSheet('time')}
216-
text={selectedTimeOption}
173+
label={selectedTimeOption}
217174
twClassName="w-[72px] shrink-0"
218175
/>
219176
</Box>

app/components/UI/Trending/components/FilterBar/FilterBar.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Icon, {
88
} from '../../../../../component-library/components/Icons/Icon';
99
import Text from '../../../../../component-library/components/Texts/Text';
1010

11-
interface FilterButtonProps {
11+
export interface FilterButtonProps {
1212
testID: string;
1313
label: string;
1414
onPress: () => void;
@@ -17,16 +17,19 @@ interface FilterButtonProps {
1717
ellipsizeMode?: 'tail' | 'head' | 'middle' | 'clip';
1818
/** Extra horizontal padding (px-3) vs default (p-2) */
1919
wide?: boolean;
20+
/** Optional Tailwind class overrides for layout in custom contexts */
21+
twClassName?: string;
2022
}
2123

22-
const FilterButton: React.FC<FilterButtonProps> = ({
24+
export const FilterButton: React.FC<FilterButtonProps> = ({
2325
testID,
2426
label,
2527
onPress,
2628
disabled = false,
2729
numberOfLines,
2830
ellipsizeMode,
2931
wide = false,
32+
twClassName,
3033
}) => {
3134
const tw = useTailwind();
3235

@@ -38,6 +41,7 @@ const FilterButton: React.FC<FilterButtonProps> = ({
3841
'min-w-0 shrink items-center rounded-lg bg-muted',
3942
wide ? 'py-2 px-3' : 'p-2',
4043
disabled && 'opacity-50',
44+
twClassName,
4145
)}
4246
activeOpacity={0.2}
4347
disabled={disabled}

0 commit comments

Comments
 (0)