icns-frontend/components/connect-wallet-modal/modal.tsx

114 lines
3.1 KiB
TypeScript
Raw Normal View History

import { FunctionComponent, useState } from "react";
2022-12-12 08:46:50 +00:00
import ReactModal from "react-modal";
2022-12-12 06:51:25 +00:00
import styled from "styled-components";
import color from "../../styles/color";
2022-12-20 07:58:21 +00:00
import { WalletList, WalletType } from "../../constants/wallet";
2022-12-12 08:46:50 +00:00
import { WalletItem } from "./wallet-item";
import { ErrorMessage } from "../../types";
import { ErrorModal } from "../error-modal";
2022-12-20 07:58:21 +00:00
import { BeforeYouStartModal } from "../before-you-start-modal";
2022-12-12 06:51:25 +00:00
interface Props {
isModalOpen: boolean;
onCloseModal: () => void;
2022-12-20 07:58:21 +00:00
currentReferal?: string;
2022-12-12 06:51:25 +00:00
}
export const ConnectWalletModal: FunctionComponent<Props> = (props) => {
2022-12-20 07:58:21 +00:00
const { isModalOpen, onCloseModal, currentReferal } = props;
const [isErrorModalOpen, setErrorModalOpen] = useState(false);
2022-12-20 07:58:21 +00:00
const [isBeforeYouStartModalOpen, setBeforeYouStartModalOpen] =
useState(false);
const [selectedWalletItem, setSelectedWalletItem] = useState<WalletType>();
const [walletKeyName, setWalletKeyName] = useState("");
const [errorMessage, setErrorMessage] = useState<ErrorMessage>();
2022-12-12 06:51:25 +00:00
return (
<ReactModal
isOpen={isModalOpen}
onRequestClose={onCloseModal}
2022-12-14 11:36:08 +00:00
ariaHideApp={false}
2022-12-12 06:51:25 +00:00
style={{
2022-12-16 06:55:31 +00:00
overlay: { background: "#121212cc" },
2022-12-12 06:51:25 +00:00
content: {
top: "50%",
left: "50%",
right: "auto",
bottom: "auto",
padding: 0,
marginRight: "-50%",
transform: "translate(-50%, -50%)",
background: color.grey["800"],
border: 0,
},
}}
>
<ModalContainer>
<ModalTitle>Connect Wallet</ModalTitle>
<ModalDescription>
2022-12-20 07:58:21 +00:00
Make sure you have selected the correct account to link to your ICNS
name.
2022-12-12 06:51:25 +00:00
</ModalDescription>
2022-12-12 08:46:50 +00:00
{WalletList.map((walletItem) => {
return (
<WalletItem
wallet={walletItem}
key={walletItem.name}
setErrorModalOpen={setErrorModalOpen}
setErrorMessage={setErrorMessage}
2022-12-20 07:58:21 +00:00
setBeforeYouStartModalOpen={setBeforeYouStartModalOpen}
setWalletKeyName={setWalletKeyName}
setSelectedWalletItem={setSelectedWalletItem}
/>
);
2022-12-12 08:46:50 +00:00
})}
2022-12-12 06:51:25 +00:00
</ModalContainer>
2022-12-20 07:58:21 +00:00
<BeforeYouStartModal
isModalOpen={isBeforeYouStartModalOpen}
onCloseModal={() => setBeforeYouStartModalOpen(false)}
currentReferal={currentReferal}
walletKeyName={walletKeyName}
selectedWalletItem={selectedWalletItem}
/>
<ErrorModal
isModalOpen={isErrorModalOpen}
onCloseModal={() => setErrorModalOpen(false)}
errorMessage={errorMessage}
isWarning={true}
/>
2022-12-12 06:51:25 +00:00
</ReactModal>
);
};
const ModalContainer = styled.div`
display: flex;
flex-direction: column;
gap: 0.9rem;
padding: 2.2rem;
2022-12-16 06:55:31 +00:00
2022-12-19 07:38:50 +00:00
max-width: 28.5rem;
2022-12-12 06:51:25 +00:00
`;
const ModalTitle = styled.div`
font-family: "Inter", serif;
font-style: normal;
font-weight: 600;
font-size: 1.5rem;
line-height: 1.8rem;
color: ${color.white};
`;
const ModalDescription = styled.div`
font-family: "Inter", serif;
font-style: normal;
font-weight: 500;
2022-12-20 07:58:21 +00:00
font-size: 0.875rem;
2022-12-12 06:51:25 +00:00
line-height: 1.1rem;
color: ${color.grey["400"]};
`;