Skip to content

Commit

Permalink
feat(suite): remake TokenSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
enjojoy committed Oct 18, 2024
1 parent 1e35dda commit fc035ee
Show file tree
Hide file tree
Showing 6 changed files with 212 additions and 104 deletions.
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
2 changes: 1 addition & 1 deletion packages/suite/src/components/suite/CoinBalance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FormattedCryptoAmount } from 'src/components/suite';

interface CoinBalanceProps {
value: string;
symbol: Account['symbol'];
symbol: Account['symbol'] | (string & {});
}

export const CoinBalance = ({ value, symbol }: CoinBalanceProps) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
validateReserveOrBalance,
} from 'src/utils/suite/validation';
import { formatTokenSymbol } from 'src/utils/wallet/tokenUtils';
import { TokenSelect } from './TokenSelect';
import { FiatInput } from './FiatInput';
import { SendMaxSwitch } from './SendMaxSwitch';

Expand Down Expand Up @@ -277,7 +276,7 @@ export const Amount = ({ output, outputId }: AmountProps) => {
control={control}
innerAddon={
withTokens ? (
<TokenSelect output={output} outputId={outputId} />
<Symbol>{token?.symbol?.toUpperCase()}</Symbol>
) : (
<Symbol>{symbolToUse}</Symbol>
)
Expand Down
Loading

0 comments on commit fc035ee

Please sign in to comment.