icns-frontend/pages/index.tsx

344 lines
7.6 KiB
TypeScript
Raw Normal View History

2022-12-17 14:45:50 +00:00
import * as amplitude from "@amplitude/analytics-browser";
2022-12-06 10:41:38 +00:00
// Styles
2022-12-16 09:14:47 +00:00
import styled from "styled-components";
2022-12-06 10:41:38 +00:00
import color from "../styles/color";
// Components
2022-12-12 08:46:50 +00:00
import { ConnectWalletModal } from "../components/connect-wallet-modal";
2022-12-21 13:39:07 +00:00
import {
PrimaryButton,
Spinner,
SpinnerWrapper,
} from "../components/primary-button";
2022-11-30 13:49:09 +00:00
2022-12-06 10:41:38 +00:00
// Image Assets
import { useEffect, useState } from "react";
2022-12-19 07:23:19 +00:00
import { Logo } from "../components/logo";
2022-12-21 13:39:07 +00:00
import { CLAIM_URL, REFERRAL_KEY } from "../constants/icns";
2022-12-19 07:23:19 +00:00
import { SELECTED_WALLET_KEY } from "../constants/wallet";
import StarIcon from "../public/images/svg/bg-asset-3.svg";
import CheckIcon from "../public/images/svg/check-icon.svg";
import MainLogo from "../public/images/svg/main-logo.svg";
import MainTitle from "../public/images/svg/main-title.svg";
2022-12-21 13:39:07 +00:00
import CountUp from "react-countup";
import useInterval from "../hooks/use-interval";
2022-11-30 13:49:09 +00:00
2022-11-30 08:11:45 +00:00
export default function Home() {
2022-12-20 07:58:21 +00:00
const [currentReferral, setCurrentReferral] = useState("");
const [isConnectWalletModalOpen, setIsConnectWalletModalOpen] =
useState(false);
2022-11-30 13:49:09 +00:00
2022-12-21 13:39:07 +00:00
const [count, setCount] = useState<{ start: number; end: number }>();
2022-12-12 06:51:25 +00:00
const onClickConnectWalletButton = async () => {
2022-12-17 14:45:50 +00:00
amplitude.track("click connect wallet button");
2022-12-20 07:58:21 +00:00
setIsConnectWalletModalOpen(true);
2022-11-30 13:49:09 +00:00
};
useEffect(() => {
2022-12-15 15:43:18 +00:00
localStorage.removeItem(REFERRAL_KEY);
if (window.location.search) {
const [, referral] =
window.location.search.match(/^(?=.*referral=([^&]+)|).+$/) || [];
if (referral) {
localStorage.setItem(REFERRAL_KEY, referral);
2022-12-20 07:58:21 +00:00
setCurrentReferral(referral);
2022-12-15 15:43:18 +00:00
}
}
localStorage.removeItem(SELECTED_WALLET_KEY);
}, []);
2022-12-21 13:39:07 +00:00
useEffect(() => {
setTimeout(() => {
countUpCallback();
}, 1000);
}, []);
useInterval(async () => {
await countUpCallback();
}, 10000);
const countUpCallback = async () => {
const response: { data: { count: number } } = await (
await fetch(CLAIM_URL)
).json();
setCount({
start: (count?.end ?? 100) - 100,
end: response.data.count,
});
};
2022-11-30 08:11:45 +00:00
return (
2022-12-16 09:14:47 +00:00
<Container>
<Logo />
2022-12-21 13:39:07 +00:00
<CountUpContainer>
{count ? (
<CountUpText>
<CountUp start={count?.start} end={count?.end ?? 0} duration={1} />
</CountUpText>
) : (
<SpinnerWrapper>
<Spinner />
<Spinner />
<Spinner />
<Spinner />
</SpinnerWrapper>
)}
<CountUpDescription>ICNS names claimed so far</CountUpDescription>
</CountUpContainer>
2022-12-16 09:14:47 +00:00
<MainContainer>
<MainTitleContainer>
<MainTitleImageBackground>
2022-12-19 08:30:00 +00:00
<StarIcon className="starIcon first" />
<StarIcon className="starIcon last" />
2022-12-16 09:14:47 +00:00
<MainTitleImageContainer>
2022-12-19 08:30:00 +00:00
<MainTitle />
2022-12-16 09:14:47 +00:00
</MainTitleImageContainer>
</MainTitleImageBackground>
2022-12-18 13:14:10 +00:00
<CTAContainer>
<ConnectButtonContainer>
<PrimaryButton onClick={onClickConnectWalletButton}>
2022-12-19 07:23:19 +00:00
Claim Now
2022-12-18 13:14:10 +00:00
</PrimaryButton>
</ConnectButtonContainer>
<ICNSDescription>
ICNS allows you to use easy-to-remember names instead of
addresses.
<br />
<LearnMoreLink
href="https://medium.com/@icns/announcing-icns-the-interchain-name-service-e61e0c3e2abb"
target="_blank"
>
Learn More
</LearnMoreLink>
</ICNSDescription>
</CTAContainer>
2022-12-16 09:14:47 +00:00
<SubContainer>
<CheckContainer>
2022-12-19 08:30:00 +00:00
<CheckIcon />
2022-12-20 12:06:57 +00:00
0.5+ Osmo is required for this transaction{" "}
<a
href="https://app.osmosis.zone"
target="_blank"
rel="noreferrer"
>
GET OSMO
</a>
2022-12-16 09:14:47 +00:00
</CheckContainer>
<CheckContainer>
2022-12-19 08:30:00 +00:00
<CheckIcon />
2022-12-20 12:06:57 +00:00
Make sure you have a Cosmos wallet installed
2022-12-16 09:14:47 +00:00
</CheckContainer>
</SubContainer>
</MainTitleContainer>
<MainLogoContainer>
2022-12-19 08:30:00 +00:00
<MainLogo />
2022-12-16 09:14:47 +00:00
</MainLogoContainer>
</MainContainer>
<ConnectWalletModal
2022-12-20 07:58:21 +00:00
isModalOpen={isConnectWalletModalOpen}
onCloseModal={() => setIsConnectWalletModalOpen(false)}
currentReferal={currentReferral}
2022-12-16 09:14:47 +00:00
/>
</Container>
2022-11-30 09:58:19 +00:00
);
2022-11-30 08:11:45 +00:00
}
2022-12-06 10:41:38 +00:00
const Container = styled.div`
display: flex;
flex-direction: column;
width: 100vw;
height: 100vh;
2022-12-17 09:10:53 +00:00
background-image: url("/images/svg/bg-asset-1.svg"),
url("/images/svg/bg-asset-2.svg"), url("/images/svg/bg-asset-2.svg"),
url("/images/svg/bg-asset-3.svg"), url("/images/svg/bg-asset-3.svg");
background-size: 5rem 5rem, 5rem 5rem, 5rem 5rem, 3.125rem 3.125rem,
3.125rem 3.125rem;
background-position: 80px 640px, 960px 80px, 1200px 720px, 136px 776px,
1016px 696px;
background-repeat: no-repeat;
2022-12-06 10:41:38 +00:00
`;
const MainContainer = styled.div`
display: flex;
flex-direction: row;
margin-top: 15rem;
margin-left: 10rem;
2022-12-17 09:10:53 +00:00
2022-12-19 08:30:00 +00:00
.starIcon {
2022-12-17 09:10:53 +00:00
position: absolute;
&.first {
left: -24px;
top: -24px;
}
&.last {
2022-12-19 07:23:19 +00:00
right: -24px;
2022-12-17 09:10:53 +00:00
top: -24px;
}
}
2022-12-06 10:41:38 +00:00
`;
2022-12-21 13:39:07 +00:00
const CountUpContainer = styled.div`
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: 1.25rem;
width: calc(25rem - 2px);
height: calc(5rem - 2px);
position: absolute;
margin-top: calc(10rem + 2px);
margin-left: calc(55rem + 2px);
background-color: ${color.black};
`;
const CountUpText = styled.div`
font-family: "Inter", serif;
font-style: normal;
font-weight: 600;
font-size: 1rem;
line-height: 1.2rem;
letter-spacing: 0.46rem;
color: ${color.white};
`;
const CountUpDescription = styled.div`
font-family: "Inter", serif;
font-style: normal;
font-weight: 500;
font-size: 0.875rem;
line-height: 1.1rem;
color: ${color.grey["400"]};
`;
2022-12-06 10:41:38 +00:00
const MainTitleContainer = styled.div`
display: flex;
flex-direction: column;
position: relative;
padding: 0.1rem;
`;
const MainTitleImageBackground = styled.div`
display: flex;
justify-content: center;
2022-12-19 07:23:19 +00:00
width: calc(70rem - 1.5px);
2022-12-06 10:41:38 +00:00
height: 19.9rem;
background-color: ${color.black};
`;
const MainTitleImageContainer = styled.div`
display: flex;
justify-content: center;
align-items: center;
position: relative;
2022-12-06 14:53:31 +00:00
width: 60rem;
2022-12-06 10:41:38 +00:00
height: 19.9rem;
`;
const MainLogoContainer = styled.div`
position: relative;
2022-12-19 07:23:19 +00:00
right: 2.58rem;
2022-12-06 10:41:38 +00:00
min-width: 25rem;
height: 25rem;
`;
2022-12-18 13:14:10 +00:00
const CTAContainer = styled.div`
display: flex;
`;
2022-12-06 10:41:38 +00:00
const ConnectButtonContainer = styled.div`
2022-12-19 07:23:19 +00:00
width: calc(20rem - 2px);
height: calc(5rem - 1.5px);
2022-12-06 10:41:38 +00:00
2022-12-19 07:23:19 +00:00
margin: 1.5px 1.5px 1.5px 5.01rem;
2022-12-18 13:14:10 +00:00
`;
const ICNSDescription = styled.p`
2022-12-19 07:23:19 +00:00
background-color: ${color.black};
width: calc(40rem - 3px);
height: calc(5rem - 1.5px);
margin: 1.5px;
padding: 13.5px 26px;
2022-12-18 13:14:10 +00:00
font-weight: 500;
font-size: 16px;
2022-12-19 07:23:19 +00:00
line-height: 162%;
2022-12-18 13:14:10 +00:00
color: #6c6c6c;
`;
const LearnMoreLink = styled.a`
2022-12-18 14:11:18 +00:00
color: #6c6c6c;
&:link,
&:hover,
2022-12-19 07:23:19 +00:00
&:active,
&:visited {
2022-12-18 13:14:10 +00:00
color: #6c6c6c;
}
2022-12-06 10:41:38 +00:00
`;
const SubContainer = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
width: 29.9rem;
height: 4.9rem;
2022-12-19 07:23:19 +00:00
margin-top: 5rem;
2022-12-06 10:41:38 +00:00
margin-left: 5rem;
background-color: ${color.black};
`;
const CheckContainer = styled.div`
display: flex;
flex-direction: row;
align-items: center;
2022-12-19 10:46:52 +00:00
gap: 0.25rem;
2022-12-06 10:41:38 +00:00
font-family: "Inter", serif;
font-style: normal;
2022-12-19 07:23:19 +00:00
font-weight: 400;
font-size: 14px;
line-height: 117.5%;
2022-12-15 15:43:18 +00:00
padding-left: 0.75rem;
color: ${color.grey["400"]};
2022-12-20 12:06:57 +00:00
a {
color: ${color.grey["400"]};
}
2022-12-15 15:43:18 +00:00
`;