Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/inevitable-changes/bento
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
junhoyeo committed Oct 18, 2022
2 parents 1ad32c0 + 0af498c commit 14e3e31
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import clsx from 'clsx';
import { AnimatePresence, motion } from 'framer-motion';
import { useTranslation } from 'next-i18next';
import { useCallback, useMemo, useState } from 'react';
import styled, { css } from 'styled-components';
Expand All @@ -9,6 +9,7 @@ import { WALLETS } from '@/constants/wallets';
import { Colors } from '@/styles';
import { toast } from '@/utils';

import { ActivityIndicator } from '../system';
import {
connectKaikas,
connectKeplr,
Expand Down Expand Up @@ -79,13 +80,22 @@ export const WalletConnector: React.FC<WalletSelectorProps> = ({
default:
break;
}

toast({
type: 'success',
title: 'Wallet Connected!',
});
} catch (error: any) {
const typedError = error as Error;
console.error(typedError);
let errorMessage = typedError?.message || 'Unknown Error';
if (errorMessage.length >= 120) {
errorMessage = errorMessage.substring(0, 120) + '...';
}
toast({
type: 'error',
title: 'Ownership Verification Failed',
description: typedError?.message ?? undefined,
description: errorMessage,
});
}

Expand Down Expand Up @@ -154,6 +164,21 @@ export const WalletConnector: React.FC<WalletSelectorProps> = ({
</IconList>
<span className="title">{t('Phantom')}</span>
</WalletButton>

<AnimatePresence>
{isLoading && (
<LoadingContainer
{...{
initial: { opacity: 0 },
animate: { opacity: 1 },
exit: { opacity: 0 },
transition: { ease: 'linear' },
}}
>
<ActivityIndicator size={56} borderSize={8} />
</LoadingContainer>
)}
</AnimatePresence>
</WalletList>
);
};
Expand Down Expand Up @@ -225,3 +250,20 @@ const IconList = styled.div.attrs({
width: 72px;
}
`;

const LoadingContainer = styled(motion.div)`
background-color: rgba(0, 56, 255, 0.45);
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
pointer-events: all;
cursor: default;
`;
32 changes: 32 additions & 0 deletions packages/bento-web/src/components/system/ActivityIndicator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import styled, { css, keyframes } from 'styled-components';

const rotate = keyframes`
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
`;

type Props = {
color?: string;
borderSize: number;
size: number;
};

export const ActivityIndicator = styled.div<Props>`
display: inline-block;
border-radius: 50%;
border-style: solid;
border-bottom-color: transparent;
border-left-color: transparent;
animation: ${rotate} linear infinite 0.75s;
${({ color = 'rgba(255, 255, 255, 0.85)', borderSize, size }) => css`
color: ${color};
border-top-color: ${color};
border-right-color: ${color};
width: ${size}px;
height: ${size}px;
border-width: ${borderSize}px;
`}
`;
1 change: 1 addition & 0 deletions packages/bento-web/src/components/system/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { ActivityIndicator } from './ActivityIndicator';
export { AnimatedToolTip } from './AnimatedToolTip';
export { AssetMedia } from './AssetMedia';
export { Badge } from './Badge';
Expand Down

0 comments on commit 14e3e31

Please sign in to comment.