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

feat(suite): send form token select #14799

Draft
wants to merge 21 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2d3a23c
refactor(product-components): SelectAssetModal independent f coinmarket
enjojoy Oct 16, 2024
04b7253
refactor(suite): getTokenExplorerUrl
enjojoy Oct 25, 2024
389a339
feat(suite): TokenAddress component
enjojoy Oct 25, 2024
b42d5c4
feat(components): can disable focus on Select component
enjojoy Oct 25, 2024
aca2b66
feat(suite): remove Evm banner
enjojoy Oct 25, 2024
223373a
feat(suite): create and implement TokenSelect
enjojoy Oct 25, 2024
b673c70
feat(suite): picker between Tokens and Hidden in modal
enjojoy Oct 25, 2024
31d19bc
feat(suite): disable search by tokens in select token modal
enjojoy Oct 25, 2024
018b25a
feat(suite): shorten selectAssetModal height
enjojoy Oct 25, 2024
1516fce
feat(suite): dirty the form context when token picked
enjojoy Oct 25, 2024
f68d3f4
feat(suite): remove balance under amount
enjojoy Oct 25, 2024
6083132
fix(suite): send form show native token symbol
enjojoy Oct 25, 2024
929ede7
fix(suite): icon size
enjojoy Oct 25, 2024
e780b99
feat(suite): remove shadow on hover on TokenSelect
enjojoy Oct 25, 2024
fd23206
feat(suite): uppercase token logo placeholder
enjojoy Oct 25, 2024
1a13ef1
feat(suite): display token fiat value
enjojoy Oct 25, 2024
f3c24b5
feat(suite): display unrecognized token
enjojoy Oct 25, 2024
0de19e8
feat(suite): add icons to send token tabs
enjojoy Oct 25, 2024
ec0e64c
refactor(product-components): filter categories in select asset modal
enjojoy Oct 25, 2024
0556f39
refactor(suite): token select
enjojoy Oct 25, 2024
47c1d33
fixup! refactor(product-components): filter categories in select asse…
enjojoy Oct 25, 2024
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
7 changes: 4 additions & 3 deletions packages/components/src/components/AssetLogo/AssetLogo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export const AssetLogo = ({
const [isPlaceholder, setIsPlaceholder] = useState(!shouldTryToFetch);
const fileName = contractAddress ? `${coingeckoId}--${contractAddress}` : coingeckoId;
const logoUrl = getAssetLogoUrl(fileName);

const frameProps = pickAndPrepareFrameProps(rest, allowedAssetLogoFrameProps);

const handleLoad = () => {
Expand All @@ -73,8 +72,10 @@ export const AssetLogo = ({
setIsPlaceholder(true);
};
useEffect(() => {
setIsPlaceholder(!shouldTryToFetch);
}, [shouldTryToFetch]);
if (shouldTryToFetch) {
setIsPlaceholder(false);
}
}, [shouldTryToFetch, fileName]);

return (
<Container $size={size} {...frameProps}>
Expand Down
17 changes: 14 additions & 3 deletions packages/components/src/components/form/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type WrapperProps = TransientProps<
$isWithPlaceholder: boolean;
$hasBottomPadding: boolean;
$elevation: Elevation;
$focusEnabled: boolean;
};

const Wrapper = styled.div<WrapperProps>`
Expand Down Expand Up @@ -152,9 +153,16 @@ const Wrapper = styled.div<WrapperProps>`
}

&:focus-within {
.${reactSelectClassNamePrefix}__dropdown-indicator {
transform: rotate(180deg);
}
${({ $focusEnabled }) =>
$focusEnabled
? css`
.${reactSelectClassNamePrefix}__dropdown-indicator {
transform: rotate(180deg);
}
`
: css`
border-color: transparent;
`}
}
}

Expand Down Expand Up @@ -258,6 +266,7 @@ interface CommonProps extends Omit<ReactSelectProps<Option>, 'onChange' | 'menuI
* @description pass `null` if bottom text can be `undefined`
*/
bottomText?: ReactNode;
focusEnabled?: boolean;
hasBottomPadding?: boolean;
minValueWidth?: string; // TODO: should be probably removed
inputState?: InputState;
Expand All @@ -284,6 +293,7 @@ export const Select = ({
useKeyPressScroll,
isSearchable = false,
minValueWidth = 'initial',
focusEnabled = true,
isMenuOpen,
inputState,
components,
Expand Down Expand Up @@ -345,6 +355,7 @@ export const Select = ({
$minValueWidth={minValueWidth}
$isDisabled={isDisabled}
$isMenuOpen={isMenuOpen}
$focusEnabled={focusEnabled}
$isWithLabel={!!label}
$isWithPlaceholder={!!placeholder}
$hasBottomPadding={hasBottomPadding === true && bottomText === null}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { spacings, spacingsPx } from '@trezor/theme';
import { Badge, Column, Icon, Row, Text } from '@trezor/components';
import styled, { useTheme } from 'styled-components';
import { NetworkSymbol } from '@suite-common/wallet-config';
import { SelectAssetOptionCurrencyProps } from './SelectAssetModal';

const ClickableContainer = styled.div`
cursor: pointer;
Expand All @@ -26,23 +28,27 @@ const BadgeWrapper = styled.div`
`;

type AssetItemProps = {
cryptoId: string;
name: string;
symbol: string;
name?: string;
symbol: NetworkSymbol;
badge: string | undefined;
networkSymbol: NetworkSymbol;
coingeckoId: string;
logo: JSX.Element;
isFavorite?: boolean;
handleClick: (selectedAsset: string) => void;
contractAddress: string | null;
handleClick: (selectedAsset: SelectAssetOptionCurrencyProps) => void;
onFavoriteClick?: (isFavorite: boolean) => void;
};

export const AssetItem = ({
cryptoId,
name,
symbol,
badge,
networkSymbol,
coingeckoId,
logo,
isFavorite = false,
contractAddress,
handleClick,
onFavoriteClick,
}: AssetItemProps) => {
Expand All @@ -51,7 +57,17 @@ export const AssetItem = ({
const handleFavoriteClick = onFavoriteClick ? () => onFavoriteClick(isFavorite) : undefined;

return (
<ClickableContainer onClick={() => handleClick(cryptoId)}>
<ClickableContainer
onClick={() =>
handleClick({
symbol,
contractAddress: contractAddress ?? null,
type: 'currency',
networkSymbol,
coingeckoId,
})
}
>
<Row gap={spacings.sm}>
{logo}
<Column flex="1" alignItems="stretch">
Expand All @@ -68,7 +84,7 @@ export const AssetItem = ({
)}
</Row>
<Text typographyStyle="hint" variant="tertiary">
{symbol}
{symbol.toUpperCase()}
</Text>
</Column>

Expand Down
Loading
Loading