import { BigNumber } from "@ethersproject/bignumber" ; import { FC } from "react" ; import styled , { css , keyframes } from "styled-components" ; import { makeClickable } from "../utils/a11y" ; import { TokenDetails , toTokenView } from "../utils/tokens" ; import { IconButton } from "./IconButton" ; import { TokenIcon } from "./TokenIcon" ; export const TokenWrapper = styled . div `
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px;
  cursor: pointer;
  border-radius: 4px;

  transition: all 200ms ease-in-out;

  &:hover,
  &:focus {
    outline: 0;
    background: rgba(255, 255, 255, 0.25);
  }
` ; export const TokenDetailsWrapper = styled . div `
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
` ; export const TokenTextGroup = styled . div `
  display: flex;
  flex-direction: column;
` ; export const TokenTitle = styled . h3 `
  font-weight: 600;
  font-size: 17px;
  line-height: 22px;
  margin: 0;
` ; export const TokenMeta = styled . p `
  font-size: 13px;
  line-height: 18px;
  color: #8f8e8c;
  margin: 0;
` ; const PulseAnimation = keyframes `
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
  100% {
    opacity: 1;
  }
` ; export const TokenBalance = styled . p < { isLoading ? : boolean ; } > `
  font-weight: 600;
  font-size: 17px;
  line-height: 22px;
  text-align: right;
  max-width: 64px;
  overflow: hidden;
  white-space: nowrap;

  opacity: 1;
  ${ ( { isLoading } ) => isLoading && css `
      animation: ${ PulseAnimation } 1.5s ease-in-out infinite;
    ` }
` ; export const AddTokenIconButton = styled ( IconButton ) `
  &:hover,
  &:focus {
    background-color: rgba(255, 255, 255, 0.15);
    outline: 0;
  }
` ; export type TokenAction = { type : "MINT" ; amount : BigNumber ; } | { type : "TRANSFER" ; to : string ; amount : BigNumber ; } ; interface TokenListItemProps { token : TokenDetails ; isLoading ? : boolean ; onClick ? : ( ) => void ; } export const TokenListItem = ( { token , isLoading = false , onClick , ... props } ) => { const { name , symbol , balance } = toTokenView ( token ) ; return ( < TokenWrapper { ... makeClickable ( onClick ) } { ... props } > < TokenIcon name = { name } /> < TokenDetailsWrapper > < TokenTextGroup > < TokenTitle > { symbol } < /TokenTitle> < TokenMeta > { name } < /TokenMeta> < /TokenTextGroup> < TokenBalance isLoading = { isLoading } > { balance } < /TokenBalance> < /TokenDetailsWrapper> < /TokenWrapper>); } ;