react-icons/ai#AiOutlineLoading TypeScript Examples

The following examples show how to use react-icons/ai#AiOutlineLoading. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Loading.tsx    From dxvote with GNU Affero General Public License v3.0 6 votes vote down vote up
Loading: React.FunctionComponent<LoadingProps> = ({
  children,
  loading,
  iconProps = { size: 40 },
  text = false,
  skeletonProps = { width: '100px', height: '16px', borderRadius: '50px' },
  skeletonStyleProps = { baseColor: '#333', highlightColor: '#555' },
  style = {},
}) => {
  return loading ? (
    <Wrapper style={style}>
      {text ? (
        <SkeletonTheme {...skeletonStyleProps}>
          <Skeleton {...skeletonProps} />
        </SkeletonTheme>
      ) : (
        <Spinner>
          <AiOutlineLoading {...iconProps} />
        </Spinner>
      )}
    </Wrapper>
  ) : (
    <>{children}</>
  );
}
Example #2
Source File: UserVestingInfoModal.tsx    From dxvote with GNU Affero General Public License v3.0 4 votes vote down vote up
UserVestingInfoModal: React.FC<UserVestingInfoModalProps> = ({
  onDismiss,
  isOpen,
  contract,
  updateContracts,
}) => {
  const [loading, setLoading] = useState(false);
  const {
    context: { tokenVestingService },
  } = useContext();

  if (!contract) return null;

  const contractValue = formatBalance(contract.value);
  const cliff = moment.unix(Number(contract.cliff));
  const canRelease = !(
    !Number(contract.value.toString()) || moment().isBefore(cliff)
  );

  const handleRedeemClick = () => {
    setLoading(true);
    tokenVestingService
      .redeemVestedDxd(contract.address)
      .on(TXEvents.RECEIPT, hash => {
        console.debug('[TX_RECEIPT]', hash);
        toast.success(
          `Successfully redeemed ${contractValue}DXD from ${contract.address}`
        );
      })
      .on(TXEvents.TX_ERROR, txerror => {
        console.error('[TX_ERROR]', txerror);
        setLoading(false);
        toast.error(`Error: ${txerror?.message}`);
      })
      .on(TXEvents.INVARIANT, error => {
        console.error('[ERROR]', error);
        setLoading(false);
        toast.error(`Error: ${error?.message}`);
      })
      .on(TXEvents.FINALLY, hash => {
        console.debug('[TX_FINALLY]', hash);
        setLoading(false);
        updateContracts();
        onDismiss();
      })
      .catch(e => {
        toast.error(`Error: ${e?.message}`);
      });
  };

  const handleDismiss = () => {
    if (!loading) onDismiss();
  };

  return (
    <Modal
      header={<Title>Vesting Contract</Title>}
      isOpen={isOpen}
      onDismiss={handleDismiss}
      maxWidth={450}
    >
      <Wrapper>
        {loading ? (
          <div>
            <Loading>
              <AiOutlineLoading size={40} />
            </Loading>
            <br /> Waiting transaction..
          </div>
        ) : (
          <>
            <Row>
              <span>Contract Address: </span>
              <StyledLink text={contract.address} toCopy>
                {contract.address}↗
              </StyledLink>
            </Row>
            <Row>
              Start: {moment.unix(Number(contract.start)).format('LLL')}
            </Row>
            <Row>
              Cliff: {cliff.format('LLL')} (
              {moment.duration(cliff.diff(moment())).humanize(true)})
            </Row>
            <Row>
              Duration:{' '}
              {moment.duration(contract.duration, 'seconds').humanize()}
            </Row>

            <Row>Value: {contractValue} DXD</Row>
            <Row>Can Release: {canRelease ? 'Yes' : 'No'}</Row>
            <Row>
              <StyledButton disabled={!canRelease} onClick={handleRedeemClick}>
                Redeem DXD
              </StyledButton>
            </Row>
          </>
        )}
      </Wrapper>
    </Modal>
  );
}